Small RPN exponential routine
|
01-03-2015, 05:31 PM
Post: #4
|
|||
|
|||
RE: Small RPN exponential routine
This is my first attempt at natural logarithm using
ln(1 + x) = x - x^2/2 + x^3/3 - x^4/4 + x^5/5 -+ ..., x < 1 There surely is a more obvious method which I cannot see, so I won't bother optimizing it. I am primarily interested in implementing these functions on TurboBCD, but rather than trying to reinvent the wheel I'll look for a ready-made solution. Code:
0.52 ENTER 35 --> -6.53926467407e-1 There are two problems, though: 1) The series does not converge for arguments greater than 1; 2) More and more terms are required as arguments approach to zero. For instance, ln(0.052) will require 525 terms for 12-digit accuracy. In these cases, conversions to and from decimal logarithms will help: ln(0.52) = -6.53926467407e-1 2.30258509299 / --> -2.83996656366e-1 1 - 2.30258509299 * --> -2.95651156041 = ln(0.052) ln(0.52) = -6.53926467407e-1 2.30258509299 / --> -2.83996656366e-1 1 + 2.30258509299 * --> 1.64865862558 = ln(5.2) ln(0.52) = -6.53926467407e-1 2.30258509299 / --> -2.83996656366e-1 2 + 2.30258509299 * --> 3.95124371856 = ln(52) ln(0.52) = -6.53926467407e-1 2.30258509299 / --> -2.83996656366e-1 3 + 2.30258509299 * --> 6.25382881155 = ln(520) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)