The question About the GFLIB_Asin function in NXP

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

The question About the GFLIB_Asin function in NXP

跳至解决方案
1,983 次查看
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 项奖励
回复
1 解答
1,815 次查看
Daniel_Popa
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

在原帖中查看解决方案

2 回复数
1,816 次查看
Daniel_Popa
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

1,815 次查看
edenli
Contributor V

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

0 项奖励
回复