[WP-34S] DEG and RAD - diffs
06-06-2014, 07:53 PM
Post: #27
 Claudio L. Senior Member Posts: 1,847 Joined: Dec 2013
RE: [WP-34S] DEG and RAD - diffs
(06-06-2014 05:42 PM)Thomas Klemm Wrote:  You can do without using the constant K. Calculate:
$\tan(\theta)=\frac{K\cdot\sin(\theta)}{K\cdot\cos(\theta)}$
From this you can calculate:
$\sin(\theta)=\frac{\tan(\theta)}{\sqrt{1+\tan(\theta)^2}}$

How normal do you consider the implementation used in most HP-calculators?

Cheers
Thomas

That seems easy to do, but then you have to do a division, a multiplication and a square root, on top of your sin/cos which both come together from CORDIC.
The square root alone will take about half the time of the sin, so you'd increase your time by 50%.
Yes, this will be faster than having to compute the constants alongside but still much worse than having a precomputed constant ready.

Also, when x is close to zero, doing sqrt(1+x^2) is really bad for precision. The x^2 "spreads" your useful digits throughout your exponent range, then the square root compresses them back, and you lost about half of them at the end (see what I meant with "small angles are tougher on precision loss").
For hyperbolics, I'm using the double-angle formulae with much better results since you don't have the square roots.

For now, I'd rather have the constants precalculated, so after CORDIC, one multiplication and I got the final result. However, if we run out of space in ROM and I have to remove my constants, we'll have no choice but to use that trick (thanks, BTW).
I'm not sure a similar trick will work well for hyperbolics, exp() and ln(), though.

Claudio
 « Next Oldest | Next Newest »