
Euler and fourth order Runge-Kutta methods. Compare your results
with the analytical solution.
y
′
= −yc o s x 0 ≤ x ≤ 1, y(0) = 1 , h = 0.05
y
′
= cos2x + sin3x 0 ≤ x ≤ 1, y( 0) = 1, h = 0.01
The analytical solutions of these equations are:
y(x) = xe
−sinx
y(x) =
1
2
sin2x −
1
3
cos3x +
4
3
B) (25pts) First convert the fo llowing quadratic differential equations into
a linear system of equations and write a program that solves them using
the Runge-Kutta method:
y
′′
= yy
′
0 ≤ x ≤ 1, y(0) = 1 , y
′
(0) = −1; h = 0.1
y
′′
− 2y
′
+ y = e
x
0 ≤ x ≤ 1, y(0) = y
′
(0) = 0; h = 0.1
C) (25pts) RLC circuits. In the alternating current circuit shown in
the figure, the voltage on each circuit element occurs as follows: Ri on
the resistor R, L(di/dt) on the inductor L and q/C on the capacitor
C. Accordingly, a voltage a pplied between terminals AB would be:
L
di
dt
+ Ri +
q
C
= V
AB
Let’s take the derivative of this equa-
tion according to the va r ia ble t and use
the relation dq/ dt = i:
L
d
2
i
dt
2
+ R
di
dt
+
i
C
=
dV
AB
dt
This differential equation is a driven da mped harmonic equation of
motion.
A voltage of V
AB
= 10sin(ωt) is applied to the circuit with R = 5 Ω,L =
0.1 H, C = 0.001 F . First convert this equation into a linear system,
then write a program to solve it by using Runge-Kutta method for the
frequency ω = 3 00 Hz. Take the numerical data as h = 0.01, ω = 1
and b = 0.5 and test tha t simple harmonic motion occurs at b = 0
(where b=R/L).
3