1 Replies - 283 Views - Last Post: 07 February 2012 - 01:12 AM Rate Topic: -----

Topic Sponsor:

#1 sokerfan  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 10-July 11

bisection method for functions roots

Posted 07 February 2012 - 12:51 AM

Hello,
I keep getting an error message, any hints would be appreciated
[Option Explicit
Function Bisection(xl, xu, es)
Dim xold As Double, xr As Double
If func(xl) * func(xu) >= 0 Then
MsgBox "No sign change!"

Exit Function

End If

Do
xold = xr

xr = (xl + xu) / 2
If func(xr) = 0 Then Exit Do
If func(xr) * func(xl) < 0 Then
xu = xr
Else
xl = xr
End If
If xr <> 0 Then
If Abs((xr - xold) / xr) * 100 < es Then
Exit Do
End If

Else
xold = xr
End If

Loop
Bisection = xr
End Function
Function func(x)
func = x ^ 3 + 4 * x ^ 2 - 10
End Function]

Is This A Good Question/Topic? 0
  • +

Replies To: bisection method for functions roots

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 211
  • View blog
  • Posts: 1,249
  • Joined: 26-March 09

Re: bisection method for functions roots

Posted 07 February 2012 - 01:12 AM

A hint at the error message would be useful, or do you expect us to run the code and debug it for you?

Also, please edit your post and put your code in the [ CODE] tags, it will make so much easier for people to read.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1