× back

Solution of differential equations

Picard's Method

Picard's method is a numerical technique used to approximate solutions to ordinary differential equations (ODEs). Consider the following differential equation: \(\frac{dy}{dx} = f(x, y)\) with an initial condition \(y(x_0) = y_0\).
We start by rewriting the differential equation as:
\(\frac{dy}{dx} = f(x, y)\) (equation 1)
On integrating both sides of equation 1, we get:
\(\int_{y_0}^{y} dy = \int_{x_0}^{x} f(x, y) \, dx\)
This simplifies to:
\(y - y_0 = \int_{x_0}^{x} f(x, y) \, dx\)
And solving for \(y\), we have:
\(y = y_0 + \int_{x_0}^{x} f(x, y) \, dx\) (equation 2)
Equation 2 is called an integral equation, which is equivalent to equation 1 but contains the unknown function \(y\) under the integral sign.
In Picard's method of successive approximation, we obtain the first approximation \(y_1\) of \(y\) by substituting \(y_0\) for \(y\) in the right-hand side of equation 2:
\(y_1 = y_0 + \int_{x_0}^{x} f(x, y) \, dx\)
This process is repeated iteratively until the desired degree of accuracy is achieved.

Q- Solve \(\frac {dy}{dx}\) = 1 + xy with \(x_0 = 0\), \(y_0 = 0\) up to the third approximation

Sol:
Given \(\frac{dy}{dx}\) = 1 + xy = f(x,y)
By Picard's method of successive approximation, we have \(y = y_0 + \int_{x_0}^{x} f(x, y_0) dx \)
Here \(x_0 = 0\) and \(y_0 = 0\)
\(y_1 = 0 + \int_{x_0}^{x} (1 + x*0) dx\)
\(y_1 = \int_{0}^{x} (1) dx\)
\(y_1 = \left. [x] \right|_{0}^{x}\)
\(y_1 = x\)

Second approximation.
Now \(x_0 = 0\), \(y_0 = 0\) and \(y_1 = x\)
\(y_{2} = y_0 + \int_{x_0}^{x} f(x,y_1) dx\)
\(y_2 = 0 + \int_{0}^{x} (1 + x^2) dx\)
\(y_2 = \int_{0}^{x} (1 + x^2) dx\)
\(y_2 = \left. [x + \frac{x^3}{3}] \right|_{0}^{x}\)
\(y_2 = x + \frac{x^3}{3}\)

Third approximation:
Here \(x_0 = 0\), \(y_0 = 0\), \(y_1 = x\), \(y_2 = x + \frac{x^3}{3}\)
\(y_3 = y_0 + \int_{x_0}^{x} f(x, y_2) dx\)
\(y_3 = 0 + \int_{0}^{x} (1 + x(x + \frac{x^3}{3})) dx\)
\(y_3 = \int_{0}^{x} (1 + x^2 + \frac{x^4}{3}) dx\)
\(y_3 = \left. [x + \frac{x^3}{3} + \frac{x^5}{15}] \right|_{0}^{x}\)
\(y_3 = x + \frac{x^3}{3} + \frac{x^5}{15}\) (Answer)

Q2- Use Picard's method to approximate y when x = 0.2, given that y = 1 when x = 0 and \(\frac{dy}{dx}\) = x - y

Sol:
Here, f(x,y) = x - y and \(x_0\) = 0, \(y_0\) = 1
By Picard's method, we have
\(y = y_0 + \int_{x0}^{x}f(x,y_0) dx \)

First approximation:
\(y_1 = y_0 + \int_{x0}^{x}f(x,y_0) dx \)
\(y_1 = 1 + \int_{0}^{x}x-1 dx \)
\(y_1 = 1 + \int_{0}^{x} x dx - \int_{0}^{x}dx\)
\(y_1 = x + \frac{x^3}{3}\)
\(y_1 = 1 + \left. [\frac{x^2}{2}] \right|_{0}^{x} + \left. [x] \right|_{0}^{x}\)
\(y_1 = \frac{x^2}{2} - x + 1\)
then \(y_1(0.2) = \frac{(0.2)^2}{2} - 0.2 + 1 = 0.82\)

Second Approxmation:
\(y_2 = y_0 + \int_{x0}^{x}f(x,y_1) dx \)
\(y_2\) = \(y_0 + \int_{x0}^{x}f(x,\frac{x^2}{2} - x + 1) dx \)
\(y_2 = 1 + \int_{0}^{x}(x - \frac{x^2}{2} + x - 1) dx \)
\(y_2 = 1 + \int_{0}^{x}(2x - \frac{x^2}{2} - 1) dx \)
\(y_2 = 1 + \left. [\frac{2x^2}{2} - \frac{x^3}{6} - x] \right|_{0}^{x} \)
\(y_2 = 1 + \left. [x^2 - \frac{x^3}{6} - x] \right|_{0}^{x} \)
\(y_2 = 1 + x^2 - \frac{x^3}{6} - x\)
\(y_2 = 1 - x + x^2 - \frac{x^3}{6} \)
\(y_2(0.2)\) =\( 1 - 0.2 + (0.2)^2 \) \( - \frac{(0.2)^3}{6} = 0.8387 \)

Third Approxmation:
\(y_3 = y_0 + \int_{x0}^{x}f(x,y_2) dx \)
\(y_3 = y_0 + \int_{x0}^{x}f(x,1 - x + x^2 - \frac{x^3}{6}) dx \)
\(y_3 = 1 + \int_{0}^{x}(x - 1 + x - x^2 + \frac{x^3}{6} ) dx \)
\(y_3 = 1 + \int_{0}^{x}(2x - 1 - x^2 + \frac{x^3}{6} ) dx \)
\(y_3 = 1 + \left. [2\frac{x^2}{2} - x - \frac{x^3}{3} + \frac{x^4}{24}] \right|_{0}^{x} \)
\(y_3 = 1 + x^2 - x - \frac{x^3}{3} + \frac{x^4}{24}\)
\(y_3(0.2) = 1 + 0.2^2 - 0.2 - \frac{0.2^3}{3} + \frac{0.2^4}{24}\) = 0.8374

Fourth Approxmation:
\(y_4 = y_0 + \int_{x0}^{x}f(x,y_3) dx \)
\(y_4 \) =\( y_0 + \int_{0}^{x}f(x,1 + x^2 - x - \frac{x^3}{3} \) \( + \frac{x^4}{24}) dx \)
\(y_4 = \) \( 1 + \int_{0}^{x}(x - 1 - x^2 + x + \frac{x^3}{3}\) \( - \frac{x^4}{24} ) dx \)
\(y_4 = \) \( 1 + \int_{0}^{x}(2x - 1 - x^2 + \frac{x^3}{3} \) \( - \frac{x^4}{24} ) dx \)
\(y_4 = 1 + \left. [2\frac{x^2}{2} - x - \frac{x^3}{3} + \frac{x^4}{12} + \frac{x^5}{120}] \right|_{0}^{x} \)
\(y_4 = 1 + \left. [x^2 - x - \frac{x^3}{3} + \frac{x^4}{12} + \frac{x^5}{120}] \right|_{0}^{x} \)
\(y_4 = 1 + x^2 - x - \frac{x^3}{3} + \frac{x^4}{12} - \frac{x^5}{120}\)
then \(y_4(0.2) = 0.8374\)
as \(y_4(0.2) = y_3(0.2)\) so we can stop here
Hence, y(0.2) = 0.837 (upto 3 decimal places) answer.

Q3- Use Picard's method to obtain y for x = 0.1, given that: \(\frac{dy}{dx} = 3x + y^2\); y = 1 and x = 0.

Euler's Method

Q- Using Euler's method find and approx value of y corresponding to x = 0.1, given \(\frac{dy}{dx} = \frac{y-x}{y+x}\), y(0) = 1 which means \(x_0 = 0\)

Sol:
given f(x, y) = \(\frac{y-x}{y+x}, x_0 = 0,\ y_0 = 1\ and\ x_n = 0.1\)
let n = 5
then h = \(\frac{x_n - x_0}{n}\)
0.02
From Euler's method, we have
\(y_n = y_{n-1} + h f(x_{n-1}, y_{n-1})\)
then \(y_1 = y_0 + h f(x_0, y_0)\)
\(y_1 = 1.02\)

till now we have:
\(x_0 = 0 \ y_0 = 1\)
\(x_1 = 0.02 \ y_1 = 1.02\)
\(x_2 = 0.04\ y_2 = ?\)
\(x_3 = 0.06 \ y_3 = ?\)
\(x_4 = 0.08 \ y_4 = ?\)
\(x_5 = 0.1 \ y_5 = ?\)

Now \(y_2 = y_1 + h.f(x_1, y_1)\)
\(y_2 = 1.02 + 0.02 * f(0.02, 1.02)\)
\(y_2 = 1.02 + 0.02 (\frac{1.02 - 0.02}{1.02 + 0.02})\)
\(y_2 = 1.0392\)

Now \(y_3 = y_2 + h.f(x_2, y_2)\)
\(y_3 = 1.0392 + 0.02 * f(0.04, 1.0392)\)
\(y_3 = 1.0392 + 0.02 (\frac{1.0392 - 0.04}{1.0392 + 0.04})\)
\(y_3 = 1.0577\)

Now \(y_4 = y_3 + h.f(x_3, y_3)\)
\(y_4 = 1.0577 + 0.02 * f(0.06, 1.0577)\)
\(y_4 = 1.0577 + 0.02 (\frac{1.0577 - 0.06}{1.0577 + 0.06})\)
\(y_4 = 1.0756\)

Now \(y_5 = y_4 + h.f(x_4, y_4)\)
\(y_5 = 1.0756 + 0.02 * f(0.08, 1.0756)\)
\(y_5 = 1.0756 + 0.02 (\frac{1.0756 - 0.08}{1.0756 + 0.08})\)
\(y_5 = 1.0928\)
Hence, the approximate value of y(0.1) = 1.0928

Q- Using Euler's method, find approximate value of y corresponding to x = 1 given that \(\frac{dy}{dx}\) = x + y, y(0) = 1

Sol:
Given: f(x, y) = x + y; \(x_0 = 0, \ y_0 = 1,\ x_n = 1\)
let n = 10, then h = \(\frac{(1-0)}{10}\) = 0.1
we will make a table of x, y, \(\frac{dy}{dx} = x + y\), old y + h*\(\frac{dy}{dx} = new\ y\)

x     y     f(x,y)    new y
0    1        1        1.1
0.1  1.1      1.2      1.22
0.2  1.22     1.42     1.36
0.3  1.36     1.66     1.53
0.4  1.53     1.93     1.72
0.5  1.72     2.22     1.94
0.6  1.94     2.54     2.19
0.7  2.19     2.89     2.48
0.8  2.48     3.28     2.81
0.9  2.81     3.71     3.18
1    3.18
                    
Hence, the approximate value of y(1) = 3.18

Taylor's Series Method

Consider the given differential equation
\(\frac{dy}{dx} = f(x,y)\) equation(1)
with initial condition \(y(x_0) = y_0\)
If y(x) is the exact solution of equation (1)
subjected to given condition, then the Taylor's series for y(x) around x = \(x_0\) is given by
\(y_1 =\)\( y(x) = y_o + (x - x_o)y^I_o + \)\( \frac{(x - x_o)^2}{2!}y^{II}_o + \)\( \frac{(x - x_o)^3}{3!}y^{III}_o + \frac{(x - x_o)^4}{4!}y^{IV}_o + ...\) equation(2)
Put x-\(x_o\) = h in equation 2
\(y_1 = y_o + h.y^I_o + \)\( \frac{h^2}{2!}y^{II}_o + \frac{h^3}{3!}y^{III}_o + \frac{h^4}{4!}y^{IV}_o + ...\) equation(3)
Similarly, Taylor's series for y(x) around x = \(x_1\) if given by
\(y_2 = y_1 + hy^I_n + \frac{h^2}{2!}y^{II}_1 + \frac{h^3}{3!}y^{III}_1 + ...\)
Preceding in the same way.
\(y_{n+1} = y_n + hy^I_n + \frac{h^2}{2!}y^{II}_n + \frac{h^3}{3!}y^{III}_n + ...\)
\(y^I, y^{II} are\ derivatives\)

Q- Solve \(\frac{dy}{dx} = x + y\) by Taylor's Series method start from x = 1, y = 0 and carry to x = 1.2 with h = 0.1

