Posts

Numerical Cantilever Simulations

Last edited: August 8, 2025

Here’s the characteristic equation again:

\begin{equation} \pdv[2] x \qty(EI \pdv[2]{w}{x}) = -\mu \pdv{w}{t}+q(x) \end{equation}

After Fourier decomposition, we have that:

\begin{equation} EI \dv[4]{\hat{w}}{x} - \mu f^{2}\hat{w} = 0 \end{equation}

Let’s solve this!

E,I,u,f = var("E I u f")
x, L = var("x L")
w = function('w')(x)
_c0, _c1, _c2, _c3 = var("_C0 _C1 _C2 _C3")
fourier_cantileaver = (E*I*diff(w, x, 2) - u*f^2*w == 0)
fourier_cantileaver
-f^2*u*w(x) + E*I*diff(w(x), x, x) == 0

And now, we can go about solving this result.

solution = desolve(fourier_cantileaver, w, ivar=x, algorithm="fricas").expand()
w = solution

\begin{equation} _{C_{1}} e^{\left(\sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} + _{C_{0}} e^{\left(i \, \sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} + _{C_{2}} e^{\left(-i \, \sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} + _{C_{3}} e^{\left(-\sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} \end{equation}

Numerical Cantilever Simulations

Last edited: August 8, 2025

Here’s the characteristic equation again:

\begin{equation} \pdv[2] x \qty(EI \pdv[2]{w}{x}) = -\mu \pdv{w}{t}+q(x) \end{equation}

After Fourier decomposition, we have that:

\begin{equation} EI \dv[4]{\hat{w}}{x} - \mu f^{2}\hat{w} = 0 \end{equation}

Let’s solve this!

E,I,u,f = var("E I u f")
x, L = var("x L")
w = function('w')(x)
_c0, _c1, _c2, _c3 = var("_C0 _C1 _C2 _C3")
fourier_cantileaver = (E*I*diff(w, x, 2) - u*f^2*w == 0)
fourier_cantileaver
-f^2*u*w(x) + E*I*diff(w(x), x, x) == 0

And now, we can go about solving this result.

solution = desolve(fourier_cantileaver, w, ivar=x, algorithm="fricas").expand()
w = solution

\begin{equation} _{C_{1}} e^{\left(\sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} + _{C_{0}} e^{\left(i \, \sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} + _{C_{2}} e^{\left(-i \, \sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} + _{C_{3}} e^{\left(-\sqrt{f} x \left(\frac{u}{E I}\right)^{\frac{1}{4}}\right)} \end{equation}

Numerical Stability

Last edited: August 8, 2025

“being careful”

numerically stable vector norms

consider:

\begin{equation} \Vert x \Vert_{2} = \sqrt{x_1^{2} + \dots + x_{m}^{2}} \end{equation}

squaring it could easily go over MAX-float for large \(m\). Instead, consider:

\begin{equation} \Vert x \Vert_{2} = z \sqrt{\qty(\frac{x_1}{z})^{2} + \dots \qty(\frac{x_{m}}{z})^{2}} \end{equation}

where \(z = \max_{i} |x_{i}|\). Notice how now we are squaring numbers which are less than one, meaning this will never blow up. Yet, the results will be the same. This is bounded, therefore, by \(m\).

NUS-ECON320 CAPM Problem Set

Last edited: August 8, 2025

NUS-ECON320 Currency Arbitrage

Last edited: August 8, 2025

Let’s import some tools.

import pandas as pd
from scipy.optimize import minimize
import numpy as np
from datetime import datetime
from tqdm import tqdm
import torch
tqdm.pandas()

And load our data:

df = pd.read_csv("./currency_signal.csv", index_col=0, header=None, parse_dates=[0])
df

Let’s rename the headers

df.index.rename("date", True)
df.columns = ["value"]

Awesome. For the rest of the calculations, we will hide the 2020 data from the model:

data = df[df.index < datetime(2020, 1,1)]
data
               value
date
2006-03-01  0.000050
2006-03-02  0.001778
2006-03-03  0.000116
2006-03-06 -0.001038
2006-03-07 -0.001197
...              ...
2019-12-25 -0.010659
2019-12-26 -0.000869
2019-12-27  0.000075
2019-12-30  0.000033
2019-12-31  0.000944

[3610 rows x 1 columns]

we will add a column of randomness to this, to serve as the seed of our epsilon: