# discontinuous forcing functions

## 2677 days ago by chrisphan

def h(t): return 1 - exp(-t) - t*exp(-t) def g(t): return heaviside(t-2)*h(t-2) - heaviside(t-8)*h(t-8) html("<h1>Example 1</h1>") html("The solution to the IVP $$y''+2y'+y = u_2(t) - u_8(t), \; \; y(0) =0, \; \; y'(0) = 0$$ is $$y(t) = u_2(t)h(t-2)- u_8(t)h(t-8),$$ where $$h(t) = 1 - e^{-t} - t e^{-t}.$$ Here is a plot of $u_2(t) - u_8(t)$:") plot(heaviside(x-2) - heaviside(x-8), 0, 20)

# Example 1

The solution to the IVP
y''+2y'+y = u_2(t) - u_8(t), \; \; y(0) =0, \; \; y'(0) = 0
is
y(t) = u_2(t)h(t-2)- u_8(t)h(t-8),
where
h(t) = 1 - e^{-t} - t e^{-t}.
Here is a plot of u_2(t) - u_8(t):

# Example 1

The solution to the IVP
y''+2y'+y = u_2(t) - u_8(t), \; \; y(0) =0, \; \; y'(0) = 0
is
y(t) = u_2(t)h(t-2)- u_8(t)h(t-8),
where
h(t) = 1 - e^{-t} - t e^{-t}.
Here is a plot of u_2(t) - u_8(t):

html("Here is a plot of $y$:") plot(g, 0, 20)
 Here is a plot of y: Here is a plot of y:
html("Here is a plot of $h$:") plot(h, 0, 20)
 Here is a plot of h: Here is a plot of h:
def r(t): return t - (1/sqrt(3))*sin(sqrt(3)*t) def f(t): return (1/18)*(heaviside(t-3)*r(t-3) - heaviside(t-9)*r(t-9)) def z(t): return (1/6)*(heaviside(t-3)*(t-3) - heaviside(t-9)*(t-9)) html("<h1>Example 2</h1>The solution to the IVP $$y''+y = g(t), \; \; y(0) =0, \; \; y'(0) = 0,$$ where $$g(t) = \\left\{\\begin{matrix} 0, & t < 3 \cr \\frac{t-3}6, & 3 \leq t < 9 \cr 1, & t \geq 9 \end{matrix}, \\right.$$ is $$y(t) = \\frac{1}{18}\\left(u_3(t)h(t-3) - u_9(t)h(t-9)\\right),$$ where $$h(t) = t - \\frac{1}{\sqrt{3}}\sin(\sqrt{3}t).$$ Here is a plot of $g$:") plot(z, 0, 20)

# Example 2

