# Matlab微積分

MATLAB提供了解決微分和積分微積分的各種方法，求解任何程度的微分方程和極限計算。可以輕鬆繪製複雜功能的圖形，並通過求解原始功能以及其衍生來檢查圖形上的最大值，最小值和其他固定點。

## 計算極限

MATLAB提供計算極限的`limit`函式。在其最基本的形式中，`limit`函式將表示式作為引數，並在獨立變數為零時找到表示式的極限。

``````syms x
limit((x^3 + 5)/(x^4 + 7))
``````

``````Trial>> syms x
limit((x^3 + 5)/(x^4 + 7))

ans =

5/7
``````

`limit`函式落在符號計算域; 需要使用`syms`函式來告訴MATLAB正在使用的符號變數。還可以計算函式的極限，因為變數趨向於除零之外的某個數位。要計算 -

``````limit((x - 3)/(x-1),1)
``````

``````ans =
NaN
``````

``````limit(x^2 + 5, 3)
``````

``````ans =
14
``````

## 使用Octave計算極限

``````pkg load symbolic
symbols
x=sym("x");

subs((x^3+5)/(x^4+7),x,0)
``````

``````ans =
0.7142857142857142857
``````

## 驗證極限的基本屬性

``````f(x) = (3x + 5)/(x - 3)
g(x) = x^2 + 1.
``````

``````syms x
f = (3*x + 5)/(x-3);
g = x^2 + 1;
l1 = limit(f, 4)
l2 = limit (g, 4)
lAdd = limit(f + g, 4)
lSub = limit(f - g, 4)
lMult = limit(f*g, 4)
lDiv = limit (f/g, 4)
``````

``````l1 =
17

l2 =
17

34

lSub =
0

lMult =
289

lDiv =
1
``````

## 使用Octave驗證極限的基本屬性

``````pkg load symbolic
symbols

x = sym("x");
f = (3*x + 5)/(x-3);
g = x^2 + 1;

l1=subs(f, x, 4)
l2 = subs (g, x, 4)
lAdd = subs (f+g, x, 4)
lSub = subs (f-g, x, 4)
lMult = subs (f*g, x, 4)
lDiv = subs (f/g, x, 4)
``````

``````l1 =

17.0
l2 =

17.0

34.0
lSub =

0.0
lMult =

289.0
lDiv =

1.0
``````

## 左右邊界極限

``````f(x) = (x - 3)/|x - 3|
``````

• 通過繪製函式圖並顯示不連續性。
• 通過計算極限並顯示兩者都不同。

``````f = (x - 3)/abs(x-3);
ezplot(f,[-1,5])
l = limit(f,x,3,'left')
r = limit(f,x,3,'right')
``````

``````Trial>>
Trial>> f = (x - 3)/abs(x-3);
ezplot(f,[-1,5])
l = limit(f,x,3,'left')
r = limit(f,x,3,'right')

l =

-1

r =

1
``````