# oscillation_animate

## 2695 days ago by chrisphan

x = var('x') y = function('y', x) def forcingExample(omega): Y = desolve(diff(y, x, 2) + 0.125*diff(y,x) + y == 3*cos(omega*x), y, ivar=x, ics=[0, 2, 0]) Yplot = plot(Y, x, 0, 50, rgbcolor=(0, 0, 1)) F = 3 * cos(omega*x) Fplot = plot(F,x, 0, 50, rgbcolor=(1, 0, 0)) omegalabel = text("omega = " + str(round(omega, 3)), [8, 5], rgbcolor=(0,0,0)) return(Fplot + Yplot + omegalabel) html("This example illustrates the relationship between the solution<br /> of a differential equation modeling forced vibration and the forcing function. Here we consider the<br /> initial value problem $$y'' + 0.125 y' + y = \cos(\omega t), \; y(0) = 0, \; y'(0) = 2.$$ In blue is the solution to the IVP, while in red is the forcing function $$F(t) = 3 \cos(\omega t).$$ Here you can see how<br /> different values of $\omega$ affect the amplitude of the solution.") a = animate([forcingExample(0.1*u) for u in range(1, 30)], figsize=[8,5]) html("Here are plots for various values of $\omega$: <br />") html("$\omega = 0.3$") show(forcingExample(0.3), figsize=[8,5]) html("$\omega = 1$") show(forcingExample(1), figsize=[8,5]) html("$\omega = 3$") show(forcingExample(3), figsize=[8,5]) html("Here is an animation showing the solution for many values of $\omega$:") a.show()
 This example illustrates the relationship between the solution of a differential equation modeling forced vibration and the forcing function. Here we consider the initial value problem y'' + 0.125 y' + y = \cos(\omega t), \; y(0) = 0, \; y'(0) = 2. In blue is the solution to the IVP, while in red is the forcing function F(t) = 3 \cos(\omega t). Here you can see how different values of \omega affect the amplitude of the solution.Here are plots for various values of \omega: \omega = 0.3\omega = 1\omega = 3Here is an animation showing the solution for many values of \omega: This example illustrates the relationship between the solution of a differential equation modeling forced vibration and the forcing function. Here we consider the initial value problem y'' + 0.125 y' + y = \cos(\omega t), \; y(0) = 0, \; y'(0) = 2. In blue is the solution to the IVP, while in red is the forcing function F(t) = 3 \cos(\omega t). Here you can see how different values of \omega affect the amplitude of the solution.Here are plots for various values of \omega: \omega = 0.3\omega = 1\omega = 3Here is an animation showing the solution for many values of \omega:
x = var('x') def forcedUndampedVibration(omega): def amp(x): return(2/(1 - omega^2) * sin((1-omega) * x / 2)) Y = amp(x) * sin((1 + omega)*x /2) output = plot(Y, x, 0, 400, figsize=[8,5]) output = output + plot(abs(amp(x)), x, 0, 400, rgbcolor=(1, 0, 0), figsize=[8,5]) output = output + text("omega = " + str(round(omega, 3)), [50, amp(pi/(1 - omega)) + 1], rgbcolor=(0, 0, 0)) return(output) b = animate([forcedUndampedVibration(0.01*u) for u in range(71, 99)], figsize=[8,5]) html("This example illustrates periodic variation of amplitude which occurs when you have a forced, <br /> undamped vibration. Suppose a vibration is modelled by $$y'' + y' = \cos(\omega t), \\; y(0) = 0, \\; y'(0) = 0.$$ Then the solution will be $$y = \\left(\\frac{2}{1 - \omega^2} \sin\left(\\frac{(1- \omega)t}{2} \\right) \\right) \sin \\left(\\frac{(1 + \omega)t}{2} \\right).$$ If $\omega$ is close to 1, then $1 - \omega$ is small, and hence the factor $$\sin \\left(\\frac{(1 + \omega)t}{2} \\right)$$ is oscillating much faster than $$\\frac{2}{1 - \omega^2} \sin\left(\\frac{(1- \omega)t}{2} \\right).$$ So, we think of $\\left|\\frac{2}{1 - \omega^2} \sin\left(\\frac{(1- \omega)t}{2} \\right) \\right|$ (shown in red) as periodically varying the amplitude of the sine curve.") html("Here are plots for various values of $\omega$:<br />") html("$\omega = 0.7$") show(forcedUndampedVibration(0.7), figsize=[8,5]) html("$\omega = 0.9$") show(forcedUndampedVibration(0.9), figsize=[8,5]) html("$\omega = 0.95$") show(forcedUndampedVibration(0.95), figsize=[8,5]) html("Here's an animation showing the solution for many values of $\omega$:") b.show()
 This example illustrates periodic variation of amplitude which occurs when you have a forced, undamped vibration. Suppose a vibration is modelled by y'' + y' = \cos(\omega t), \; y(0) = 0, \; y'(0) = 0. Then the solution will be y = \left(\frac{2}{1 - \omega^2} \sin\left(\frac{(1- \omega)t}{2} \right) \right) \sin \left(\frac{(1 + \omega)t}{2} \right). If \omega is close to 1, then 1 - \omega is small, and hence the factor \sin \left(\frac{(1 + \omega)t}{2} \right) is oscillating much faster than \frac{2}{1 - \omega^2} \sin\left(\frac{(1- \omega)t}{2} \right). So, we think of \left|\frac{2}{1 - \omega^2} \sin\left(\frac{(1- \omega)t}{2} \right) \right| (shown in red) as periodically varying the amplitude of the sine curve.Here are plots for various values of \omega:\omega = 0.7\omega = 0.9\omega = 0.95Here's an animation showing the solution for many values of \omega: This example illustrates periodic variation of amplitude which occurs when you have a forced, undamped vibration. Suppose a vibration is modelled by y'' + y' = \cos(\omega t), \; y(0) = 0, \; y'(0) = 0. Then the solution will be y = \left(\frac{2}{1 - \omega^2} \sin\left(\frac{(1- \omega)t}{2} \right) \right) \sin \left(\frac{(1 + \omega)t}{2} \right). If \omega is close to 1, then 1 - \omega is small, and hence the factor \sin \left(\frac{(1 + \omega)t}{2} \right) is oscillating much faster than \frac{2}{1 - \omega^2} \sin\left(\frac{(1- \omega)t}{2} \right). So, we think of \left|\frac{2}{1 - \omega^2} \sin\left(\frac{(1- \omega)t}{2} \right) \right| (shown in red) as periodically varying the amplitude of the sine curve.Here are plots for various values of \omega:\omega = 0.7\omega = 0.9\omega = 0.95Here's an animation showing the solution for many values of \omega: