Calculating the sine and Cosine - Printable Version +- Forums - Open Redstone Engineers (https://forum.openredstone.org) +-- Forum: ORE General (https://forum.openredstone.org/forum-39.html) +--- Forum: Projects & Inventions (https://forum.openredstone.org/forum-19.html) +---- Forum: Completed Projects (https://forum.openredstone.org/forum-21.html) +---- Thread: Calculating the sine and Cosine (/thread-15806.html) |
Calculating the sine and Cosine - _Mystery_Man - 05-23-2020 Hello, The first project I have worked on as I became builder, is a concept for calculating sine and cosine using the Taylor series polynomials. The machine calculates enough terms to be 4 decimal places accurate most of the time, which is probably enough accuracy for graphing. The total calculation takes 1 min and 15 secs approximately, and that is for the sine and cosine being generate side by side. The attachment is an image of the device. Since I used serial based multiplication, I was able to compact this device a bit and still get good speed to calculating each term of the polynomials. I understand that I could have used the coordinate rotation digital computer algorithm, however it is actually less reasonable in this case. video sort explains my thoughts of the matter XD now due to the nature of it being a periodic function, I actually can extract 8 points with just 1 pair using a side algorithm to convert the coordinates by changing the sign to negative and switch the sine and cosine for complementary use. Demo of the device RE: Calculating the sine and Cosine - GISED_Link - 05-24-2020 Hi, That is some good stuff. I've made something similar but only for the sinus. I was using only 8 bit integer to map the sinus signal. The input is given in ° instead of radian (wich we are more familiar with). This is the precision I had using the given formula (in the picture) : I have only taken the 2 first term of the Taylor series of the sinus. It explained why it is so unaccurate after 80° ... Do you have a graph like mine that show the error ? Because I use 8 bit to represent the sin(x), I have always a big error when the sine curve get flat (around x=90°). I don't have enough bit to represent the diffrence between sin(87°) and sin(90°). Both equal to 255... RE: Calculating the sine and Cosine - jxu - 06-06-2020 (05-24-2020, 09:06 PM)GISED_Link Wrote: I have only taken the 2 first term of the Taylor series of the sinus. It explained why it is so unaccurate after 80° ... You know you can just mirror the result past 90 deg? Also the graph is a good demonstration that x approximates sin x to 0.001 between +/- 0.18 and to 0.01 between +/- 0.39 |