# Mandatory exercises

1. Consider the ODE
\begin{equation}
    \begin{split}
        y'-y-t=0,\\
        y(0)=0
    \end{split}
\end{equation}

    1. Use forward Euler method to compute an approximation of the solution at $t=0.2$ with step size $h=0.1$.
    2. Use backward Euler method to compute an approximation of the solution at $t=0.2$ with step size $h=0.1$.
    3. Use classical Runge-Kutta method to compute an approximation of the solution at $t=0.1$ with step size $h=0.1$.

2. Consider the ODE
\begin{equation}
    \begin{split}
        y'-cos(yt)=0,\\
        y(0)=0
    \end{split}
\end{equation}
Write down the backward Euler formula to solve the ODE. Comparing with problem 1.2, what is the difficulty here?

3. Ordinary differential equations can be used to describe the movement of a satellite around a planet. Let $x(t)$ and $y(t)$ denote the $x$ and $y$ coordinate, respectively, for the satellite position at time $t$. The planet’s position is at the origin. Then the following model describes how the position of the satellite changes with time:
\begin{equation}
    \begin{split}
        x''(t)= -k\frac{x(t)}{\left(\sqrt{x(t)^2+y(t)^2}\right)^3}\\
        y''(t)= -k\frac{y(t)}{\left(\sqrt{x(t)^2+y(t)^2}\right)^3}
    \end{split}
\end{equation}
For simplicity, assume that $k = 1$. The initial time is $t = 0$, the initial satellite position $(x(0), y(0)) = (a, b)$ and the initial velocity in the $x$-and $y$-directions $(x'(0), y'(0)) = (c, d)$.

    1. Formulate the model above as a system of first order ordinary differential equations. Remember initial conditions.
    2. (*) Describe how you can use the model to simulate the satellite orbit around the planet for $0\leq t\leq100$ with the help of Matlab’s built-in function `ode45` or Python function `scipy.integrate.solve_ivp`. You do not have to write a complete program. It is enough to write the code for representing the mathematical model and to show how `ode45` or `scipy.integrate.solve_ivp` can be called to solve the ODE system.
    3. (*) You wrote a code for the SIR model in the lab session. Can you use that code to simulate the movement of a satellite around a planet?

# Non-mandatory exercises

4. Implement the forward Euler method in Matlab/Python. For simplicity we consider scalar ODEs. The function header should be: 
```Fortran
function [t, y] = euler(f,a,b,y0,n)
```
or 
```python
def euler(f,a,b,y0,n):
    ...
    return [t, y]
```
The input parameter `f` should be a function handle to a Matlab/Python function evaluating the right-hand side of the ODE. The values `a` and `b` represent
initial time and final time, respectively. The last input parameter, `n`, is the number of time steps.
The output parameter `y` is a vector, where $y_k$ is the approximate solution at time step `k`, $k = 0,\dots, n$.

5. What modifications would be required in your function `euler`, to make it able to handle *a system* of ODEs?

6. Your next task is to simulate how an object is winched from the ground and into a helicopter. As the object is winched, it will make a pendular movement under the helicopter. Consequently, this process can be modelled as a variable–length pendulum:
\begin{equation}
    \theta''(t)+2\frac{r'(t)}{r(t)}\theta'(t)+\frac{g}{r(t)}\sin(\theta(t))=0
\end{equation}
where $\theta(t)$ is the angle of the pendulum, $r(t)$ is the length of the pendulum, and $g$ is the gravity. The winching is represented by a ”winching
strategy” in the form of a model for how $r'(t)$ varies with time. This gives an additional differential equation:
\begin{equation}
    r'(t)=f(t,\theta(t),\theta'(t)).
\end{equation}
The purpose of the simulation is to investigate the effect of different winching strategies.
Suppose that you are to use Heun’s method to simulate how the object is winched to the helicopter. Your present task is to give a detailed
description of how to apply Heun’s method to this problem. (Note: this is a purely theoretical exercise. You are not required to carry out the
computations, only to describe the approach in principle.)

cf3d477ea1459fc837559283e7d04e69b38185de
ipynb
Jupyter Notebook
Workouts/Workout2.ipynb
enigne/ScientificComputingBridging
920f3c9688ae0e7d17cffce5763289864b9cac80
MIT
2021-05-04T01:15:32.000Z
2021-11-08T15:08:27.000Z
Workouts/Workout2.ipynb
enigne/ScientificComputingBridging
920f3c9688ae0e7d17cffce5763289864b9cac80
MIT
Workouts/Workout2.ipynb
enigne/ScientificComputingBridging
920f3c9688ae0e7d17cffce5763289864b9cac80
MIT
Qwen/Qwen-72B
1. YES
2. YES