metodo de biseccion

mara
11 de Enero del 2006
alguien que me pueda ayudar para programas el metodo de biseccion!!!!! mi corre es [email protected] o [email protected]
cualquiera de esos dos de verdd lo necesito

Noel Solw
11 de Enero del 2006
// program k2c6b.CPP - page 39
// numerical solution - bisection
// solve the equation : x^3 + 7xý + 6x - 14 = 0.
// 7/7/2001
// written in Borland CPP ver 3.1

#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <math.h>

const double aprox = 0.0001;
const char *sign[2] = {\\\\\\\" - \\\\\\\",\\\\\\\" + \\\\\\\"};
int a2 = 7, a1 = 6,a0 = -14;

double f(double x)
{
return ((x+a2)*x+a1)*x+a0;
} // F

int FindRootArea()
{
double previous = f(0);
for(int x = 1;; x++)
{
double now = f(x);
if(previous*now <= 0)
break;
previous = now;
}
return x;
} // FIND ROOT AREA

double Process(double a, double b)
{
double c = (a + b)/2;
cout << setw(15) << a << setw(15) << c << setw(15) << b
<< setw(15) << b-a << endl;
if(fabs(a-b)<aprox)
return c;
if(f(a)*f(c) <= 0)
return Process(a,c);
else
return Process(c,b);
} // PROCESS

void main()
{
clrscr();
cout.setf(ios::fixed);
cout << setprecision(5);
cout << \\\\\\\"numerical solution - bisection \\\\\\\" << endl << endl;
cout << \\\\\\\"solve the equation : \\\\\\\" << \\\\\\\"x^3\\\\\\\"
<< sign[a2 > 0] << abs(a2) << \\\\\\\"xý\\\\\\\"
<< sign[a1 > 0] << abs(a1) << \\\\\\\"x\\\\\\\"
<< sign[a0 > 0] << abs(a0) << \\\\\\\" = 0 \\\\\\\"
<< \\\\\\\" aproximation = \\\\\\\" << aprox << endl << endl;
double b = FindRootArea();
double a = b-1;
double x = Process(a,b);
cout << endl;
cout << \\\\\\\"x = \\\\\\\" << x << setw(15) << \\\\\\\"f(\\\\\\\" << x << \\\\\\\") = \\\\\\\" << f(x) << endl;
cout << endl << endl;
getch();
} // MAIN

/*
numerical solution - bisection

solve the equation : x^3 + 7xý + 6x - 14 = 0 aproximation = 0.0001

0 0.5 1 1
0.5 0.75 1 0.5
0.75 0.875 1 0.25
0.875 0.9375 1 0.125
0.9375 0.96875 1 0.0625
0.96875 0.98437 1 0.03125
0.98437 0.99219 1 0.01563
0.99219 0.99609 1 0.00781
0.99609 0.99805 1 0.00391
0.99805 0.99902 1 0.00195
0.99902 0.99951 1 0.00098
0.99951 0.99976 1 0.00049
0.99976 0.99988 1 0.00024
0.99988 0.99994 1 0.00012
0.99994 0.99997 1 0.00006

x = 0.99997 f(0.99997) = -0.0007
*/