ECE120L - Activity 6
ECE120L - Activity 6
LABORATORY ACTIVITY #6
Higher Mathematical Operations
I. Learning Outcomes:
At the end of the laboratory activity, the students should be able to:
1. Use MATLAB to solve the derivative and integral of a given mathematical function
2. Use MATLAB to obtain linear transforms of higher equations such as Laplace Transforms and Fourier
Transform
II. Introduction:
A. Derivative of a Function
𝑑𝑓(𝑥)
The derivative of a function 𝑦 = 𝑓(𝑥) is written 𝑑𝑥
and is defined as the rate of change of the
dependent variable y with respect to x. The derivative is the slope of the line tangent to the function at a given
point.
MATLAB is capable to solve the derivative of a given function.
a) polyder
Polynomial derivative
Syntax
k = polyder(p)
k = polyder(a,b)
[q,d] = polyder(b,a)
Description
The polyder function calculates the derivative of polynomials, polynomial products, and polynomial quotients.
The operands a, b, and p are vectors whose elements are the coefficients of a polynomial in descending
powers.
k = polyder(p) returns the derivative of the polynomial p.
k = polyder(a,b) returns the derivative of the product of the polynomials a and b.
[q,d] = polyder(b,a) returns the numerator q and denominator d of the derivative of the
polynomial quotient b/a.
Examples:
1. The derivative of the polynomial 𝑦 = 3𝑥 5 + 6𝑥 4 − 4𝑥 3 + 9𝑥 2 + 2𝑥 + 10 is obtained with
%Derivative of a Polynomial
clear
y = [3 6 -4 9 2 10];
k = polyder(y)
k =
15 24 -12 18 2
This result represents the polynomial 15𝑥 4 + 24𝑥 3 − 12𝑥 2 + 18𝑥 + 2
Examples:
1. Solve the derivative of 𝑓(𝑥) = 𝑥 4 .
% Derivative a function with respect to a variable
clear
symvar x;
f = x^4;
k = diff(f)
k =
4*x^3
The derivative is 4𝑥 3 .
B. Integral of a function
Finding the integral of a function with respect to x means finding the area to the x axis from the curve.
The integral is usually called the anti-derivative, because integrating is the reverse process of differentiating.
The fundamental theorem of calculus shows that antidifferentiation is the same as integration.
𝑏
The integral of a function 𝑓(𝑥) between the limits given by 𝑥 = 𝑎 and 𝑥 = 𝑏 is written as ∫𝑎 𝑓(𝑥)𝑑𝑥
and is defined as the area under the curve 𝑓(𝑥) from 𝑎 to 𝑏, as long as the function is above the 𝑥 − 𝑎𝑥𝑖𝑠.
Numerical integration techniques involve approximating this.
a) polyint
Integrate polynomial analytically
Syntax
polyint(p,k)
polyint(p)
Description
polyint(p,k) returns a polynomial representing the integral of polynomial p, using a scalar
constant of integration k.
polyint(p) assumes a constant of integration k=0.
Examples:
1. The indefinite integral of the polynomial 𝑦 = 3𝑥 5 + 6𝑥 4 − 4𝑥 3 + 9𝑥 2 + 2𝑥 + 10 is obtained with
% Indefinite integral of a polynomial function
clear
a = [3 6 -4 9 2 10];
k = polyint(a)
k =
0.5000 1.2000 -1.0000 3.0000 1.0000 10.0000 0
6 5 4 3 2
The integral is 0.5𝑥 + 1.2𝑥 − 𝑥 + 3𝑥 + 𝑥 + 10𝑥
Examples:
1
1. The indefinite integral of the function 𝑓(𝑥) = 1+𝑥2 is obtained with
% Indefinite integral of a function
clear
syms f x;
f = 1/(1+x^2);
k = int(f)
k =
atan(x)
The integral is tan−1 𝑥
2. The indefinite integral of the function 𝑓(𝑥) = sin 2𝜋𝑛𝑥 with respect to 𝑥 is obtained with
% Indefinite integral of a function with respect to x
clear
syms f pi n x;
f = sin(2*pi*n*x);
k = int(f,x)
k =
-cos(2*pi*n*x)/(2*pi*n)
1
The integral is − cos 2𝜋𝑛𝑥
2𝜋𝑛
3. The definite integral of the function 𝑓(𝑥) = 4𝑥 3 + 2𝑥 2 + 5𝑥 + 9 from 1 to 2 is obtained with
% Definite integral of a function
clear
syms f x;
f = 4*x^3 + 2*x^2 +5*x + 9;
k = int(f,1,2)
k =
217/6
The integral is 217⁄6 or 36.1667.
a) Derivative
• Using MATLAB, determine the derivative of the following functions
1. 𝑓(𝑥) = 𝑥 𝑛
2. 𝑓(𝑡) = sin(𝑎𝑡 + 𝑏)
3. 𝑓(𝑥) = 𝑥 2 + 3𝑥 + 1
4. 𝑓(𝑥) = ln 𝑥
• Determine the derivatives of the following functions with respect to 𝑥 and then with respect to 𝑦.
1. 𝑓 = 5 ln 𝑥𝑦
2. 𝑓 = 2𝑦 sin 𝑥 2
• Determine the second derivative of the following functions with respect to 𝑥 and then with respect to
𝑦.
1. 𝑓 = 2𝑥 5 𝑦 3 − 3𝑥 4 𝑦 2 + 9𝑥 2 𝑦
2. 𝑓 = 10 cos(𝑥𝑦 2 )
b) Integral
• Using MATLAB, determine the indefinite integral of the following functions
1. 𝑓(𝑥) = 𝑥 𝑛
2. 𝑓(𝑡) = sin(𝑎𝑡 + 𝑏)
3. 𝑓(𝑥) = 𝑥 2 + 3𝑥 + 1
4. 𝑓(𝑥) = ln 𝑥
• Determine the integral of the following functions with respect to 𝑥 and then with respect to 𝑦.
(1
3. 𝑓 = − 𝑥)⁄𝑥𝑦
4. 𝑓 = 2𝑦 sin 𝜋𝑥 2
• Determine the second integral of the following functions with respect to 𝑥 and then with respect to 𝑦.
1. 𝑓 = 2𝑥 5 𝑦 3 − 3𝑥 4 𝑦 2 + 9𝑥 2 𝑦
2. 𝑓 = 10 cos(2𝜋𝑥𝑦 2 )
• Determine the integral with limit from 0 to 3 of the following functions
1. 𝑓(𝑥) = −𝑥 3
2. 𝑓(𝑥) = 𝑥 2 sin(𝜋𝑥)
c) Laplace Transform
• Determine the Laplace transform of the following t – domain function.
1. 𝑓(𝑡) = 10 sin 2𝑡
2. 𝑓(𝑡) = 2 cosh 4𝑡
3. 𝑓(𝑡) = 5 cos 5𝑡
4. 𝑓(𝑡) = 2𝑡 3 𝑒2𝑡
5. 𝑓(𝑡) = 6𝑒−6𝑡