Poor math question

For everything that's not in any way related to PureBasic. General chat etc...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by WolfgangS.

HI !
I know how to use log10/20 but ...
what is the different between log10/20 and log with basis e ?

MFG
:)WolfgangS
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

...,

When you use a decimal log you get the power of ten to find the initial value. When using the e based log, it is the power of e you use.

It means ie :

e.f = 2.71828
x.f = 12345
Debug Log(e)
Debug Log10(e)
Debug Pow(e, Log(x))
Debug Pow(10, Log10(x))

Does it help ?

KRgrds


Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Oh ... just assume that e (natural log basis approx. equal to 2.71828 ...). I will not demonstrate how to calculate this well known constant.

...

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Finally ... I suppose it is not to teach anything but I guess it is interesting to know a bit more about e constant.

Here is how to calculate e, based on Euler's sequence using factorial (here coded as a recursive function). Note that I use integers which means you have a poor range limitation (but today's Purebasic floats range is not better anyway).

Procedure.l fact(x.l)
If x > 1
ProcedureReturn x * fact(x - 1)
Else
ProcedureReturn 1
EndIf
EndProcedure

For i = 0 To 15
e.f = 0
For j = 0 To i
e = e + 1/fact(j)
Next
Debug "recurring " + Str(i) + " times : e=" + StrF(e)
Next


Francois Weil
14, rue Douer
F64100 Bayonne
Post Reply