Powered By Blogger

martes, 11 de diciembre de 2012

REGLA FALSA


#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>

//void IniciarGraficos();
//void Portada (int entrada);


void main ()
{
textbackground(BLACK);
textcolor(WHITE);
double long s;
double Xr, AXr, Xi, Xu, Fx, FXi, FXr, FXuA, FXiA, Erpa, Erpv, Es;
double const Vv = 0.56714329;
int j,i;
float k1[20],k2[20];
char resp;
int entrada = 1;
int gdriver = DETECT,gmode,errorcode;
//closegraph ();
do
{
clrscr ();
cout<<"\n\t\t\t METODO DE REGLA FALSA";
cout<<"\n\n\n\n\t\t La funcion es:";
cout<<"\n\n\t\t\t\t Fx = (e^-(x)) - x";
cout<<"\n\n\n ®Cuales son tus valores iniciales?:";
cout<<"\n\n\t Xi: ";
cin>>Xi;
cout<<"\n\t Xu: ";
cin>>Xu;
cout<<"\n\t       Cifras significativas: ";
cin>>s;
if(s<4)
{
cout<<"\n\n En Analisis, para un calculo permitido se requiere como minimo 4 cifras significativas";
getch(); }
else
{
Es=(0.5*pow(10,(2-s)));
AXr = 0;
cout<<"\n\t Confirmando Es="<<Es<<endl;
j = 0;
do
{
j++;
cout<<"\n\n"<<j<<"¯  Iteracion";

FXuA = pow(M_E,-(Xu))-Xu;

FXiA = pow(M_E,-(Xi))-Xi;

Xr = Xu - ((FXuA*(Xi-Xu))/(FXiA-FXuA));

cout<<"\n\n\t Xr: "<<Xr;

FXr = pow(M_E,-(Xr))-Xr;
cout<<"\n\n\t fXr: "<<FXr;

Fx = FXiA * FXr;
cout<<"\n\n\t F(Xi)(Xr) = "<<Fx;
k1[j]=Xi;
k2[j]=FXiA;

if (Fx > 0)
Xi = Xr;

else
Xu = Xr;


Erpv = ((Vv-Xr)/Vv)*100;

if (Erpv<0)
Erpv*=-1;
cout<<"\n\n\t\t Erpv: "<<Erpv;

Erpa = ((Xr - AXr)/Xr)*100;

if (Erpa<0)
Erpa*=-1;

cout<<"\n\n\t\t Erpa: "<<Erpa;

AXr = Xr;
getch ();

}
while (Erpa>=Es);

cout<<"\n\n\n\t Erpa < Es ->  FIN DEL PROCESO";
cout<<"\n\n\t\t\t\t DESEA REPETIR?: ";
cin>>resp;

}
}
while (resp=='s'||resp=='S');
entrada = 2;
 }
//cout<<j;
getch();

/*initgraph(&gdriver, &gmode, "C:\\TC\\BGI");


errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Pulse una tecla para salir");
getch();
exit(1);
}
setcolor(15);
line(320,0,320,480);
line(0,240,640,240);
Es=(0.5*pow(10,(2-s)));
AXr = 0;
cout<<"\n\t Confirmando Es="<<Es<<endl;
j = 0;

do
{
j++;
//cout<<"\n\n"<<j<<"¯  Iteracion";

FXuA = pow(M_E,-(Xu))-Xu;

FXiA = pow(M_E,-(Xi))-Xi;

Xr = Xu - ((FXuA*(Xi-Xu))/(FXiA-FXuA));

//cout<<"\n\n\t Xr: "<<Xr;

FXr = pow(M_E,-(Xr))-Xr;
//cout<<"\n\n\t fXr: "<<FXr;

Fx = FXiA * FXr;
//cout<<"\n\n\t F(Xi)(Xr) = "<<Fx;
putpixel(320+(10*Xi),240+(10*FXiA),15);
if (Fx > 0)
Xi = Xr;

else
Xu = Xr;


Erpv = ((Vv-Xr)/Vv)*100;

if (Erpv<0)
Erpv*=-1;

 // cout<<"\n\n\t\t Erpv: "<<Erpv;

Erpa = ((Xr - AXr)/Xr)*100;

if (Erpa<0)
Erpa*=-1;

//cout<<"\n\n\t\t Erpa: "<<Erpa;

AXr = Xr;
getch ();
} while (Erpa>=Es);

outtextxy(10,10,"INSTITUTO POLITECNICO NACIONAL");
getch();
}
closegraph();*/




void Portada (int entrada)
{
int i,x,y;
setbkcolor(1);
 }

No hay comentarios:

Publicar un comentario