BCAM and UPV/EHU courses 2011-2012: Advanced aspects in applied mathematics Topics on numerics for wave propagation LAB1: HARMONIC OSCILLATORS AURORA MARICA AND ENRIQUE ZUAZUA Problem 1. Consider the harmonic oscillator equation: (0.1) x00 (t) + ω 2 x(t) = 0, t ∈ [0, T ], x(0) = x0 , x0 (0) = x1 . Set T = 4ωπ, ω = 1 and the following four initial data: (0.2) I) x0 = 1, x1 = 0; II) x0 = 0, x1 = 1; III) x0 = 1, x1 = 1; IV ) x0 = 1, x1 = −1. Task 1. Compute the explicit solution and plot it using Matlab. Consider a general system of the form (0.3) x0 (t) = f (x(t), v(t)), v 0 (t) = g(x(t), v(t)), t ∈ (0, T ), x(0) = x0 , v(0) = v 0 . To solve system (0.3) with Matlab we can proceed as follows: Step 1. Introduce the following function and save it as funct.m function der=funct(t,X) der=[f(X(1),X(2));g(X(1),X(2))]; Step 2. The following Matlab program solves problem (0.3) using the ode45 function: X0 = [x0 , v 0 ]; % vector of initial data T = 4π; dt = T /1000;% the time step divt = [0 : dt : T ]; [t0, sol] = ode45(@f unct, divt, x0); Task 2. Solve problem (0.1) by using the above program. Plot the true solution x(t) and the numerical one sol(:, 1) in the same figure. Plot sol(:, 1) against sol(:, 2) in the horizontal/vertical direction. The following program draws the phase portrait (x, v) of system (0.3) for x ∈ [a, b] and v ∈ [c, d]. x = [a : hx : b]; v = [c : hv : d]; % the division of the intervals [a, b] and [c, d]; [X, V ] = meshgrid(x, v); Xdot = f (X, V ); V dot = g(X, V ); quiver(X, V, Xdot, V dot) Task 3: Draw the phase portrait of problem (0.1) for a = b = c = d = 2 and hx = hv = 0.2. Problem 2. Consider the pendulum equation: (0.4) x00 (t) + ω 2 sin(x(t)) = 0, t ∈ [0, T ], x(0) = x0 , x0 (0) = x1 . Set T = 4π, ω = 1 and the following four initial data: (0.5) I) x0 = π/10, x1 = 0; II) x0 = π/2, x1 = 0; III) x0 = π, x1 = 0; IV ) x0 = 3π/2, x1 = 0. Repeat Tasks 2 and 3 in the previous problem. Problem 3. Consider the damped harmonic oscillator: (0.6) x00 (t) + 2βx0 (t) + x(t) = 0, t ∈ [0, T ], x(0) = x0 , x0 (0) = x1 . Set T = 4π, x0 = 1, x1 = 0 and the following four values of β: (0.7) I) β = 0.05; II) β = 0.5; III) β = 1; Repeat Tasks 1,2,3 in Problem 1. 1 IV ) β = 1.5. 2 AURORA MARICA AND ENRIQUE ZUAZUA Problem 4. Consider the damped harmonic oscillator with driven force: (0.8) x00 (t) + 2βx0 (t) + x(t) = A cos(ωt), t ∈ [0, T ], x(0) = x0 , x0 (0) = x1 . Set T = 1/β, x0 = 1, x1 = 0, A = 1 and the following four values of β: (0.9) I) β = 1; II) β = 1/10; III) β = 1/50; IV ) β = 1/200. Repeat Task 2 of Problem 1 for all the following six values ofpω: ω = 1/2, ω = 1/4, ω = (1 + ωd )/2, p ω = ωd , ω = (ωd + ωr )/2 and ωr , where ωd := 1 − β 2 and ωr := 1 − 2β 2 are the damping and resonance frequencies.
© Copyright 2026 Paperzz