How to approximate a multivariable arctan function?

5 ビュー (過去 30 日間)
Jannis Erz
Jannis Erz 2022 年 9 月 18 日
コメント済み: Jannis Erz 2022 年 9 月 24 日
let the following function be given:
Is there a way in Matlab to approximate this function as a multivariable (x1,x2,x3,u1) rational polynomial?
lv and bv are positive constants.
x2 should be defined within -pi/4 and pi/4 [rad].
x3 should be defined within (-pi/4) and (pi/4) [rad/sec].
x1 > 0 [meter/sec].
u1 should be defined within (-pi/12) and (pi/12) [rad].
Thanks a lot in advance!
  19 件のコメント
Jannis Erz
Jannis Erz 2022 年 9 月 24 日
Thanks for the explanation! Really appreciate it!


回答 (1 件)

John D'Errico
John D'Errico 2022 年 9 月 18 日
編集済み: John D'Errico 2022 年 9 月 18 日
@Sam Chak has suggested an interesting idea in a comment. However, while it is not a bad idea at first glance, I suspect it will be problematic. The issue is, that classic atan series is not very strongly convergent. Expect to need many terms before you get anything good. And that means the polynomial approximation will be poor at best.
For example, how many terms do you need for convergence as a function of x to k significant digits, in the simple atan series?
For example, when x == 1, how many terms are required? We can look at it easily, since that is just the Leibniz formula for pi/4. Thus...
N = 0:1000;
S = mod(N+1,2)*2 - 1;
approx = cumsum(S./(2*N+1));
truth = pi/4;
semilogy(N,abs(approx - truth))
grid on
So we need thousands of terms for convergence near x==1.
However, if you can use range reduction methods to force the argument x to the atan to be in a small interval near zero, you get much faster convergence. The problem is, that in itself may take some work, and it is not at all trivial to get good convergence.
Instead, you may gain from using a direct rational polynomial approximation, perhaps something like those found in the classic, by JF Hart, et al, "Computer Approximations". (Start reading around page 120 in my edition from 1978. The tables there give some pretty good approxmations, though they still employ range reduction.)
Note: Even though Hart is an old text, it is still a book I love dearly, but that might apply only to a real gearhead numerical analyst like me. I think I recall it is available as a Dover reprint.
  7 件のコメント
Sam Chak
Sam Chak 2022 年 9 月 19 日
Found the pade() command. Maybe @Jannis Erz can work out the desired Rational Polynomial function.
help \sym\pade
PADE approximation of a symbolic expression PADE(f <, x> <,options>) computes the third order Pade approximant of f at x = 0. If x is not given, it is determined using symvar. PADE(f, x, a <, options>) computes the third order Pade approximant of f at x = a. A different order can be specified using the option 'Order' (see below). The following options can be given as name-value pairs: Parameter Value 'ExpansionPoint' a Compute the Pade approximation about the point a. It is also possible to specify the expansion point as third argument without explicitly using a parameter value pair. 'Order' [m, n] Compute the Pade approximation with numerator order m and denominator order n. 'Order' m Compute the Pade approximation with both numerator and denominator order equal to m. By default, 3 is used. 'OrderMode' 'Absolute' or 'Relative'. If the order mode is 'Relative' and f has a zero or pole at the expansion point, add the multiplicity of that zero to the order. If f has no zero or pole at the expansion point, this option has no effect. Default is 'Absolute'. Examples: syms x pade(sin(x)) returns (60*x - 7*x^3)/(3*(x^2 + 20)) pade(cos(x), x, 'Order', [1, 2]) returns 2/(x^2 + 2) See also TAYLOR. Documentation for pade doc pade



Find more on Oceanography and Hydrology in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by