TAILIEUCHUNG - Root Finding and Nonlinear Sets of Equations part 3

Maximum allowed number of bisections. float rtbis(float (*func)(float), float x1, float x2, float xacc) Using bisection, find the root of a function func known to lie between x1 and x2. The root, returned as rtbis, will be refined until its accuracy is ±xacc. { void nrerror(char error_text[]); int j; float dx,f,fmid,xmid,rtb; f=(*func)(x1); fmid=(*func)(x2); if (f*fmid = ) nrerror("Root must be bracketed for bisection in rtbis"); rtb = f 0 for (j=1;j | 354 Chapter 9. Root Finding and Nonlinear Sets ofEquations include define JMAX 40 Maximum allowed number of bisections. float rtbis float func float float x1 float x2 float xacc Using bisection find the root of a function func known to lie between x1 and x2. The root returned as rtbis will be refined until its accuracy is ixacc. void nrerror char error_text int j float dx f fmid xmid rtb f func x1 fmid func x2 if f fmid nrerror Root must be bracketed for bisection in rtbis rtb f dx x2-x1 x1 dx x1-x2 x2 Orient the search so that f 0 for j 1 j JMAX j lies at x dx. fmid func xmid rtb dx Bisection loop. if fmid rtb xmid if fabs dx xacc fmid return rtb nrerror Too many bisections in rtbis return Never get here. Secant Method False Position Method and Ridders Method For functions that are smooth near a root the methods known respectively as false position or regula falsi and secant method generally converge faster than bisection. In both of these methods the function is assumed to be approximately linear in the local region of interest and the next improvement in the root is taken as the point where the approximating line crosses the axis. After each iteration one of the previous boundary points is discarded in favor of the latest estimate of the root. The only difference between the methods is that secant retains the most recent of the prior estimates Figure this requires an arbitrary choice on the first iteration while false position retains that prior estimate for which the function value has opposite sign from the function value at the current best estimate of the root so that the two points continue to bracket the root Figure . Mathematically the secant method converges more rapidly near a root of a sufficiently continuous function. Its order of convergence can be shown to be the golden ratio . so that lim efc 1 const x rk I1 618 k 1 Sample page from NUMERICAL RECIPES IN C THE ART OF SCIENTIFIC COMPUTING .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.