Topic

Steps and impulses

Forces that switch on at a time, or strike at an instant, are where the Laplace transform is at its best. A factor heaviside(t - c) switches a term on at time cc. dirac(t - c) is a unit impulse at cc. laplaceSolve solves a linear equation with such forcing by transform, and then proves the answer piece by piece.

laplace("heaviside(t - 2)");            // "exp(-2*s)/s"
laplace("heaviside(t - 1)*t");          // "exp(-s)*(1/s + 1/s^2)"
laplace("heaviside(t - 1)*sin(t)");     // "exp(-s)*(sin(1)*(s/(s^2 + 1)) + cos(1)*(1/(s^2 + 1)))"
laplace("t*dirac(t - 2)");              // "exp(-2*s)*2"

inverseLaplace("exp(-2*s)/s^2").result;      // "heaviside(t - 2)*(t - 2)"
inverseLaplace("exp(-3*s)").result;          // "dirac(t - 3)"

const r = laplaceSolve([1, 0, 1], "heaviside(t - 1)", [0, 0]);   // y'' + y = u(t − 1), at rest
r.solution;    // "heaviside(t - 1)*(-cos(t - 1) + 1)"
r.pieces;      // [{ from: "0", y: "0" }, { from: "1", y: "-cos(t - 1) + 1" }]
r.verified;    // true

The shift theorems

Write u(t−c)u(t - c) for the unit step that is 0 before cc and 1 after, with c≥0c \ge 0. Then

L{u(t−c) g(t)}=e−cs L{g(t+c)},L{δ(t−c) g(t)}=e−cs g(c). \mathcal{L}\{u(t - c)\,g(t)\} = e^{-cs}\,\mathcal{L}\{g(t + c)\}, \qquad \mathcal{L}\{\delta(t - c)\,g(t)\} = e^{-cs}\,g(c).

For the first, substitute τ=t−c\tau = t - c in ∫c∞e−stg(t) dt\int_c^\infty e^{-st} g(t)\,dt. For a term g=tkeatcos⁡wtg = t^k e^{at}\cos wt, the shifted g(t+c)g(t + c) is expanded exactly: (t+c)k(t + c)^k by the binomial theorem, and cos⁡(wt+wc)\cos(wt + wc) by the addition formula. That leaves constants such as eace^{ac}, cos⁡wc\cos wc and sin⁡wc\sin wc, which stay as exact formulas. The second is the defining property of the impulse: ∫0∞e−stδ(t−c) g(t) dt=e−csg(c)\int_0^\infty e^{-st}\delta(t - c)\,g(t)\,dt = e^{-cs}g(c).

Going back, inverseLaplace groups the terms of F(s)F(s) by their factor e−cse^{-cs}, inverts each group by partial fractions, and shifts: e−csR(s)↦u(t−c) r(t−c)e^{-cs}R(s) \mapsto u(t - c)\,r(t - c). A constant left over after the partial fractions is an impulse: e−cs↦δ(t−c)e^{-cs} \mapsto \delta(t - c). A polynomial of higher degree would need derivatives of the impulse, and is refused.

Solving with switched forcing

For any(n)+⋯+a0y=g(t)a_n y^{(n)} + \dots + a_0 y = g(t) with y(0),…,y(n−1)(0)y(0), \dots, y^{(n-1)}(0) given, transforming gives

p(s) Y(s)=G(s)+∑j=1naj∑i<js j−1−i y(i)(0),p(s)=ansn+⋯+a0, p(s)\,Y(s) = G(s) + \sum_{j=1}^{n} a_j \sum_{i<j} s^{\,j-1-i}\,y^{(i)}(0), \qquad p(s) = a_n s^n + \dots + a_0,

and Y=(… )/p(s)Y = (\dots)/p(s) is inverted group by group. steps records each stage.

const kick = laplaceSolve([1, 2, 5], "dirac(t - 2)", [1, 0]);   // a damped spring, struck at t = 2
kick.solution;
// "cos(2*t)*exp(-t) + 1/2*sin(2*t)*exp(-t) + heaviside(t - 2)*(1/2*sin(2*t - 4)*exp(-t + 2))"

const pulse = laplaceSolve([1, 3, 2], "heaviside(t - 1) - heaviside(t - 3)", [0, 0]);   // on from 1 to 3
pulse.pieces.map((p) => p.from);   // ["0", "1", "3"]

Why the answer is proved, not just computed

Between switching times the forcing is an ordinary formula, and so is the solution. laplaceSolve checks, by exact symbolic differentiation:

  • On each interval, the piece satisfies the equation identically.
  • The first piece has the given initial values.
  • At each switching time cc, the pieces join with y,y′,…,y(n−2)y, y', \dots, y^{(n-2)} continuous. At an impulse w δ(t−c)w\,\delta(t - c), y(n−1)y^{(n-1)} jumps by exactly w/anw/a_n; everywhere else it is continuous too.

That is exactly the meaning of a solution with step and impulse forcing. The uniqueness theorem for linear equations then says it is the solution, so verified: true is a proof.

callreturns
laplace(f, { t, s, delay })a formula in s; f may contain heaviside(t - c) factors and dirac(t - c)
inverseLaplace(F, { s, t }){ partialFractions, result } for sums of e−cse^{-cs} times rational functions
laplaceSolve(coefficients, forcing, initial, { t, s }){ transform, partialFractions, solution, pieces, verified, steps, at(time) }

heaviside and dirac are understood by these transform tools only. To evaluate or plot a switched solution, take its pieces.

Try itEdit the code and run it with @ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs