Motion of a mass on a spring
Context equations-of-motion
uses mechanics/dynamics
uses quantities/angular-frequency
force: F = -(k × x)
newton: 𝒟(𝒟(x)) = -((k ÷ m) × x).
A force constant times a length is a force:
force-constant × L : F
force-constant × T→L : T→F
(k × f)[t] ⇒ k × f[t]
∀ f : T→L
∀ t : T
∀ k : force-constantA force constant divided by a mass is the square of an angular frequency:
force-constant ÷ M : angular-frequency-squaredA squared angular frequency times a length is an acceleration:
angular-frequency-squared × L : A
angular-frequency-squared × T→L : T→A
(ω2 × f)[t] ⇒ ω2 × f[t]
∀ f : T→L
∀ t : T
∀ ω2 : angular-frequency-squared
Context analytical-solution
extends equations-of-motion
uses quantities/angular-frequency
1 Analytical solution
solution: x[t] = A × cos((ω × t) + δ) ∀ t : T,
√(angular-frequency-squared) : angular-frequency
2 Numerical solution
Context euler-template
includes transformed quantities/function-with-finite-difference-template
Δ(f, h)[t] ⇒ (f[t + h] - f[t]) ÷ h ∀ t : SQD.
Context numerical-solution
extends equations-of-motion
includes transformed euler-template
includes transformed euler-template
newton1.x: 𝒟(x) = v,
newton1.v: subst(newton) 𝒟(v) = -((k ÷ m) × x).
We can now discretize the equations newton1 by applying the substitution discretize: 𝒟(f) ⇒ Δ(f, h), where f:Q→Q is an arbitrary function of time and h : Tnz is the integration time step:
newtonΔ.x: discretize(newton1.x) Δ(x, h) = v
newtonΔ.v: discretize(newton1.v) Δ(v, h) = -((k ÷ m) × x)
Applying at-t: f → f[t] yields the equations for an explicit value of t : T:
newtonΔ-t.x: newtonΔ.x ⁞ at-t ⇩ (x[t + h] - x[t]) ÷ h = v[t]
newtonΔ-t.v: newtonΔ.v ⁞ at-t ⇩ (v[t + h] - v[t]) ÷ h = -((k ÷ m) × x[t])
These equations can be used to construct an iterative algorithm that computes time-series.x: xn = x[t0 + (n × h)] and time-series.v: vn = v[t0 + (n × h)] for any n:ℕ, given the initial values x0 and v0 at time t0 : T:
algo.x: xn ⇒ xn - 1 + (h × vn - 1) ∀ n : ℕnz
algo.v: vn ⇒ vn - 1 + (h × ((k ÷ m) × xn - 1)) ∀ n : ℕnz
Integer indices select a time value on a grid:
T→Lℤ : L
T→Vℤ : V