Chen Yulin's BlogChen Yulin's Blog
HomeArchivesCategoriesTagsAbout
  目录
Posted 2025-07-14Updated 2025-07-16Note5 minutes read (About 786 words)   visits

Math6003 Hw5

Homework 5 Report

Zhichen Tang
124370910020


Exercise 1

In this first part, I looked at the logistic model for population growth. The main goal was to solve the equation $u’(t) = C u(t) (1 - u(t)/B)$ using a couple of different numerical methods. The parameters were set to $u_0=100$, $B=1000$, and $C=2/15$.

a)

I take the current value and add the slope at that point multiplied by the time step to get the next value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
% Completed feuler.m
function [t, u, dt] = feuler( f, I, u0, N )
dt = (I(2)-I(1))/N;
t = linspace(I(1),I(2),N+1);
u = zeros(1,N+1);
u(1) = u0;
for n = 1:N
u(n+1) = u(n) + dt * f(t(n), u(n));
end
end
````


### b)
First, I calculated a temporary "predicted" value (just like a standard Euler step). Then, I averaged the slope at the current point and the slope at the next point (using the predicted value) to get a more accurate step.

Matlab

% Completed heun.m
function [t, u, dt] = heun( f, I, u0, N )
dt = (I(2)-I(1))/N;
t = linspace(I(1),I(2),N+1);
u = zeros(1,N+1);
u(1) = u0;
for n = 1:N
u_predictor = u(n) + dt * f(t(n), u(n));
u(n+1) = u(n) + (dt/2) * ( f(t(n), u(n)) + f(t(n+1), u_predictor) );
end
end


<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex1b.png" alt="" title=""></div>
### c) 

After implementing the methods, I ran them with a coarse time step (Deltat=5, corresponding to N=20) and plotted them against the exact solution.

It's pretty clear from the graph that the Heun method does a much better job. Its curve hugs the exact solution line much more tightly than the Forward Euler curve does. This makes sense because it's a higher-order method, so you'd expect it to be more accurate for the same step size.

<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex1c.png" alt="" title=""></div>

### d)

Next, I repeated the comparison but with a much smaller time step (Deltat=0.05, or N=2000).


Absolutely. With the smaller time step, both methods improved dramatically. The plot shows that the lines for the Euler method, Heun's method, and the exact solution are basically right on top of each other. This really shows how decreasing the step size can significantly reduce the error in numerical solutions. However, the Heun method's absolute error is still lower than the Euler method.

<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex1d.png" alt="" title=""></div>

---

## Exercise 2

### a)

To solve this, I first had to convert the single 2nd-order equation into a system of two 1st-order equations. I defined a new variable, V(t)=U′(t). This gives the first equation of the system.

Then, I rearranged the original RLC equation to isolate U′′(t):

$$ U''(t) = -\frac{R}{L}U'(t) - \frac{1}{LC}U(t) + \frac{f}{LC} $$

By substituting V for U′ and V′ for U′′, I got the second equation. This allowed me to write the whole system in matrix form, X′=AX+b:

$$\begin{pmatrix} V' \\ U' \end{pmatrix} = \begin{pmatrix} -R/L & -1/(LC) \\ 1 & 0 \end{pmatrix} \begin{pmatrix} V \\ U \end{pmatrix} + \begin{pmatrix} f/(LC) \\ 0 \end{pmatrix} $$
### b)
Stability Analysis of Forward Euler The Forward Euler method is only stable if $|1 + \Delta t \lambda_i| \le 1$ for all eigenvalues ($\lambda_i$) of the matrix A. Using the given component values (L=0.01, C=10, R=0.1), the matrix A becomes: $$ A = \begin{pmatrix} -10 & -10 \\ 1 & 0 \end{pmatrix} $$ I calculated the eigenvalues to be $\lambda = -5 \pm \sqrt{15}$. To ensure stability, the time step $\Delta t$ has to be less than a critical value determined by the eigenvalue with the largest magnitude. The calculation showed that the method is stable only if: $$ \Delta t \le \frac{2}{5 + \sqrt{15}} \approx 0.2254 \text{ s} $$
### c) 
Simulating with Forward Euler I ran simulations for three different time steps. The results were a perfect illustration of the stability condition. 
<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex2c.png" alt="" title=""></div>
As you can see: - With **N=43** ($\Delta t \approx 0.233$), the time step was too large, and the solution completely blew up. - With **N=46** ($\Delta t \approx 0.217$), the time step was just inside the stable range, and the solution correctly showed a damped wave. - With **N=500** ($\Delta t = 0.02$), the solution was also stable and much smoother. 
### d)
Simulating with Backward Euler Finally, I repeated the same simulations using the Backward Euler method. 
<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex2d.png" alt="" title=""></div>
The difference is night and day. The Backward Euler method was **stable for all three time steps**, even the large one that made the Forward Euler method fail. This shows that implicit methods like Backward Euler are much more robust for systems like this, as they don't have the same strict stability requirements on the time step. While the accuracy still gets better with smaller steps, you can trust it to give a stable answer no matter what.

