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

Mitchalsup mitchalsup at aol.com
Thu Jan 16 17:53:15 GMT 2020



Mitch AlsupMitchAlsup at aol.com

-----Original Message-----
From: Jacob Lifshay <programmerjake at gmail.com>
To: Libre-RISCV General Development <libre-riscv-dev at lists.libre-riscv.org>
Cc: MitchAlsup <mitchalsup at aol.com>
Sent: Thu, Jan 16, 2020 3:37 am
Subject: Re: [libre-riscv-dev] [isa-dev] Re: FP transcendentals (trigonometry, root/exp/log) proposal

On Thu, Jan 16, 2020, 01:22 Luke Kenneth Casson Leighton <lkcl at lkcl.net> wrote:

On Thursday, January 16, 2020, <whygee at f-cpu.org> wrote:

> On 2020-01-16 04:04, lkcl . wrote:



> the time (let alone rounding).  how do you *know* when the rounding (or the
>> last bit of the mantissa) is wrong?
>>
>
> That was my reaction :
> if you *know* your LSB is wrong then you can correct it...


... or can you? this is what i'm fascinated to hear about, mitch.

is there some mathematical way in which the accuracy can be computed yet
the effort not known?


Yes. you just compute the output to a few more bits where the output is known to always be within a certain distance of the correct output, then you just check if the output is within that distance of the transition between two rounded outputs, if it is, then it could be rounded incorrectly, otherwise it rounds correctly.RIght, in my implementation we drag 58-bits through the calculation and paste on a 62-bit C[0] coefficient which gives us at least 56-bits known to be correct.

or... oh hold on, are you saying that the exception would be raised (every
time?) then the partially-accurate result would be dropped into Newton
Raphson for (probably only one iteration) to get full accuracy?


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..
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