用Octave求泰勒展开(5)
广告
{{v.name}}
反正切函数的麦克劳林展开

泰勒展开是用多项式逼近函数的重要方法。反正切函数的麦克劳林展开是微积分学习中的重要内容,理解其数学原理是掌握后续知识的基础。

数学上,这一概念通过严格的极限语言来定义,符号计算工具可以帮助我们快速验证和计算相关问题。

用Octave求泰勒展开

在Octave中,使用 taylor(f, 'order', n+1) 可以方便地计算函数 f 在 x=0 处的 n 阶泰勒展开(麦克劳林展开)。

通过下面的代码示例,你可以学习如何用Octave来求泰勒展开。Octave的Symbolic包提供了强大的符号计算能力,让我们能够专注于理解数学概念,而不是繁琐的手工计算。

常见麦克劳林展开式(5)
\(\frac{1}{1+x}=1-x+x^{2}-\cdots+-1^{n}x^{n}+o(x^{n})\)
求\(\frac{1}{1+x}\)的泰勒展开.
程序代码如下
function [text_result, numeric_result] = func43(order)
    pkg load symbolic;
    x = sym('x');
    question = 1 / (1 + x);
    d = taylor(question, 'order', order + 1);
    text_result = ["\n", disp(d)];
    numeric_result = eval(d);
endfunction
计算5阶泰勒展开,结果如下
>> [text_result, numeric_result] = func43(5)
text_result =
       5    4    3    2
    - x  + x  - x  + x  - x + 1

numeric_result = (sym)

       5    4    3    2
    - x  + x  - x  + x  - x + 1
计算10阶泰勒展开,结果如下
>> [text_result, numeric_result] = func43(10)
text_result =
     10    9    8    7    6    5    4    3    2
    x   - x  + x  - x  + x  - x  + x  - x  + x  - x + 1

numeric_result = (sym)

     10    9    8    7    6    5    4    3    2
    x   - x  + x  - x  + x  - x  + x  - x  + x  - x + 1
友链