Good morning sir,
Iam new to the c i need a help from u. I dont know the roots of an equation in c program language so i kindly requested u to give the solution.
Thank you sir
Good morning sir,
Iam new to the c i need a help from u. I dont know the roots of an equation in c program language so i kindly requested u to give the solution.
Thank you sir
The title reminded me of this:
http://www.embedded.com/showArticle....cleID=18901336
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
How would you do it in math? If you know how to find the roots, mathematically, it's easy to convert that into functions. If not then no knowlege of C will help you.
Though I guess you could always use the brute force aproach.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
> so i kindly requested u to give the solution.
http://cboard.cprogramming.com/annou...t.php?f=4&a=39
http://cboard.cprogramming.com/annou...t.php?f=4&a=51
Make an effort, then we will help you.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
You could use the Newton-Raphson method.
double solve (double (*) (double), double low, double high);
1) If the problem states that there is just one root in a given interval, like [a,b], than the solution is straightforward: you just have to use the bisection method.
2) You should take great care when using Newton-Raphson method (a badly designed algorithm implementing Newton-Raphson method will go, for certain roots, to infinity)
Last edited by rieman; 12-16-2006 at 08:01 AM.
Actually, bisection will only work if there are at least two points in your interval for which their y-value is of opposite sign. An interval can have one root in it, but if the signs never change in that interval, your bisection method will do much worse than Newton-Raphson (namely, it will crash or have undefined behaviour.)1) If the problem states that there is just one root in a given interval, like [a,b], than the solution is straightforward: you just have to use the bisection method.
2) You should take great care when using Newton-Raphson method (a badly designed algorithm implementing Newton-Raphson method will go, for certain roots, to infinity)
Also, to avoid all these infinity deals, usually what's best is to see if you reach a fix point after a certain number of iterations.
If I was you, doing a homework assignment, I'd simply do bisection, unless order of convergence and efficiency are THAT important to you.
Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction