|
-
April 4th, 2008, 08:27 AM
#1
Problem with Bissection method
Hello.
First sorry for bad English.
Can somebody help me with this:
Using Bisection method find one real root for
f(x)=x^9-x^7+2x^2-1 x E [0;1]
I have to write a program in c++ witch founds me the root.
The problem is that I am begginer in c++ and it is very difficult to me.
this is what i can do sad.gif but it is very ugly and it doesn't work.can someone fix it and make it good arranged and beauty.Please help me.
double F( double x){return x*x*x*x*x*x*x*x*x -x*x*x*x*x*x*x + 2*x*x - 1;}
double L = -100 , R = 100;
for(int i = 0; i < 1000; i++) // to make a 1000 steps
{
double Mid = (L + R) / 2;
double current_value = F(Mid );
if( current_value== 0 ) cout<<"root is: " <<Mid;
if (current_value < 0 ) L = mid;
else if (current_value> 0 ) R = mid;
}
I know that it may be very stupid and wrong but please help me
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
|