1 / 47

最小二平方法 與 方程式求解

最小二平方法 與 方程式求解. 張基昇製作. 目錄. 最小二平方法 方程式求解 方程式範例: van der Waals EOS Analysis of the problem 嘗試錯誤法 B isection method Secant method ; False position method Newton’s method ; Muller’s method 疊代法 : Fixed-point iteration. 最小二平方法. 實驗量測取得數據. 最小二平方法. 數據處理 數據點作圖 選擇三個數學模 式來吻合數據 , 何者最適當?.

Download Presentation

最小二平方法 與 方程式求解

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 最小二平方法與方程式求解 張基昇製作

  2. 目錄 • 最小二平方法 • 方程式求解 • 方程式範例:van der Waals EOS • Analysis of the problem • 嘗試錯誤法 • Bisection method • Secant method ; False position method • Newton’s method ; Muller’s method • 疊代法:Fixed-point iteration

  3. 最小二平方法 • 實驗量測取得數據

  4. 最小二平方法 • 數據處理 • 數據點作圖 • 選擇三個數學模式來吻合數據,何者最適當?

  5. 最小二平方法 • 最適當數學模式的觀念: • 該模式計算值與實驗值間之誤差較小 • 取誤差的平方和最小為判別標的

  6. 最小二平方法 • 在數學上極值的取得 • 對函數作變數之一次偏導數等於 0 時之變數值

  7. 最小二平方法 • 移項整理得兩個方程式的方程組 • 兩個未知變數 a 與 b,有兩個方程式,系統自由度為0

  8. 最小二平方法 • 第(1)式與第(2)式除以數據點數 N,可以得到如下平均值表示為(3) 、(4)

  9. 最小二平方法 • 第(1)式減去第(4)式乘以xi值,將消去 b 變數,取得a (5)式(或值)

  10. 最小二平方法 • 將 a (5)式(或值)帶入第(4)式,即可求取 b (6)式(或值)

  11. Fit1.for 程式解說 • 宣告因次與宣告實數 • (426) dimension x(100),y(100) • real*4 interp,meanx,meany • 開啟檔案 • open(1,file='fit1d.dat', status='old') • open(6,file='fit1.prn', status='new')

  12. Fit1.for 程式解說 • 讀入數據組數 • (430) read(1,*)n • 用迴圈讀入數據 • (431) do 1 i=1,n read(1,*)x(i),y(i) 1 continue

  13. Fit1.for 程式解說 • 宣告各個計算變數為 0.0 的值 • (434) sumx = 0.0 • sumy = 0.0 • sumx2 = 0.0 • sumy2 = 0.0 • sumxy = 0.0 • meanx = 0.0 • meany = 0.0

  14. Fit1.for 程式解說 • 利用迴圈計算各個總和數值 • (441) do 2 i = 1, n • sumx = sumx + x(i) • sumy = sumy + y(i) • sumx2 = sumx2 + x(i)*x(i) • sumy2 = sumy2 + y(i)*y(i) • sumxy = sumxy + x(i)*y(i) • 2 continue enddo

  15. Fit1.for 程式解說 • 計算平均值、斜率與截距 • (449) meanx = sumx / n • meany = sumy / n • (a值) slope = (sumxy - sumx*meany) /(sumx2 - sumx*meanx) • (b值) interp = meany - slope*meanx • coef = (…) 計算統計上的標準偏差值

  16. Fit1.for 程式解說 • 依指定格式列印結果 • (455) write(6,1000) slope,interp,coef • 1000 format( …) • stop • end

  17. 最小二平方法 • ㄧㄝˋ ! • 完成最小二平方法之數據處理,取得系統之最適當數學模式的參數 a 與 b。

  18. van der Waals equation of state • 立方型體積狀態方程式 • ㄧ、 • 二、 • 三、

  19. Cubic EOS • 立方型體積狀態方程式 • 臨界常數應用於方程式物質參數的求取

  20. van der Waals equation of state • vdW 狀態方程式的物質參數 • ㄧ、 , ,. • 二、 , .

  21. Phase Diagram

  22. Phase Diagram

  23. Cubic Equation of State • 體積的一元三次方程式 • 在一指定溫度與指定壓力之下,可以解得三個體積的根。

  24. Cubic EOS • 立方型體積狀態方程式 • 蒸氣相莫耳體積的求取計算式

  25. Cubic EOS • 立方型體積狀態方程式 • 液相莫耳體積的求取計算式

  26. 題解分析 • Degree of Freedom of problems • 自由度:數學的與熱力學的觀點 • 依 Gibbs 相律計算,自由度為 2,指定 T與 P • ,V 為所剩唯一變數;一個未知變數,一個方程式,自由度F = 0

  27. (一)嘗試錯誤法求解 • 嘗試錯誤法 • 給一個解的起猜值 V ,計算函數值是否為 0 ,若函數值小於容忍誤差() ,即可視為計算收斂,取得函數的解。 • 否則,繼續嘗試可能的解,ㄧ直到得到適當解為止。

  28. Bisection method • 解題的邏輯觀念示意圖

  29. Bisection method • Step A • Read: T、P、Tc、Pc,calculate a and b。 • Set V0 and V1 ,calculate f0 and f1 ,have to satisfy [ f0*f1 < 0 ] • IF ( | f0 | < .or. | f1 |<  ) THEN Stop。

  30. Bisection method • Step B • Repeat • Calculate V2 and f2 • IF ( f2 * f0 > 0 ) THEN Set V0 = V2 and f0 = f2ELSE Set V1 = V2 and f1 = f2ENDIF • Until | f2 |<  Then Stop。

  31. Bisection method • Formula by Bisection method

  32. Secant method • 解題的邏輯觀念示意圖

  33. Secant method • Step A • Read: T、P、Tc、Pc,calculate a and b。 • Set V0 and V1 ,calculate f0 and f1 • IF ( | f0 | <  .or. | f1 |<  ) THEN Stop。 • IF ( | f1 | > | f0 | ) THENSwap V0 withV1 andf0 with f1

  34. Secant method • Step B • Repeat • Calculate V2 and f2 • Set V0 = V1 and f0 = f1 Set V1 = V2 and f1 = f2 • Until | f2 |<  Then Stop。

  35. Secant method • Formula by Secant method

  36. False position method • 解題的邏輯觀念示意圖

  37. False position method • Step A • Read: T、P、Tc、Pc,calculate a and b。 • Set V0 and V1 ,calculate f0 and f1 , have to satisfy [ f0*f1 > 0 ] • IF ( | f0 | < .or. | f1 |<  ) THEN Stop。

  38. False position method • Step B • Repeat • Calculate V2 and f2 • IF ( f2 * f0 > 0 ) THEN Set V0 = V2 and f0 = f2ELSE Set V1 = V2 and f1 = f2ENDIF • Until | f2 |<  Then Stop。

  39. False position method • Formula by False position method

  40. Newton’s methods • 解題的邏輯觀念示意圖

  41. Newton’s methods • Step A • Read: T、P、Tc、Pc,calculate a and b。 • Set Vi,calculate fi and fi’, • IF ( | fi | < 1.or. | fi’|< 2 ) THEN Stop。

  42. Newton’s methods • Step B • Repeat • Calculate Vi+1 and fi+1 and fi+1’, • Until ( | fi | < 1.or. | fi’|< 2 )

  43. Newton’s methods • Formula by Newton’s methods

  44. (二)疊代法求解 • 疊代計算的邏輯觀念 • 將體積狀態方程式整理成為體積之自我函數關係式 • 疊代計算收斂之判別式

  45. 疊代法求解 • vdW 狀態方程式範例 • ㄧ、 • 二、 • 三、 • 四、

  46. 您可已曉得! • 劇情如何發展! • 敬請期待!

More Related