The solution to the IVP
y''+y = g(t), \; \; y(0) =0, \; \; y'(0) = 0,
where
g(t) = \left\{\begin{matrix} 0, & t < 3 \cr \frac{t-3}6, & 3 \leq t < 9 \cr 1, & t \geq 9 \end{matrix}, \right.
is
y(t) = \frac{1}{18}\left(u_3(t)h(t-3) - u_9(t)h(t-9)\right),
where
h(t) = t - \frac{1}{\sqrt{3}}\sin(\sqrt{3}t).
Here is a plot of g:

# Example 2

The solution to the IVP
y''+y = g(t), \; \; y(0) =0, \; \; y'(0) = 0,
where
g(t) = \left\{\begin{matrix} 0, & t < 3 \cr \frac{t-3}6, & 3 \leq t < 9 \cr 1, & t \geq 9 \end{matrix}, \right.
is
y(t) = \frac{1}{18}\left(u_3(t)h(t-3) - u_9(t)h(t-9)\right),
where
h(t) = t - \frac{1}{\sqrt{3}}\sin(\sqrt{3}t).
Here is a plot of g:

html("Here is a plot of $y$:") plot(f, 0, 20)
 Here is a plot of y: Here is a plot of y:
html("Here is a plot of $h$:") plot(r, 0, 20)
 Here is a plot of h: Here is a plot of h:
def q(t): return heaviside(t-2) - heaviside(t-20) def l(t): return (-1/2)*exp(-t/4)*cos(sqrt(15)*t/4) - (1 / (2 * sqrt(15))) * exp(-t/4)*sin(sqrt(15)*t/4) + 1/2 def m(t): return heaviside(t-2)*l(t-2) - heaviside(t-20) * l(t-20) html("<h1>Example 3</h1>The solution to the IVP $$y''+2y'+y = u_2(t) - u_{20}(t), \; \; y(0) =0, \; \; y'(0) = 0$$ is $$y(t) = u_2(t)h(t-2)- u_{20}(t)h(t-20),$$ where $$h(t) = -\\frac{1}{2}e^{-t/4}\cos\\left(\\frac{\sqrt{15}}{4}t\\right) - \\frac{1}{2\sqrt{15}}e^{-t/4}\sin\\left(\\frac{\sqrt{15}}{4}t\\right) + \\frac{1}{2}.$$ Here is a plot of $u_2(t) - u_{20}(t)$:") plot(q, 0, 40)

# Example 3

The solution to the IVP
y''+2y'+y = u_2(t) - u_{20}(t), \; \; y(0) =0, \; \; y'(0) = 0
is
y(t) = u_2(t)h(t-2)- u_{20}(t)h(t-20),
where
h(t) = -\frac{1}{2}e^{-t/4}\cos\left(\frac{\sqrt{15}}{4}t\right) - \frac{1}{2\sqrt{15}}e^{-t/4}\sin\left(\frac{\sqrt{15}}{4}t\right) + \frac{1}{2}.
Here is a plot of u_2(t) - u_{20}(t):

# Example 3

The solution to the IVP
y''+2y'+y = u_2(t) - u_{20}(t), \; \; y(0) =0, \; \; y'(0) = 0
is
y(t) = u_2(t)h(t-2)- u_{20}(t)h(t-20),
where
h(t) = -\frac{1}{2}e^{-t/4}\cos\left(\frac{\sqrt{15}}{4}t\right) - \frac{1}{2\sqrt{15}}e^{-t/4}\sin\left(\frac{\sqrt{15}}{4}t\right) + \frac{1}{2}.
Here is a plot of u_2(t) - u_{20}(t):

html("Here is a plot of $y$:") plot(m, 0, 40)
 Here is a plot of y: Here is a plot of y:
html("Here is a plot of $h$:") plot(l, 0, 40)
 Here is a plot of h: Here is a plot of h:
def w(t): return int(t)- t + 1 def b(t,c): return (1/2)*(1+c) - (1/2)*(1+c)*cos(sqrt(2)*t) + 1/(2*sqrt(2))*sin(sqrt(2)*t) - (1/2)*t def v(t): retnum = 0 for c in range(0, int(t)+1): retnum = retnum + heaviside(t-c)*b(t-c, c) - heaviside(t - c - 1)*b(t - c - 1, c) retnum = retnum + cos(sqrt(2)*t) + (1/sqrt(2))*sin(sqrt(2)*t) return retnum html("<h1>Example 4</h1>The solution to the IVP $$y''+2y = \sum_{c =0}^\\infty (1 + c - t)(u_c(t) - u_{c+1}(t)), \; \; y(0) =1, \; \; y'(0) = 1$$ is $$y(t) = \sum_{c=0}^\infty (u_c(t)h_c(t-c)- u_{c+1}(t)h_c(t-c-1)) + \cos(\sqrt{2}t) + \\frac{1}{\sqrt{2}} \sin(\sqrt{2}t),$$ where $$h_c(t) = \\frac{1}{2}(1+c) - \\frac{1}{2}(1+c)\cos(\sqrt{2}t) +\\frac{1}{2\sqrt{2}}\sin(\sqrt{2}t) - \\frac{1}{2}t.$$ Here is a plot of $$\sum_{c =0}^\\infty (1 + c - t)(u_c(t) - u_{c+1}(t)):$$") plot(w, 0, 20)

# Example 4

The solution to the IVP
y''+2y = \sum_{c =0}^\infty (1 + c - t)(u_c(t) - u_{c+1}(t)), \; \; y(0) =1, \; \; y'(0) = 1
is
y(t) = \sum_{c=0}^\infty (u_c(t)h_c(t-c)- u_{c+1}(t)h_c(t-c-1)) + \cos(\sqrt{2}t) + \frac{1}{\sqrt{2}} \sin(\sqrt{2}t),
where
h_c(t) = \frac{1}{2}(1+c) - \frac{1}{2}(1+c)\cos(\sqrt{2}t) +\frac{1}{2\sqrt{2}}\sin(\sqrt{2}t) - \frac{1}{2}t.
Here is a plot of
\sum_{c =0}^\infty (1 + c - t)(u_c(t) - u_{c+1}(t)):

# Example 4

The solution to the IVP
y''+2y = \sum_{c =0}^\infty (1 + c - t)(u_c(t) - u_{c+1}(t)), \; \; y(0) =1, \; \; y'(0) = 1
is
y(t) = \sum_{c=0}^\infty (u_c(t)h_c(t-c)- u_{c+1}(t)h_c(t-c-1)) + \cos(\sqrt{2}t) + \frac{1}{\sqrt{2}} \sin(\sqrt{2}t),
where
h_c(t) = \frac{1}{2}(1+c) - \frac{1}{2}(1+c)\cos(\sqrt{2}t) +\frac{1}{2\sqrt{2}}\sin(\sqrt{2}t) - \frac{1}{2}t.
Here is a plot of
\sum_{c =0}^\infty (1 + c - t)(u_c(t) - u_{c+1}(t)):

html("Here is a plot of $y$:") plot(v, 0, 20)
 Here is a plot of y: Here is a plot of y: