# Thread: calculate the ln of a number?

1. ## calculate the ln of a number?

hey, i was wondering if there was a function you could use to find the ln of a number ( such as: ln(2) ). i've done some searching on google about it, but either i've been using the wrong keywords or i didn't look deep enough, lol. i also tried declaring a double and having this:
Code:
`lntwo = ln(2);`
which..doesn't work. lol thanks

2. Code:
`lntwo = log(2);`

3. Code:
`log(2) != ln(2)`

4. Then you need to base convert it.
Code:
`log(2) / log(2.7182)`
http://mathforum.org/library/drmath/view/55568.html

5. http://www.rt.com/man/log.3.html
The log() function returns the natural logarithm of x.
Code:
```#include <stdio.h>
#include <math.h>

int main(void)
{
double lntwo = log(2);
printf("lntwo = %g\n", lntwo);
return 0;
}

/* my output
lntwo = 0.693147
*/```

6. Ha...maybe you don't. My bad.

7. awesome thank you

8. Hehe I was wondering if you'd fail for that

Remember in higher mathematics when you say log you are really saying ln not log10

9. Originally Posted by Thantos
Hehe I was wondering if you'd fail for that

Remember in higher mathematics when you say log you are really saying ln not log10
Well it depends, many universitybooks log for base e (2.71...) denote like ln while log is actuallly log10. That is on also used on windows calculator. But in programming world and because of programming world log denots ln not log10. For example in MATLAB, C and C++ (and many others prog languages) log means ln.

And just in case you wondering about pianorain's formula consider this problem.
How to calculate logarithm log4(15) (base is 4)?
Simple
Let log4(15) is equal x so x = log4(15). Now that means 4^x = 15.
Now if we take logarithm (base e ln ) we have ln(4^x) = ln(15)=>
x*ln(4) = ln(15) (logarithms property)=> x=ln(15)/ln(4). And remeber now what x is?
x is log4(15). That means we got a formula for logarithms converting: log4(15) = ln(15)/ln(4).
On you0re calaculator you usually don't have opportunity to calculate logarithms for different bases (usually e and 10) so knowing this makes calculation of logarithm of any base simple.
I don't know why I wrote this.
Maybe someone will find it useful.

Micko

10. Well it depends, many universitybooks log for base e (2.71...) denote like ln while log is actuallly log10. That is on also used on windows calculator. But in programming world and because of programming world log denots ln not log10. For example in MATLAB, C and C++ (and many others prog languages) log means ln.
I haven't see log in my text books since trig or so. You know why log is ln in programming langauges? Because they were created by mathematicans

Popular pages Recent additions