The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

OT: Cosine curio
Message #1 Posted by Bob Patton on 11 Dec 2011, 5:17 p.m.

      Laguerre cosine approximation
         Math history fun fact
 I came across this some 50 years ago,
 before calculators had trig keys.

It's good to about 4 significant digits for first quadrant, and exact at 0, 45, 60, 90 degrees.

m = angle/90 for degrees or angle/pi/2 for radians

-m^2 ( --------------------------------- - 1) sqrt((-m^3 + 4m^2 -5m + 2)/3) + m

This can be expressed in linear form as:

-(((((((4-m)m-5)m+2)/3)^(1/2)+m)^(-1)mm)-1)

which can be keyed in directly on a simple chain-logic memory calculator with a square root key and the ability to find the reciprocal using some combination of / and = keys. Handle the leading minus at the end, just mentally if necessary.

To test it, on a 12C, for angles in degrees:

90 / ENTER ENTER ENTER 4 x<>y - X 5 - X 2 + 3 / g-sqrt + 1/x X X 1 - CHS

<*** End of File ***>
      
Re: OT: Cosine curio
Message #2 Posted by Crawl on 11 Dec 2011, 9:23 p.m.,
in response to message #1 by Bob Patton

It seems like the final 1 should be positive, not negative.

      
Re: OT: Cosine curio
Message #3 Posted by Namir on 12 Dec 2011, 6:49 p.m.,
in response to message #1 by Bob Patton

Interesting approximation! Can we enhance it now that we have tools like Matlab and Excel?

Crawl it right in pointing out that the trailing -1 in the first two equations should be +1.

Namir

      
Re: OT: Cosine curio
Message #4 Posted by C.Ret on 13 Dec 2011, 5:45 a.m.,
in response to message #1 by Bob Patton

Really interesting approximation.

As Namir and Crawl have already point out, there is a typo in the developed formulae only.

The linear formulea and the RPN instructions are all correct.

Using my HP-41C, I just test a few points to observe error between cosine and the Laguerre approximation (express in the following table as ppm

 Angle(°)  m=a/90°    Laguerre(m)  Cos(a)      Error(ppm)

-90 -1 0.0000000 0.0000000 0 -45 -0.5 0.7124144 0.7071068 7506 0 0 1.0000000 1.0000000 0 10 1/9 0.9848786 0.9848078 72 20 2/9 0.9398473 0.9396926 165 30 1/3 0.8661695 0.8660254 166 40 4/9 0.7660945 0.7660444 65 45 0.5 0.7071068 0.7071068 0 50 5/9 0.6427550 0.6427876 -50 60 2/3 0.5000000 0.5000000 0 70 7/9 0.3421859 0.3420201 484 80 8/9 0.1739508 0.1736482 1742 90 1 0.0000000 0.0000000 0 120 4/3 -0.1927647 -0.5000000 -614471 !!!!! 135 1.5 -0.3203263 -0.7071068 -546 145 1.6111 -0.4175237 -0.8191520 -490 180 2 -1.0000000 -1.0000000 0 225 2.5 n.a.r.v. -0.7071068 nan


As explain, in first quadrant, few error and exact value for same remarkable values are obtained.
No more approximation can be obtained after 180° due to the sign of the polynôme under the square root.

The following figure better illustrate accuracy and region of interest for this cosine approximation:

Note that in this graph, Lag(a) is the real part of the laguerre approximation. That’s why plot continue after the 180° limit.

As Namir point it out, we can enhance this approximation, but not only in accuracy, other way may be to make it usable on a larger domain.

Edited: 13 Dec 2011, 5:58 a.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall