[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Math question. pow(a,b)

What is the easiest way to use java.lang.Math to solve the equation 10^x = 3000? Solve for x.
0
kevinhol
Asked:
kevinhol
  • 3
  • 3
1 Solution
 
tgoetzeCommented:
To solve for x, you take the log of both sides. Here log means the log base 10. This results in a solution of:
x = log(3000);

This is done via the log() method in java.lang.Math.

double x = java.lang.Math.log(3000.0);
0
 
kevinholAuthor Commented:
Adjusted points from 50 to 100
0
 
kevinholAuthor Commented:
Thanks tqoetze,

Although you did answer my original question, I have decided to change it to include different bases other than 10. ie 4^x = 3000. I've up'd the points and will hold them for you if you can answer.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tgoetzeCommented:
Good thing you ask for some more details, I checked and found out that java.lang.Math.log is the natural logarithm, which is the log base e.

For convseion, the general rule is that the log base a of x is equal to the log base c of x divided by the log base c of a. This allows the conversion between bases.

To answer your original question (which I was wrong with first), you would need to do:

double x = java.lang.Math(3000.0)/java.lang.Math(10.0);

And for your next problem:

To solve 4^x = 3000. You simply do
log(3000)/log(4).
In java:

double x = java.lang.Math.log(3000.0)/java.lang.Math.log(4.0);

0
 
tgoetzeCommented:
kevinhol,

Does the answer I posted make sense? Does it answer your question for you? Please let me know if you have any further questions about this.

0
 
kevinholAuthor Commented:
Thanks, it worked well in my program.

P.S. I thought I excepted your comment as an answer last week, sorry for the delay.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now