Ing civil

Solo disponible en BuenasTareas
  • Páginas : 9 (2176 palabras )
  • Descarga(s) : 0
  • Publicado : 28 de febrero de 2012
Leer documento completo
Vista previa del texto
Selected Solutions for Exercises in

Numerical Methods with Matlab: Implementations and Applications Gerald W. Recktenwald Chapter 6 Finding the Roots of f (x) = 0

The following pages contain solutions to selected end-of-chapter Exercises from the book Numerical Methods with Matlab: Implementations and Applications, by Gerald W. Recktenwald, c 2000, Prentice-Hall, Upper Saddle River, NJ. Thesolutions are c 2000 Gerald W. Recktenwald. The PDF version of the solutions may be downloaded or stored or printed only for noncommercial, educational use. Repackaging and sale of these solutions in any form, without the written consent of the author, is prohibited. The latest version of this PDF file, along with other supplemental material for the book, can be found atwww.prenhall.com/recktenwald.

2

Finding the Roots of f (x) = 0

6–2 The function f (x) = sin(x2 ) + x2 − 2x − 0.09 has four roots in the interval −1 ≤ x ≤ 3. Given the m-file fx.m, which contains
function f = fx(x) f = sin(x.^2) + x.^2 - 2*x - 0.09;

the statement
>> brackPlot(’fx’,-1,3)

produces only two brackets. Is this result due to a bug in brackPlot or fx? What needs to be changed so that all fourroots are found? Demonstrate that your solution works. Partial Solution: The statement
>> Xb = brackPlot(’fx’,-1,3) Xb = -0.1579 0.0526 2.1579 2.3684

returns two brackets. A close inspection of the plot of f (x) reveals that f (x) crosses the x-axis twice near x = 1.3. These two roots are missed by brackPlot because there default search interval is too coarse. There is no bug in brackPlot.Implementing a solution using a finer search interval is left as an exercise. 6–11 Use the bisect function to evaluate the root of the Colebrook equation (see Exercise 8) for /D = 0.02 and Re = 105 . Do not modify bisect.m. This requires that you write an appropriate function m-file to evaluate the Colebrook equation. Partial Solution: Using bisect requires writing an auxiliary function to evaluate theColebrook equation in the form F (f ) = 0, where f is the friction factor. The following form of F (f ) is used in the colebrkz function listed below. 1 F (f ) = √ + 2 log10 f Many other forms of F (f ) will work.
function ff = colebrkz(f) % COLEBRKZ Evaluates the Colebrook equation in the form F(f) = 0 % for use with root-finding routines. % % Input: f = the current guess at the friction factor % %Global Variables: % EPSDIA = ratio of relative roughness to pipe diameter % REYNOLDS = Reynolds number based on pipe diameter % % Output: ff = the "value" of the Colebrook function written y = F(f) % Global variables allow EPSDIA and REYNOLDS to be passed into % colebrkz while bypassing the bisect.m or fzero function global EPSDIA REYNOLDS ff = 1.0/sqrt(f) + 2.0*log10( EPSDIA/3.7 + 2.51/(REYNOLDS*sqrt(f) ) );

/D 2.51 √ + 3.7 ReD f

Because the bisect function (unlike fzero) does not allow additional parameters to be passed through to the F (f ) function, the values of /D and Re are passed to colebrkz via global variables. Running bisect with colebrkz is left to the reader. For Re = 1 × 105 and /D = 0.02 the solution is f = 0.0490.
Copyright c 2000, Gerald W. Recktenwald.Photocopying is permitted only for non-commercial educational purposes.

Chapter 6: Finding the Roots of f (x) = 0

3

6–13 Derive the g3 (x) functions in Example 6.4 and Example 6.5. (Hint: What is the fixed-point formula for Newton’s method?) Partial Solution: The fixed point iteration formulas designated as g3 (x) in Example 6.4 and Example 6.5 are obtained by applying Newton’s method. The generalform of Newton’s method for a scalar variable is f (xk ) xk+1 = xk − f (xk ) Example 6.4: The f (x) function and its derivative are f (x) = x − x1/3 − 2 1 f (x) = 1 − x−2/3 3

Substituting these expressions into the formula for Newton’s method and simplifying gives xk+1 = xk − xk − xk 1−
1/3

−2

−2/3 (1/3)xk

=

xk (1 − (1/3)xk 1− xk − (1/3)xk 1− (2/3)xk 1− 2xk 3−
1/3 1/3 1/3

−2/3...
tracking img