You are on page 1of 15

Higher Mathematical

Operations

INTRODUCTION TO MATLAB
ECE120L
Derivative of a function

The MATLAB/Octave is capable to solve the derivative of a given


function. We use the following commands to evaluate the derivative
of a function:
polyder(p) returns the derivative of polynomial p
polyder(a,b) returns the derivative of ab
[q,d]=polyder(a,b) returns the numerator q an denominator d of
the derivative of a/b
Examples

Evaluate the derivative of the following expressions:


1. 𝑦 = 3𝑥 5 + 6𝑥 4 − 4𝑥 3 + 9𝑥 2 + 2𝑥 + 10
2. 𝑦 = 3𝑥 2 + 6𝑥 + 9 𝑥 2 + 2𝑥
3𝑥 2 +6𝑥+9
3. 𝑦 =
𝑥 2 +2𝑥
Derivative of Symbolic
Variables
The derivative of a given function can be solved in MATLAB/Octave
using symbolic variables and the command ‘diff’.
diff(f) differentiates a symbolic expression f with respect
to its free variable as determined by SYMVAR.

Example: Find the derivative of 𝑥 4 .


Syntax: syms f x;
f = x^4;
diff(f)
Derivative of Symbolic
Variables
diff(f,‘x’) or diff(f,sym(‘x’)) differentiates f with respect to x

Example: Find the derivative of 2𝑥 4 𝑦 − 5𝑥 3 𝑦 2 + 10𝑥𝑦 with respect


to x.
Syntax: syms f x y;
f = (2*x^4*y)-(5*x^3*y^2)+10*x*y;
diff(f,’x’)
Derivative of Symbolic
Variables
diff(f,n) for a positive integer n, differentiates f n times

Example: Find the 3rd derivative of 4𝑥 6 + 6 sin 5𝑥.


Syntax: syms f x;
f = (4*x^6)+(6*sin(5*x));
diff(f,3)
Derivative of Symbolic
Variables
diff(f,’x’,n) Evaluates nth derivative of f with respect to x

Example: Find the 3rd derivative of 4𝑥 6 + 6 sin 5𝑥.


Syntax: syms f x
f = (4*x^6)+(6*sin(5*x));
diff(f,’x’,3)
Integral of a Function

polyint(p,k) returns a polynomial representing the integral of


the polynomial p using scalar constant of
integration k.
polyint(p) assumes a constant of integration k=0.

Example: Find the integral of the polynomial 𝑦 = 3𝑥 2 + 6𝑥 + 9.


Syntax: y=[3 6 9];
polyint(y)
Integral of Symbolic
Variables
int(f) indefinite integral of f with respect to its symbolic
variable as defined by SYMVAR.

1
Example: What is the integral of 𝑦 = .
1+𝑥 2

Syntax: syms f x;
f=1/(1+x^2);
int(f)
Integral of Symbolic
Variables
int(f,x) indefinite integral of f with respect to its symbolic
variable x. The variable x is a symbolic scalar.

Example: Find the integral of 𝑦 = sin 2𝜋𝑛𝑥 with respect to x.


Syntax: syms f pi n x;
f = sin(2*pi*n*x);
int(f,x)
Integral of Symbolic
Variables
int(f,a,b) definite integral of f with respect to its symbolic
variable from a to b. The variables a and b are
symbolic scalars.
int(f,x,a,b) definite integral of f with respect to x from a to b.
The variables a and b are symbolic scalars.
Example: find the integral of 4𝑥 6 + 6 sin 5𝑥 from 0.1 to 0.5.
Syntax: syms f x;
f = (4*x^6)+(6*sin(5*x));
int(f,0.1,0.5)
Laplace Transform of
Symbolic Variables
laplace(f) laplace transform of the function f

Example: find the laplace transform of 𝑦 = 2𝑡 3 + 𝑒 −3𝑡


Syntax: syms f t;
f = 2*t^3 + exp(-3*t);
laplace(f)
Inverse Laplace Transform
of Symbolic Variables
ilaplace(f) inverse laplace transform of the function f.

10
Example. Find the inverse Laplace of the function 𝐹 𝑠 = 3 .
𝑠

Syntax: syms f s;
f = 10/s^3;
ilaplace(f)
Fourier Transform of
Symbolic Variables
fourier(f) Evaluates the fourier transform of f with respect to
its symbolic variable x and returns a function of 𝜔.
fourier(f,v) returns a function of v instead of 𝜔.
fourier(f,u,v) Evaluates the fourier transform of f with respect to
its symbolic variable u (instead of x) and returns a
function of v instead of 𝜔.
2
Example: find the fourier transform of 𝑓 = 𝑒 .
−𝑥

Syntax: syms x
f = exp(-x^2)
fourier(f)
END

You might also like