主要内容

泰勒

泰勒系列

描述

example

t= taylor(f,var)近似f泰勒系列扩展f达到该点的第五阶var = 0。如果您不指定var, then泰勒uses the default variable determined bysymvar(f,1)

example

t= taylor(f,var,a)近似f与泰勒系列扩展的fat the pointvar = a

example

t= taylor(___,名称,价值)使用一个或多个指定的其他选项名称,价值配对参数。您可以指定名称,价值after the input arguments in any of the previous syntaxes.

例子

全部收缩

Find the Maclaurin series expansions of the exponential, sine, and cosine functions up to the fifth order.

syms x T1 = taylor(exp(x)) T2 = taylor(sin(x)) T3 = taylor(cos(x))
t1 = x^5/120 + x^4/24 + x^3/6 + x^2/2 + x + x + 1 t2 = x^5/120 -x^3/6 + x t3 = x^4/24- x^2/2 + 1

You can use thesympref修改符号多项式的输出顺序的函数。重新播放多项式按顺序排列。

sympref('polyenlomialldisplaystyle','ascend');T1 T2 T3
t1 = 1 + x + x^2/2 + x^3/6 + x^4/24 + x^5/120 T2 = x - x^3/6 + x^5/120 T3 = 1 - x^2/2 + x^4/24

您使用的显示格式sympref通过您当前和未来的Matlab持续存在®sessions. Restore the default value by specifying the'默认'选项。

sympref('default');

Find the Taylor series expansions atx= 1对于这些功能。默认扩展点为0。要指定不同的扩展点,请使用ExpansionPoint:

syms x t = taylor(log(x),x,'膨胀点',1)
t= x - (x - 1)^2/2 + (x - 1)^3/3 - (x - 1)^4/4 + (x - 1)^5/5 - 1

Alternatively, specify the expansion point as the third argument of泰勒:

t =泰勒(acot(x),x,1)
t= pi/4 - x/2 + (x - 1)^2/4 - (x - 1)^3/12 + (x - 1)^5/40 + 1/2

找到Maclaurin系列的扩展f = sin(x)/x。the default truncation order is 6. Taylor series approximation of this expression does not have a fifth-degree term, so泰勒用四度多项式近似此表达:

symsxf = sin(x)/x; T6 = taylor(f, x);

利用命令控制截断奥德er. For example, approximate the same expression up to the orders 8 and 10:

t8 = taylor(f, x,'命令', 8); T10 = taylor(f, x,'命令',10);

Plot the original expressionf和its approximationst6,t8, 和T10。注意近似的精度如何取决于截断顺序。

fplot([T6 T8 T10 F])xlim([ -  4 4])网格传奇('approximation of sin(x)/x up to O(x^6)',。。。'approximation of sin(x)/x up to O(x^8)',。。。'sin(x)/x的近似值o(x^{10})',。。。'sin(x)/x','地点','Best') 标题(“泰勒系列扩展”)

Figure contains an axes object. The axes object with title Taylor Series Expansion contains 4 objects of type functionline. These objects represent approximation of sin(x)/x up to O(x^6), approximation of sin(x)/x up to O(x^8), approximation of sin(x)/x up to O(x^{10}), sin(x)/x.

Find the Taylor series expansion of this expression. By default,泰勒uses an absolute order, which is the truncation order of the computed series.

t =泰勒(1/(exp(x)) - exp(x) + 2*x, x, 'Order', 5)
t = -x^3/3

Find the Taylor series expansion with a relative truncation order by usingOrderMode。对于某些表达式,相对截断顺序提供了更准确的近似值。

t = taylor(1/(exp(x)) -  exp(x) + 2*x,x,'order',5,'ordermode',''相对')
t = -x^7/2520 -x^5/60 -x^3/3

找到此多元表达的Maclaurin系列扩展。如果您不指定变量的向量,泰勒零食fas a function of one independent variable.

syms x y z f = sin(x) + cos(y) + exp(z);t =泰勒(F)
t= x^5/120 - x^3/6 + x + cos(y) + exp(z)

Find the multivariate Maclaurin expansion by specifying the vector of variables.

syms x y z f = sin(x) + cos(y) + exp(z);t =泰勒(f,[x,y,z])
t= x^5/120 - x^3/6 + x + y^4/24 - y^2/2 + z^5/120 + z^4/24 + z^3/6 + z^2/2 + z + 2

You can use thesympreffunction to modify the output order of a symbolic polynomial. Redisplay the polynomial in ascending order.

sympref('polyenlomialldisplaystyle','ascend');t
t = 2 + z + z^2/2 + z^3/6 + z^4/24 + z^5/120 -y^2/2 + y^4/24 + x -x -x^3/6 +X^5/120

您使用的显示格式sympref通过您当前和未来的MATLAB会议持续存在。通过指定默认值来还原默认值'默认'选项。

sympref('default');

Find the multivariate Taylor expansion by specifying both the vector of variables and the vector of values defining the expansion point:

syms x y f = y*exp(x -1) -  x*log(y);t =泰勒(f,[x,y],[1,1],'order',3)
t = x +(x -1)^2/2 +(y -1)^2/2

如果you specify the expansion point as a scalara,泰勒将标量转换为与变量向量相同长度的向量。扩展向量相等的所有元素a:

t =泰勒(f,[x,y],1,'order',3)
t = x +(x -1)^2/2 +(y -1)^2/2

输入参数

全部收缩

Input to approximate, specified as a symbolic expression or function. It also can be a vector, matrix, or multidimensional array of symbolic expressions or functions.

扩展变量,指定为符号变量。如果您不指定var, then泰勒uses the default variable determined bysymvar(f,1)

扩展点,指定为数字或符号数,变量,函数或表达式。扩展点不能取决于扩展变量。您还可以将扩展点指定为名称,价值pair argument. If you specify the expansion point both ways, then the名称,价值配对参数优先。

Name-Value Arguments

Specify optional comma-separated pairs of名称,价值参数。Nameis the argument name and价值是相应的值。Name必须出现在引号中。您可以按任何顺序指定几个名称和值对参数NAME1,Value1,...,Namen,Valuen

例子:泰勒(log(x),x,'stuplyionpoint',1,'order',9)

扩展点,指定为数字或符号数,变量,函数或表达式。扩展点不能取决于扩展变量。You can also specify the expansion point using the input argumenta。如果您两种方式指定了扩展点,那么名称,价值配对参数优先。

泰勒串联扩展的截断顺序,指定为正整数或符号正整数。泰勒计算泰勒系列近似n - 1。截断令nis the exponent in theO-term:O(varn)

命令mode indicator, specified as'绝对'或者'relative'。该指标指定计算泰勒多项式近似时是否要使用绝对顺序或相对顺序。

绝对顺序是计算系列的截断顺序。Relative ordern意味着var在里面computed series range from the leading orderm到最高指数M + N -1。Herem + nis the exponent ofvar在里面O-term:O(varm + n)

More About

全部收缩

泰勒系列扩展

泰勒系列扩展represents an analytic functionf(x)作为围绕扩展点的无限条款总和x=a:

f ( x ) = f ( a ) + f ( a ) 1 ! ( x a ) + f ( a ) 2 ! ( x a ) 2 + = m = 0 f ( m ) ( a ) m ! ( x a ) m

泰勒串联扩展需要一个函数,使衍生物在扩展点附近的无限顺序中最大。

Maclaurin Series Expansion

泰勒系列扩展aroundx= 0称为Maclaurin系列扩展:

f ( x ) = f ( 0 ) + f ( 0 ) 1 ! x + f ( 0 ) 2 ! x 2 + = m = 0 f ( m ) ( 0 ) m ! x m

提示

  • 如果you use both the third argumentaExpansionPointto specify the expansion point, the value specified viaExpansionPoint盛行。

  • 如果varis a vector, then the expansion pointamust be a scalar or a vector of the same length asvar。如果varis a vector anda是标量ais expanded into a vector of the same length asvarwith all elements equal toa

  • 如果the expansion point is infinity or negative infinity, then泰勒计算Laurent系列扩展,这是一个功率系列1/var

  • You can use thesympref修改符号多项式的输出顺序的函数。

在R2006a之前引入