Explicit and Implicit Methods In Solving Differential Equations

advertisement
University of Connecticut
DigitalCommons@UConn
Honors Scholar Theses
Honors Scholar Program
Spring 5-9-2010
Explicit and Implicit Methods In Solving
Differential Equations
Timothy Bui
University of Connecticut - Storrs, tbui0401@yahoo.com
Follow this and additional works at: http://digitalcommons.uconn.edu/srhonors_theses
Part of the Mathematics Commons
Recommended Citation
Bui, Timothy, "Explicit and Implicit Methods In Solving Differential Equations" (2010). Honors Scholar Theses. Paper 119.
http://digitalcommons.uconn.edu/srhonors_theses/119
This Article is brought to you for free and open access by the Honors Scholar Program at DigitalCommons@UConn. It has been accepted for inclusion
in Honors Scholar Theses by an authorized administrator of DigitalCommons@UConn. For more information, please contact
digitalcommons@uconn.edu.
Explicit and Implicit Methods In
Solving Differential Equations
By: Timothy Bui
Peoplesoft ID# 1500510
Honors Thesis Advisor: Dr. Yung S. Choi
12/11/2009
Contents
1
Abstract………………………………………………………………………………………… 1
2
Introduction…………………………………………………………………………………… 2
3
Explicit and Implicit Methods in Solving Differential Equations……… 3-19
4
Conclusion and Future Work…………………………………………………………… 20-21
5
Works Cited…………………………………………………………………………………… 22-23
6
Appendix………………………………………………………………………………………… 24-45
Bui 1
Abstract:
Differential equations are equations that involve an unknown function and derivatives.
There will be times when solving the exact solution for the equation may be unavailable
or the means to solve it will be unavailable. At these times and most of the time explicit
and implicit methods will be used in place of exact solution. In the simpler cases,
ordinary differential equations or ODEs, the forward Euler's method and backward
Euler's method are efficient methods to yield fairly accurate approximations of the actual
solutions. By manipulating such methods, one can find ways to provide good
approximations compared to the exact solution of parabolic partial differential equations
and nonlinear parabolic differential equations. Further, the experimental results show
that smaller h values result in reduction in error which is true in both cases of differential
equations.
Bui 2
Introduction
Differential equations are equations that involve an unknown function and derivatives.
Braun, Golubitsky, Sirovich and Jager (1992) defined differential equation as the
equation relates a function to its derivatives in such a way that the function itself can be
determined. Vrabie (2004) indicated that mathematicians had realized that many
differential equations cannot be solved using explicitly. The Euler Implicit method was
identified as a useful method to approximate the solution. In other cases, ordinary
differential equations or ODEs, the forward Euler's method and backward Euler's
method are also efficient methods to yield fairly accurate approximations of the actual
solutions. This study attempts to show that by manipulating explicit and implicit
methods, one can find ways to provide good approximations compared to the exact
solution of parabolic partial differential equations and nonlinear parabolic differential
equations. Furthermore, the result of h values, step size, is also part of the discussion in
error reduction in both cases of differential equations.
Bui 3
Explicit and Implicit Methods in Solving Differential Equations
A differential equation is also considered an ordinary differential equation (ODE) if the
unknown function depends only on one independent variable. Frequently exact
solutions to differential equations are unavailable and numerical methods become
necessary to yield fairly accurate approximations of the actual solutions. Bronson and
Costa (2006) discussed the concept of qualitative methods regarding differential
equations; that is, techniques which are used when analytical solutions are difficult or
virtually impossible to obtain.
Let us take as an example an initial value problem in ODE
= , , = where f is a given smooth function. There are numerical methods that provide
quantitative information about solutions even if formulas or the exact solution cannot be
found. Most of the time the work done by using numerical methods can be performed by
the machine. However numerical investigations possess limitations in that only
approximations can be obtained and a finite number of initial conditions can be
experimented. Groisman (2005) took a similar numerical approximation approach and
utilized totally discrete explicit and semi-implicit Euler methods to explore problem in
several space dimensions.
The forward Euler’s method is one such numerical method and is explicit. Explicit
methods calculate the state of the system at a later time from the state of the system at
the current time without the need to solve algebraic equations. For the forward (from
this point on forward Euler’s method will be known as forward) method, we begin by
Bui 4
choosing a step size or ∆. The size of ∆ determines the accuracy of the approximate
solutions as well as the number of computations . Graphically this method produces a
series of line segments, which thereby approximates the solution curve.
Let , = 0, 1, 2, …, be a sequence in time with
= + ∆.
Let and be the exact and the approximate solution at = , respectively. To
obtain from , , we use the differential equation. Since the slope of the solution
to the equation = , at the point , is , , the Euler method determines
the point , by assuming that it lies on the line through , with the slope
, . Hence the formula for the slope of a line gives
− = , ∆
or
= + , ∆.
As the step size or ∆ decreases then the error between the actual and approximation is
reduced. Roughly speaking we halve the error by halving the step size in this case.
However, halving the ∆ doubles the amount of computation.
The backward Euler’s method is an implicit one which contrary to explicit
methods finds the solution by solving an equation involving the current state of the
system and the later one.
More precisely we have
Bui 5
= + , ∆.
This disadvantage to using this method is the time it takes to solve this equation.
However, advantages to this method include that they are usually more numerically
stable for solving a stiff equation a larger step size ∆ can be used.
Let us take following initial value problem
′ + 2 = 2 − , 0 = 1,
0 ≤ ≤ 0.5,
we will use forward and the backward Euler’s method to approximate the solution to this
problem and these approximations to the exact solution
= 1 + 0.5 ∗ − 0.5 ∗ .
In both methods we let ∆ = 0.1 and the final time = 0.5.
Table 1a. Forward and Backward Euler’s Method Compared To Exact Solution
Yn, forward
Yn, backward
tn
Euler’s
Euler’s
(time) approximation
approximation
0
1
1
0.1
0.9
0.9441
0.2
0.853
0.916
0.3
0.8374
0.9049
0.4
0.8398
0.9039
0.5
0.8517
0.9086
yn, exact
1
0.925795
0.889504
0.876191
0.876191
0.883728
|ei| error
forward
0
0.025795
0.036504
0.03791
0.036391
0.032028
|ei| error
backward
0
0.018305
0.026496
0.028709
0.027709
0.024872
The | | error averages were also computed for both methods and the result was for the
average error for forward Euler’s method was 0.028105 and the average error for the
Bui 6
backward Euler’s method was 0.021015. As it can be seen in both the chart above and
the | | error averages that the backward Euler’s method seems to be the more
accurate between the methods.
The solution at ! = 0.5 was approximated using the forward Euler’s method (Fi. A) and
backward Euler’s method (Fig. B) with ∆ = 0.1, ∆ = 0.05, ∆ = 0.0125, ∆ = 0.00625.
The solutions for these four conditions varying h were compared by taking the absolute
difference against the exact solution at that point.
1
0.1
0.05
0.025
0.0125
ei error
0.1
0.01
0.001
h
Figure A. Plot of ei error varying h at =0.5 and ! =0.5 with the Forward Euler’s method
Bui 7
1
0.1
0.05
0.025
0.0125
ei error
0.1
0.01
0.001
h
Figure B. Plot of ei error varying h at =0.5 and ! =0.5 with the Backward Euler’s method
The slope of Fig. A is approximately 1.06, which means that as the ∆ decreases by half
the accuracy of the analytical solution of the forward method changes by that factor.
The slope of Fig. B is approximately 0.946; as ∆ is halved in the case of the backward
method the accuracy of the solution is improved by a smaller degree than that of the
forward method.
Next we tackle the parabolic partial-differential equation. The simplest example is
the heat conduction equation given by
#$
# $
%, = α %, , 0 < % < ', > 0, )
#
#%
with boundary conditions
$0, = 0, $', = 0, > 0,
Bui 8
And initial conditions
$%, 0 = %, 0 ≤ % ≤ '.
One approach used to solve such a problem involves finite differences. First select a
spatial mesh constant h and a time step size k with stipulation that * = '/ℎ being an
integer. Hence a typical point in the domain is given by -% , . / = 01 , 2 We obtain the difference method by using the Taylor series in to form the difference
quotient
$-% , . + / − $% , . # #$
-% , . / =
−
$-% , 3. /,
#
2 # 4
for some 3. ∈ -. , . /, and the Taylor series in % to form the difference quotient
$-% + ℎ, . / − 2$-% , . / + $% − ℎ, . # $
-% , . / =
ℎ
#%
−
ℎ # $
-6 , . /,
12 #% where 6 8% , % . Thus we employ
7
9 ,. − 9 ,.
9 ,. − 29 ,. + 9 ,.
− :
= 0, ;
ℎ
as a numerical scheme to solve equation (a), where 9 . approximates $% , . . We note
that 9 ,
is given by the initial condition 0ℎ, and 9
,. = 9<,. = 0 due to the boundary
conditions.
Bui 9
Which simplifies to
9 ,. = =1 −
2: > 9 ,. + : -9 ,. + 9 ,. /, ℎ
ℎ
for each 0 = 1, 2, … , * − 1 and 2 = 1, 2, …. With known initial and boundary conditions
for w, one can solve for 9 ,. for successively larger j.
If we let ? = : 1@ ,
A
= % , % , … , %< ,
E
D
for each 2 = 1, 2, …, and B = D
D
C
equivalent to
A. = 9,. , 9,. , … , 9<,. ,
1 − 2?
?
?
1 − 2?
0
..
..
..
0
0
0……….
?………
..
..
?
0
H
…….
G
0
G, then (e) is
?
G
1 − 2?F
A. = BA. ,
for each 2 = 1, 2, …. There is no need to solve a system of an algebraic equation for 9
IIJ .
as this forward difference method is explicit. The forward difference method is the result
of a modification to the Forward Euler’s method. There are stability requirements that
must be met in order for method to yield accurate solutions, namely
? = :
∆
1
=
:
≤
ℎ
∆% 2
Bui 10
As long as this inequality holds, this method is numerically stable and solution 9
IIJ .
remains bounded even when ∆ and ∆% go to zero. Once this stability condition is met,
9 K,.K converges to $% , . with a note of convergence L + ℎ .
Forward-difference method was tested using the following example. Consider the
example with : = 1, ' = 1 and $%, 0 = sin P%. The exact solution is given by $%, =
Q sinP%.
@
The solution at = 0.5 was then approximated using the forward difference method first
with ℎ = 0.1, ℎ = 0.05, ℎ = 0.0125, ℎ = 0.00625 successively while keeping ? = 0.05 by
adjusting . The solutions for these four conditions varying h were compared at % = 0.5
by taking the absolute difference against the exact solution at that point.
0.00025
ei error
0.0002
0.00015
0.0001
0.00005
0
0.1
0.05
0.025
0.0125
h
Figure 1. Plot of ei error varying h at xi=0.5 and t=0.5 with the Forward-Difference
method
Bui 11
0
-1
-1.301029996
-1.602059991
-1.903089987
log |ei| error
-1
-2
-3
-4
-5
-6
log h
Figure 2. Logarithmic plot of Figure 1
A straight line plot can be observed in Fig. 2 with a slope of approximately 2. As the
value of h decreases so does the error.
Another way to compare the data is to take the '2 error, which is R ∑<
T .
<
0.00016
0.00014
l2 Error
0.00012
0.0001
0.00008
0.00006
0.00004
0.00002
0
0.1
0.05
0.025
0.0125
h
Figure 3. Plot of value of h with respect to L2 error with Forward-Difference method
Bui 12
0
-1
-1.301029996
-1.602059991
-1.903089987
-1
log (l2 error)
-2
-3
-4
-5
-6
-7
log (h)
Figure 4. Logarithmic plot of Figure 3
The slope of the line featured in Fig. 4 is also about 2.
The forward-difference method limits the conditions we put on ∆ and ∆%, so we need
another method that is unconditionally stable. Consider an implicit-difference method
which uses a backward-difference quotient for U V X % , . in the form
VW
$-% , . / − $% , . # $
#$
-% , . / =
+
-% , 3. /,
#
2 # where 3. is in . , . . Substituting this equation, together with equation (c) for VY @ , into
the partial differential equation yields the following:
V@ W
Bui 13
$-% , . / − $% , . $-% , . / − 2$-% , . / + $% , . − :
ℎ
# $
ℎ # $
=−
-% , 3. / − :
-6 , . /,
2 # 12 #% for some 6 8% , % . All these calculations, suggests a numerical scheme
9 ,. − 9 ,.
9 ,. − 29 ,. + 9 ,.
− :
=0
ℎ
for each 0 = 1, 2, … , * − 1 and 2 = 1, 2, …, where 9 ,. is an approximation to $% , . .
As we did with the forward-difference method, let ? = : 1@ , the backward difference
method becomes
1 + 2?9 ,. − ?9 ,. − ?9 ,. = 9 ,. ,
for each 0 = 1, 2, … , * − 1 and 2 = 1, 2, …. Knowing that 9 ,
= % , for each 0 =
1, 2, … , * − 1 and 9<,. = 9
,. = 0, for each 2 = 1, 2, …, this difference method, just like
the forward-difference, also has a matrix representation:
E
D
D
D
C
1 + 2? −?
−?
…
0
…
.
…
0
…
0…
0
9,.
H 9,.
…
.
9
9
G
,.
,.
…
0
[, GZ . [ = Z
.
…
−? G 9
9<,.
<,.
−? 1 + 2?F
or
\A. = A. , ]^ )7ℎ 2 = 1, 2, ….
We now test this method using the same example as used previously with the forwarddifference method.
Bui 14
Let us consider again the heat equation
#$ # $
−
= 0, 0 < % < 1, 0 ≤ ,
# #% with the boundary conditions
$0, = $1, = 0, 0 < ,
and the initial conditions
$%, 0 = sinP% , 0 ≤ % ≤ 1.
The solution at = 0.5 was approximated using the backward-difference method with
ℎ = 0.1, ℎ = 0.05, ℎ = 0.0125, ℎ = 0.00625; just as the example was tested with the
Forward-Difference method, ? was kept constant at 0.05. The solutions for these four
cases were compared at % = 0.5 by taking the absolute difference against the exact
solution at that point.
0.0014
0.0012
ei error
0.001
0.0008
0.0006
0.0004
0.0002
0
0.1
0.05
0.025
h
0.0125
Bui 15
Figure 5. Plot of ei error at xi=0.5 and t=0.5 for various h using backward-difference
method
1
0.1
0.05
0.025
0.0125
ei error
0.1
0.01
0.001
0.0001
0.00001
h
Figure 6. Logarithmic plot of Figure 5
The logarithmic plot of the ei error (Fig. 6) shows that a slope of about 2; this value is
approximately close to the value of the slope in Fig. 2. So similarly to the forwarddifference method, the backward-difference decreases in error as h decreases.
Bui 16
0.0018
0.0016
0.0014
0.0012
l2
0.001
0.0008
0.0006
0.0004
0.0002
0
0.1
0.05
0.025
0.0125
h
Figure 7. Plot of L2 error varying h at xi=0.5 and t=0.5 with Backward-Difference
method
1
0.1
0.05
0.025
0.0125
0.1
l2
0.01
0.001
0.0001
0.00001
h
Figure 8. Logarithmic plot of Figure 7
Both line plots Figure 6 and Figure 8, which are plots of ei error and l2 error respectively
have slope of approximately 2. The slopes are comparatively similar to the plots
Bui 17
constructed to analyze the forward difference method, so as the value of h decreases
so does the error.
In many applications the governing parabolic differential equations are nonlinear. The
numerical methods for solving such equations will be based on that for the linear
equations. Let us consider now the nonlinear parabolic differential equation:
$ = $YY + $1 − $ + _%, with boundary conditions $0, = $1, = 0 and some given initial conditions.
Using forward Euler’s method as a guide, if 9 ≅ $0∆%, ∆, then we employ
9 − 9 9 − 29 + 9 =
+ _% , + 9 -1 − 9 /.
∆
∆%
Next, we can rearrange the terms and utilize the tridiagonal A matrix as previously
defined before to rewrite the equation as:
BA
Where _
.
.
= A + a + b$ 1 − $ c
.
_% , ⋮
=d
f. Let us now apply this to an example, in which we know the
_%! , exact solution. Consider the following example:
$ = $YY + %1 − % − 1g1 − %1 − %h, $0, = $1, = 0
with the boundary conditions and initial condition $%, 0 = 0. We vary h or ∆x and
choose ∆ such that ? = ∆j@ = . The numerical solution at = 0.5 were obtained
∆
Bui 18
when ℎ = 0.1, ℎ = 0.05, and ℎ = 0.0125. These solutions were compared also with the
actual solution which can be calculated using:
$kYlm = %1 − % − 1.
The results are reported in the following table:
Table 2. A comparison of the exact and the numerical solution 9 at %, = 0.5,0.5
h=
0.1
0.05
0.025
w
0.461279
0.459834
0.459473
uexact
0.42957
0.42957
0.42957
ei error
0.031709
0.030264
0.029903
The results in the Table 2 show that as smallest h step used results in a smallest ei
error compared to the other h steps.
1
log (ei error)
0.1
0.05
0.025
0.1
0.01
log (h)
Figure 9. Logarithmic Plot of ei error for various h using the nonlinear forward-difference
method
Bui 19
1
log(L2 error)
0.1
0.05
0.025
0.1
0.01
0.001
log (h)
Figure 10. Logarithmic Plot of l2 error for various h using the nonlinear forwarddifference method
The slope in Fig. 9 is about 0.04 and in Fig. 10 about 0.05. It shows that halving the h
value does little to affect the error whether it is ei or L2. Strangely enough the error does
not decrease at a faster rate when the h step is halved as seen with the parabolic partial
differential equations or the ordinary differential equations.
Bui 20
Conclusion/Future Work
This study showed that by manipulating explicit and implicit methods, one can
successfully provide good approximations compared to the exact solution of parabolic
partial differential equations and nonlinear parabolic differential equations. MATLAB
software was used as an analytical aid and tool to manipulate the data. Robinson
(2004) pointed out that useful of MATLAB commands to visualize and solve a variety of
differential equations. Data from MATLAB was imported to Microsoft Excel where
numerical and graphical approximations were examined. Bronson and Costa (2006)
discussed about the choice of constant h, step size, and the accuracy of the
approximation solution. In this study, the smaller the values of h are preferred to
minimize the error in both cases of differential equations. As shown by the data
produced by each method, both explicit and implicit methods of solving differential
equations produce solutions fairly close to the exact solutions. As ∆ and h go to zero
while the stability requirement is satisfied, the methods show convergence to the exact
solution. From our numerical experiments for solving the linear parabolic equations,
while keeping 1@ constant, by halving the h-step, pointwise error ei and the l2 error
∆
decreases roughly by a factor of two. However, the forward-difference does possess a
stability criterion
? = :
∆
1
=
≤
ℎ ∆% 2
otherwise the solution will not be stable. There is an unconditionally stable method
called the backward-difference method. This method does require more calculation per
time step compared to the forward-difference method. Both have similar rates of error
Bui 21
reduction for pointwise error ei: halving the step size h cuts the error in half. However for
L2, error reduction for Backward-Difference is by a factor of 2 and Forward-Difference is
by 2. For nonlinear parabolic equations, both exact solutions and error analysis are
difficult to obtain. However, our experiment does show a convergence by using a slight
modification of the forward difference method. Further investigation is needed to explore
the depth of nonlinear parabolic equations, as the data extracted in this research is far
from conclusive. Data and calculations to support the findings are located in the
Appendix A.
Bui 22
Works Cited
Blanchard, Paul, Robert L Devaney and Glen R Hall. Differential Equations Third
Edition. Belmont: Thomson, 2006.
Braun, M., Golubitsky, M., Marsden, J., Sirovich, L., & Jager, W. (1992). Differential
Equations and Their Applications. New York: Springer-Verlag LLC.
Bronson, Richard. Modern Introductory Differential Equations. McGraw-Hill, 1973.
Bronson, Richard; Costa, Gabriel. Schaum's Outline of Differential Equations (3rd
Edition) Blacklick, OH, USA: McGraw-Hill Companies, The, 2006.
Burden, Richard L and F. Douglas. Numerical Analysis 8th Edition. Thomson, 2005.
Groisman, Pablo; Totally Discrete Explicit and Semi-implicit Euler Methods for a Blow
up Problem in several Space dimensions. Coumputing 76, page 325- 352, 2006.
Jones, Keith. Solution by forward differences (Euler Method). 23 January 2000.
<http://www.physics.uq.edu.au/people/jones/ph362/cphys/node3.html>.
Robinson, James. Introduction to Ordinary Differential Equations. West Nyack, NY,
USA: Cambridge University Press, 2004.
Vrabie, Ioan I.. Differential Equations : An Introduction to Basic Concepts, Results and
Applications. River Edge, NJ, USA: World Scientific Publishing Company, Incorporated,
2004
Williamson, Richard E. Introduction to Differential Equations and Dynamical Systems.
McGraw Hill, 2001.
Bui 23
Zeltkevic, Michael. Forward and Backward Euler Methods. 4 April 1998.
<http://web.mit.edu/10.001/Web/Course_Notes/Differential_Equations_Notes/node3.ht
ml>.
Bui 24
APPENDIX
Data extrapolated from MATLAB (software version 7.7.0.471)
and Calculated in Excel
Euler:
0.1
0.05
0.025
0.0125
0.007399 0.291731 0.734684 0.925798
0.002287
0.004349
0.005986
0.007037
0.007399
0.045637
0.09015
0.132443
0.171475
0.206285
0.236015
0.259934
0.277452
0.288139
0.291731
0.03125
0.057643
0.11493
0.171509
0.22703
0.281152
0.33354
0.383872
0.431837
0.477139
0.5195
0.558658
0.594372
0.626421
0.654609
0.67876
0.698726
0.714385
0.725639
0.73242
0.734684
0.007813
0.036347
0.072637
0.108816
0.144827
0.180614
0.216123
0.251299
0.286087
0.320434
0.354288
0.387594
0.420303
0.452365
0.483728
0.514346
0.54417
0.573156
0.601258
0.628432
0.654638
0.679834
0.703982
0.727045
0.748986
0.769773
0.789372
0.807755
0.824892
0.840757
0.855326
0.868576
Bui 25
0.880486
0.891039
0.900218
0.908009
0.9144
0.919381
0.922944
0.925084
0.925798
% Input:
t_0=0;
w_0=[0.9 0];
t_final=1;
h=0.05;
% initial time
% initial condition for the solution
% final time
% time steps
% Count flops
%flops(0)
% Call Euler's or Runge Kunta's method
% Output is
result, which contain [t w]
method=input('method to be employed: (Euler=1, RK4=2) ')
if method==1,
euler
else
rk4
end
%Euler's method
t=t_0; w=w_0; result=[t w];
while t < t_final
w_new=w+h*euler_fcn(t,w);
result=[result; t+h, w_new];
w=w_new; t=t+h;
end
function slope=euler_fcn(t,y)
slope(1)=y(2);
slope(2)=y(1)^2-1;
%function t=t(n,t0,t1,y0)
function y=y(n,t0,t1,y0)
h=(t1-t0)/n;
t(1)=t0;
y(1)=y0;
for i=1:n
t(i+1)=t(i)+h;
y(i+1)=y(i)+h*ex(t(i),y(i));
end;
Bui 26
V=[t',y']
plot(t,y)
title('satya')
Bui 27
Backward Euler:
dx=dt
exact
0.002287
0.004349
0.005986
0.007037
0.007399
0.007037
0.005986
0.004349
0.002287
0.10
0.01
0.05
0.005
0.025
0.0025
0.0125
0.00125
0.010183
0.01937
0.026661
0.031342
0.032954
0.031342
0.026661
0.01937
0.010183
0.002853
0.005636
0.008279
0.010719
0.012896
0.014754
0.016249
0.017344
0.018013
0.018237
0.018013
0.017344
0.016249
0.014754
0.012896
0.010719
0.008279
0.005636
0.002853
0.000955
0.001904
0.002842
0.003761
0.004658
0.005526
0.00636
0.007155
0.007905
0.008607
0.009256
0.009847
0.010378
0.010845
0.011246
0.011576
0.011836
0.012022
0.012135
0.012172
0.012135
0.012022
0.011836
0.011576
0.011246
0.010845
0.010378
0.009847
0.009256
0.008607
0.007905
0.007155
0.00636
0.005526
0.004658
0.003761
0.002842
0.001904
0.000955
0.000374
0.000748
0.001121
0.001492
0.00186
0.002226
0.002588
0.002947
0.0033
0.003649
0.003992
0.004329
0.004659
0.004982
0.005297
0.005605
0.005903
0.006193
0.006473
0.006742
0.007002
0.007251
0.007488
0.007714
0.007928
0.00813
0.008319
0.008496
0.008659
0.008809
0.008946
0.009069
0.009177
0.009272
0.009352
0.009418
0.009469
0.009506
0.009528
Bui 28
0.009535
0.009528
0.009506
0.009469
0.009418
0.009352
0.009272
0.009177
0.009069
0.008946
0.008809
0.008659
0.008496
0.008319
0.00813
0.007928
0.007714
0.007488
0.007251
0.007002
0.006742
0.006473
0.006193
0.005903
0.005605
0.005297
0.004982
0.004659
0.004329
0.003992
0.003649
0.0033
0.002947
0.002588
0.002226
0.00186
0.001492
0.001121
0.000748
0.000374
0.1
0.05
0.025
-2.3025
-2.9957
-3.6888
-3.65883
-4.50576
-5.30228
Bui 29
0.0125
-4.3820
-6.05617
1.152502
0.007192 0.009378 0.002186299
0.01
0.007192 0.007712 0.000519869
0.0025
0.007192 0.00732 0.000128276 0.000625
0.007192 0.007224 3.19651E-05 0.000156
dt=dx^2
0.002898
0.005512
0.007587
0.008919
0.009378
0.891918
0.007587
0.005512
0.002898
-4.6051
-5.9914
-7.3776
-8.7645
0.01
0.0025
0.000625
0.000156
0.002898
0.005512
0.007587
0.008919
0.009378
0.008919
0.007587
0.005512
0.002898
0.001206
0.002383
0.003501
0.004533
0.005453
0.006239
0.006871
0.007334
0.007617
0.007712
0.007617
0.007334
0.006871
0.006239
0.005453
0.004533
0.003501
0.002383
0.001206
0.000574
0.001145
0.001709
0.002262
0.002801
0.003323
0.003825
0.004303
0.004754
0.005176
0.005566
0.005922
0.006241
0.006522
0.006763
0.006962
0.007118
0.00723
0.007298
0.00732
0.007298
0.00723
0.007118
0.006962
0.006763
0.006522
0.006241
0.005922
0.005566
0.005176
0.004754
0.004303
0.000284
0.000567
0.000849
0.00113
0.001409
0.001686
0.001961
0.002232
0.0025
0.002764
0.003024
0.00328
0.00353
0.003774
0.004013
0.004246
0.004472
0.004692
0.004904
0.005108
0.005305
0.005493
0.005673
0.005844
0.006006
0.006159
0.006303
0.006436
0.00656
0.006674
0.006777
0.00687
-6.12555
-7.56193
-8.96133
-10.3509
1.015322
Bui 30
0.003825
0.003323
0.002801
0.002262
0.001709
0.001145
0.000574
0.006953
0.007024
0.007085
0.007135
0.007174
0.007202
0.007218
0.007224
0.007218
0.007202
0.007174
0.007135
0.007085
0.007024
0.006953
0.00687
0.006777
0.006674
0.00656
0.006436
0.006303
0.006159
0.006006
0.005844
0.005673
0.005493
0.005305
0.005108
0.004904
0.004692
0.004472
0.004246
0.004013
0.003774
0.00353
0.00328
0.003024
0.002764
0.0025
0.002232
0.001961
0.001686
0.001409
Bui 31
0.00113
0.000849
0.000567
0.000284
0.000376
0.000716
0.000985
0.001158
0.001218
0.001158
0.000985
0.000716
0.000376
0.05
0.001171
0.002314
0.003399
0.004401
0.005294
0.006057
0.006671
0.007121
0.007395
0.007487
0.007395
0.007121
0.006671
0.006057
0.005294
0.004401
0.003399
0.002314
0.001171
0.03
0.00057
0.001137
0.001696
1.41672E-07
5.12567E-07
9.71005E-07
1.3419E-06
1.48358E-06
1.3419E-06
9.71005E-07
5.12567E-07
1.41672E-07
7.41787E-06
0.002723577
0.000272358
0.001125
0.002222
0.003265
0.004227
0.005085
0.005818
0.006408
0.00684
0.007103
0.007192
0.007103
0.00684
0.006408
0.005818
0.005085
0.004227
0.003265
0.002222
0.001125
5.64E-04
0.001125
0.001679
4.62E-05
9.12E-05
0.000134
0.000173
0.000209
0.000239
0.000263
0.000281
0.000291
0.000295
0.000291
0.000281
0.000263
0.000239
0.000209
0.000173
0.000134
9.12E-05
4.62E-05
5.74E-06
1.14E-05
1.71E-05
2.13049E-09
8.31342E-09
1.79436E-08
3.00782E-08
4.35296E-08
5.6981E-08
6.91157E-08
7.87459E-08
8.49288E-08
8.70593E-08
8.49288E-08
7.87459E-08
6.91157E-08
5.6981E-08
4.35296E-08
3.00782E-08
1.79436E-08
8.31342E-09
2.13049E-09
3.91767E-07
0.000625913
3.12956E-05
3.29593E-11
1.31026E-10
2.91784E-10
Bui 32
0.002245
0.00278
0.003298
0.003796
0.00427
0.004718
0.005137
0.005524
0.005878
0.006194
0.006473
0.006712
0.006909
0.007064
0.007176
0.007243
0.007265
0.007243
0.007176
0.007064
0.006909
0.006712
0.006473
0.006194
0.005878
0.005524
0.005137
0.004718
0.00427
0.003796
0.003298
0.00278
0.002245
0.001696
0.001137
0.00057
0.002222
0.002752
0.003265
0.003758
0.004227
0.004671
0.005085
0.005469
0.005818
0.006132
0.006408
0.006644
0.00684
0.006993
0.007103
0.00717
0.007192
0.00717
0.007103
0.006993
0.00684
0.006644
0.006408
0.006132
0.005818
0.005469
0.005085
0.004671
0.004227
0.003758
0.003265
0.002752
0.002222
0.001679
0.001125
5.64E-04
2.26E-05
2.8E-05
3.32E-05
3.82E-05
4.3E-05
4.75E-05
5.17E-05
5.56E-05
5.92E-05
6.24E-05
6.52E-05
6.76E-05
6.96E-05
7.12E-05
7.23E-05
7.29E-05
7.32E-05
7.29E-05
7.23E-05
7.12E-05
6.96E-05
6.76E-05
6.52E-05
6.24E-05
5.92E-05
5.56E-05
5.17E-05
4.75E-05
4.3E-05
3.82E-05
3.32E-05
2.8E-05
2.26E-05
1.71E-05
1.14E-05
5.74E-06
5.11276E-10
7.84098E-10
1.10353E-09
1.46171E-09
1.84982E-09
2.25829E-09
2.67708E-09
3.09586E-09
3.50434E-09
3.89245E-09
4.25062E-09
4.57006E-09
4.84288E-09
5.06237E-09
5.22313E-09
5.3212E-09
5.35416E-09
5.3212E-09
5.22313E-09
5.06237E-09
4.84288E-09
4.57006E-09
4.25062E-09
3.89245E-09
3.50434E-09
3.09586E-09
2.67703E-09
2.25829E-09
1.84982E-09
1.46171E-09
1.10353E-09
7.84098E-10
5.11276E-10
2.91784E-10
1.31026E-10
3.29593E-11
8.42449E-09
9.1785E-05
2.29463E-06
0.01
0.000283
0.000566
0.000847
2.82E-04
5.64E-04
8.45E-04
7.17E-07
1.43E-06
2.15E-06
5.13695E-13
2.05162E-12
4.60428E-12
Bui 33
0.001128
0.001407
0.001683
0.001957
0.002228
0.002496
0.002759
0.003019
0.003273
0.003523
0.003767
0.004006
0.004238
0.004464
0.004683
0.004894
0.005098
0.005295
0.005483
0.005662
0.005833
0.005995
0.006148
0.006291
0.006424
0.006548
0.006661
0.006764
0.006857
0.006939
0.007011
0.007072
0.007121
0.00716
0.007188
0.007205
0.00721
0.007205
0.007188
0.00716
0.007121
0.007072
0.007011
1.13E-03
1.40E-03
1.68E-03
1.95E-03
2.22E-03
2.49E-03
2.75E-03
3.01E-03
3.27E-03
3.51E-03
3.76E-03
4.00E-03
4.23E-03
4.45E-03
4.67E-03
4.88E-03
5.09E-03
5.28E-03
5.47E-03
5.65E-03
5.82E-03
5.98E-03
6.13E-03
6.27E-03
6.41E-03
6.53E-03
6.64E-03
6.75E-03
6.84E-03
6.92E-03
6.99E-03
7.05E-03
7.10E-03
7.14E-03
7.17E-03
7.19E-03
7.19E-03
7.19E-03
7.17E-03
7.14E-03
7.10E-03
7.05E-03
6.99E-03
2.86E-06
3.56E-06
4.26E-06
4.96E-06
5.64E-06
6.32E-06
6.99E-06
7.64E-06
8.29E-06
8.92E-06
9.54E-06
1.01E-05
1.07E-05
1.13E-05
1.19E-05
1.24E-05
1.29E-05
1.34E-05
1.39E-05
1.43E-05
1.48E-05
1.52E-05
1.56E-05
1.59E-05
1.63E-05
1.66E-05
1.69E-05
1.71E-05
1.74E-05
1.78E-05
1.78E-05
1.79E-05
1.8E-05
1.81E-05
1.82E-05
1.82E-05
1.83E-05
1.82E-05
1.82E-05
1.81E-05
1.8E-05
1.79E-05
1.78E-05
8.15595E-12
1.26847E-11
1.81627E-11
2.45561E-11
3.18254E-11
3.9926E-11
4.88078E-11
5.84161E-11
6.86915E-11
7.95709E-11
9.09871E-11
1.0287E-10
1.15146E-10
1.27739E-10
1.40572E-10
1.53566E-10
1.6664E-10
1.79715E-10
1.92708E-10
2.05542E-10
2.18135E-10
2.30411E-10
2.42293E-10
2.53709E-10
2.64589E-10
2.74864E-10
2.84473E-10
2.93354E-10
3.01455E-10
3.16071E-10
3.15118E-10
3.20596E-10
3.25124E-10
3.28676E-10
3.31229E-10
3.32767E-10
3.3328E-10
3.32767E-10
3.31229E-10
3.28676E-10
3.25124E-10
3.20596E-10
3.15118E-10
Bui 34
0.006939
0.006857
0.006764
0.006661
0.006548
0.006424
0.006291
0.006148
0.005995
0.005833
0.005662
0.005483
0.005295
0.005098
0.004894
0.004683
0.004464
0.004238
0.004006
0.003767
0.003523
0.003273
0.003019
0.002759
0.002496
0.002228
0.001957
0.001683
0.001407
0.001128
0.000847
0.000566
0.000283
6.92E-03
6.84E-03
6.75E-03
6.64E-03
6.53E-03
6.41E-03
6.27E-03
6.13E-03
5.98E-03
5.82E-03
5.65E-03
5.47E-03
5.28E-03
5.09E-03
4.88E-03
4.67E-03
4.45E-03
4.23E-03
4.00E-03
3.76E-03
3.51E-03
3.27E-03
3.01E-03
2.75E-03
2.49E-03
2.22E-03
1.95E-03
1.68E-03
1.40E-03
1.13E-03
8.45E-04
5.64E-04
2.82E-04
1.76E-05
1.74E-05
1.71E-05
1.69E-05
1.66E-05
1.63E-05
1.59E-05
1.56E-05
1.52E-05
1.48E-05
1.43E-05
1.39E-05
1.34E-05
1.29E-05
1.24E-05
1.19E-05
1.13E-05
1.07E-05
1.01E-05
9.54E-06
8.92E-06
8.29E-06
7.64E-06
6.99E-06
6.32E-06
5.64E-06
4.96E-06
4.26E-06
3.56E-06
2.86E-06
2.15E-06
1.43E-06
7.17E-07
0.1
0.05
0.025
0.0125
0.00841
0.007487
0.007265
0.00721
0.007192
0.007192
0.007192
0.007192
0.1 0.000272 0.099728
0.05 3.13E-05 0.049969
3.08724E-10
3.01455E-10
2.93354E-10
2.84473E-10
2.74864E-10
2.64589E-10
2.53709E-10
2.42293E-10
2.30411E-10
2.18135E-10
2.05542E-10
1.92708E-10
1.79715E-10
1.6664E-10
1.53566E-10
1.40572E-10
1.27739E-10
1.15146E-10
1.0287E-10
9.09871E-11
7.95709E-11
6.86915E-11
5.84161E-11
4.88078E-11
3.9926E-11
3.18254E-11
2.45561E-11
1.81627E-11
1.26847E-11
8.15595E-12
4.60428E-12
2.05162E-12
5.13695E-13
1.4248E-10
1.19365E-05
1.49206E-07
0.001218
0.000295
7.32E-05
1.83E-05
-1
-1.3010
-1
-1.3010
-1.6020
-1.9030
-1.00118
-1.3013
-2.91434
-3.53009
-4.13563
-4.73852
2.019088
Bui 35
0.025
0.0125
2.29E-06 0.024998
1.49E-07
0.0125
-1.6020
-1.9030
-1.6021
-1.9031
0.998748
Bui 36
Forward Euler:
global A
% Input:
mm=(1/.0005);
m=mm-1;
h1=1/mm;
x=[h1:h1:1-h1];
t_0=0;
% initial time
w_0=[sin(pi*x)];
% initial condition for the solution
t_final=0.5;
% final time
h=.1;
% time steps
e=ones(m,1);
A=spdiags([e -2*e e],-1:1,m,m);
A=A/(h1*h1);
%Euler's method
t=t_0; w=w_0;
while t < t_final
w_new=w+h*slope_fcn(t,w);
w=w_new; t=t+h;
end
function slope=slope_fcn(t,y)
global A
slope=A*y;
4.11019E-09
1.48696E-08
2.81666E-08
3.89263E-08
4.30383E-08
3.89263E-08
2.81666E-08
1.48696E-08
4.11019E-09
2.15184E-07
0.000463879
4.63879E-05
0.001132
0.002236
0.003284
0.001125
0.002222
0.003265
6.6263E-06
1.3089E-05
1.9230E-05
4.39082E-11
1.71335E-10
3.69806E-10
Bui 37
0.004252
0.005115
0.005853
0.006446
0.00688
0.007145
0.007234
0.007145
0.00688
0.006446
0.005853
0.005115
0.004252
0.003284
0.002236
0.001132
0.000565
0.001127
0.001681
0.002226
0.002756
0.00327
0.003763
0.004233
0.004678
0.005093
0.005477
0.005827
0.006141
0.006417
0.006654
0.00685
0.007003
0.007114
0.00718
0.007202
0.00718
0.007114
0.007003
0.00685
0.004227
0.005085
0.005818
0.006408
0.00684
0.007103
0.007192
0.007103
0.00684
0.006408
0.005818
0.005085
0.004227
0.003265
0.002222
0.001125
5.64E-04
0.001125
0.001679
0.002222
0.002752
0.003265
0.003758
0.004227
0.004671
0.005085
0.005469
0.005818
0.006132
0.006408
0.006644
0.00684
0.006993
0.007103
0.00717
0.007192
0.00717
0.007103
0.006993
0.00684
2.4897E-05
2.9952E-05
3.4268E-05
3.7741E-05
4.0285E-05
4.1837E-05
4.2358E-05
4.1837E-05
4.0285E-05
3.7741E-05
3.4268E-05
2.9952E-05
2.4897E-05
1.9230E-05
1.3089E-05
6.6263E-06
8.29E-07
1.65E-06
2.47E-06
3.26E-06
4.04E-06
4.79E-06
5.52E-06
6.21E-06
6.86E-06
7.47E-06
8.03E-06
8.54E-06
9.01E-06
9.41E-06
9.76E-06
1.00E-05
1.03E-05
1.04E-05
1.05E-05
1.06E-05
1.05E-05
1.04E-05
1.03E-05
1.00E-05
6.19895E-10
8.9712E-10
1.17435E-09
1.42443E-09
1.62291E-09
1.75033E-09
1.79424E-09
1.75033E-09
1.62291E-09
1.42443E-09
1.17435E-09
8.9712E-10
6.19895E-10
3.69806E-10
1.71335E-10
4.39082E-11
1.79424E-08
0.000133949
6.69746E-06
6.86675E-13
2.7298E-12
6.07905E-12
1.0652E-11
1.63359E-11
2.2991E-11
3.04534E-11
3.85392E-11
4.70494E-11
5.57744E-11
6.44995E-11
7.30097E-11
8.10955E-11
8.85578E-11
9.52129E-11
1.00897E-10
1.0547E-10
1.08819E-10
1.10862E-10
1.11549E-10
1.10862E-10
1.08819E-10
1.0547E-10
1.00897E-10
Bui 38
0.006654
0.006417
0.006141
0.005827
0.005477
0.005093
0.004678
0.004233
0.003763
0.00327
0.002756
0.002226
0.001681
0.001127
0.000565
0.006644
0.006408
0.006132
0.005818
0.005469
0.005085
0.004671
0.004227
0.003758
0.003265
0.002752
0.002222
0.001679
0.001125
5.64E-04
9.76E-06
9.41E-06
9.01E-06
8.54E-06
8.03E-06
7.47E-06
6.86E-06
6.21E-06
5.52E-06
4.79E-06
4.04E-06
3.26E-06
2.47E-06
1.65E-06
8.29E-07
0.000282
0.000564
0.000846
0.001125
0.001404
0.00168
0.001953
0.002223
0.00249
0.002753
0.003012
0.003266
0.003515
0.003759
0.003997
0.004229
0.004454
0.004672
0.004884
0.005087
0.005283
0.005471
0.00565
0.00582
0.005982
2.82E-04
5.64E-04
8.45E-04
1.13E-03
1.40E-03
1.68E-03
1.95E-03
2.22E-03
2.49E-03
2.75E-03
3.01E-03
3.27E-03
3.51E-03
3.76E-03
4.00E-03
4.23E-03
4.45E-03
4.67E-03
4.88E-03
5.09E-03
5.28E-03
5.47E-03
5.65E-03
5.82E-03
5.98E-03
1.04E-07
2.07E-07
3.10E-07
4.13E-07
5.15E-07
6.16E-07
7.16E-07
8.15E-07
9.13E-07
1.01E-06
1.10E-06
1.20E-06
1.29E-06
1.38E-06
1.47E-06
1.55E-06
1.63E-06
1.71E-06
1.79E-06
1.87E-06
1.94E-06
2.01E-06
2.07E-06
2.13E-06
2.19E-06
9.52129E-11
8.85578E-11
8.10955E-11
7.30097E-11
6.44995E-11
5.57676E-11
4.70494E-11
3.85392E-11
3.04534E-11
2.2991E-11
1.63359E-11
1.0652E-11
6.07905E-12
2.7298E-12
6.86675E-13
2.23097E-09
4.72331E-05
1.18083E-06
1.07316E-14
4.28604E-14
9.61889E-14
1.70387E-13
2.64998E-13
3.79439E-13
5.13005E-13
6.64868E-13
8.34099E-13
1.01965E-12
1.22038E-12
1.43504E-12
1.66233E-12
1.90082E-12
2.14906E-12
2.40552E-12
2.66861E-12
2.93671E-12
3.20816E-12
3.4813E-12
3.75444E-12
4.02589E-12
4.29399E-12
4.55708E-12
4.81353E-12
Bui 39
0.006134
0.006277
0.00641
0.006534
0.006647
0.00675
0.006842
0.006924
0.006996
0.007056
0.007106
0.007145
0.007172
0.007189
0.007195
0.007189
0.007172
0.007145
0.007106
0.007056
0.006996
0.006924
0.006842
0.00675
0.006647
0.006534
0.00641
0.006277
0.006134
0.005982
0.00582
0.00565
0.005471
0.005283
0.005087
0.004884
0.004672
0.004454
0.004229
0.003997
0.003759
0.003515
0.003266
6.13E-03
6.27E-03
6.41E-03
6.53E-03
6.64E-03
6.75E-03
6.84E-03
6.92E-03
6.99E-03
7.05E-03
7.10E-03
7.14E-03
7.17E-03
7.19E-03
7.19E-03
7.19E-03
7.17E-03
7.14E-03
7.10E-03
7.05E-03
6.99E-03
6.92E-03
6.84E-03
6.75E-03
6.64E-03
6.53E-03
6.41E-03
6.27E-03
6.13E-03
5.98E-03
5.82E-03
5.65E-03
5.47E-03
5.28E-03
5.09E-03
4.88E-03
4.67E-03
4.45E-03
4.23E-03
4.00E-03
3.76E-03
3.51E-03
3.27E-03
2.25E-06
2.30E-06
2.35E-06
2.40E-06
2.44E-06
2.48E-06
2.51E-06
2.75E-06
2.57E-06
2.59E-06
2.61E-06
2.62E-06
2.63E-06
2.64E-06
2.64E-06
2.64E-06
2.63E-06
2.62E-06
2.61E-06
2.59E-06
2.57E-06
2.54E-06
2.51E-06
2.48E-06
2.44E-06
2.40E-06
2.35E-06
2.30E-06
2.25E-06
2.19E-06
2.13E-06
2.07E-06
2.01E-06
1.94E-06
1.87E-06
1.79E-06
1.71E-06
1.63E-06
1.55E-06
1.47E-06
1.38E-06
1.29E-06
1.20E-06
5.06178E-12
5.30028E-12
5.52756E-12
5.74222E-12
5.94295E-12
6.1285E-12
6.29773E-12
7.54843E-12
6.58316E-12
6.6976E-12
6.79222E-12
6.86641E-12
6.91974E-12
6.95187E-12
6.9626E-12
6.95187E-12
6.91974E-12
6.86641E-12
6.79222E-12
6.6976E-12
6.58316E-12
6.4496E-12
6.29773E-12
6.1285E-12
5.94295E-12
5.74222E-12
5.52756E-12
5.30028E-12
5.06178E-12
4.81353E-12
4.55708E-12
4.29399E-12
4.02589E-12
3.75444E-12
3.4813E-12
3.20816E-12
2.93671E-12
2.66861E-12
2.40552E-12
2.14906E-12
1.90082E-12
1.66233E-12
1.43504E-12
Bui 40
0.003012
0.002753
0.00249
0.002223
0.001953
0.00168
0.001404
0.001125
0.000846
0.000564
0.000282
dx
0.1
0.05
0.025
0.0125
dx
0.1
0.05
0.025
0.0125
3.01E-03
2.75E-03
2.49E-03
2.22E-03
1.95E-03
1.68E-03
1.40E-03
1.13E-03
8.45E-04
5.64E-04
2.82E-04
at 0.5
1.10E-06
1.01E-06
9.13E-07
8.15E-07
7.16E-07
6.16E-07
5.15E-07
4.13E-07
3.10E-07
2.07E-07
1.04E-07
1.22038E-12
1.01965E-12
8.34099E-13
6.64868E-13
5.13005E-13
3.79439E-13
2.64998E-13
1.70387E-13
9.61889E-14
4.28604E-14
1.07316E-14
2.79603E-10
1.67213E-05
2.09017E-07
difference
0.007399
0.007234
0.007202
0.007195
log dx
0.000207
4.24E-05
1.06E-05
2.64E-06
-1
-1.3010
-1.6020
-1.9030
L2 error
2.1E-08
8.9E-10
5.5E-11
3.5E-12
4.6E-05
6.7E-06
1.1E-06
2.0E-07
-1
-1.3010
-1.6020
-1.9030
-4.3336
-5.17409
-5.92781
-6.67982
2.588577
log error
-3.68307
-4.37303
-4.97613
-5.57806
2.088853
Bui 41
Nonlinear-Forward Euler:
solving nonlinear forward euler
tinit=0
tfinal=0.5
let uexact= x(1-x)((e^t)-1)
dx=.1
dt=.0025
I.C=
0
refining the time step: dx=.05, .025
x=
exact
fwnon
dx=.05
fwnon
0.1 0.05838 0.061664
0.003284
0.025 0.032582
0.2
0.1038 0.109922
0.006122
0.05 0.061849
0.3 0.13623 0.144522
0.008292
0.075 0.087753
0.4 0.15569 0.165324
0.009634
0.1 0.110259
0.5 0.16218 0.172265
0.010085
0.125 0.129338
0.15 0.14497
0.175 0.157142
0.2 0.165842
0.171064
0.172806
h=
uestimate uexact
ei error
0.1 0.461279 0.42957 0.031709
0.05 0.459834 0.42957 0.030264
0.025 0.459473 0.42957 0.029903
0.16218 0.010626
global A
global U
% Input:
mm=40;
m=mm-1;
h1=1/mm;
x=[h1:h1:1-h1];
t_0=0;
% initial time
w_0=zeros(1,m);
% initial condition for the solution
t_final=1;
% final time
h=0.25*(1/mm)^(2);
% time steps
e=ones(m,1);
A=spdiags([e -2*e e],-1:1,m,m);
A=A/(h1*h1);
t=t_0; w=w_0; result=[t w];
while t < t_final
z_0=exp(t).*x.*(1-x)+2.*(exp(t)-1)+x.*(1-x).*(exp(t)-1).*(1-x.*(1-x));
%U=w_0*(1-w_0);
w_new=w+h*z_0+h*fnon_fcn(t,w);
result=[result; t+h, w_new];
w=w_new; t=t+h;
end
Bui 42
BACKWARD/FORWARD EULER:
global A
% Input:
%mm=1000;
%m=mm-1;
%h1=1/mm;
%x=[h1:h1:1-h1];
t_0=0;
% initial time
l1=-1;
l2=-100;
l3=l1*0.5;
l4=l2*0.5;
w_0=[0;1];
% initial condition for the solution
t_final=.29;
% final time
h=0.02;
% time steps
A=[(l3+l4) (l3-l4);
(l3-l4) (l3+l4)];
%e=ones(m,1);
%A=spdiags([e -2*e e],-1:1,m,m);
%A=A/(h1*h1);
method=input('method to be employed: (newfwrd=1, newbwrd=2) ')
if method==1,
newfwrd
else
newbwrd
end
parameters
t init=0
t finl=0.5
w_0=[0;1]
h=.01
dx=.01
fwrd sol'n
0.3025
0.3025
bkwd
sol'n
l1
0.304 l2
0.304
t init=0
t finl=0.5
w_0=[0;1]
h=.02
dx=.01
0.8017
-0.1983
0.3048
0.3048
tinit=0
tfinl=1
w_0=[0;1]
0.183
0.183
0.1849
0.1849
-1
-100
Bui 43
h=.01
dx=.01
tinit=0
tfinl=1
w_0=[0;1]
h=.02
dx=.01
t=
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.1
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.2
0.21
0.22
0.23
0.24
0.25
0.26
0.27
0.28
0.29
0.3
0.31
0.32
0.33
0.34
-0.3179
0.6821
x
y
0.31109
0.67896
0.42243
0.55777
0.46033
0.51012
0.47124
0.48955
0.47225
0.47898
0.46964
0.47212
0.46574
0.46665
0.46139
0.46173
0.4569
0.45703
0.4524
0.45244
0.44791
0.44793
0.44346
0.44346
0.43905
0.43905
0.43468
0.43468
0.43035
0.43035
0.42607
0.44793
0.42183
0.42607
0.41764
0.41764
0.41348
0.41348
0.40937
0.40937
0.40529
0.40529
0.40126
0.40126
0.39727
0.39727
0.39331
0.39331
0.3894
0.3894
0.38553
0.38553
0.38169
0.38169
0.37789
0.37789
0.37416
0.37416
0.37041
0.37041
0.36672
0.36672
0.36307
0.36307
0.35946
0.35946
0.35589
0.35589
0.1858
0.1858
Bui 44
0.35
0.36
0.37
0.38
0.39
0.4
0.41
0.42
0.43
0.44
0.45
0.46
0.47
0.48
0.49
0.5
t=
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.1
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.2
0.21
0.22
0.23
0.24
0.25
0.26
0.35234
0.34884
0.34537
0.34193
0.33853
0.33516
0.33183
0.32852
0.32525
0.32202
0.31881
0.31564
0.3125
0.30939
0.30631
0.30327
x
0.31109
0.42243
0.46033
0.47124
0.47225
0.46964
0.46574
0.46139
0.4569
0.4524
0.44791
0.44346
0.43905
0.43468
0.43035
0.42607
0.42183
0.41764
0.41348
0.40937
0.40529
0.40126
0.39727
0.39331
0.3894
0.38553
0.35234
0.34884
0.34537
0.34193
0.33853
0.33516
0.33183
0.32852
0.32525
0.32202
0.31881
0.31564
0.3125
0.30939
0.30631
0.30327
bw
0.24505
0.365148
0.422795
0.44924
0.460108
0.46321
0.462453
0.459788
0.456193
0.452155
0.447918
0.443603
0.43927
0.434951
0.430659
0.426403
0.422185
0.418007
0.413869
0.409772
0.405715
0.401698
0.397721
0.393783
0.394246
0.386516
fw
0.495
0.49005
0.48515
0.480298
0.475495
0.47074
0.466033
0.461372
0.456759
0.447669
0.443192
0.438761
0.434373
0.430029
0.430029
0.425729
0.421472
0.417257
0.413084
0.408953
0.404864
0.400815
0.396807
0.392839
0.388911
0.394246
Bui 45
0.27
0.28
0.29
0.3
0.31
0.32
0.33
0.34
0.35
0.36
0.37
0.38
0.39
0.4
0.41
0.42
0.43
0.44
0.45
0.46
0.47
0.48
0.49
0.5
0.38169
0.37789
0.37416
0.37041
0.36672
0.36307
0.35946
0.35589
0.35234
0.34884
0.34537
0.34193
0.33853
0.33516
0.33183
0.32852
0.32525
0.32202
0.31881
0.31564
0.3125
0.30939
0.30631
0.30327
0.386516
0.378937
0.378937
0.371507
0.371507
0.364223
0.364223
0.357081
0.357081
0.35008
0.35008
0.343215
0.343215
0.336486
0.336486
0.329888
0.329888
0.32342
0.32342
0.317078
0.317078
0.310861
0.310861
0.304765
0.386516
0.386516
0.378937
0.378937
0.371507
0.371507
0.364223
0.364223
0.357081
0.357081
0.35008
0.35008
0.343215
0.343215
0.336486
0.336486
0.329888
0.329888
0.32342
0.32342
0.317078
0.317078
0.310861
0.310861
Download