Given \(y^I = x + y \ and\ h = 0.1\)
\(x_o = 1, y_o = 0\)
\(x_1 = 1.1, y_1 = ?\)
\(x_2 = 1.2, y_2 = ? \) this is what we have to find
\(y_1 = y_o +h y^I_o + \)\( \frac{h^2}{2!}y^{II}_0 +\)\( \frac{h^3}{3!}y^{III}_o + \frac{h^4}{4!}y^{IV}_o \)
\(y_0 = 0, y^I = x + y\)

  • we will use this:
    \(y^I = x + y\)
    \(y^{II} = \frac{d (x+y)}{dx} = 1 + y^I\)
    \(y^{III} = 0 + y^{II} = y^{II}\)
    \(y^{IV} = y^{III}\)
for \(y_0\):
\(y^I_o = x_o + y_o = 1 + 0 = 1\)
\(y^{II}_o = 1 + y^I_o = 1 + 1 = 2\)
\(y^{III}_o = 2\)
\(y^{IV}_o = 2\)
Now we can put these value in formula:
\(y_1 = 0 + 0.1(1) +\)\(\frac{(0.1)^2}{2!} (2) + \frac{(0.1)^3}{3!} (2) + \)\( \frac{(0.1)^4}{4!} (2)\) + ...
\(y_1 = 0.1 + 0.01 + 0.00033 + 0.0000083 + ... \)
\(y_1 = 0.110\)

for \(y_2\):
\(y_2 = y_1 +h y^I_1 +\)\( \frac{h^2}{2!}y^{II}_1 + \frac{h^3}{3!}y^{III}_1 + \frac{h^4}{4!}y^{IV}_1 \)
\(x_1 = 1.1\ and \ y_1 = 0.11\)
\(y^I_1 = x_1 + y_1 = 1.1 + 0.11 = 1.21\)
\(y^{II}_1 = 1 + y^I_1 = 1 + 1.21 = 2.21\)
\(y^{III}_1 = 2.21\)
\(y^{IV}_1 = 2.21\)
Now we can put these value in formula:
\(y_2 = 0.11 + 0.1(1.21) +\)\( \frac{(0.1)^2}{2!} (2.21) +\)\( \frac{(0.1)^3}{3!} (2.21) + \frac{(0.1)^4}{4!} (2.21)\) + ...
\(y_2 \) = 0.11 + 0.121 + 0.01105 = 0.0003683 + 0.000009208 + ...
\(y_2 = 0.242\)

Use Taylor's series method to solve \(\frac{dy}{dx} = 2y + 3e^x\) with initial condition as \(x_o = 0,\ y_o = 1\) find approximate value of y for x = 0.1 and x = 0.2

Sol:
f(x) = \(2y + 3e^x\)
Given than \(x_o = 0,\ y_o = 1, x_1 = 0.1\)
h = \(x_1 - x_o = 0.1 - 0 = 0.1\)

  • We will use the following:
    \(y^I = 2y + 3e^x\)
    \(y^{II} = 2y^I + 3e^x\)
    \(y^{III} = 2y^{II} + 3e^x\)
    \(y^{IV} = 2y^{III} + 3e^x\)
    \(y^{V} = 2y^{IV} + 3e^x\)
now for \(y_0\):
\(y^I_0 = 2(1) + 3e^0 = 5\)
\(y^{II}_0 = 2(5) + 3e^0 = 13\)
\(y^{III}_0 = 2(13) + 3e^0 = 29\)
\(y^{IV}_0 = 2(29) + 3e^0 = 61\)
\(y^{V}_0 = 2y^{IV} + 3e^x\)
Now by Taylor's Series:
\(y_1 = y_o +h y^I_o + \)\( \frac{h^2}{2!}y^{II}_0 + \)\(frac{h^3}{3!}y^{III}_o + \frac{h^4}{4!}y^{IV}_o + ...\)
\(y_1 = 1 + 0.1(5) + \)\( \frac{(0.1)^2}{2!}13 + \)\(\frac{(0.1)^3}{3!}29 + \frac{(0.1)^4}{4!}61 + ... \)
\(y_1 \) = 1 + 0.5 + 0.0650 + 0.00483 + 0.000254 + ...
\(y_1 = 1.570 \)

