Solved

Math question.  pow(a,b)

Posted on 2000-05-11
6
189 Views
Last Modified: 2010-04-01
What is the easiest way to use java.lang.Math to solve the equation 10^x = 3000? Solve for x.
0
Comment
Question by:kevinhol
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:tgoetze
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

by:kevinhol
ID: 2804871
Adjusted points from 50 to 100
0
 

Author Comment

by:kevinhol
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:tgoetze
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);

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
 
LVL 3

Accepted Solution

by:
tgoetze earned 100 total points
ID: 2807853
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
 

Author Comment

by:kevinhol
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java  and programming certification ? 4 86
Java / Linux and Regular Expressions 11 69
netstat -ano | find "8000" and taskkill /f /pid 2984 3 32
ForLoop Example 3 40
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now