Numerical Analysis – Final Exam
Jaykumar Mavani
October 7, 2025
Problem 1 — Nondimensionalization
Dimensional governing equations. Let (u, √ v) be the dimensional velocity components along the
horizontal (x) and vertical (y) axes, with w = u2 + v 2 the speed and θ the flight-path angle so that
v u
sin θ = , cos θ = .
w w
Let m be the mass, g gravity, ρ air density, S reference area, and cl , cd constant lift/drag coefficients.
Lift and drag are
L = 12 ρ w2 S cl , D = 12 ρ w2 S cd .
Translational dynamics (Newton’s second law) give
du
m = −L sin θ − D cos θ, (1)
dt
dv
m = −mg + L cos θ − D sin θ. (2)
dt
Choice of scales and barred variables. Let w0 be the reference speed.
u v gt gx gy
ū = , v̄ = , t̄ = , x̄ = , ȳ = . (3)
w0 w0 w0 w02 w02
From (3) we have the inverse relations
w0 w02 w02
u = w0 ū, v = w0 v̄, t= t̄, x= x̄, y= ȳ,
g g g
and the speed becomes p p
w= u2 + v 2 = w0 ū2 + v̄ 2 .
Hence the trigonometric kinematics read
v v̄ u ū
sin θ = =√ , cos θ = =√ . (4)
w ū + v̄ 2
2 w ū + v̄ 2
2
Chain rule on accelerations. Using u = w0 ū(t̄) and t = (w0 /g)t̄,
du d(w0 ū) dū dt̄ dū g dū
= = w0 = w0 =g .
dt dt dt̄ dt dt̄ w0 dt̄
dv dv̄
=g .
dt dt̄
1
√
Lift/drag in barred form. With w = w0 ū2 + v̄ 2 ,
1 1
L 2 ρScl w02 D 2 ρScd w02
= (ū2 + v̄ 2 ), = (ū2 + v̄ 2 ).
mg mg mg mg
Introduce the dimensionless parameters
cl ρ w02 S cd
A := , B := . (5)
2mg cl
Then
L D
= A(ū2 + v̄ 2 ), = AB(ū2 + v̄ 2 ).
mg mg
Substitution into (1)–(2). Divide (1)–(2) by mg and use the relations above:
1 du L D v̄ ū
=− sin θ − cos θ = −A(ū2 + v̄ 2 ) √ − AB(ū2 + v̄ 2 ) √
g dt mg mg ū2 + v̄ 2 ū2 + v̄ 2
p
= −A ū2 + v̄ 2 ( B ū + v̄ ),
1 dv L D
= −1 + cos θ − sin θ
g dt mg mg
ū v̄
= −1 + A(ū2 + v̄ 2 ) √ − AB(ū2 + v̄ 2 ) √
2
ū + v̄ 2 ū + v̄ 2
2
p
= −1 + A ū2 + v̄ 2 ( ū − Bv̄ ).
1 du dū 1 dv dv̄
But g dt = dt̄ and g dt = dt̄ from the chain rule step above, so
dū p dv̄ p
= −A ū2 + v̄ 2 (B ū + v̄), = −1 + A ū2 + v̄ 2 (ū − Bv̄). (6)
dt̄ dt̄
Kinematics for x̄, ȳ. From x̄ = (g/w02 )x and t̄ = (g/w0 )t,
u 1 dx 1 dx dt̄ 1 dx g dx̄
ū = = = = = .
w0 w0 dt w0 dt̄ dt w0 dt̄ w0 dt̄
dȳ
Similarly, v̄ = . Differentiating once more gives
dt̄
d2 x̄ dū d2 ȳ dv̄
= , = .
dt̄2 dt̄ dt̄2 dt̄
dū dv̄
Replacing , using (6) yields the final dimensionless equations in barred variables:
dt̄ dt̄
d2 x̄ p d2 ȳ p
= −A ū2 + v̄ 2 (B ū + v̄), = −1 + A ū2 + v̄ 2 (ū − Bv̄), (7)
dt̄2 dt̄2
with the kinematic identities
dx̄ dȳ
ū = , v̄ = .
dt̄ dt̄
Problem 2: Glider Trajectory
(a) Plot of ȳ(x̄)
The system of ODEs was solved using a 4th-order Runge–Kutta (RK4) method. A representative plot
of ȳ versus x̄ is generated for two initial conditions: θ0 = −90◦ and θ0 = 180◦ .
2
(b) Description of the Plot
For θ0 = −90◦ : The glider starts vertically downward. Lift gradually redirects the motion horizontally,
resulting in oscillatory trajectories with smooth arcs.
For θ0 = 180◦ : The glider begins moving horizontally to the left. It dives and loops, reaching periodic
oscillations similar to the first case but phase-shifted.
—
Problem 3: Angular Evolution
(a) Plot of θ(t̄)
Simulations were conducted for θ0 = 90◦ and θ0 = 0◦ .
3
(b) Steady-State Results
Steady state is reached when |θi+1 − θi | ≤ 0.001◦ .
For θ0 = 90◦ :
• Dimensional Time: 5.39 s
• Steady-State Angle: -3.18464°
For θ0 = 0◦ :
• Dimensional Time: 5.80 s
• Steady-State Angle: -3.21288°
—
Appendix: Complete MATLAB Code
1
2 clear ; clc ; close all ;
3
4 % --- Problem 2: Glider Trajectory ---
5 A = 1.5;
6 B = 0.05563;
7 w0 = 1; g = 9.81;
8 dt_dim = 0.01;
9 dt_bar = dt_dim * g / w0 ;
10 t_max_dim = 10;
11 t_max_bar = t_max_dim * g / w0 ;
12
13 theta0_deg_p2 = [ -90 , 180];
14 theta0_rad_p2 = deg2rad ( theta0_deg_p2 ) ;
15
16 figure ( ’ Name ’ , ’ Problem 2: Glider Trajectory ’) ; hold on ; grid on ; box on ;
17 colors = { ’r - ’ , ’b - - ’ }; legends_p2 = {};
18
19 for i = 1: length ( theta0_rad_p2 )
20 u0_bar = cos ( theta0_rad_p2 ( i ) ) ;
21 v0_bar = sin ( theta0_rad_p2 ( i ) ) ;
22 y0 = [ u0_bar ; v0_bar ; 0; 0];
23 [ t_bar , y ] = rk4_system ( @EOM , [0 , t_max_bar ] , y0 , dt_bar , A , B ) ;
24 x_bar = y (: ,3) ; y_bar = y (: ,4) ;
25 plot ( x_bar , y_bar , colors { i } , ’ LineWidth ’ , 2) ;
26 legends_p2 { end +1} = [ ’$ \ theta_0 = ’ num2str ( theta0_deg_p2 ( i ) ) ’ ^{\ circ } $ ’ ];
27 end
28
29 title ( ’ Problem 2: Glider Trajectory $ \ bar { y }(\ bar { x }) $ ’ , ’ Interpreter ’ , ’ latex ’) ;
30 xlabel ( ’$ \ bar { x } $ ’ , ’ Interpreter ’ , ’ latex ’) ; ylabel ( ’$ \ bar { y } $ ’ , ’ Interpreter ’ , ’ latex ’) ;
31 legend ( legends_p2 , ’ Interpreter ’ , ’ latex ’ , ’ Location ’ , ’ northeast ’) ; axis equal ;
32
33 % --- Problem 3: Angle vs . Time ---
34 theta0_deg_p3 = [90 , 0];
35 theta0_rad_p3 = deg2rad ( theta0_deg_p3 ) ;
36 figure ( ’ Name ’ , ’ Problem 3: Angle vs Time ’) ; hold on ; grid on ; box on ;
37
38 colors_p3 = { ’g - ’ , ’k - ’ }; s t e a d y _ s t a t e _ s t y l e s = { ’m - - ’ , ’k - - ’ }; legends_p3 = {};
39
40 for i = 1: length ( theta0_rad_p3 )
41 u0_bar = cos ( theta0_rad_p3 ( i ) ) ;
42 v0_bar = sin ( theta0_rad_p3 ( i ) ) ;
43 y0 = [ u0_bar ; v0_bar ; 0; 0];
44 [ t_bar , y ] = rk4_system ( @EOM ,[0 , t_max_bar ] , y0 , dt_bar ,A , B ) ;
45 u_bar = y (: ,1) ; v_bar = y (: ,2) ;
46 theta_deg = rad2deg ( atan2 ( v_bar , u_bar ) ) ;
47 plot ( t_bar , theta_deg , colors_p3 { i } , ’ LineWidth ’ , 2) ;
48 legends_p3 { end +1} = [ ’$ \ theta_0 = ’ num2str ( theta0_deg_p3 ( i ) ) ’ ^{\ circ } $ ’ ];
49
50 % Steady state
51 for j = 1: length ( theta_deg ) -1
52 if abs ( theta_deg ( j +1) - theta_deg ( j ) ) <= 0.001
4
53 t_steady_bar = t_bar ( j +1) ;
54 t_steady_dim = t_steady_bar * w0 / g ;
55 t h e t a _ s t e a d y _ d e g = theta_deg ( j +1) ;
56 plot ([ t_steady_bar t_steady_bar ] , [ -100 100] , s t e a d y _ s t a t e _ s t y l e s { i } , ’
LineWidth ’ ,1.5) ;
57 legends_p3 { end +1} = [ ’ Steady State ( $ \ theta_0 = ’ num2str ( theta0_deg_p3 ( i ) ) ’
^{\ circ } $ ) ’ ];
58 fprintf ( ’ Theta0 = %.0 f -> Steady State : %.2 f s , %.5 f \ n ’ , ...
59 theta0_deg_p3 ( i ) , t_steady_dim , t h e t a _ s t e a d y _ d e g ) ;
60 break ;
61 end
62 end
63 end
64
65 title ( ’ Problem 3: Glider Angle $ \ theta (\ bar { t }) $ ’ , ’ Interpreter ’ , ’ latex ’) ;
66 xlabel ( ’ Dimensionless Time $ \ bar { t } $ ’ , ’ Interpreter ’ , ’ latex ’) ;
67 ylabel ( ’ Angle $ \ theta$ ( degrees ) ’ , ’ Interpreter ’ , ’ latex ’) ;
68 legend ( legends_p3 , ’ Interpreter ’ , ’ latex ’ , ’ Location ’ , ’ east ’) ; ylim ([ -100 ,100]) ;
69
70 % --- Local Functions ---
71 function [t , y ] = rk4_system (f , tspan , y0 ,h ,A , B )
72 t = tspan (1) : h : tspan (2) ; nt = length ( t ) ;
73 y = zeros ( length ( y0 ) , nt ) ; y (: ,1) = y0 ;
74 for i = 1: nt -1
75 k1 = h * f ( t ( i ) ,y (: , i ) ,A , B ) ;
76 k2 = h * f ( t ( i ) +0.5* h , y (: , i ) +0.5* k1 , A , B ) ;
77 k3 = h * f ( t ( i ) +0.5* h , y (: , i ) +0.5* k2 , A , B ) ;
78 k4 = h * f ( t ( i ) +h , y (: , i ) + k3 , A , B ) ;
79 y (: , i +1) = y (: , i ) +( k1 +2* k2 +2* k3 + k4 ) /6;
80 end
81 t = t ’; y = y ’;
82 end
83
84 function dydt = EOM (~ ,y ,A , B )
85 u_bar = y (1) ; v_bar = y (2) ;
86 w_bar = sqrt ( u_bar ^2 + v_bar ^2) ;
87 dudt_bar = -A * w_bar *( B * u_bar + v_bar ) ;
88 dvdt_bar = -1 + A * w_bar *( u_bar - B * v_bar ) ;
89 dxdt_bar = u_bar ; dydt_bar = v_bar ;
90 dydt = [ dudt_bar ; dvdt_bar ; dxdt_bar ; dydt_bar ];
91 end
Listing 1: MATLAB script