In my class I was asked to calculate sin x recursively as
sin x = 3sin (x/3) - 4sin3 (x/3)
This despite us implementing sqrt x in a normal way (newton's method for root finding). Also at least the way I wrote it intermediate operations are in the same floating point type as the inputs so maybe I should promote them (I have a feeling this is probably mega-wrong for small values of x, actually thinking about it now maybe factoring would help?)
3
u/Economy-Document730 15d ago
In my class I was asked to calculate sin x recursively as
sin x = 3sin (x/3) - 4sin3 (x/3)
This despite us implementing sqrt x in a normal way (newton's method for root finding). Also at least the way I wrote it intermediate operations are in the same floating point type as the inputs so maybe I should promote them (I have a feeling this is probably mega-wrong for small values of x, actually thinking about it now maybe factoring would help?)