用Octave求泰勒展开(9)
广告
{{v.name}}
常见麦克劳林展开式(9)
\({\rm arctan}x=x-\frac{x^{3} }{3}+\frac{x^{5} }{5}-\cdots+\frac{(-1)^{n} }{2n+1}x^{2n+1}+o(2n+1)\)
求\({\rm arctan}x\)的泰勒展开.
程序代码如下
function [text_result, numeric_result] = func47(order)
pkg load symbolic;
x = sym('x');
question = atan(x);
d = taylor(question, 'order', order + 1);
text_result = ["\n", disp(d)];
numeric_result = eval(d);
endfunction
计算5阶泰勒展开,结果如下
>> [text_result, numeric_result] = func47(5)
text_result =
5 3
x x
── - ── + x
5 3
numeric_result = (sym)
5 3
x x
── - ── + x
5 3
计算10阶泰勒展开,结果如下
>> [text_result, numeric_result] = func47(10)
text_result =
9 7 5 3
x x x x
── - ── + ── - ── + x
9 7 5 3
numeric_result = (sym)
9 7 5 3
x x x x
── - ── + ── - ── + x
9 7 5 3