东北石油大学计算方法上机实验答案(0页).docVIP

  • 48
  • 0
  • 约1.04万字
  • 约 8页
  • 2017-04-21 发布于重庆
  • 举报

东北石油大学计算方法上机实验答案(0页).doc

东北石油大学计算方法上机实验答案(0页)

PAGE  PAGE 8 实验一 1. Private Function f(x!) f=x^3-2*x^2-4*x-7 End Function Private Sub form_click() Dim a!, b!, x!, c! a = 3: b = 4 Do While Abs(b - a) 0.00001 c = (a + b) / 2 If f(c) = 0 Then Exit Do Else If f(a) * f(c) 0 Then b = c Else a = c End If End If Loop Print c End Sub 1.(对1题进行修改后,要求输入隔根区间的上下界就能求出根的程序) Private Function f(x!) f = x ^ 3 - 2 * x ^ 2 - 4 * x - 7 End Function Private Function g(a!, b!) Dim y! Do While Abs(b - a) 0.00001 y = (a + b) / 2 If f(y) = 0 Then Exit Do Else If f(a) * f(y) 0 Then b = y Else a = y End If End I

文档评论(0)

1亿VIP精品文档

相关文档