Professional Documents
Culture Documents
Introduction To Numerical Analysis: Riham K. Ahmed
Introduction To Numerical Analysis: Riham K. Ahmed
Analysis
Riham K. Ahmed
Lecture 3 – Part 2
The Secant Method
Secant Method Technique
• Secant methodهي تطوير ل Newton’s methodعن طريق التخلص من المشتقة 𝑓 ′بتعويض:
′
) 𝑓 𝑥 − 𝑓(𝑝𝑛−1
𝑓 𝑝𝑛−1 = lim
𝑥→𝑝𝑛−1 𝑥 − 𝑝𝑛−1
• إذا كان 𝑝𝑛−1قريبة من :𝑝𝑛−2
) 𝑓 𝑝1 (𝑝1 − 𝑝0
𝑝2 = 𝑝1 −
𝑓 𝑝1 − 𝑓 𝑝0
• نكرر العملية وذلك بتعويض القيم الناتجه في:
𝒏 𝒑𝒏 𝒏 𝒑𝒏
1 0.7853981634 1 0.7853981635
2 0.7390851781 2 0.7363841388
3 0.7390851332 3 0.7390581392
𝑝 ≈ 0.74
4 0.7390851332 4 0.7390851493
5 0.7390851332
The Secant Method Algorithm
• INPUT: initial approximations 𝑝0 , 𝑝1 ; tolerance TOL; maximum number of iterations 𝑁0 .
• OUTPUT: approximate solution 𝑝 or message of failure.
• Step 1 Set 𝑖 = 2;
𝑞0 = 𝑓(𝑝0 );
𝑞1 = 𝑓 𝑝1 .
• Step 2 While 𝑖 ≤ 𝑁0 do Steps 3 – 6.
Step 3 Set 𝑝 = 𝑝1 − 𝑞1 (𝑝1 − 𝑝0 )/ (𝑞1 − 𝑞0 ); (Compute 𝑝𝑖 )
Step 4 If 𝑝 − 𝑝1 < TOL then
OUTPUT (𝑝); (Procedure completed successfully.)
STOP.
Step 5 Set 𝑖 = 𝑖 + 1.
Step 6 Set 𝑝0 = 𝑝1 ; (Update 𝑝0 , 𝑞0 , 𝑝1 , 𝑞1 .)
𝑞0 = 𝑞1 ;
𝑝1 = 𝑝;
𝑞1 = 𝑓(𝑝);
• Step 7 OUTPUT (‘Method failed after 𝑁0 iterations, 𝑁0 =`, 𝑁0 );
(The procedure was unsuccessful.)
STOP.
Exercises
−4 𝜋
𝜀 = 10 [0,وذلك بأخذ الفترة ] .1بإستخدام Secant Methodأوجد جذر المعادلة 𝑥 − cos 𝑥 = 0في
2
.2أكتب برنامج بلغه Pythonاليجاد جذر المعادله غيرالخطية مستخدما .Secant Method