Now \(y_2:\)
\(x1 = \) \( 0.1,\ y_1 = 1.570,\ x2 = 0.2, \)\( h = x_2 - x_1 = 0.2 - 0.1 \)\( = 0.1, h = 0.1\)
now for finding \(y_1\):
\(y^I_1 = 2(1.570) + 3e^{0.1} = 6.4555\)
\(y^{II}_1 = 2(6.4555) + 3e^ {0.1}= 16.2265\)
\(y^{III}_1 = 2(16.2265) + 3e^{0.1} = 35.7685\)
\(y^{IV}_1 = 2(35.7685) + 3e^{0.1} = 74.8525\)
Now by Taylor's Series:
\(y_2 = y_1 + h y^I_1 +\)\( \frac{h^2}{2!}y^{II}_1 + \)\(\frac{h^3}{3!}y^{III}_1 + \frac{h^4}{4!}y^{IV}_1 + ...\) \( y_2 = 1.57 + (0.1)(6.4555)\)\( + \frac{(0.1)^2}{2!}16.2265 + \)\(\frac{(0.1)^3}{3!}35.7685 + \frac{(0.1)^4}{4!}74.8525 + ... \)
\(y_2 = 1.57 + 0.64555 + 0.081132\)\( + 0.00596 + 0.000311 + ...\)
\(y_2 = 2.303\)
So, at \(x_2 = 0.2\ y_2 = 2.303\)

Runge Kutta Method

The Runge Kutta method is applied as follows:
Calculate successive: \(k_1, k_2, K_3, k_4\)
\(k_1 = h f(x_n, y_n)\)
\(k_2 = h f(x_n + \frac{h}{2}, y_n + \frac{k1}{2})\)
\(k_3 = h f(x_n + \frac{h}{2}, y_n + \frac{k2}{2})\)
\(k_4 = h f(x_n + h, y_n + k_3)\)
then compute k = \(\frac{1}{6} ( k_1 + 2k_2 + 2k_3 + k_4)\)
where k = weighted mean of \(k_1, k_2, k_3\ and \ k_4\)
\(y_{n+1} = y_n + k\)

Q- Apply Runge Kutta method and solve \(\frac{dy}{dx} = \frac{y^2 - x^2}{y^2 + x^2}\) with y(0) = 1 at x = 0.2 and x = 0.4.

Sol:
Given \(\frac{dy}{dx} = f(x,y) = \frac{y^2 - x^2}{y^2 + x^2};\ x_o = 0, y_o = 1\)
Taking h = 0.2 → \(x_1 = x_0 + h = 0.2\)
Using Runge Kutta method :
k1 = h.f(\(x_o, y_o\)) = (0.2)f(0,1) = (0.2)\(\frac{(1^2 - 0^2)}{1^2 + 0^2}\) = 0.2
\(k_2 = h f(x_o + \frac{h}{2}, y_n + \frac{k1}{2})\) = (0.2)f(0.1, 1.1) = 0.1967
\(k_3 = h f(x_o + \frac{h}{2}, y_n + \frac{k2}{2})\) = (0.2)f(0.2, 1.0984) = 0.1967
\(k_4 = h f(x_o + h, y_n + k_3)\) = (0.2) f(0.2, 1.1967) = 0.1891
k = \(\frac{1}{6}\)(\(k_1\) + 2\(k_2\) + 2\(k_3\) + \(k_4\)) = 0.1960
\(y_1\) = y(0.2) = \(y_o\) + k = 1 + 0.1960 = 1.1960
Now \(x_1\) = 0.2, \(y_1\) = 1.1960, h = 0.2, f(x,y) = \(\frac{y^2 - x^2}{y^2 + y^2}\), \(x_2\) = \(x_1\) + h = 0.2 + 0.2 = 0.4
\(k_1\) = h f(\(x_1\), \(y_1\)) = (0.2) f(0.2, 1.1960) = 0.1891
\(k_2\) = h f(\(x_1 + \frac{h}{2}\), \(y_1 + \frac{k_1}{2}\)) = (0.2) f(0.3, 1.2906) = 0.1795
\(k_3\) = h f(\(x_1 + \frac{h}{2}\), \(y_1 + \frac{k_2}{2}\)) = (0.2) f(0.3, 1.2858) = 0.1793
\(k_4\) = h f(\(x_1 + h\), \(y_1 + k_3\)) = (0.2) f(0.4, 1.3753) = 0.1688
k = \(\frac{1}{6}\)(\(k_1\) + 2\(k_2\) + 2\(k_3\) + \(k_4\))
k = \(\frac{1}{6}\)(0.1891 + 2*0.1795 + 2*0.1793 + 0.1688)
k = 0.17925
\(y_2\) = \(y_1 + k = 1.1960 + 0.1792 = 1.3752\) answer

Reference