The question About the GFLIB_Asin function in NXP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The question About the GFLIB_Asin function in NXP

Jump to solution
1,065 Views
edenli
Contributor V

The model about the GFLIB_Asin function comparing with the Asin Math Function in Matlab/Simulink:

pastedImage_1.png

As above Shown,The input paramater is 0.5 ,but the answer is difference,why?who can help us ,Thanks a lot. 

0 Kudos
1 Solution
898 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Eden Li,

With this question you have opened the Pandora's box of numerical methods on embedded system :-)

There are a lot of technical articles about numeric approximations in the field of transcendental functions. Since we are dealing with an embedded system where time matters - we need to take into account some "shortcuts" when computing a specific function. In other words, you do not want to spend a great amount of time computing a number with a high precision by introducing penalties to other critical processes.

For this particular case asin(x), the implementation is using the Taylor polynomial approximation for 2 different numerical intervals: [0, 0.4) with relative good precision using a specific set of polynomial coefficients and [0.4, 1) with "some" precision using a different set.

On the other hand, the Matlab is using the FDLIBM implementation (you can get details here: http://www.netlib.org/fdlibm/e_asin.c ) which gives much better results but the execution time is longer if implemented on MPC564x e200@150MHz. 

Hence, the difference results depending on the value received as input between our implementation and the one from Matlab. If we compare the 2 methods over the entire range of inputs we get:

error.JPG

As said before, you need to accept a trade off between speed vs. precision.

If we compare the output dynamically for an input sine signal [-1,1] we get the following:

Capture.JPG

For the reference I've included a model to replicate this.

Hope this clarify your concern!

Best regards,
Daniel

View solution in original post

2 Replies
899 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Eden Li,

With this question you have opened the Pandora's box of numerical methods on embedded system :-)

There are a lot of technical articles about numeric approximations in the field of transcendental functions. Since we are dealing with an embedded system where time matters - we need to take into account some "shortcuts" when computing a specific function. In other words, you do not want to spend a great amount of time computing a number with a high precision by introducing penalties to other critical processes.

For this particular case asin(x), the implementation is using the Taylor polynomial approximation for 2 different numerical intervals: [0, 0.4) with relative good precision using a specific set of polynomial coefficients and [0.4, 1) with "some" precision using a different set.

On the other hand, the Matlab is using the FDLIBM implementation (you can get details here: http://www.netlib.org/fdlibm/e_asin.c ) which gives much better results but the execution time is longer if implemented on MPC564x e200@150MHz. 

Hence, the difference results depending on the value received as input between our implementation and the one from Matlab. If we compare the 2 methods over the entire range of inputs we get:

error.JPG

As said before, you need to accept a trade off between speed vs. precision.

If we compare the output dynamically for an input sine signal [-1,1] we get the following:

Capture.JPG

For the reference I've included a model to replicate this.

Hope this clarify your concern!

Best regards,
Daniel

898 Views
edenli
Contributor V

Hi,Dumitru-daniel.popa,thank you very much for your reply,Iam very grateful for your help!

0 Kudos