tailieunhanh - c for engineers and scientists introduction to programming with ansi c phần 7

Khi các giá trị tương tự đã được nhập vào cho chương trình chia làm hai đoạn gốc nhỏ hơn x = -5,3 đã được tìm thấy sau 21 lần lặp lại. Dưới đây là lớn chứ không phải là gốc nhỏ hơn đã được tìm thấy nhưng với lặp đi lặp lại ít hơn. Chú ý rằng các kết quả phạm vi lớn được quy định trong việc tính toán đầu tiên của x [3] được xa ~ di chuyển từ gốc. | Root Finding 385 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x ll x 12 x 13 x 14 x 15 A root is at X Root found after 14 iterations When the same values were entered for the bisection program the smaller root X was found after 21 iterations. Here the larger rather than the smaller root was found but with fewer iterations. Notice that the large range specified results in the first calculation of X 3 being far rfemoved from the root. This is not surprising in view of the fact that the parabolic function evaluates to about 10 000 for X -100 and for X 100. Enter the maximum function error Enter the maximum number of iterations 100 30 Enter left and right bounds of X x l X 2 100 -100 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x ll x 12 x 13 x 14 x 15 . A root is at X Root found after 14 iterations For this run we fool the program by reversing the bound numbers entered despite the prompt message the right bound is entered before the left bound and the program has no provision for rejecting the entry. Notice that the first calculation is the same as for the previous run a secant line is drawn between the same two points regardless of which one we choose as X 1 . The next calculation that of X 4 and subsequent ones differ from those from the first run can you see 386 Chapter Nine Numerical Techniques why . The result is that the negative root rather than the positive root has been found in the same number of iterations. Enter the maximum function error Enter the maximum number of iterations 100 30 Enter left and right bounds of X x l x 2 -100 0 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 A root is at X

TỪ KHÓA LIÊN QUAN