本帖最後由 rictirse 於 2014-12-24 08:25 編輯
- Dim $h
- Dim $x
- Dim $derivatives ; 微分結果
- $x = 2.0
- $h = 1E-1
- ;
- ;求 func'(x) , x = 2.0 之值, 正解 = 6x = 12.0
- ;
- While True
- If $h < 1E-10 Then ExitLoop
- $h *= 0.1
- ;
- ;微分定義 :
- ;
- ; f ' (x) = lim f(x+h) - f(x)
- ;---------------------
- ; h->0 h
- $derivatives = ( _dc($x+$h) - _dc($x)) / $h
- ConsoleWrite ( StringFormat (" h = %e , f'(2.0) = %lf\n", $h, $derivatives))
- WEnd
- Func _dc($x)
- $x = 3.0*$x*$x ; 3x^2
- Return $x
- EndFunc
複製代碼 |