Natural Logarithm
Revision as of 16:08, 6 May 2006 by imported>DragoonWraith
This is a script for finding the natural logarithm (ln) of a number.
scn NaturalLogarithm ; supplied by dysesothymteric float inputNumber float x1 float x3 float x5 float x7 float x9 ; more can be used for greater accuracy float LNvalue Begin {appropriate blocktype} ;how inputNumber is set depends on implementation ;here it is set to the number of diseases the player has contracted set inputNumber to GetPCMiscStat 26 set x1 to ( ( inputNumber - 1 ) / ( inputNumber + 1 ) ) set x3 to ( x1 * x1 * x1 ) set x5 to ( x3 * x1 * x1 ) set x7 to ( x5 * x1 * x1 ) set x9 to ( x7 * x1 * x1 ) ;again, follow this pattern for increased accuracy set LNvalue to ( x1 + ( x3 / 3 ) + ( x5 / 5 ) + ( x7 / 7 ) + ( x9 / 9 ) ) ;yes, more accuracy means adding more terms here End
The inputNumber variable is your input, and LNvalue is your output. In other words, LNvalue=LN(inputNumber). As stated repeatedly in this code's comments, greater accuracy may be achieved by adding more x# variables.