Re: algorithms for exp and ln calculations

This is a discussion on Re: algorithms for exp and ln calculations within the pl1 forums in Programming Languages category; "cyrille de brebisson" <cyrille @ hp.com> wrote in message news:g3rnco$eut$1 @ usenet01.boi.hp.com... > I am trying to understand how computers calcualte exp and ln. > > can someone point me toward a nice website that explains all that? or at > least give me the name of the algorithm (basically the exp/ln equivalent of > CORDIC for trig)? Power series can be used for these operations. log(1+x) = x - x*x/2 + x**3/3 - x**4/4 + ... for |x| < 1. exp(x) = 1 + x + x**2/2 + x**3/3! + x**4/4! + ... Algorithms in software libraries often use ...

Go Back   Application Development Forum > Programming Languages > pl1

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-19-2008, 09:42 AM
robin
Guest
 
Default Re: algorithms for exp and ln calculations

"cyrille de brebisson" <cyrille@hp.com> wrote in message news:g3rnco$eut$1@usenet01.boi.hp.com...

> I am trying to understand how computers calcualte exp and ln.
>
> can someone point me toward a nice website that explains all that? or at
> least give me the name of the algorithm (basically the exp/ln equivalent of
> CORDIC for trig)?


Power series can be used for these operations.

log(1+x) = x - x*x/2 + x**3/3 - x**4/4 + ...
for |x| < 1.

exp(x) = 1 + x + x**2/2 + x**3/3! + x**4/4! + ...

Algorithms in software libraries often use
specific approximation formulas tailored to the
accuracy that a particular machine can deliver.

Such formulas are typically quicker than using
a power series.

Illustration in PL/I using power series:

TEST: PROCEDURE OPTIONS (MAIN);

declare (s, t, x) float;
declare n fixed binary;

get (x);
s, t = 1;
do n = 1 to 20;
t = t * x / n;
s = s + t;
end;
put (s);
END TEST;

In practice, if this were used, a different method
would be used to terminate the loop.


Reply With Quote
  #2  
Old 07-20-2008, 02:35 AM
glen herrmannsfeldt
Guest
 
Default Re: algorithms for exp and ln calculations


"cyrille de brebisson" <cyrille@hp.com> wrote in message
news:g3rnco$eut$1@usenet01.boi.hp.com...

>I am trying to understand how computers calcualte exp and ln.


There is probably one, but it is usual to do it based on
the floating point representation. In a base 2 floating
point system, the internal representation has a binary
number multiplied by some power of two.

See:
http://en.wikipedia.org/wiki/Talk:Ex...9_in_computers

-- glen

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:49 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.