Author Topic: ARM CMSIS - Something wrong with trig functions?  (Read 2280 times)

0 Members and 1 Guest are viewing this topic.

Offline SolarSunriseTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: ua
  • Hi there!
ARM CMSIS - Something wrong with trig functions?
« on: June 13, 2014, 07:35:27 pm »
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.
« Last Edit: June 13, 2014, 07:40:41 pm by SolarSunrise »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ARM CMSIS - Something wrong with trig functions?
« Reply #1 on: June 13, 2014, 08:36:04 pm »
I got one 0.9999998, and the rest are roughly 50/50 between 0.9999999 and 1.

The calculation for those functions is via a set of look-up tables so it is very difficult to go wrong.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ARM CMSIS - Something wrong with trig functions?
« Reply #2 on: June 13, 2014, 08:37:21 pm »
Quote
was written 2 years ago.

I was using dsp 1.0.3. And the example was written in 2010.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf