views:

683

answers:

6

How would a programmer like myself learn how to find an inverse exponential of a number? on my calculator 2nd LN or e^x. It is similar in concept to the neperien function on calculator e.g. the log of 2 is about 0.3 and the inverse log or 10^x of 0.3 is 2.)

Note: This is to be used within an iPhone project using iPhone SDK

Note: Here is an example of what I am needing to compute: then 0.91831 is raised to the power of the inverse exponential of .773848284, or, 0.91831^2.168332164 = 0.831282.

A: 

man exp
man log

Nikolai N Fetissov
lol that makes no sense. is there a term for this so i can look into it more?
HollerTrain
**man** is Unix (Mac also) command for *manual*, i.e. a way to read documentation.
Nikolai N Fetissov
"man" is unix-speak for "manual." It gives you a help page for that command/function
BlueRaja - Danny Pflughoeft
+1  A: 

Simple answer: use the log() function from <math.h>. Or are you interested in an algorithm to compute it yourself?

ergosys
sorry, it's for an iPhone application I am building. I have edited OP to reflect this. sorry for any confusion on my part.
HollerTrain
I'd be surprised if math.h doesn't exist on the iphone, but I'm not sure.
ergosys
`math.h` absolutely exists on the iphone.
Stephen Canon
+2  A: 

It's the exp function in <math.h>. Or if you're looking for ln(x), use the log function in math.h with log(number).

Kaleb Brasee
log() from math.h is the natural log, so dividing by log(e) is silly.
ergosys
Oh yeah you're right, I was thinking it was log10 by default.
Kaleb Brasee
is this same thing as the pow function or different?
HollerTrain
A: 

Well, I haven't fully understood if you want to find the log or the exp. If don't want to use C's math library, you can write your own functions using a series expansion for approximation (for both functions).

You can find the general idea for Taylor series here.

For efficient log series you could read the "Series for calculating the natural logarithm" section here.

3lectrologos
yeah i'm getting confused myself. i basically need to compute: 0.91831 is raised to the power of the inverse exponential of .773848284, or, 0.91831^2.168332164 = 0.831282
HollerTrain
The thing confusing me is what you mean by "inverse exponential". From your example I see that e^(0.77384) = 2.16833, so do you maybe mean "exponential" and not "inverse exponential"?
3lectrologos
+1  A: 

double pow(double x, double y);

The pow() function returns the value of x raised to the power of y.

double exp(double x);

The exp() function returns the value of e (the base of natural logarithms) raised to the power of x.

So you want

pow(0.91831, exp(.773848284));
caf
A: 

It's not clear what you mean by "inverse exponential", but I'm going to list all of the potentially relevant math library functions and hopefully you can figure out which one you actually need.

  • exp(x) returns e^x (where e is the base of the natural logarithm, 2.71828...).

  • exp2(x) returns 2^x.

  • log(x) returns the natural logarithm of x (the number a that satisfies e^a = x).

  • log2(x) returns the base-2 logarithm of x.

  • log10(x) returns the base-10 logarithm of x.

  • pow(x,y) returns x^y.

All of these functions are available on the iPhone. In order to get the prototypes, you will need to include the header that defines them. Add the line #include <math.h> to the beginning of your source file to do so.

If you need a more precise explanation of exactly what any of these functions do, or examples of their use, let me know.

Stephen Canon