|
-
Jun 17th, 2002, 11:07 PM
#1
Thread Starter
Addicted Member
-
Jun 18th, 2002, 09:02 AM
#2
Hyperactive Member
I think the problem that you're having has to do with the precision of the numbers stored in memory. Try using doubles and see what happens.
That aside, the approach that you're taking to finding a root isn't the best way. If you happened to find one it would be pure luck. It's better to get a good first guess and proceed from there. There are many methods of finding roots, one of these is Newtons method, which uses derivatives to provide good guesses to 'zero' in on the root of an equation.
I wrote a program that computes the all roots of a cubic equation. However, it's not very elegant since it uses a 'standard' solution from a textbook. That's like writing a program that uses the quadratic formula to find the roots of a 2nd-order polynomial.
Guv, submitted a program that finds the roots for an nth-degree polynomial. It was very nice. Take a look around and see if you can find it.
-
Jun 19th, 2002, 12:31 PM
#3
Hyperactive Member
Suppose you have
s=x^3+2x^2+7x+3
and you want to find value(s) of x for which s=0. Say, for the purposes of argument, that an exact value of x is 0.1234. Your program is only accurate to 0.1 from the look of it, so it will never find this exact root.
Look at the bottom of this thread for Guv's program. The thread also contains better methods you might find useful. Post back if you still need help.
There are 10 types of people in the world - those that understand binary, and those that don't.
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
|