通常,微分不过是基于函数变量之一的变化率。 MATLAB在求解这些导数,积分等方面非常有用。求解导数时要遵循某些规则,稍后将对此进行讨论。让我们看一些例子,以更好地理解事物。
句法:
diff(f,n)
Parameters:
- f: Function
- n: Order of derivative
范例1:
MATLAB
% MATLAB program to illustrate
% differentiation using diff() function
syms t
% function f(t) to be passed into diff()
f = 3*t^2 + 2*t^(-2);
diff(f)
MATLAB
% MATLAB program to illustrate
% rules of derivatives
% Sum rule
f = 2*x + 3*y;
sumDer = diff(f)
% Subtraction rule
f = x^3 - 2;
subDer = diff(f)
% Product rule
f = x^3 * 5;
prodDer = diff(f)
% Quotient rule
f = (2*x^2)/(x^2 + 2);
quoDer = diff(f)
f = (x^2 + 1)^17;
powDer = diff(f)
输出:
ans =
6*t - 4/t^3
区分的基本规则
让我们快速回顾在解决和操作功能时要遵循的规则。让我们考虑用相同的传统符号表示微分函数的阶数(即,对于一阶导数,f’(x);对于二阶导数,f“(x))。以下是一些重要的差异化规则:
规则1:
对于任何函数f和g,b,任何实数a和b是函数的常数。
h(x) = af(x) + bg(x), with respect to x is
h'(x) = af'(x) + bg'(x)
规则2:
是导数的和以及减法规则如下:
(f(x) + g(x))' = f'(x) + g'(x)
(f(x) - g(x))' = f'(x) - g'(x)
规则三:
如果h(x)是两个函数f(x)和g(x)的乘积,则h’(x)将为:
(f(x) * g(x))' = (f'(x) * g(x)) + (f(x) * g'(x))
规则四:
商法则指出(Low * High的导数)–(High * Low的导数)除以(Low的平方) 。让我们通过使用函数f(x)和g(x)更好地理解它。
( f/g )' = (g*f' - fg') / g2
规则5:
倒数规则定义为:如果f(x)是一个函数,则其倒数的导数(即1 / f)将如下所示。
(1/f(x))' = -f / f2
规则6:
幂定律被描述为f(x) = y n是一个函数,那么它的导数就是。
y(n)' = n * yn-1
现在,让我们看一些示例,以更好地理解上述规则。
范例2:
的MATLAB
% MATLAB program to illustrate
% rules of derivatives
% Sum rule
f = 2*x + 3*y;
sumDer = diff(f)
% Subtraction rule
f = x^3 - 2;
subDer = diff(f)
% Product rule
f = x^3 * 5;
prodDer = diff(f)
% Quotient rule
f = (2*x^2)/(x^2 + 2);
quoDer = diff(f)
f = (x^2 + 1)^17;
powDer = diff(f)
输出:
sumDer =
2
subDer =
3*x^2
prodDer =
15*x^2
quoDer =
(4*x)/(x^2 + 2) - (4*x^3)/(x^2 + 2)^2
powDer =
34*x*(x^2 + 1)^16