[Webinar] Streamline your web hosting managementRegister Today


Math question.  pow(a,b)

Posted on 2000-05-11
Medium Priority
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.
Question by:kevinhol
  • 3
  • 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);

Author Comment

ID: 2804871
Adjusted points from 50 to 100

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.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.


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);

And for your next problem:

To solve 4^x = 3000. You simply do
In java:

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


Accepted Solution

tgoetze earned 400 total points
ID: 2807853

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.


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.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

640 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