The iterative process is continued, reducing the interval at each step, until the change in the approximation to the root from one iteration to the next is less than a chosen convergence
Trang 1containing the root The iterative process is continued, reducing the interval at each step, until the change in the approximation to the root from one iteration to the next is less than a chosen convergence criterion, as given by
| ( ) ( )|
( ) ( ) ( )
Probably the most important and widely used method for root solving is the
Newton-Raphson method, in which the iterative approximation to the root x i is
used to calculate the next iterative approximation to the root x i 1 as
f x
i i
`1
( )
where f`(x i ) is the derivative of f (x) at x x i This equation gives an iterative
pro-cess for finding the root, starting with an initial guess x1 The process is nated when the convergence criterion, given by Equation (4.11), is satisfied.The Newton-Raphson method can be used for real as well as complex roots,
termi-employing complex algebra for the functions, their derivatives, and for x It can also be used for multiple roots where the graph of f (x) versus x is tangent to the
x-axis, with no sign change in f (x) When the scheme converges, it converges
very rapidly to the root It can be shown that it has a second-order convergence, implying that the error in each iteration varies as the square of the error in the previous iteration and thus reduces very rapidly However, the iteration process may diverge, depending on the initial guess and nature of the equation Figure 4.5 shows graphically the iterative process in a convergent case The tangent to the curve at a given approximation is used to obtain the next approximation to the root Figure 4.6 shows a few cases in which the method diverges If the scheme diverges, a new starting point is chosen and the process repeated
A method similar to the Newton-Raphson method is the secant method,
which uses interpolation and extrapolation to approximate the root in each
FIGURE 4.5 The Newton-Raphson iterative method for solving an algebraic equation
f (x) 0.
Trang 2iteration, employing the last two iterative values in the approximation The iterative scheme is given by the equation
on the starting values If the method diverges, new values are taken and the cess is repeated
pro-A particularly simple method for root solving is the successive substitution method, in which the given equation f (x) 0 is rewritten as x g(x) At the root,
A g(A), where A is the root of the original equation and thus f (A) 0 This yields
an iterative scheme given by the equation
Therefore, the iteration starts with an initial approximation to the root x1, which
is substituted on the right-hand side of this equation to yield the next
approxi-mation, x2 Then x2 is substituted in the equation to obtain x3, and so on The process is continued until Equation (4.11) is satisfied The scheme is a very simple one and is based on the successive substitution of the approximations to the root to obtain more accurate values However, convergence is not assured
and depends on the initial guess as well as on the choice of the function g(x),
which can be formulated in many ways and is not unique It can be shown that
FIGURE 4.6 A few cases in which the Newton-Raphson method does not converge.
Trang 3if |g`(A)| 1, the method converges to the root in a region near the root Here,
g `(A) is the derivative of g(x) at the root and is known as the asymptotic
conver-gence factor The converconver-gence characteristics of the method may be improved by
employing the recursion formula
ficient Find the temperature T using the secant method.
where the subscripts i – 1, i, and i 1 represent the values for three consecutive
iterations The starting values are taken as T i–1 T1 350 and T i T2 850 The
equation just given is used to calculate T i1 T3 Then T2 and T3 are used to calculate
T4 , and so on The iteration is terminated when
Trang 4where E is a chosen small quantity Thus, the relative change in T from one iteration
to the next is used for the convergence criterion The numerical results obtained from the secant method follow, indicating a few steps in the convergence to the desired root.
Therefore, the temperature T is obtained as 645.92 K, rounding off the
numeri-cal result to two decimal places A fast convergence to the root is observed The convergence parameter E is taken as 10 –5 here, and it was confirmed that the result was negligibly affected if a still smaller value of E was employed A significant change in the root was obtained if E was increased to larger values.
Though computer programs may be written in Fortran, C , or other ming languages to solve this root-solving problem, the MATLAB environment pro- vides a particularly simple solution scheme on the basis of the internal logic of the
program-software By rearranging f(T), polynomial p is given in terms of the coefficients a,
b, c, d, and e, in descending powers of T, as:
System of Nonlinear Algebraic Equations
The mathematical modeling of thermal systems frequently leads to sets of linear equations The solution of these equations generally involves iteration and combines the strategies for root solving and those for linear systems Two impor-tant approaches for solving a system of nonlinear algebraic equations are based
non-on Newtnon-on’s method and non-on the successive substitutinon-on method If x1, x2,z , x n are
Trang 5the unknowns and f1(x1, x2,z , x n) 0, f2 (x1, x2,z , x n) 0, z , f n (x1, x2,z , x n)
0 are the nonlinear equations, Newton’s method gives the solution as
2 1
( ) ( ) ( )
( ) ( ) ( )
where the superscripts (l) and (l 1) represent the values after l and l 1 iterations
The increments $i are obtained from the following system of linear equations:
tt
tt
ttt
t
tt
tt
t
f x
f x
f x f
x
f x
f x
n
n
1 1 1 2
1
2 1 2 2
f x
f x
tt
1 2
Therefore, the iterative scheme starts with an initial guess of the values of the
unknowns, x i( ) 1 From these values, the functions f i( ) 1 and their derivatives needed for Equation (4.17) are calculated Then the linear system given by Equation (4.17) is solved for the increments $i( ) 1 , which are employed in Equation (4.16)
to obtain the next iteration, x i( ) 2 This process is continued until the unknowns
do not change from one iteration to the next, within a specified convergence criterion, such as that given by Equation (4.7)
Clearly, this scheme is much more involved than that for a system of linear equations In fact, a system of linear equations has to be solved for each iteration
to update the values of the unknowns In addition, the derivatives of the tions have to be determined at each step Therefore, the method is appropriate for relatively small sets of nonlinear equations, typically less than ten, and for cases where the derivatives are continuous, well behaved, and easy to compute The scheme may diverge if the initial guess is too far from the exact solution Usually, the physical nature of the problem and earlier solutions are employed to guide the selection of the initial guess
func-The system of equations may also be solved using the successive substitution approach, i.e., each unknown is computed in turn and the value obtained is substi-tuted into the corresponding equations to generate an iterative scheme Therefore,
Trang 6if the system of equations is rewritten by solving for the unknowns, we obtain
x i G i [x1, x2, x3,z , x i,z , x n] for i 1, 2, z , n (4.18)
The unknown x i is retained on the right-hand side in this case, since these are
nonlinear equations and x i may appear as a product with other unknowns or as
a nonlinear function Again, the function G i can be formulated from the given
equation f i 0 in many different ways An iterative scheme similar to the Seidel method may be developed as
Gauss-x i G x i l x l x x
i l i
( 1 ) ( ), ( ), , ( ), ( )
1 1 2 1 1
Here, the unknowns are calculated for increasing i, starting with x1 The most
recently calculated values of the unknowns are used in calculating the function G i.This scheme is often also known as the modified Gauss-Seidel method It is similar to the successive substitution method for linear equations and is much simpler to implement than Newton’s method since no derivatives are needed The approach is particularly suitable for large sets of equations However, Newton’s method generally has better convergence characteristics than the successive sub-stitution, or modified Gauss-Seidel, method SUR is often used to improve the convergence characteristics of this method Convergence of the iterative scheme for nonlinear equations is often difficult to predict because a general theory for convergence is not available as in the case of linear equations Several trials, with different starting values and different formulations, are frequently needed to solve these equations Newton’s method and the successive substitution method
also represent two different approaches to simulation, namely simultaneous and
sequential, and are discussed later, along with a few solved examples.
4.2.3 O RDINARY D IFFERENTIAL E QUATIONS
Ordinary differential equations (ODE), which involve functions of a single pendent variable and their derivatives, are encountered in the modeling of many
inde-thermal systems, particularly for transient lumped modeling A general nth-order
ODE may be written as
d y
dx F x y
dy dx
d y dx
n n
n n
¦¥
³µ´
where x is the independent variable and y(x) is the dependent variable This tion requires n independent boundary conditions for a solution If all these condi- tions are specified at one value of x, the problem is referred to as an initial-value problem If the conditions are given at two or more values of x, it is referred to as a
equa-boundary-value problem We shall first consider initial-value problems, followed
by boundary-value problems
Trang 7n n n
2
1 1
1
! ( , , 1,Y Y2, 3,!,Y n1)
The n boundary conditions are given in terms of y and its derivatives, all these being specified at one value of x for an initial-value problem The given nth-order
equation may be linear or nonlinear Linear equations can frequently be solved
by analytical methods available in the literature However, numerical methods are usually needed for nonlinear equations
It is clear from the foregoing discussion that if we can solve a first-order ODE,
we can extend the solution to higher-order equations and to systems of ODEs Therefore, the numerical solution procedures are directed at the simple first-order equation written as
dy
with the boundary condition
where y0 is the value of y(x) at a given value of the independent variable, x x0
A numerical solution of this differential equation involves obtaining the value of
the function y(x) at discrete values of x, given as
Therefore, the numerical scheme must provide the means for determining the
values y1, y2, y3, y4,z for the dependent variable y corresponding to these
dis-crete values of x If the solution is sought for x x0, then x i is taken as x i x0 – i$ and a similar procedure is employed as for increasing x.
There are several methods available for the solution of a first-order ODE and thus of higher-order equations and systems of ODEs Two main classes of meth-ods are
1 Runge-Kutta methods
2 Predictor-corrector methods
Trang 8In the Runge-Kutta methods, the derivative of the function y, as given by F(x,y),
is evaluated at different points within the interval x i to x i1 x i $
mean of these values is obtained and used to calculate y i1, the value of the
depen-dent variable at x i1 The simplest formula in these classes of methods is that of
Euler’s method, which has a cumulative error of O($ i and is, therefore, a first-order method since error varies as first power of $x The compu-tational formula for Euler’s method is
y i1 y i $i , y i) with i 0, 1, 2, 3, z (4.24)
Therefore, the solution can be obtained for increasing x, starting with x x0.Figure 4.7 shows this method graphically, indicating the accumulation of error
with increasing x.
The most widely used method is the fourth-order Runge-Kutta method given
by the computational formula
For higher-order equations, a system of first-order equations is solved, as mentioned earlier The computations are carried out in sequence to obtain the
values of all the unknowns at the next step All the conditions, in terms of y and
its derivatives, must be known at the starting point to use this method Therefore, the scheme, as given here, applies to initial-value problems
Predictor-corrector methods use an explicit formula to predict the first mate of the solution, followed by the use of an implicit formula as the corrector
esti-to obtain an improved approximation esti-to the solution Previously obtained values
Trang 9FIGURE 4.7 Graphical interpretation of Euler’s method (a) Numerical solution and error
after the first step; (b) accumulation of error with increasing value of the independent
variable x.
Trang 10of the dependent variable y are extrapolated to obtain the predicted value, and the
corrector equation is solved by iteration, though only one or two steps are ally needed for it to converge because the predicted value is close to the solution These methods are not self-starting because the first few values are needed to start the predictor, and a method such as Runge-Kutta is used to obtain the ini-tial points Therefore, programming is more involved than Runge-Kutta methods, which are self-starting However, the predictor-corrector methods are generally more efficient, resulting in smaller CPU time, and have a better estimate of the error at each step Several predictor-corrector methods are available with differ-ent accuracy levels MATLAB is particularly well suited to solving initial-value problems, as seen in the following
gener-Example 4.3
The motion of a stone thrown vertically at velocity V from the ground at x 0 and
at time T 0 is governed by the differential equation
d x
dx d
2 2
.
where g is the magnitude of gravitational acceleration, given as 9.8 m/s2 , and the
velocity is dx/dT, also denoted by V Solve this equation, as well as the first-order equation in V, to obtain the displacement x and velocity V as functions of time Take the initial velocity V as 25 m/s.
Trang 11Runge-Kutta methods and use adaptive step sizes Two solutions are obtained at each step, allowing the algorithm to monitor the accuracy and adjust the step size according to a given or default tolerance The first method, ode23, uses second- and third-order Runge-Kutta formulas and the second one, ode45, uses fourth- and fifth-order formulas.
Considering the equation for the velocity, the following MATLAB statements
yield the solution in terms of V:
valid only until V 0.
Similarly, the equation for x may be solved However, this is a second-order
equation, which is first reduced to two first-order equations as
0 5
Trang 12First, the right-hand sides of these two equations are defined as
Boundary-Value Problems
In the simulation of thermal systems, we are frequently concerned with problems
in which the boundary conditions are given at two or more different values of the
independent variable Such problems are known as boundary-value problems
Since the number of boundary conditions needed equals the order of the ODE, the equation must at least be of second order to give rise to a boundary-value problem
1.4 1.2 1 0.8 0.6 0.4 0.2 0 –5
0 5