Euler Integration Comparison (Part 3)

Calculus Level pending

Consider the time-domain differential equation:

d d t x ( t ) = x 2.5 ( t ) \frac{d}{dt} x(t) = x^{2.5}(t)

Let us discretize the function and time itself. Function x 1 x_1 is the explicit Euler approximation, and x 2 x_2 is the implicit Euler approximation. Let the time step Δ t = 0.001 \Delta t = 0.001

x 1 k = x 1 k 1 + x ˙ 1 k 1 Δ t = x 1 k 1 + x 1 k 1 2.5 Δ t x 2 k = x 2 k 1 + x ˙ 2 k Δ t = x 2 k 1 + x 2 k 2.5 Δ t t k = t k 1 + Δ t x_{1 k} = x_{1 \, k-1} + \dot{x}_{1 \, k-1} \Delta t \\ = x_{1 \, k-1} + x^{2.5}_{1 \, k-1} \Delta t \\ \,\\ x_{2 k} = x_{2 \, k-1} + \dot{x}_{2 \, k} \Delta t \\ = x_{2 \, k-1} + x^{2.5}_{2 \, k} \Delta t \\ \, \\ t_k = t_{k - 1} + \Delta t

In the above equations, the k k subscript denotes the present processing step, and the k 1 k-1 subscript denotes the previous processing step. The simulation is initialized as follows:

t 0 = 0 x 1 0 = 1 x 2 0 = 1 t_0 = 0 \\ x_{1 \, 0} = 1 \\ x_{2 \, 0} = 1 \\

When t = 0.6 t = 0.6 , what is x 2 x 1 x_2 - x_1 , rounded to the nearest integer multiple of 0.1 0.1 ?


The answer is 0.2.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Karan Chatrath
Mar 20, 2021

The explicit scheme reads as follows:

x 1 ( k + 1 ) = x 1 ( k ) + δ t x 1 ( k ) 2.5 x_1(k+1) = x_1(k) + \delta t \ x_1(k)^{2.5}

The implicit scheme reads as follows:

x 2 ( k + 1 ) = x 2 ( k ) + δ t x 2 ( k + 1 ) 2.5 x_2(k+1) = x_2(k) + \delta t \ x_2(k+1)^{2.5}

So the solution at the next time step depends on the solution at the current as well as the next time step. The goal is to solve for x 1 ( k + 1 ) x_1(k+1) . This is a nonlinear equation in terms of the variable to solve.

Let: x 2 ( k ) = x o x_2(k) = x_o and x 2 ( k + 1 ) = x n x_2(k+1) = x_n and h = δ t h = \delta t

Then we can use the Newton-Raphson iteration scheme to solve for this unknown x n x_n . The nonlinear equation to solve is:

f ( x n ) = h x n 2.5 + x o x n f(x_n) = hx_n^{2.5} + x_o - x_n f ( x n ) = 2.5 h x 1.5 1 f'(x_n) = 2.5hx^{1.5} -1

We can use the following iteration formula to calculate the updated value of x n x_n as follows:

x n , n e w = x n , o l d f ( x n , o l d ) f ( x n , o l d ) x_{n,new} = x_{n,old} - \frac{f(x_{n,old})}{f'(x_{n,old})}

This iteration can be performed to solve for the roots of f ( x n ) f(x_n) . This can be done to some specified numerical tolerance or for a fixed number of steps. I chose to perform 20 steps. This choice is random.

Finally, we can use the result of the final iteration of the above formula and plug it into the implicit scheme as such:

x 2 ( k + 1 ) = x 2 ( k ) + δ t x n , f i n a l 2.5 x_2(k+1) = x_2(k) + \delta t \ x_{n,final}^{2.5}

The calculation code is attached below. Of course, there may be better ways of solving the implicit problem and I looks forward to seeing them.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
clear all
clc

dt      = 0.001;                          % Time step
t       = 0:dt:0.6;                       % Time array

x1(1)   = 1;                              % Explicit solution initial condition
x2(1)   = 1;                              % Implicit solution initial condition


for k = 1:length(t)-1


    x1(k+1)       = x1(k) + dt*x1(k)^2.5; % Explicit Euler Numerical Integration

    % Newton Raphson Method Initialisation:
    xo            = x2(k);                
    xn            = xo;

    for j = 1:20

        fxn   = dt*xn^2.5 + xo - xn;      % Function f(x_n)
        dfxn  = 2.5*dt*xn^1.5 - 1;        % Derivative of f(x_n)

        xn    = xn - fxn/dfxn;            % Newton-Raphson Iteration

    end

    x2(k+1) = x2(k) + dt*xn^2.5;          % Implicit Euler Numerical Integration


end


ANSWER   = x2(end) - x1(end)
% ANSWER = 0.1785 ~ 0.2

Thanks for the solution. I also did NR iteration on each time step

Steven Chase - 2 months, 3 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...