necesito programa del metodo biseccion en C

raulantonio16
10 de Junio del 2006
necesito el programa en C del metodo de biseccion, de interopolacion lineal, newton-raphson, y segundo orden de newton, por favor ayudenme porfavor

Noel Solw
10 de Junio del 2006
te envio un programa del metodo de biseccion en c++.
creo que no tendras demasidado problemas en pasarlo a c.


// program k2c6a.CPP - page 39
// numerical solution - bisection
// solve the equation : 2*sin(n) + 2ü - eü/10 = 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.001;

double f(double x)
{
return 2*sin(x) + pow(x,2) - exp(x)/10;
} // 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 : 2*sin(n) + 2ü - eü/10 = 0"
<< " aproximation = " << aprox << endl << endl;
double b = FindRootArea();
double a = b-1;
double x = Process(a,b);
cout << endl << endl;
cout << "x = " << x << setw(15) << "f(" << x << ") = " << f(x) << endl;
cout << endl << endl;
getch();
} // MAIN

/*
numerical solution - bisection

solve the equation : 2*sin(n) + 2ü - eü/10 = 0 aproximation = 0.001

0 0.5 1 1
0 0.25 0.5 0.5
0 0.125 0.25 0.25
0 0.0625 0.125 0.125
0 0.03125 0.0625 0.0625
0.03125 0.04688 0.0625 0.03125
0.04688 0.05469 0.0625 0.01563
0.04688 0.05078 0.05469 0.00781
0.05078 0.05273 0.05469 0.00391
0.05078 0.05176 0.05273 0.00195
0.05078 0.05127 0.05176 0.00098


x = 0.05127 f(0.05127) = -0.00014
*/