This pr reintroduces Number.sin after it was removed in #2046, this uses the implementation found in libc, with some adaptations made for wasm and grain. It uses a small kernal function that accuratly can compute sin for values between -pi/4 to pi/4 and a range reduction algorithm to map any values outside the range into the range efficently.
Notes:
I made a new math folder in the stdlib, as these functions can be used for multiple number types it makes sense to seperate them out so they are easier to understand.
I am going to make a follow up pr for gamma and factorial
I am going to make another follow up pr for Float32 and Float64, sin, cos and tan
Some Notes:
When it comes to bigints we lose a lot of accuracy do to how f64s store numbers.
This pr reintroduces
Number.sin
after it was removed in #2046, this uses the implementation found in libc, with some adaptations made for wasm and grain. It uses a small kernal function that accuratly can computesin
for values between-pi/4
topi/4
and a range reduction algorithm to map any values outside the range into the range efficently.Notes:
gamma
andfactorial
Float32
andFloat64
,sin
,cos
andtan
Some Notes:f64
s store numbers.Although I ported the argument reduction algorithm if anyone wants to better understand it here is a link: https://userpages.cs.umbc.edu/phatak/645/supl/Ng-ArgReduction.pdf to a paper on a similar algorithm.
work for #1478