I was trying to get the CMSIS DSP library working on my STM32F4. In my program, I utilized trig functions to calculate data for windowing. But I noticed that these trig functions were somewhat inaccurate:
I ran an example program, which calculated sin^2(x) + cos^(x) where x is random data in radians, and this is what I got:
(Ideally these should be 1)
0.999962747
0.999964297
0.999964118
0.999962568
0.999983013
0.999968827
0.999984443
0.999978364
0.999972343
0.999993682
0.999974668
0.999974966
0.999995768
1
0.999998093
0.999969602
0.999977887
0.999986827
0.999962986
0.999975741
0.999993563
0.99996531
0.99996233
0.999972165
0.999972939
0.999974489
0.99998796
0.999972522
0.99999088
0.999992192
0.99997431
0.999977529
Well you can see the tolerances of these results are +/-0.001. According to the example program, they should've been +/-0.0000001
Did I screw something up? Can anyone try out the example (CMSIS/DSP_Lib/Examples/arm_sin_cos_example) and see if the tolerances are any better? This seems a little bit too inaccurate for a "good" library...
Thanks in advance!
EDIT:
It turned out that the example program I was running was written 2 years ago. The new documentation points out the tolerances are +/-0.0001.
LESSON LEARNED: NEVER USE OUTDATED PROGRAMS. Damn it spent 4 hours trying to figure out this crap.