home *** CD-ROM | disk | FTP | other *** search
-
- { ******************************************* }
- { * * }
- { * The following is store as LN.INC * }
- { * * }
- { ******************************************* }
-
-
- { Turbo Pascal with BCD option does not support the ln function. }
-
- { This used the taylor series expansion about x=1 to approximate ln(x). }
- { ln(x):= }
- { (1/1)*((x-1)^1) - (1/2)*((x-1)^2) + (1/3)*((x-1)^3) - }
- { (1/4)*((x-1)^4) + .. - (1/(n-1))*((x-1)^(n-1)) + (1/n)*((x-1)^n) - .. }
-
- { This expansion is valid for real values in the range 2>=x>0. }
-
- function LN(X:real):real;
- var WorkTotal:real;
- term :real;
- i :integer;
- begin;
- term:=x - 1;
- WorkTotal:=term;
- for i:=2 to 25 do
- begin;
- term:=term * (x - 1)*(-1) / i;
- WorkTotal:=WorkTotal + term;
- end;
- ln:=WorkTotal;
- end;
-
-