Euler Code:
A first ODE solver
MATH1090: Numerical Methods in Scientific Computing II
http://people.sc.fsu.edu/∼jburkardt/classes/math1090 2020/euler code/euler code.pdf
The Euler method steps off in the right direction, and gradually drifts away.
Euler Code
Writing a simple, general Euler code to solve a differential equation will give you an idea of the kind
of mathematical problems we are interested in, and the computational methods we use to solve them.
1 Introduction
This is an introduction for all of us. You would like to know what we are working on. We would like to
know how well prepared you are for the computational efforts in this directed study class.
Without knowing much about your backgrounds, we are asking you to try the following sequence of tasks,
writing up the necessary MATLAB code. You are welcome to ask us for help at any point. When you think
you are done, send us the files you have written and the plot you have created. We will meet on Tuesday,
January 21, at 2:00pm in Thackeray 624 to go over this task, and to talk about plans for future work.
2 A differential equation
Consider the following differential equation:
dy
dt
=
−2 ∗ (t − 0.3)
((t − 0.3)
2
+ 0.01)
2
−
2 ∗ (t − 0.9)
((t − 0.9)
2
+ 0.04)
2
with initial condition y(0) = 5.1765. From this information, we can estimate the value of y(t) for future
times. We are interested in creating a plot of our estimate over the interval 0 ≤ t ≤ 2.
1