Professional Documents
Culture Documents
School of Engineering and Computer Science Department of Electrical & Electronic Engineering
School of Engineering and Computer Science Department of Electrical & Electronic Engineering
School of Engineering and Computer Science Department of Electrical & Electronic Engineering
Course ID EEE-314L
Student ID 1711396
Experiment No: 05
Experiment Name: Study on solving Differential Equation using Euler Method.
Objectives:
➢ To get introduced with basic MATLAB commands to perform Eulers Method.
➢ Perform Eulers Method on given examples.
➢ Verify MATLAB output with the theoretical hand calculations.
Apparatus:
➢ MATLAB
A differential equation contains derivatives which are either partial derivatives or ordinary
derivatives. The derivative represents a rate of change, and the differential equation describes a
relationship between the quantity that is continuously varying with respect to the change in
another quantity.
• Euler Method
Euler's method is used for approximating solutions to certain differential equations and works by
approximating a solution curve with line segments.
In some cases, it's not possible to write down an equation for a curve, but we can still find approximate
coordinates for points along the curve by using simple lines. These line segments have the same slope as the
curve, so they stay relatively close to it. Euler's method is useful because differential equations appear frequently
in physics, chemistry, and economics, but usually cannot be solved explicitly, requiring their solutions to be
approximated. For example, Euler's method can be used to approximate the path of an object falling through a
viscous fluid, the rate of a reaction over time, the flow of traffic on a busy road, to name a few.
Equations:
𝑌𝑛+1 = 𝑌𝑛 + ℎ𝑓(𝑋𝑛 )
h = Step size
f(x) = differential equation
MATLAB Code:
Code for Single N points
This experiment in on the graphical visualization of Euler Method solved derivation. if we break
down the MATLAB code, we can see at first the code started with declaring the interval which
starts from t0=0 to t5=5. Number of Y values are set to 5 for single N point. The common
distance between the points or step size h = (t0−t)/N is given as the equation. Initial Y(1) is
solved by hand from the given equation.
After that a “for” loop is introduced as the body of the function there the 1st order derived
solving is written from the given function. In next line the main Euler method equation is written
to conduct the derived function. “end” ends the loop.
To see the graph at first ‘plot(x,y)’ is written to set graph in 2D x and y axis. In following line
‘plot(x,y(i+1))’ sets the mesh points in x vs. new y. Legend function creates descriptive labels for
plotted data series in the form of 'Approximate','Exact'. 2 lines will be formed where the blue line
is continuous approximation to the solution y(t) and the red line will be the exact solution. As
Euler method focuses on the approximation of y(t) so the comparison is showed for error rate on
Approximate values from graph and calculation.
In Multiple point code two loops are intertwined in one another to avoid the writing each code
separately for every points. 1st loop of “for” will run via the “length” of N to run the loop for
that many times. “j” will specify the length for step size. 2nd loop of “for” will run inside the 1st
loop to solve the Euler equation.
From result analysis we can see that the values of both theoretical and graphical are same in 3x5
and cos(x2 ) but had a slight shift in error percentage in 2x+e -2x . It happened because of
calculating with approximate answers after point.
LAB REPORT RUBRICS
Result and Analyzed and Intermediate The results are Intermediate The results are
analysis (25%) interpreted the results between analyzed to some between novice analyzed poorly
properly using the developing extent according and developing. due to
converter parameters. and to specified incomplete
accomplished. requirements. simulation.
Sub Total 80
Deduction for late
submission / any
other issue
Total (100%)
10% of Total