?
Solved

Math question.  pow(a,b)

Posted on 2000-05-11
6
Medium Priority
?
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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 400 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

771 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