Re: A92: Floating Point Logarithm
[Prev][Next][Index][Thread]
Re: A92: Floating Point Logarithm
On Wed, 2 Jun 1999, David [iso-8859-1] K=FChling wrote:
>=20
> Hallo everybody
>=20
> I'm currently working at Floating Point routines for my Forth on-calc
> compiler and my problem is now, that I don't know how to create an
> efficent routine for caculating logarithms. My best idea would be to
> calculate the integral of the differentiated logarithm, 1/x, using
> some integral approximation algorithm like the Simpson algorithm.
> Does anybody of you know a better algorithm to approximate logarithms?
> Another problem is how to calculate powers. I thought that implementing
> a 2^n routine should be easy, but it's not if n is a floating point=20
> number. If I could calculate powers, the problems with the logarithms
> would be solved since logarithms can be approximated by powers using=20
> Newton or Regula Falsi approximation.=20
a VERY bad idea... (using powers to calculate logs i mean...)
to get a good aproximation, one needs to use a big amount of terms.
Well, i think i remember something:=20
1) get a table of logs for known values. (Xk, where k belongs to [0..n])
2) x =3D min ( x - Xk*Xm ) + y : if you minimize the difference, y is
minimized and x =3D~ Xk*Xm
3) x =3D log Xk + log Xm=20
4) the problem is to minize the difference . ie: how to choose these Xm
and Xk... You can use more than just two terms: 3: Xk, Xm and Xl so that=20
x =3D~ min ( x - Xk*Xm*Xl )
I think that this method was used by sailers when they had to calculate
their latitude and longitude: logs had been invented for them.
But, once more, i am not sure.
Hope this helps.
>=20
> Any help would be appreciated.
>=20
> Thanks in advance,
> =09=09=09=09=09=09=09David K=FChling
>=20
-------------------------------------------------
Mathieu Lacage=20
Snailmail: ch 224, 212 Rue de Tolbiac 75013 Paris
email: mathieu.lacage@email.enst.fr
url: http://www.stud.enst.fr/~lacage
Follow-Ups:
References: