當前位置:編程學習大全網 - 編程軟體 - matlab實現下公式的taylor級數展開

matlab實現下公式的taylor級數展開

妳好,很簡單,只要用taylor函數就可以

syms x2 x1 d1 d2 L

y=L^2/(L+x1*d1+x2*d2)^2;

f = taylor(y)

f =

L^2/(L + d2*x2)^2 - (2*L^2*d1*x1)/(L + d2*x2)^3 + (3*L^2*d1^2*x1^2)/(L + d2*x2)^4 - (4*L^2*d1^3*x1^3)/(L + d2*x2)^5 + (5*L^2*d1^4*x1^4)/(L + d2*x2)^6 - (6*L^2*d1^5*x1^5)/(L + d2*x2)^7

>>

下面是matlab提供的關於taylor 函數的壹些幫助,可以通過 doc taylor 調出來

Examples

Compute the Maclaurin series expansions of these functions:

syms x

taylor(exp(x))

taylor(sin(x))

taylor(cos(x))

ans =

x^5/120 + x^4/24 + x^3/6 + x^2/2 + x + 1

ans =

x^5/120 - x^3/6 + x

ans =

x^4/24 - x^2/2 + 1

Compute the Taylor series expansions around x = 1 for these functions. The default expansion point is 0. To specify a different expansion point, use ExpansionPoint:

syms x

taylor(log(x), x, 'ExpansionPoint', 1)

ans =

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 taylor:

taylor(acot(x), x, 1)

ans =

pi/4 - x/2 + (x - 1)^2/4 - (x - 1)^3/12 + (x - 1)^5/40 + 1/2

Compute the Maclaurin series expansion for this function. The default truncation order is 6. Taylor series approximation of this function does not have a fifth-degree term, so taylor approximates this function with the fourth-degree polynomial:

syms x

f = sin(x)/x;

t6 = taylor(f)

t6 =

x^4/120 - x^2/6 + 1

Use Order to control the truncation order. For example, approximate the function up to the orders 8 and 10:

t8 = taylor(f, 'Order', 8)

t10 = taylor(f, 'Order', 10)

t8 =

- x^6/5040 + x^4/120 - x^2/6 + 1

t10 =

x^8/362880 - x^6/5040 + x^4/120 - x^2/6 + 1

  • 上一篇:modeler需要什麽電腦配置
  • 下一篇:c語言編程大神求幫忙寫個程序。
  • copyright 2024編程學習大全網