Posted: 11th Mar 2016 23:55
This is for that rare breed interested in how to compute sine and cosine with pencil and paper. Precision matches that of a float type variable.

+ Code Snippet
#constant Degtorad 0.017453292519943295769236907684886

function Factorial(n as integer)
   retvalue as integer

   retvalue = 1
   for i = 2 to n
      retvalue = retvalue * i
   next i
endfunction retvalue

function ComputeCosine(ang as float)
   retvalue as float

   ang = ang * Degtorad
   retvalue = 1 - ang^2 / Factorial(2) + ang^4 / Factorial(4) - ang^6 / Factorial(6) + ang^8 / Factorial(8) - ang^10 / Factorial(10)
endfunction retvalue

function ComputeSine(ang as float)
   retvalue as float

   ang = ang * Degtorad
   retvalue = ang - ang^3 / Factorial(3) + ang^5 / Factorial(5) - ang^7 / Factorial(7) + ang^9 / Factorial(9) - ang^11 / Factorial(11)
endfunction retvalue
Posted: 13th Mar 2016 23:11
Nice one. I have no clue why it works, but it works

By the way, DEGTORAD ( AngleInDegrees ) is a Matrix1 function, so your constant will register as a reserved word and will not compile with Matrix1 installed.

Thanks
Posted: 13th Mar 2016 23:54
Thank you, Chris. For some reason I have Matrix1 Util's. I just haven't found a real need to use it.
Posted: 14th Mar 2016 12:34
No problem.

You appear to be na extremely skilled programmer; I look forward to seeing more of your examples. I will likely have some programming questions to ask in future.
Posted: 14th Mar 2016 22:07
Thanks, I find you a wicked skilled programmer yourself. I will be happy to answer any questions, just don't ask me how this works. To make a long story short, I got the formula out of a calculus book.