Bisection Newton’s Method (1-D) Broyden’s Method (Multi-dimensional) Newton’s Method (Multi-dimensional)10.34, Numerical Methods Applied to Chemical Engineering Professor William H. Green Lecture #6: Modern Methods for Solving Nonlinear Equations. 1D-Problem unknown: T of reactor f(x) = 0 Qrxnexp(-Ea/RT) + h(T – Ta) + c(T4 – Ta4) = 0 heat of reaction convection radiation (+) (-) (-) Gain heat Lose heat Lose heat f(T) 0 T 2 steady state temperatures Make a plot with MATLAB *netheat.m* function qdot = netheat(T) % computes the net heating rate of a reactor % qdot = 0 at the steady state qdot = Q.*exp(-Ea/(R.*T)) + h.*(T-Ta) + c.*(T.^4-Ta.^4); Figure 2. Professor Green modified variables Q and c until the plot looked like the one above. Increased Q and decreased c. To solve for steady state zeros f(T) = 0 a Æ Å b Figure 1. 1D problem Q = -2e-5; Ea = 5000; R = 1.987; h = 3; Ta = 300; c = 1e-8; Tvec = linspace(300,3000)qdot = netheat(Tvec) plot(Tvec,qdot) Figure 3. Have computer bracket in and find small range where plot goes from negative to positive. Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD Month YYYY].Bisection 10.34 Numerical Methods Applied to Chemical Engineering Lecture 6 Prof. William Green Page 2 of 4 Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD Month YYYY]. start a,b such that f(a)<0 and f(b) < 0 2bax+= Figure 4. Function must be continuous. if f(x) · f(a) > 0 a = x else b = x This is a problem of TOLERANCE if((b-a) < tol) stop Types of tolerance Absolute tolerance Relative tolerance atol: has units if |f(x)| < atol·f rtol: if(b-a) < rtol*|a| has to be BIG number In MATLAB while abs(b-a) > atolx x = (a+b)/2 if f(x)·f(a) > 0 a = x else b = x end *bisect.m* function x = bisect(f,a,b,atolx,rtolx, atolf) %solves f(x) = 0 while abs(b-a) > atolx x = 0.5*(b+a); if((feval(f,x)*feval(f,a))>0) a=x; else b=x; end end Command Window x = bisect(@netheat,300,2000,0.1,0,0) x = 1.2373e+003 CHECK: netheat(1237) = -1.0474 Í close Keep in mind: never get actual solution, but can come close We can change tolerances to improve results. Æ while(abs(b-a)>atolx)&&(abs(b-a)>(rtolx*abs(a))) x = 0.5*(b+a); AND: must satisfy both conditions if(abs(feval(f,x))<atolf) return %if value becomes low enough, return value x = bisect(@netheat,300,2000,0.1,1e-2,0.5) x = 1.2363e+003 looser tolerance gives less accurate answer Bisection cuts interval by 2 each timeEvery time we cut 3 times, we lose a sig fig In bisection, time grows linearly with the number of significant figures. a < xtrue < b xtrue = xsoln ± b-a/2 Newton’s Method (1-D) evaluates slope of f(x) next guess is the xnew that satisfies f(xnew)=0 for a line from f(xguess) with the slope at f(xguess) Figure 5. Newton’s Method. For a good guess Newton’s method doubles the number of significant figures after every iteration; however, we lose robustness if guess is poor f(x) = f(x0)+f’(x0)*(x-x0)+O(Δx2) 0 = f(xguess)+f’(xguess)*(x-xguess) If f’(xguess) ≈ 0 -- doesn’t work xnew = xguess – f(xguess)/f’(xguess) f’(x) = 0 Figure 6. NO intersection Another drawback is one needs a derivative of the function. Secant Method same as Newton’s, but uses f’(x) approximate ]1[][]1[][)()()('−−−−=kkkkapproxxxxfxfxf Bisection method works only for 1D problems, but Newton/Secant can be used for problems with greater dimension 10.34 Numerical Methods Applied to Chemical Engineering Lecture 6 Prof. William Green Page 3 of 4 Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD Month YYYY].Broyden’s Method (Multi-dimensional) F(x) = F(x0) + J(x0)·(x-x0) Method breaks down when J is singular ∑−⎟⎟⎠⎞⎜⎜⎝⎛∂∂jjojxjixxxfo)(, 10.34 Numerical Methods Applied to Chemical Engineering Lecture 6 Prof. William Green Page 4 of 4 Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD Month YYYY]. f(x) = 0 approx J = B outer product is opposite of dot product 2T][]1[]1[][1||||)()(xxxxBBΔ−∗+=+++kkkk][kF Outer Product: ⎟⎟⎠⎞⎜⎜⎝⎛ΔΔΔΔΔΔ…322212312111xFxFxFxFxFxF Newton’s Method (Multi-dimensional) O = F(x0)+J(x0)·(x-x0) J*Δx = -F(x0) B[k]Δx = -FLU LU LU[k+1] without redoing factorization Done in detail in homework
View Full Document