0% found this document useful (0 votes)
12 views3 pages

LAB Sheet-8

The document provides a lab sheet for a mathematics course focused on intelligent systems, detailing methods for differentiation, integration, and solving ordinary differential equations using MATLAB. It includes examples of symbolic differentiation, integration, double integration, and plotting functions, as well as solving initial value problems both symbolically and numerically. Additionally, it contains practice problems for students to apply the concepts learned.

Uploaded by

xtremelysurya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

LAB Sheet-8

The document provides a lab sheet for a mathematics course focused on intelligent systems, detailing methods for differentiation, integration, and solving ordinary differential equations using MATLAB. It includes examples of symbolic differentiation, integration, double integration, and plotting functions, as well as solving initial value problems both symbolically and numerically. Additionally, it contains practice problems for students to apply the concepts learned.

Uploaded by

xtremelysurya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Amrita Vishwa Vidyapeetham, Amritapuri Campus

23MAT126 - Mathematics for Intelligent Systems – 1

Lab Sheet-8

1. Differentiation

You can differentiate symbolic expressions using the diff function.

syms x
f = x^3 + 2*x^2 + x; % Define a symbolic function
df = diff(f, x); % First derivative
disp(df) % Display the derivative

Integration

Use the int function for symbolic integration (indefinite or definite).

syms x
f = x^2 + 3*x + 5; % Define a symbolic function
F = int(f, x); % Indefinite integral
disp(F)

I = int(f, x, 0, 2); % Definite integral from 0 to 2


disp(I)

Symbolic Double Integration

Use the int function for symbolic double integrals.

syms x y
f = x^2 + y^2; % Define the function to integrate
inner_integral = int(f, y, 0, x); % Integrate with respect to y from 0 to x
result = int(inner_integral, x, 0, 1); % Integrate with respect to x from 0 to 1
disp(result) % Display the result

Plotting Functions

Use MATLAB's plotting capabilities to visualize functions and solutions.

Example:

fplot(@(x) x^3 - 3*x^2 + 4, [-2, 2]); % Plot the function on the interval [-2, 2]
xlabel('x');
ylabel('f(x)');
title('Function Plot');
grid on;
Solving Ordinary Differential Equations (ODEs)
MATLAB provides the dsolve function for symbolic solutions and numerical solvers such as
ode45 for numerical solutions.

syms y(x)
Dy = diff(y, x); % Define derivative
ODE = Dy + 3*y == sin(x); % Define the ODE
ySol = dsolve(ODE); % Solve the ODE
disp(ySol);

Solving IVPs Symbolically

Use dsolve for exact solutions to IVPs.

syms y(x)
Dy = diff(y, x); % Define the derivative
ODE = Dy + 2*y == exp(-x); % Define the ODE
cond = y(0) == 1; % Initial condition
ySol = dsolve(ODE, cond); % Solve the IVP
disp(ySol); % Display the solution

Numerical Solution
% Solve y' = -2*y with initial condition y(0) = 1

f = @(t, y) -2*y; % Define the ODE as a function handle


[t, y] = ode45(f, [0, 5], 1); % Solve numerically from t=0 to t=5 with y(0)=1
plot(t, y); % Plot the solution
xlabel('t'); ylabel('y(t)');
title('Solution of y'' = -2y');

Practise Problems:

You might also like