4 - Matlab Mathemathical Modelling
4 - Matlab Mathemathical Modelling
• Mathematical modelling
• Differential equations
• Numerical differentiation and integration
Applications
• Mathematical methods
1
Applications
• Mathematical methods
– Learning how mathematical models can be formulated on the basis
of scientific principles to simulate the behavior of a simple physical
system.
• Numerical methods
– Understanding how numerical methods afford a means to
generalize solutions in a manner that can be implemented on a
digital computer.
• Problem solving
– Understanding the different types of conservation laws that lie
beneath the models used in the various engineering disciplines and
appreciating the difference between steady-state and dynamic
solutions of these models.
Mathematical modelling
Mathematical Modeling
Approximation & Assumption
Common
Formulation or Governing features
Equations operation
Applications
2
Differential Equations
3
Mathematical model – Function example
4
Exercise using .m files
5
Mathematical model – Solving the equation
6
Exercise using .m files
% Plotting of results
plot(t,v)
grid
title('Velocity for the bungee jumper')
legend('v (m/s)')
dv Δv
= lim
dt Δt →0 Δ t
Δv v ( t i + 1 ) − v ( t i )
=
Δt ti+1 − ti
Assume constant slope (i.e,
constant drag force) over Δt
7
Mathematical model – Numerical (approximate) solution
⎡ c ⎤
v ( t i + 1 ) = v( t i ) + ⎢ g − d v( t i ) 2 ⎥( t i + 1 − t i )
⎣ m ⎦ Fdown
t0 = 0; v( t0 ) = 0
8
Mathematical model – Example: Euler’s method
9
Exercise using .m files
10
Exercise using .m files
11
Mathematical model – Effect of chord
dv c
= g − d v |v | Fup
dt m
Ø At the end of the chord, additional forces appear
Gravitation Drag force
dv c k γ
= g − d v⋅ | v | − ( x − L) − v Fdown
dt m m m
12
Mathematical model – System of two ODEs
Fup
Fdown
dydt = [y(2);
g – sign(y(2))*cd/m*y(2)^2 – chord]
Ø If we make a new variable for the the extra force from
the chord
chord = k/m*(y(1)-L) + gamma/m*y(2)
13
Mathematical model – System of two ODEs
14
Differential equations
• Question
– How can we solve a first-order differential equation of the form
with x(0) = 0, i.e. we need to find the right function x(t) which fulfils
the ODE and the initial conditions (IC).
Differential equations
15
Differential equations
Differential equations
• In the expression on the previous page, we approximate the
slope of the tangent line at tn (“the derivative”) by the slope of
the chord that connects the point (tn,x(tn)) with the point (tn
+1,x(tn+1)). This is illustrated in the figure below
16
Differential equations
• Substituting the approximation for the derivative into the
ODE, we obtain
Differential equations
• For example, the value of x at the next grid point, t1=h, after
the starting point is
17
Differential equations
• In the corresponding Matlab code, we choose h = 0.001 and
N=10000, and so tN=10. Here is a plot of x(t), where the
discrete points have been connected by straight lines.
Differential equations
• Accuracy
We see that the value of xN depends upon the step size h. In
theory a higher accuracy of the numerical solution in
comparison to the exact solution can be achieved by
decreasing h since our approximation of the derivative
more accurate.
18
Differential equations
• For Euler’s method it turns out that the global error (error at a
given t) is proportional to the step size h while the local error
(error per step) is proportional to h2. This is called a first-
order method.
Differential equations
• We can now summarize Euler’s method
Given the ODE
19
Differential equations
• Instability
Apart from its fairly poor accuracy, the main problem with
Euler’s method is that it can be unstable, i.e. the numerical
solution can start to deviate from the exact solution in
dramatic ways. Usually, this happens when the numerical
solution grows large in magnitude while the exact solution
remains small
• A popular example to demonstrate this feature is the ODE
• The exact solution is simply x(t) = e-t. It fulfils the ODE and
the initial condition.
Differential equations
• On the other hand, our Euler methods reads
20