Solved

Math question.  pow(a,b)

Posted on 2000-05-11
6
187 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
Comment Utility
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
Comment Utility
Adjusted points from 50 to 100
0
 

Author Comment

by:kevinhol
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Expert Comment

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 55
endX challenge 2 48
best (free) software to access postgres db (java) 1 17
base64 decode encode 12 96
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 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

19 Experts available now in Live!

Get 1:1 Help Now