## Transcribed Text

Suspension system of car can be modelled as mass spring damper. The equation for the position
y of the mass in the mass spring damper system is second order differential equation
d²y
dy
where m is mass of the object, b is damping ratio, k is spring constant, and f(t) is the force that
is acting on the system
Use central differencing to find the propagation equation and obtain the solution assuming zero
condition for the position and velocity of the mass, i.e.
dy
y(0) 0.
(0) = 0
Write Python function that given m, b, k, initial time to final time t, and time step At calculate
and return y in list Use the function to plot your response for the following parameters
0 15
At 0.005
m
k 5
b 0.5. 1.and 2
f(t)
Your graph should show three plots, one for each value of b. Include axis labels and a legend
identifying the different plots
Challenge:
Experiment with different values of At and determine the largest value that results in a "good
approximation" of the solution for the parameters given below. You need to choose your own
criteria for a "good approximation" Plot graph supporting your claim
1, k=5, b 0.5, f(t)
Finite difference formulas
Forward difference
dx Ax
Backward difference
df 1-10-1-1
dx-Ax
Central difference
1-4-1-1
dx 2Ax
Forward difference
Backward difference
Central difference
Euler's method
Numerical solution to initial value problems (IVPs)
dy f(y,t), y(0)=y
dt
Yi+1 =y1 Propagation Equation
,
At
2At
3At
44t
SAt
y
y(0)
y(At)
y(2At)
y(3At)
y(4At)
y(5At)
y,
y1
y2
y3
y4
11
Euler's method
.
Numerical solution to initial value problems (IVPs)
dy
dt f(y,t), y(0)=
Yi+1 =y f(yw.4) Propagation Equation
5
,
At
2At
3At
4At
5At
y
y(0)
y(At)
y(2At)
y(3At)
y(4At)
y(5At)
y,
Yo
y,
y2
y3
y4
11
Euler's method
. Numerical solution
dt
dt
At
Yi+1
y
At
t
ti
ti+1

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

import matplotlib.pyplot as plt

import seaborn as sns

sns.set_style("whitegrid")

# y'' = (f(t) - b * y' - k * y)/m i.e.

# y'' = F(t, y, y', f)

# initial conditions:

# y(0) = 0 - initial position

# y'(0) = 0 - initial velocity

"""

*** Euler method - central differenciating ***

second derivative:

y(t)'' = F[t, y(t), y'(t), f(t)] (1)

y(t)'' = [y(t+h) - 2y(t) + y(t-h)]/h^2 (2)

from (1) and (2) we obtain --->

[y(t+h) - 2y(t) + y(t-h)]/h^2 = F[t, y(t), y'(t), f(t)]

equation of time propagation of y:

--- > y(t+h) = 2y(t) - y(t-h) + F[t, y(t), y'(t), f(t)]*h^2 (3)

first derivative:

(y(t)')' = F[t, y(t), y'(t), f(t)]

(y(t)')' = [y(t+h)'-y(t-h)']/2h

equation of time propagation of first derivative y':

---> y(t+h)' = y(t-h) + 2h*F[t, y(t), y'(t), f(t)] (4)

"""

def F(b, f):

# function that returns left-hand side of our equation y'' = (f(t) - b * y' - k * y)/m

# function has damping ratio and func f as input parameters

# y1 = first derivative...