[libre-riscv-dev] [isa-dev] Re: FP transcendentals (trigonometry, root/exp/log) proposal

Jacob Lifshay programmerjake at gmail.com
Thu Jan 16 21:13:35 GMT 2020


On Thu, Jan 16, 2020, 09:53 Mitchalsup <mitchalsup at aol.com> wrote:

>
> Newton Raphson is basically useless for functions like sin or cos, since
> you have to compute the inverse function (asin or acos) to a higher
> accuracy which takes even more work than just computing the function to
> enough accuracy in the first place.
>
> You have to compute the derivative of SIN() and COS() which just happen to
> be COS() and -SIN().
> But I am not doing this with NR..
>

I was thinking that to use NR to compute cos(x) = y, you'd construct the
function:
f(y) = acos(y) - x
and solve it for zero using NR:

y[n+1] = y[n] - f(y[n]) / f'(y[n])

f'(y) = -1 / sqrt(1 - y^2)

y[n+1] = y[n] - (acos(y[n]) - x) / (-1 / sqrt(1 - y[n]^2))

and similarly for sin(x) = y

obviously, computing acos takes about as much work as computing cos in the
first place, making NR basically useless for computing cos (it also
probably has other issues too, such as |y[n]| > 1 for some n).

>
> Newton Raphson is useful for square-roots because computing the inverse
> function (and its derivative) to high accuracy is easy (just multiplication
> and addition).
>
> Jacob
>


More information about the libre-riscv-dev mailing list