Home task
Home task
College of E&ME
Department of Mechatronics Engineering
LAB TASKS
TASK 1:
Construct a program to Euler’s Method and 2nd order R-K Method to solve the following initial
value problem
Keep your step size h=0.5 and solve till t=2. Repeat for h=0.05
TASK 2:
Construct a program to implement 4th order R-K Method to solve the following initial value
problem
𝑚𝑚𝑥𝑥̈ + 𝑐𝑐𝑥𝑥̇ + 𝑘𝑘𝑘𝑘 = cos 3𝑡𝑡
Use m=1, c=2, k=4. Solve for initial velocity, 𝑥𝑥̇ (0) = 0 ; and an initial displacement, 𝑥𝑥(0) = 1.
Plot displacement vs time. Use an appropriate time step and end time to capture the dynamics of the
system.
Note that the 2nd order equation can be converted in to two first order equations, using a newly defined
set of “state variables” 𝑥𝑥1 = 𝑥𝑥 and 𝑥𝑥2 = 𝑥𝑥̇
𝑥𝑥̇ 1 = 𝑥𝑥2
𝑥𝑥̇ 2 = cos 3𝑡𝑡 − 2𝑥𝑥2 − 4𝑥𝑥1
LAB 10
Aim:
The main aim for this lab is to learn about the following topics:
• Euler’s Method
Software Required:
• MATLAB
EULER’s METHOD:
Without explicit solutions to the differential equations it would be hard to get any information about
the solution.
For instance, maybe we need to determine how a specific solution behaves, including some values
that the solution will take. There are also a fairly large set of differential equations that are not easy
to sketch good direction fields for.
There are many different methods that can be used to approximate solutions to a differential
equation. This method was originally devised by Euler and is called, oddly enough, Euler’s Method.
where f(t,y) is a known function and the values in the initial condition are also known numbers. We
want to approximate the solution to (1) near t=t0 . We’ll start with the two pieces of information that
we do know about the solution. First, we know the value of the solution at t=t0 from the initial
condition. Second, we also know the value of the derivative at t=t0 . We can get this by plugging the
initial condition into f(t,y) into the differential equation itself. So, the derivative at this point is.
If h is the step size then the formula for the next approximation becomes.
Aim:
The main aim for this lab is to learn about the following topics:
• 2nd order R.K Method
• 4th order R.K Method
Software Required:
• MATLAB
K1 = h f ( xi , yi )
K2 = h f( xi + h , yi + K1 )
Yi+1 = yi + ( K1 + K2 ) / 2
K1 = h f ( xi , yi )
K2 = h f ( xi + h / 2 , yi + K1 / 2)
K3 = h f ( xi + h / 2 , yi + K2 / 2)
K4 = h f( xi + h , yi + K3 )
Where f(x,y) = dy / dx
Y(t0) = α
α is the initial value of y.