Adam Report
Adam Report
G21096943 | 22100233
Have you checked the following in order to maximise the grade you can Please mark X to confirm
achieve for this assignment?
Learning Outcomes have been addressed X
Similarity check via Turn-it-in X
Referencing accuracy according to provided guide X
Grammar X
Spelling X
Word count (or other length limitation as described in the brief) X
WELLBEING
We wish to support any student who is experiencing I believe that I do / I do not need to apply for mitigating
mitigating circumstances which prevents students circumstances for this assignment at this moment in
from performing to the best of their ability when time
completing or submitting assignments. If you are Please delete as appropriate
experiencing such circumstances then you may apply (You may still apply for mitigating circumstances if you
for mitigating circumstances. Wherever possible this subsequently feel that your performance has been
must be done prior to handing in your assignment. adversely affected by issues that you may currently be
unaware of).
SELF – REFLECTION This section suggested for inclusion if appropriate otherwise remove
Details of this can be found in the assignment Simply rate how you think your submission will perform against
brief. In order to ensure the assessment the assessment criteria; i.e. 1st (very good/excellent), 2:1
process is fair, we want to make sure that the (good), 2:2 (competent), 3rd (basic), fail (weak).
assessment criteria are clear to you in advance. This helps us provide comments on your work and clarify
things you do not understand
E.g. Understanding, including knowledge
E.g. Applying, including analysis and evaluation
E.g. Researching, including range of sources,
referencing and citation
E.g. Communicating, including structure, clarity
of argument and use of English
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Contents
Problem 1 ............................................................................................................................................................................ 2
Introduction .................................................................................................................................................................... 2
Solving the problem ........................................................................................................................................................ 2
Function Code ................................................................................................................................................................. 2
Solver Code ..................................................................................................................................................................... 3
Output ............................................................................................................................................................................. 3
Problem 2 ............................................................................................................................................................................ 4
Introduction .................................................................................................................................................................... 4
Solving the problem ........................................................................................................................................................ 4
Function code and explanation....................................................................................................................................... 5
ODE Solver Code and Explanation .................................................................................................................................. 6
Output (Lorenz) ............................................................................................................................................................... 9
Problem 3 .......................................................................................................................................................................... 11
Introduction .................................................................................................................................................................. 11
Solving the Problem ...................................................................................................................................................... 11
Function Code ............................................................................................................................................................... 12
ODE Solver Code ........................................................................................................................................................... 13
Graphs Results/Output ................................................................................................................................................. 15
Problem 4 .......................................................................................................................................................................... 16
Introduction .................................................................................................................................................................. 16
Solving the problem ...................................................................................................................................................... 16
Function Code ............................................................................................................................................................... 17
ODE Solver Code ........................................................................................................................................................... 17
Output Table and Graph ............................................................................................................................................... 18
1
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Problem 1
Introduction
The question asks us to examine the motion of a particle projected vertically from the ground at a velocity of 50 m/s
under the impact of air resistance, which is proportional to the particle's speed squared. The goal is to find the particle's
maximum height. To do so, we will use Newton's second law along the y-axis, which connects the net force exerted on
the particle to its acceleration. The air resistance force opposes the particle's motion with (0.01𝑣𝑣 2 𝑁𝑁) and hence acts in
the opposite direction of its velocity. This causes the particle's velocity to diminish over time, causing it to slow down
and eventually come to a rest at its maximum height.
o Passing parameters:
• m = 10kg
• g = 9.81m/s2
o Degree of the Equation is of a first-degree ordinary differential equation.
o Given variables.
• ds = displacement
• dv = velocity
Function Code
[line 1] Creates a function and assigning the “Prob_1” title to it and specifies the differentiated variables.
[line 2,3] States the passing variables and assigning them their respective values.
2
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Solver Code
[line 1,2] Specifies the initial conditions and creates variables and assigning their respective values.
[line 4] creates a row vector for the velocity span from 50 to 0 with a step of -0.01.
[line 5] The ODE function solves the differential equation entered in the function code. The inputs for the ODE are the
function itself, the tspan/vspan in this case, and initial conditions. Additionally, there is an options input but that will
come at a later question.
[line 7] Creates a figure with a graph that plots the displacement (s) against the velocity (v).
[line 8-11] Assigns a label for the graph and creates labels for the x-axis and the y-axis respectively. And the (grid on)
setting enables grid lines for the graph.
Output
The output from this function looks like the figure below. With, as specified, the displacement on the x-axis and the
velocity on the y-axis.
Displacement vs Velocity
50
45
40
35
30
Velocity(m/s)
25
20
15
10
0
0 20 40 60 80 100 120
x(m)
3
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Problem 2
Introduction
Edward Lorenz was a well-known mathematician and meteorologist who made a monumental discovery in chaos theory
in the early 1960s (Britannica, The Editors of Encyclopaedia, 2022). He discovered that small changes in beginning
conditions could have a large impact on the outcome of a weather forecast while investigating atmospheric convection.
This prompted him to create the Lorenz system, a mathematical model that illustrates the concept of deterministic
chaos. The Lorenz system is a set of three ordinary differential equations that describe the behavior of a simplified
atmospheric convection model. It is widely used in nonlinear dynamics and chaos theory research.
4
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
[line 1] Creates a function with the title “Lorenz” and states the variables to be differentiated.
[line 11] Creates an empty matrix with 3 rows and 1 column full of zeros. Essentially a vector matrix.
[line 12-14] Assigns each equation to a row in the vector to calculate later.
5
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
[line 1] Inputs the initial values for the three axes of [x y z] into a matrix for easier input and edit into the ODE function.
[line 3] The ODE function solves the differential equation entered in the function code. The inputs for the ODE are the
function itself ('Lorenz'), the tspan in this case a range from 0 to 20, and initial conditions (x0). Additionally, there is an
(options) input but that will come at a later question.
[line 6] Creates a Figure that will not be overridden when we add more figures later.
[line 7 and 15] The subplot() function divides the figure into a table of graphs. The first input is the number of rows.
The second is the number of columns. And lastly, the third input is the selected spot where the graph will be in.
[line 8-10] Plots all three axes against time (t). And I have separated each line so that they can be colour coded to easily
distinguish between them. (x(1) = x =>red); (x(2) = y =>blue); (x(3) = z =>green). The (grid on) function enables the grid
on the graph.
[line 11-12] The xlabel() and ylabel() labels the x and y axes respectively with the input text given. (x axis- Time(t));
(y-axis- Lorenz Solutions y(t)).
[line 13] Adds a legend for the graph that titles each line in their chronological order. One special character in this line is
the “\Delta” character, the output of this is the icon in the graph legend (Δ) to signify the change in each axis.
[line 16] Plots the y graph on its own for comparison and assign to the line the same colour in the previous graph. The
(grid on) function enables the grid on the graph.
[line 17-18] Labels the x and y axes as (Time(t)) and (Lorenz Solutions y(t)) respectively.
6
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Part (b)
[line 23] Creates a Figure that will not be overridden or override others when we add more figures later.
[line 24] Plots the y values against time on a graph, with the colour of blue.
[line 25-26] Labels the x and y axes with (Time (t)) and (Lorenz Solutions y(t)) respectively.
[line 28] Holds all operations on this plot function to plot another line on the same graph.
[line 30] Adds another list of initial conditions with changed x-axis starting position of (-2.04) instead of (-2).
[line 32] Calculates another solution for the Lorenz system but with the new initial conditions in the variable (x_0) and
outputs them to new variables (t1 and x1).
[line 34] Plots the new-found solution on the same graph aa the old one thanks to the (hold all) function on line 28.
[line 35] Adds a legend for the whole graph with labels for the two, old and new, plots.
7
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Part (c)
[line 39] Creates a Figure that will not be overridden or override others when we add more figures later.
[line 40] plots the x(3), i.e. Z, against the x(1), i.e. X, results from the ODE function from part (a).
[line 41] Adds a title for the graph. (“Lorenz Chaotic in 2D”)
[line 42-43] Labels the x and y axes with (X-axis) and (Y-axis) respectively.
Part (d)
[line 47] Creates a Figure that will not be overridden or override others when we add more figures later.
[line 48] The plot3() function is the same as the plot() function but only allows for a third axis enabling a 3d graph
output. Here the X, Y, and Z solutions are plotted on the same 3d graph.
[line 49] Adds a title for the graph of (“Lorenz Chaotic in 3D”).
[line 50-52] Labels the X, Y, and Z axes with their respective titles.
8
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Output (Lorenz)
Part (a)
60
x/t
y/t
40
z/t
Lorenz Solutions y(t)
20
-20
0 2 4 6 8 10 12 14 16 18 20
Time (t)
20
y/t
10
Lorenz Solutions y(t)
-10
-20
0 2 4 6 8 10 12 14 16 18 20
Time (t)
Part (b)
25
y/t
20 y1 / t
15
10
5
Lorenz Solutions y(t)
-5
-10
-15
-20
-25
0 2 4 6 8 10 12 14 16 18 20
Time (t)
9
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Part (c)
Lorenz Chaotic in 2D
45
40
35
30
Z-axis
25
20
15
10
5
-20 -15 -10 -5 0 5 10 15 20
X-axis
Part (d)
Lorenz Chaotic in 3D
Lorenz Chaotic in 3D
45
45
40
40
35
35
30
30
25
Z-axis
25
Z-axis
20
20
15
15
10
10
5
20 5
-20
0 -10 20
20 10
10 0 0
0 10 -10
-20 -10
Y-axis -20 20 -20
X-axis X-axis Y-axis
View 1 View 2
10
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Problem 3
Introduction
(Britannica, The Editors of Encyclopaedia, 2023) The Apollo program, launched by NASA in the 1960s, was a series of
manned space missions that aimed to land humans on the Moon and bring them back to Earth safely. The program
involved the use of various spacecraft, including the Apollo satellite, which was a critical component of the mission's
success. The trajectory of the Apollo satellite involved launching it into orbit around the Earth, using the Moon's gravity
to slingshot it towards its destination, and then placing it in lunar orbit. The satellite played a crucial role in
communications between the astronauts and mission control and helped to facilitate safe landings and takeoffs from
the Moon's surface.
11
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Function Code
[line 1] Creates a function with the title “Apollo” and states the variables to be differentiated.
[line 13] Initiates a zeros matrix, essentially empty, to store the equations and values in it as illustrated in the mind map.
[line 14-17] Inputs the equations and variables given into the matrix according to the mind map.
12
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
[line 1-4] Illustrating the mind map mentioned in the Solving the Problem part.
[line 6] Inputs the initial conditions in a matrix and assigns that to the variable (x0).
[line 8] The (tic; toc) function at the beginning and end of this line records the amount of time and the number of
calculations steps the function inside it takes. And the ODE45() function solves the system of equations given in the
function code.
[line 10] Displays the output of the (tic; toc) function above in amount of time taken and in number of steps taken.
[line 14] Initiates a figure independent figure to prevent it from overriding or being overridden by other figures.
[line 15] Plots the y(2) and y(4), x and y, calculated points on a graph.
[line 16] Labels the figure with a title. “Unoptimized Apollo Satellite Trajectory”
[line 17-18] Labels the x and y axes on the graph by “X-axis” and “Y-axis” respectively.
13
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
[line 21] Initiates a figure independent figure to prevent it from overriding or being overridden by other figures.
[line 22] Plots the y(2) and y(4), x and y, unoptimized calculated points on a graph.
[line 23-24] Labels the x and y axes on the graph by “X-axis” and “Y-axis” respectively.
[line 25] Labels the figure with a title. “Optimized vs Unoptimized Apollo Satellite Trajectory”
[line 26] Holds all operations on the figure until a new plot is added.
[line 28] The (RelTol) function in MATLAB is a relative error tolerance parameter used to control the accuracy of
numerical solutions obtained through differential equation solvers. (1e-6) = (10-6) is a better tolerance limit for accurate
results for ODEs.
[line 30] The (tic; toc) function at the beginning and end of this line records the amount of time and the number of
calculations steps the function inside it takes. And the ODE45() function solves the system of equations given in the
function code with the extra parameter of options mentioned above.
[line 32] Displays the output of the (tic; toc) function above in amount of time taken and in number of steps taken.
[line 34-35] Plots the optimized x and y points (y1(2) and y1(4)) on a graph with a blue-colored line.
[line 40] Initiates a figure independent figure to prevent it from overriding or being overridden by other figures.
[line 41] Plots the optimized x and y points (y1(2) and y1(4)) on a graph with a blue-colored line.
[line 42-43] Labels the x and y axes on the graph by “X-axis” and “Y-axis” respectively.
[line 44] Labels the figure with a title. “Optimized Apollo Satellite Trajectory”
14
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Graphs Results/Output
tic; toc function output
Visible in this figure, that the first unoptimized result took 0.0467 seconds and 689 steps, but the last one took a shorter
time of only 0.0147 second and a 1873 steps. Meaning the second one has more resolution and accuracy that the first.
Unoptimized Apollo Satellite Trajectory Optimized vs Unoptimized Apollo Satellite Trajectory
0.8 0.8
Unoptimized Results
0.4 0.4
0.2 0.2
Y-axis
Y-axis
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1.5 -1 -0.5 0 0.5 1 1.5 -1.5 -1 -0.5 0 0.5 1 1.5
X-axis X-axis
0.6
0.4
0.2
Y-axis
-0.2
-0.4
-0.6
15
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Problem 4
Introduction
Safety bumpers are frequently used on racetracks to safeguard drivers and spectators in the case of an out-of-control
car. In this situation, we must calculate the deceleration of a 2000-kilogram car colliding with a safety bumper at 100
km/h. We can utilize Newton's second rule of motion to answer this problem, which states that the force exerted to an
object equals its mass times acceleration. We can compute the vehicle's deceleration once it hits the bumper by using
this law. We can also utilize velocity as a function of x, which can be determined by substituting acceleration into the
equation: adv=adx. This approach allows us to model the vehicle's motion after it collides with the bumper and
determine the distance it will travel before coming to a stop. This scenario is a typical example of how physics principles
can be applied to real-world situations to enhance safety and prevent accidents.
16
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
Function Code
[line 1] Initializes a function with the input of x and v and the function of dvdx with the title of “bumper”.
[line 2-3] Adds in the passing parameters of the elastic constant and the mass,
[line 1-3] Inputs the initial conditions and the x range to calculate for. Line 2 converts the initial velocity units from km/h
to m/s.
[line 5] The ODE function solves the differential equation entered in the function code. The inputs for the ODE are the
function itself (@bumper), the tspan in this case is the xspan, and initial condition (v0mps).
[line 8] Converts the arrays to a table form with the input data as (A,), the title function (“VariableNames”) and the titles
themselves (“Displacement”, “Velocity”). The titles are added in their chronological order in the first line.
17
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
[line 10] Plotting the outputs from the ODE function, x and y, on a graph.
[line 11] Titles the graph with the label of “Velocity as a Function of Displacement”
[line 12-13] Labels the axes of the graph with “Displacement x (m)” and “Velocity v (m/s)” for the x and y axes
respectively.
[line 14] Adds a legend for the graph with the line title of “v(x)”
v(x)
25
20
Velocity m/s
15
10
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Displacement x (m)
18
ERC006 | Assignment 2 | Semester 2
Adam Hazem
G21096943 | 22100233
References
Britannica, The Editors of Encyclopaedia, 2022. Edward Lorenz. [Online]
Available at: https://www.britannica.com/biography/Edward-Lorenz
[Accessed 9 March 2023].
19