English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

請問如何求此方程式的根...

2X^3+X^2/(X^2+1)+5X-7=0


vb設計樣試為

一個Button
一個Textbox

Button按下後方程式的根出現在Textbox裡面
此vb程式碼該如何設計...

2007-01-13 11:14:18 · 1 個解答 · 發問者 丫捷 2 in 電腦與網際網路 程式設計

1 個解答

本題的低限 請輸入 0
本題的高限 請輸入 1
Public Sub Command1_Click()
Dim a As Single, b As Single, c As Single, e As Single, fx As Single
Dim done As Integer
e = 0.000001
a = InputBox("請輸入低限 a")
b = InputBox("請輸入高限 b")
done = 0
Do
c = (a + b) / 2
fx = fun(c)
If (Abs(fx) > e) Then
If (fx * fun(a) > 0) Then
a = c
Else
b = c
End If
Else
done = 1
End If
Loop While (done = 0)
Text1.Text = "The root is " & c
End Sub
Public Function fun(x As Single) As Single
fun = 2 * x ^ 3 + x ^ 2 / (x ^ 2 + 1) + 5 * x - 7
End Function
如果有問題, 請來函討論. 不然, 我可能會錯失你再補充的疑點.

2007-01-15 06:34:16 · answer #1 · answered by JJ 7 · 0 0

fedest.com, questions and answers