Metodo pegaso

Páginas: 2 (346 palabras) Publicado: 30 de marzo de 2011
/*ESTE PROGRAMA CALCULA LAS RAICES DE UNA ECUACION DADA,POR EL METODO DE PEGASO*/
#include <stdio.h>
#include <math.h>
void leer_datos(),pegaso(),imprimir();
double f(doublex),ERROR,tolerancia,a,b,raiz;
unsigned int niteraciones,contador;
main()
{
leer_datos();
pegaso();
imprimir();
return (0);
}
void leer_datos()
{
printf("\n\tESTE PROGRAMA CALCULA LA RAIZDE UNA ECUACION OCUPANDO EL METODO DE PEGASUS\n");
printf("\n\tINGRESE EL INTERVALO DONDE QUIERE ENCONTRAR LA RAIZ\n");
printf("\n\ta=");
scanf("%lf",&a);printf("\n\tb=");
scanf("%lf",&b);
printf("\n\tTolerancia=");
scanf("%lf",&tolerancia);
printf("\n\t# Maximo de Iteraciones=");
scanf("%u",&niteraciones);
}double f(double x)
{
return(pow(x,2.0)-sin(x));
}
void pegaso()
{
ERROR=1.0;
contador=0;
double W=a,T=b,K,U,S,R;
while (ERROR>tolerancia && contador<niteraciones)
{contador++;
S=f(T);
U=f(W);
K=T-((S*(T-W))/(S-U));
raiz=K;
R=f(K);
ERROR=fabs(R);
if(R*S==0)
{
T=K;
S=R;
}if(R*S<0)
{
W=T;
U=S;
}
if(R*S>0)
{
W=T;
U=((U*S)/(S+R));
}
W=T;
T=K;
printf("\nIteracion=%uRaiz=%12.18lf Error=%12.18lf",contador,raiz,ERROR);
}
}

void imprimir()
{
printf("\n\n************************RESULTADO*****************************\n");printf("\nRaiz=%12.18lf",raiz);
printf("\nError=%12.18lg ",ERROR);
printf("\nEn la Iteracion=%u",contador);
printf("\n**************************************************************\n\n");

}ESTE PROGRAMA CALCULA LA RAIZ DE UNA ECUACION OCUPANDO EL METODO DE PEGASUS

INGRESE EL INTERVALO DONDE QUIERE ENCONTRAR LA RAIZ

a=0.5

b=1

Tolerancia=1e-8...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Método de pegaso
  • PEGASO
  • pegaso
  • pegaso
  • Pegaso
  • satelite pegaso
  • La Leyenda De Pegaso
  • el señor pegaso

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS