Numerically stable implementation of sin(y*atan(x))/x
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to implement a modified version of the Magic Tyre Formula. The simplified version of my problem ist that i need to calculate this function:
sin(y*atan(x))/x
especially at and around x = 0. I know that this function is defined for x = 0 because:
sin(y*atan(x))/x = sin(y*atan(x))/(y*atan(x)) * (y*atan(x))/x = sin(c)/c * atan(x)/x * y with c = y*atan(x)
Both
sin(c)/c and atan(x)/x
are defined for x = 0 and c = 0.
I would like to use built in functions to solve my problem, because im not that good at numerics.
What I have tried until now is:
1) I can calculate sin(c)/c by using the built in sinc function, but then I still have to calculate atan(x)/x which i have found no solution for by now.
2) I know that
sin(atan(x)) = x/(sqrt(1+x^2))
But i havent found a way to rewrite this equation using
sin(y*atan(x))
Does anyone have an idea how to solve my problem?
0 件のコメント
採用された回答
その他の回答 (2 件)
Majid Farzaneh
2018 年 5 月 17 日
Hi, You can easily add an epsilon to x like this:
sin(y*atan(x+eps))/(x+eps)
Ameer Hamza
2018 年 5 月 17 日
How about defining it like this
f = @(x,y) y.*(x==0) + sin(y.*atan(x))./(x+(x==0)*1);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!