aca tambien tienen un link con el archivo (.cpp, lei las reglas ) quisiera que elguien lo probara por si mismo para que vea lo que pasa http://www.mediafire.com/?f8yn9o2oksk4794
Código
# include <stdio.h> # include <conio.h> # include <windows.h> # include <math.h> # include <string.h> main(void) { int opcion,j,i,fun; float a,b,es,x,p,fp,fa,fb,p1,ea,x0,fp1,fx,fx0,xi1,mat[3][4],a1,a2,a3,b1,b2,b3,ea1,ea2,ea3,pa[5],ln0,ln2,ln3,ln1,ln4,co1,co2,co3,co4,co0; float ex0,ex1,ex2,ex3,ex4,l1,l2,l3,l4,l0,l5,xi2,ln,Ln,LN,Cos,COS,Exp,EXP,va[10],vv,suma,n,f0,func[10],h,con,sum,I; system ("color 0a"); printf("\nMENU\n"); printf(" \n"); printf("1.-Newton Raphson\n"); printf("2.-Gauss Seidel\n"); printf("Ingrese su Opcion\n"); scanf("%d",&opcion); switch(opcion) { case 1: printf("Ha seleccionado: Newton Raphson\n"); printf("La Ecuacion a Evaluar sera: x^2*E^x\n"); printf("F'(x)=2x*E^x\n"); printf("Ingrese x0:\n"); scanf("%f",&x0); printf("Ingrese la Tolerancia:\n"); scanf("%f",&es); do { printf("\n--------------------------------------\n"); fx=pow(x0,2)*exp(x0); fx0=(2*x0)*exp(x0); if (fx0!=0) { printf("el valor de F(x): %.4f\n",fx); printf("el valor de F'(x): %.4f\n",fx0); xi1=x0-(fx/fx0); printf("el valor de xi+1: %.4f\n",xi1); ea=fabs((xi1-x0)/xi1)*100; printf("El valor relativo fue: %.4f \%",ea); } else { printf("Ya que F'(x)=0, no se puede aplicar el metodo\n"); } printf("\n--------------------------------------\n"); x0=xi1; fx=pow(x0,2)*exp(x0); fx0=(2*x0)*exp(x0); if (fx0!=0) { printf("el valor de F(x): %.4f\n",fx); printf("el valor de F'(x): %.4f\n",fx0); xi2=x0-(fx/fx0); printf("el valor de xi+1: %.4f\n",xi2); } else { printf("Ya que F'(x)=0, no se puede aplicar el metodo\n"); } ea=fabs((xi2-x0)/xi2)*100; printf("El valor relativo fue: %.4f \%",ea); printf("\n--------------------------------------\n"); }while (ea>es); break; case 2: printf("Ha seleccionado Gauss Seidel\n"); printf("Ingrese la Matriz 3x4\n"); for(i=1;i<=3;i++) for(j=1;j<=4;j++) { printf("Ingrese el elemento %d,%d de la matriz:", i,j); scanf("%f",&mat[i][j]); } printf("La matriz generada fue:\n"); for(i=1;i<=3;i++) { for (j=1;j<=4;j++) { printf("\t%f",mat[i][j]); } printf("\n"); } printf("Ingrese la Tolerancia:\n"); scanf("%f",&es); do { printf("\n--------------------------------------\n"); a1=mat[1][4]-((mat[1][2]+mat[1][3])/mat[1][1]); a2=mat[2][4]-((mat[2][1]+mat[2][3])/mat[2][2]); a3=mat[3][4]-((mat[3][1]+mat[3][2])/mat[3][3]); printf("el valor de X1 fue: %.4f\n",a1); printf("el valor de X2 fue: %.4f\n",a2); printf("el valor de X3 fue: %.4f\n",a3); ea1=fabs((b1-a1)/b1)*100; ea2=fabs((b2-a2)/b2)*100; ea3=fabs((b3-a3)/b3)*100; printf ("Ea1=%.2f\n",ea1); printf ("Ea2=%.2f\n",ea2); printf ("Ea3=%.2f\n",ea3); printf("\n--------------------------------------\n"); b1=mat[1][4]-(((mat[1][2]*a2)+(mat[1][3]*a3))/mat[1][1]); b2=mat[2][4]-(((mat[2][1]*b1)+(mat[2][3]*a3))/mat[2][2]); b3=mat[3][4]-(((mat[3][1]*b1)+(mat[3][2]*b2))/mat[3][3]); ea1=fabs((b1-a1)/b1)*100; ea2=fabs((b2-a2)/b2)*100; ea3=fabs((b3-a3)/b3)*100; printf("el valor de X1 fue: %.4f\n",b1); printf("el valor de X2 fue: %.4f\n",b2); printf("el valor de X3 fue: %.4f\n",b3); printf ("Ea1=%.2f\n",ea1); printf ("Ea2=%.2f\n",ea2); printf ("Ea3=%.2f\n",ea3); }while ((ea1>es) and (ea2>es) and (ea3>es)); break; getch ();