# sawtooth

## 2580 days ago by chrisphan

t = var('t') def g(alpha): return lambda t: int(t/alpha) - t/alpha + 1 def h(alpha, c): return lambda t: (-1/2)*(c+1)*cos(sqrt(2)*t)+(1/2)*c + (sqrt(2)*sin(sqrt(2)*t))/(4*alpha) - t/(2*alpha) + 1/2 def y(alpha): return lambda t: sum([(lambda t : heaviside(t - alpha*c)*h(alpha, c)(t - alpha*c) - heaviside(t - alpha*(c+1))*h(alpha,c)(t - (c+1)*alpha))(t) for c in range(0, int(100/alpha)+2)]) + cos(sqrt(2)*t) + (1/sqrt(2))*(sin(sqrt(2)*t)) html("<h1>Variable Sawtooth Example</h1>Let $$g_\\alpha(t) = \sum_{c = 0}^\infty (u_{\\alpha c}(t) - u_{\\alpha(c+1)}(t))\left(1-\\frac{t-\\alpha c}{\\alpha}\\right).$$ Then $g_\\alpha$ is a sawtooth with period $\\alpha$. Here is a plot of $g_\\alpha$ with $\\alpha = 25$:") plot(g(25), 0, 100, rgbcolor=(1,0,0))

# Variable Sawtooth Example

Let
g_\alpha(t) = \sum_{c = 0}^\infty (u_{\alpha c}(t) - u_{\alpha(c+1)}(t))\left(1-\frac{t-\alpha c}{\alpha}\right).
Then g_\alpha is a sawtooth with period \alpha. Here is a plot of g_\alpha with \alpha = 25:

# Variable Sawtooth Example

Let
g_\alpha(t) = \sum_{c = 0}^\infty (u_{\alpha c}(t) - u_{\alpha(c+1)}(t))\left(1-\frac{t-\alpha c}{\alpha}\right).
Then g_\alpha is a sawtooth with period \alpha. Here is a plot of g_\alpha with \alpha = 25:

html("Now consider the IVP $$y'' + 2y = g_\\alpha, \; \; y(0) = 1, \;\; y'(0) = 1.$$ The solution is $$y = \sum_{c=0}^{\infty}(u_{\\alpha c}(t)h_{c, \\alpha}(t - c\\alpha) - u_{\\alpha(c+1)}(t)h_{c, \\alpha}(t - c\\alpha - \\alpha)) + F(t)$$ where $$h_{c, \\alpha}(t) = - \\frac{1}{2} \cos(\sqrt{2} t) + \\frac{1}{2} c + \\frac{\sqrt{2} \sin(\sqrt{2}t)}{4\\alpha} - \\frac{t}{2\\alpha} + \\frac{1}{2}$$ and $$F(t) = \cos(\sqrt{2}t) + \\frac{1}{\sqrt{2}}\sin(\sqrt{2}t).$$ Here are plots of $y$ and $g_\\alpha$ for various values of $\\alpha$.<br />When $\\alpha = 10$:") show(plot(g(10), 0, 100, rgbcolor=(1,0,0)) + plot(y(10)(t), 0, 100))
 Now consider the IVP y'' + 2y = g_\alpha, \; \; y(0) = 1, \;\; y'(0) = 1. The solution is y = \sum_{c=0}^{\infty}(u_{\alpha c}(t)h_{c, \alpha}(t - c\alpha) - u_{\alpha(c+1)}(t)h_{c, \alpha}(t - c\alpha - \alpha)) + F(t) where h_{c, \alpha}(t) = - \frac{1}{2} \cos(\sqrt{2} t) + \frac{1}{2} c + \frac{\sqrt{2} \sin(\sqrt{2}t)}{4\alpha} - \frac{t}{2\alpha} + \frac{1}{2} and F(t) = \cos(\sqrt{2}t) + \frac{1}{\sqrt{2}}\sin(\sqrt{2}t). Here are plots of y and g_\alpha for various values of \alpha.When \alpha = 10: Now consider the IVP y'' + 2y = g_\alpha, \; \; y(0) = 1, \;\; y'(0) = 1. The solution is y = \sum_{c=0}^{\infty}(u_{\alpha c}(t)h_{c, \alpha}(t - c\alpha) - u_{\alpha(c+1)}(t)h_{c, \alpha}(t - c\alpha - \alpha)) + F(t) where h_{c, \alpha}(t) = - \frac{1}{2} \cos(\sqrt{2} t) + \frac{1}{2} c + \frac{\sqrt{2} \sin(\sqrt{2}t)}{4\alpha} - \frac{t}{2\alpha} + \frac{1}{2} and F(t) = \cos(\sqrt{2}t) + \frac{1}{\sqrt{2}}\sin(\sqrt{2}t). Here are plots of y and g_\alpha for various values of \alpha.When \alpha = 10:
html("When $\\alpha = 20$:") show(plot(g(20), 0, 100, rgbcolor=(1,0,0)) + plot(y(20)(t), 0, 100))
 When \alpha = 20: When \alpha = 20:
html("When $\\alpha = 50$:") show(plot(g(50), 0, 100, rgbcolor=(1,0,0)) + plot(y(50)(t), 0, 100))
 When \alpha = 50: When \alpha = 50:
b = [[plot(g(alpha), 0, 100, rgbcolor=(1,0,0)),plot(y(alpha)(t), 0, 100)] for alpha in range(5, 55, 5)] a = animate(b, ymin=-2, ymax=2.5) html("Here is an animation showing plots for various values of $\\alpha$:") show(a)
 Here is an animation showing plots for various values of \alpha: Here is an animation showing plots for various values of \alpha: