Michal Pleban wrote on 23.09.2022 22:48: > Basically, it amounts to something like this for SIN(X): > > S = X : REM RESULT > Z = 1 : REM SIGN > P = X : REM POWER > F = 1 : REM FACTORIAL > FOR I = 3 TO [SOME_LIMIT] STEP 2 > P = P * X * X > F = F * (I - 1) * I > Z = -Z > S = S + Z * P / F > NEXT I Just ran this program on my CBM-II. With the floating point precision that is used in Commodore BASIC, the number of iterations needed to converge on a result when X is in the range [-PI, PI] is 10 (so the LIMIT = 21). If you use bigger precision, you may need a few more steps. 10 steps is not much, so you can get really a result in a reasonable CPU time. For what it's worth, I also measured the speed of the SIN function in CBM BASIC, and it turns out it is about 11 times slower than a multiplication. Makes sense given the above. Regards, Michau.Received on 2022-09-24 15:00:16
Archive generated by hypermail 2.3.0.