|
-
April 5th, 2008, 03:35 PM
#7
Re: Problem with Bissection method
Hi rottweiler,
Please don't post a new thread on the same topic, it's easier for everyone to keep track of all the information if it's in the same thread.
One thing I don't like is this:
if (val < 0 )
low = mid;
else
high = mid;
In the bissect method, you need to identify a sign-change to find the next interval. For example, let say you have the interval [low, high] and the point mid. In order to have a sign change, you need to have:
F(low) * F(high) < 0
To find the next interval (between [low, mid] or [mid, high]), you need to identify where is the sign change. The pseudo-code would be:
if (F(low) * F(mid) < 0)
high = mid
elseif F(mid) * F(high) < 0
low = mid
else
// mid is a root
That way, your function can be anything, and the algorithm will work.
JeffB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|