Math6003 Hw5

http://chen-yulin.github.io/2025/07/14/[OBS]课程-Math6003 Hw5/

Author

Chen Yulin

Posted on

2025-07-14

Updated on

2025-07-16

Licensed under

MATH6003J Project Proposal
Use SSH to Connect TensorboardX

Comments

Chen Yulin

Chen Yulin

SJTU student

Manchester by the Sea

Posts

273

Categories

10

Tags

191

Follow

Catalogue

  • Homework 5 Report
    • Exercise 1
      • a)

Archives

  • July 20254
  • June 20256
  • May 202510
  • April 202517
  • March 202545
  • February 202512
  • January 202513
  • December 202412
  • November 20244
  • October 202418
  • September 202416
  • August 202413
  • July 20243
  • June 20245
  • May 202413
  • April 202417
  • March 20241
  • January 20241
  • December 20231
  • May 202346
  • August 20221
  • May 20226
  • April 20229

Recents

2025-07-17

MATH6003J Project Proposal

Note

2025-07-14

Math6003 Hw5

Note

Use SSH to Connect TensorboardX

2025-07-06

Use SSH to Connect TensorboardX

Note

♥夏天和波子汽水是绝配♥

2025-07-02

♥夏天和波子汽水是绝配♥

甜甜的恋爱日常呀

2025-06-22

Math6003 Hw4

Note

Tags

3D-Scene4
6-D3
AI10
AIGC1
API1
AR2
Academic1
Algorithm1
Aliyun1
App2
Atlas1
BS41
Beautify1
Behaviorism1
Business1
C1
CADC1
CD1
CLIP5
CNN1
CV28
Capstone10
Communication2
Contrastive-Learning3
Control2
Csharp9
Css1
Cuda3
DD1
DINO4
DT1
Dataframe1
Debate5
Debugger1
Diffusion1
Discrete-Mathematics1
Disney1
Docker1
Docs2
Dynamic-programming1
ESP322
Education1
Embeded-System9
Embodied-AI8
Emoation1
Emotion13
Ethic1
FL1
FPN2
Family1
Federated-Learning1
Foundation1
Functional programming1
GPT3
Game5
Gated-NN2
Git7
Github1
Godot3
HPC1
HRI2
Haskell1
Health2
Hexo10
Hierarchical1
Html5
Humanism1
Hyprland2
IK1
Image-Grounding1
Image-Text5
Image-generation1
ImitationLearning3
Jolt1
Json1
LLM12
LSP2
Latex2
Life4
LinearAlgebra1
Linux22
Live2d1
Love4
Lua1
MBTI1
ML8
MR/AR3
Mason1
Math6
Meme1
Message-Passing1
Mod3
Motivation1
Movie1
Multi-modal6
Multi-view1
Music5
NLP4
NN4
Network2
Nodejs5
Numpy1
Nvim9
Object-Detection4
Open-Vocabulary9
OpenCV1
Oral1
PHD1
PSY5
Pandas2
Panoptic1
Path1
Philosophy3
PhysX1
Physical-Scene4
Physics-engine1
Pio2
Planning1
Plugin8
PoseEstimation3
Postgraduate1
Prefab1
Probability1
Python27
Pytorch1
QML1
Quantum1
RNN4
ROS3
Reading19
Real2Sim1
Reconstruct9
Regex2
Reinforcement-learning1
Repository5
Representation-Learning1
Research-paper86
Robot1
Robotics16
SJTU-Lecture1
SQL2
SSH3
Scene-graph29
Scene-synthesis1
Science-fiction1
Scrap1
Script2
Segmentation7
Semantic12
Shader3
Shell4
Signals and Systems1
Sim2Real1
Sklearn1
Snippets1
Society4
Star-rail1
Subgraph1
Submodule1
Supervised-learning2
Survey3
TC1
TOEFL1
Task-Planning6
Tasks4
Tech Communication1
Torch4
Transformer11
Translation-Embedding2
Travel3
Unity20
Unsupervised-learning1
VLM6
VLP2
Version-management1
ViT4
VideoEditing2
Vim1
Visual-Relation20
WSL1
Waybar1
Wayland1
Web1
Website1
Well-being1
Window-manager2
YKLL3
Zen2
🍰1
🐱2
🧀1
Chen Yulin's BlogChen Yulin's Blog

© 2025 Chen Yulin  Powered by Hexo & Icarus

×