Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1

# 數值分析作業 Secant-Method

Ratings:

4.67

(3)
|Views: 902 |Likes:

### Availability:

See more
See less

05/08/2014

pdf

text

original

printf("\n\n %15.15f \n", SecantMethod(xm_1, xm, E, M));//(9)return 0;}程式說明：欲解方程式：
3
+ x + 1 = 0Secant Method解法方程式如下圖(圖1)所式(1)Secant Method持續執行直到以下兩個條件其中之一發生：1.|
+ 1

| <
2.
>
說明(1)：宣告副程式函式f型別為雙精度浮點數，傳入值x，回傳(-x*x*x)+x+1計算後值。說明(2)：宣告副程式函式SecantMethod型別為雙精度浮點數，傳入值xn_1, xn, e, m說明(3)：使用For迴圈疊代m說明(4)：Secant Method右式(1)assignd，如d的絕對值小於e(Tolerance，最小忍值)，回傳xn的值。把xn assignxn_1，再把(xn-d) assignxn(疊代置xnxn_1的值)。螢幕輸xnf(xn)的值。說明(5)：主程式，宣xm_1,xm,E,M的型別說明(6)：輸入第一個和第二個起始猜測值x0x1。說明(7)：輸入最大疊代數目。說明(8)：輸入最小容忍值。說明(9)：螢幕顯示SecantMethod回傳值(SecantMethod函式傳入值xm_1, xm, E, M計算後之值)。程式執行結果及討論：[

：改x0,x1的相隔區間，固定最大疊代數為50及最小容忍值0.00001 ](1)x01.1x11.2
Enter 1st initial guess x0:1.1

Enter 2nd initial guess x1:1.2Enter Max iteration number:50Enter tolerance:0.000011.358922558922559, -0.1505596711636001.320488768042503, 0.0179649335929401.324585858208551, 0.0005632845615641.324718479412076, -0.0000022268531101.324718479412076
xn1.3247184794120764f(x)-0.000002226853110(2)x01.1x150
Enter 1st initial guess x0:1.1Enter 2nd initial guess x1:50Enter Max iteration number:50Enter tolerance:0.000011.100300953737658, 0.7682081927512981.100601595747396, 0.7674166086390561.392064837568101, -0.3055403682523731.309066368705039, 0.0657785578618401.323769415607835, 0.0040416071485031.324731950018435, -0.0000596748225521.324717944868202, 0.0000000527814161.324717944868202
xn1.3247179448682027f(x)0.000000052781416(3)x01.001x11.002
Enter 1st initial guess x0:1.001Enter 2nd initial guess x1:1.002Enter Max iteration number:50Enter tolerance:0.000011.497761334828597, -0.8621502163429661.267734989017586, 0.2302921629315231.316225660665854, 0.0359305282770301.325189854921204, -0.0020133555022001.324714202246012, 0.0000160136354771.324714202246012
xn1.3247142022460125f(x)0.000016013635477

：從實驗(1)(2)(3)，可得出一個可能趨勢，當固定最大疊代數及最小容忍值，起始猜測值x0x1的相隔區間越大時，f(x)的值越趨近零，也就是說xn(解)精確度越高。[

：改變最小容忍值，固定最大疊代數為50x0,x1的值各別1.1,1.2 ]