function root = bisectnewfunc,xl,xu,Ead function root = falseposfunc,xl,xu,es,maxit

33 CHAPTER 5 5.1 The function to evaluate is tanh t v t m gc c gm c f d d d − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = or substituting the given values 36 4 80 81 . 9 tanh 80 81 . 9 − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = d d d c c c f The first iteration is 15 . 2 2 . 1 . = + = r x 175944 . 204516 . 860291 . 15 . 1 . − = − = f f Therefore, the root is in the first interval and the upper guess is redefined as x u = 0.15. The second iteration is 125 . 2 15 . 1 . = + = r x 20 100 125 . 15 . 125 . = − = a ε 273923 . 318407 . 860291 . 125 . 1 . = = f f Therefore, the root is in the second interval and the lower guess is redefined as x u = 0.125. The remainder of the iterations are displayed in the following table: i x l fx l x u fx u x r fx r | ε a | 1 0.1 0.86029 0.2 −1.19738 0.15 −0.20452 2 0.1 0.86029 0.15 −0.20452 0.125 0.31841 20.00 3 0.125 0.31841 0.15 −0.20452 0.1375 0.05464 9.09 4 0.1375 0.05464 0.15 −0.20452 0.14375 −0.07551 4.35 5 0.1375 0.05464 0.14375 −0.07551 0.140625 −0.01058 2.22 6 0.1375 0.05464 0.140625 −0.01058 0.1390625 0.02199 1.12 Thus, after six iterations, we obtain a root estimate of 0.1390625 with an approximate error of 1.12.

5.2 function root = bisectnewfunc,xl,xu,Ead

bisectnewxl,xu,es,maxit: 34 uses bisection method to find the root of a function with a fixed number of iterations to attain a prespecified tolerance input: func = name of function xl, xu = lower and upper guesses Ead = optional desired tolerance default = 0.000001 output: root = real root if funcxlfuncxu0 if guesses do not bracket a sign change errorno bracket display an error message and terminate end if necessary, assign default values if nargin4, Ead = 0.000001; end if Ead blank set to 0.000001 bisection xr = xl; compute n and round up to next highest integer n = round1 + log2xu - xlEad + 0.5; for i = 1:n xrold = xr; xr = xl + xu2; if xr ~= 0, ea = absxr - xroldxr 100; end test = funcxlfuncxr; if test 0 xu = xr; elseif test 0 xl = xr; else ea = 0; end end root = xr; The following is a MATLAB session that uses the function to solve Prob. 5.1 with E a,d = 0.0001. fcd = inlinesqrt9.8180cdtanhsqrt9.81cd804-36,cd fcd = Inline function: fcdcd = sqrt9.8180cdtanhsqrt9.81cd804-36 format long bisectnewfcd,0.1,0.2,0.0001 ans = 0.14008789062500 5.3 The function to evaluate is 36 4 80 81 . 9 tanh 80 81 . 9 − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = d d d c c c f 35 The first iteration is 141809 . 19738 . 1 86029 . 2 . 1 . 19738 . 1 2 . = − − − − − = r x 030292 . 03521 . 860291 . 141809 . 1 . − = − = f f Therefore, the root is in the first interval and the upper guess is redefined as x u = 0.141809. The second iteration is 140165 . 03521 . 86029 . 141809 . 1 . 03521 . 141809 . = − − − − − = r x 17 . 1 100 140165 . 141809 . 140165 . = − = a ε Therefore, after only two iterations we obtain a root estimate of 0.140165 with an approximate error of 1.17 which is below the stopping criterion of 2.

5.4 function root = falseposfunc,xl,xu,es,maxit

falseposxl,xu,es,maxit: uses the false position method to find the root of the function func input: func = name of function xl, xu = lower and upper guesses es = optional stopping criterion default = 0.001 maxit = optional maximum allowable iterations default = 50 output: root = real root if funcxlfuncxu0 if guesses do not bracket a sign change errorno bracket display an error message and terminate end default values if nargin5, maxit=50; end if nargin4, es=0.001; end false position iter = 0; xr = xl; while 1 xrold = xr; xr = xu - funcxuxl - xufuncxl - funcxu; iter = iter + 1; if xr ~= 0, ea = absxr - xroldxr 100; end test = funcxlfuncxr; if test 0 xu = xr; elseif test 0 xl = xr; else ea = 0; 36 end if ea = es | iter = maxit, break, end end root = xr; The following is a MATLAB session that uses the function to solve Prob. 5.1: fcd = inlinesqrt9.8180cdtanhsqrt9.81cd804-36,cd fcd = Inline function: fcdcd = sqrt9.8180cdtanhsqrt9.81cd804-36 format long falseposfcd,0.1,0.2,2 ans = 0.14016503741282 5.5 Solve for the reactions: R 1 = 265 lbs. R 2 = 285 lbs. Write beam equations: 0x3 3 2 55 . 5 265 1 265 3 667 . 16 x M x x x M − = = − + 3x6 150 415 50 2 265 3 3 2 150 2 3 3 100 2 − + − = = − − + − − + x x M x x x x M 6x10 1650 185 3 265 5 . 4 300 3 3 2 150 + − = − − + − = x M x x x M 10x12 1200 100 4 12 100 − = = − + x M x M Combining Equations: Because the curve crosses the axis between 6 and 10, use 3. 3 1650 185 + − = x M Set 10 ; 6 = = U L x x 37 200 540 L − = = U x M x M 8 2 = + = U L r x x x L R x replaces x M → = 170 200 170 L − = = U x M x M 9 2 10 8 = + = r x U R x replaces x M → − = 15 15 170 L − = = U x M x M 5 . 8 2 9 8 = + = r x L R x replaces x M → = 5 . 77 15 5 . 77 L − = = U x M x M 75 . 8 2 9 5 . 8 = + = r x L R x replaces x M → = 25 . 31 15 25 . 31 L − = = U x M x M 875 . 8 2 9 75 . 8 = + = r x L R x replaces x M → = 125 . 8 15 125 . 8 L − = = U x M x M 9375 . 8 2 9 875 . 8 = + = r x U R x replaces x M → − = 4375 . 3 4375 . 3 125 . 8 L − = = U x M x M 90625 . 8 2 9375 . 8 875 . 8 = + = r x L R x replaces x M → = 34375 . 2 4375 . 3 34375 . 2 L − = = U x M x M 921875 . 8 2 9375 . 8 90625 . 8 = + = r x U R x replaces x M → − = 546875 . 546875 . 34375 . 2 L − = = U x M x M 9140625 . 8 2 921875 . 8 90625 . 8 = + = r x 8984 . R = x M Therefore, feet x 91 . 8 =

5.6 a The graph can be generated with MATLAB