[Webinar] Streamline your web hosting managementRegister Today

x
Solved

# Math question.  pow(a,b)

Posted on 2000-05-11
Medium Priority
217 Views
What is the easiest way to use java.lang.Math to solve the equation 10^x = 3000? Solve for x.
0
Question by:kevinhol
• 3
• 3

LVL 3

Expert Comment

ID: 2802811
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

Author Comment

ID: 2804871
Adjusted points from 50 to 100
0

Author Comment

ID: 2804872
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

LVL 3

Expert Comment

ID: 2804944
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);

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

LVL 3

Accepted Solution

tgoetze earned 400 total points
ID: 2807853
kevinhol,

0

Author Comment

ID: 2811046
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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
###### Suggested Courses
Course of the Month11 days, 11 hours left to enroll