Natural Logarithm
This is a script for finding the natural logarithm (ln) of a number.
This is a Stage Function, and as such must be created as a Quest Stage of a global script and called as a function. This assumes a Quest called Wiki with the variables declared. Therefore, you must modify this code to include the name of your Quest (assuming it is not Wiki, which it shouldn't be). Alternatively, however, it would not be difficult to incorporate this code into your script directly.
The list of variables you will need declared in your Global Script:
float input (the number whose root you need) float x1 (used internally) float x3 (used internally) float x5 (used internally) float x7 (used internally) float x9 (used internally) more x# variables will increase accuracy float LN (the root, your answer)
Your input variable need not necessarily be a float, it could be a short or long, but SqRt needs to be a float, as few square roots are integers. You are free to rename either, but remember to change the function code.
; supplied by dysesothymteric set x1 to ( ( input - 1 ) / ( input + 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 LN to ( x1 + ( x3 / 3 ) + ( x5 / 5 ) + ( x7 / 7 ) + ( x9 / 9 ) ) ;yes, more accuracy means adding more terms here
As stated repeatedly in this code's comments, greater accuracy may be achieved by adding more x# variables.