solucion
dsolve({(diff(y(x), x))/y(x)^2 = -e^cos(x)*sin(x)}); print(`output redirected...`); # input placeholder ln(e) |y(x) = ------------------- cos(x) _C1 ln(e) - e
videotutoriales de matlab, octave, numpy, python, POA, algoritmia, simulacion de procesos en ingenieria quimica, y algo de ingenieria quimica
dsolve({(diff(y(x), x))/y(x)^2 = -e^cos(x)*sin(x)}); print(`output redirected...`); # input placeholder ln(e) |y(x) = ------------------- cos(x) _C1 ln(e) - e
function lotecomplejo [t,x]=ode45(@lote,[0 2],[16 0 0 0]) subplot(4,1,1); plot(t,x(:,1)) subplot(4,1,2); plot(t,x(:,2)) subplot(4,1,3); plot(t,x(:,3)) subplot(4,1,4); plot(t,x(:,4)) function dx=lote(t,x) % definicion de parametros k1=5; k2=4; k3=3; k4=3; dx=zeros(4,1); % ecuaciones de diseño (balances de masa), x1 = Ca, x2 = Cb, x3 = Cc, x4 = Cd dx(1) = - k1*x(1); dx(2) = k1*x(1) - k2*x(2) + k3*x(3) - k4*x(2); dx(3) = k2*x(2) - k3*x(3); dx(4) = k4*x(2);
function []=regu_fal(x1, x2, n); fx1=f(x1); fx2=f(x2); c = x2 - ((f(x2)*(x2-x1))/(f(x2) - f(x1))) fc=f(c) if fx1*fx2<0; for i=1:n if fc<0 x1=c; fx1=f(x1); c = x1 - (fx1*(x1-x2)/(fx1-fx2)) fc = f(c) else x2=c; fx2=f(x2); c = x2 - (fx2*(x2-x1)/(fx2-fx1)) fc = f(c) end end else disp('Error en los Valores X1, X2'); end end
function fx = f(x); fx = x^3-9*x+1; %% puedes cambiar por la funcion que gustes return;
#include<stdio.h> #include<conio.h> #include<math.h> #include<process.h> #include<string.h> void main(){ int n; int i,j; float ax[10]; float ay[10]; float y=0; float x; float h; float p; float diff[20][20]; float y1,y2,y3,y4; printf("\n Numero de Terminos: "); scanf("%d",&n); printf("\n\n Valor de X: "); for(i=0;i<n;i++){ printf("\n\n Valor de x%d: ",i+1); scanf("%f",ax[i]); } printf("\n\n Valor de Y: "); for(j=0;j<n;j++){ printf("\n\n Valor de y%d: ",i+1); scanf("%f",ay[i]); } printf("\n Valor para x: "); printf("\n Valor para y: "); scanf("%f",&x); h = ax[1]-ax[0]; for(i=0;i<n-1;i++){ diff[i][1]=ay[i+1]-ay[i]; } for(j=2;j<=4;j++){ for(i=0;i<n-j;i++){ diff[i][j]=diff[i+1][j-1]-diff[i][j-1]; } } i=0; do{ i++; }while(ax[i]<x); i--; p=(x-ax[i])/h; y1= p*diff[i-1][1]; y2=p*(p+1)*diff[i-1][2]/2; y3=(p+1)*p*(p-1)*diff[i-2][3]/6; y4 = (p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24; y =ay[i]+y1+y2+y3+y4; printf(" x= %6.4f, y= 6.4%f ",x,y); printf("\n\n\n Enter para Salir"); getch(); }
#include<stdio.h> #include<string.h> #include<conio.h> #include<math.h> #include<process.h> #define f(x) 3*x -cos(x) -1 #define df(x) 3 -sin(x) void nwrap(); void main(){ printf("\n Solucion por el Método de Newton Raphson \n"); printf("\n F(x): "); printf("\n\t\t\t 3*x -cos(x) -1 = 0 \n\t"); nwrap(); getch(); } void nwrap(){ float x1,x0; float f1,f0; float df0; int i=0, itr=0; float TOL; float error; for(x1=0;;x1 +=0.01){ f1=f(x1); if (f1>0){ break; } } x0 = x1-0.01; f0 = f(x0); printf("Numero de Iteraciones: "); scanf("%d",&itr); printf("Tolerancia Maxima: "); scanf("%f",&TOL); if(fabs(f0)>f1){ printf("\n\t\t La raiz es: %0.4f\n",x1); } if(f1 > fabs(f(x0))){ printf("\n\t\t La raiz es: %0.4f\n",x1); } x0 = (x0+x1)/2; for(;i<=itr;i++){ f0=f(x0); df0=df(x0); x1 = x0 - (f0/df0); printf("\n\t\t iteracion %d aproximacion: %f",i,x1); error = fabs(x1-x0); if(error < TOL){ break; } x0 = x1; } if(error > TOL){ printf("\n\n\t Iteraciones No suficientes" ); } printf("\n\n\n\t\t\t--------------------------"); printf("\n\n\t\t Raiz: %0.4f ",x1); printf("\n\n\n\t\t\t--------------------------"); }
# include <stdio.h> # include <math.h> # include<conio.h> # include<string.h> # include<process.h> #define TOL 0.000005 #define f(x) 3*x+sin(x)-exp(x) void falsaposicion(); void main() { printf("\n Solucion por el metodo de Falsa posicion \n"); printf("\n La Ecuacion a resolver es: "); printf("\n\t\t\t 3*x+sin(x)-exp(x)= 0 \n\n"); falsaposicion(); } void falsaposicion(){ float f0,f1,f2; float x0,x1,x2; int itr; int i; printf("Numero Maximo de Iteracciones: "); scanf("%d",&itr); for(x1=0.0;;){ f1=f(x1); if (f1>0){ break; } else { x1 = x1+0.1; } } x0= x1-0.1; f0 = f(x0); printf("\n\t\t----------------------------------------"); printf("\n\t\t Iteraccion\t x\t\t F(X) \n"); printf("\n\t\t----------------------------------------"); for(i=0;i<itr;i++){ x2 = x0-((x1-x0)/(f1-f0))*f0; f2=f(x2); if(f0*f2>0){ x1=x2; f1=f2; } else { x0=x2; f0=f2; } if (fabs(f(2))>TOL){ printf("\n\t\t%d\t%f\t%f\n",i+1,x2,f2); } } printf("\t\t--------------------------------"); printf("\n\t\t\t Raiz= %f\n",x2); printf("\t\t------------------------------"); getch(); }
Ejecutando:# include<stdio.h> # include<conio.h> # include<math.h> # include<process.h> # include<string.h> # define TOL 0.000001 # define F(x) (x)*log10(x) - 1.2 void Bisect(); int i=1, n; float raiz = 1; void main(){ printf("\n Solucion por el Metodo de Biseccion \n"); printf ("\n La ecuacion es: "); printf("\n\t\t\t (x)*log10x) -1.2 = 0 \n\n"); printf("Numero Maximo de Iteracciones: "); scanf ("%d",&n); Bisect(); } void Bisect(){ float x1,x2,x0; float f0,f1,f2; int j=0; for (x2=1;;x2++){ f2 = F(x2); if(f2 >0){ break; } } for (x1=x2-1;;x2--){ f1 = F(x1); if(f1<0){ break; } } printf ("\t\t------------------------------------\t\t"); printf ("\n\t\t Iteracion Raiz \n"); printf("\t\t-------------------------------------\t\t"); for (;i<=n;i++){ x0 = (x1+x2)/2.0; f0 = F(x0); if (f0==0){ raiz = x0; } if(f0*f1<0){ x2=x0; } else{ x1 = x0; f1= f0; } printf("\n\t\t Iteracion %d ", i); printf("\t :\t %f", x0); if(fabs((x1-x2)/x1) < TOL ){ printf("\n\t\t ------------------------------------"); printf("\n\t\t Raiz = %f",x0); printf("\n\t\t Iteracion = %d\n",i); printf("\t\t-------------------------------------"); getch(); exit(0); } } printf("\n\t\t---------------------------------------"); printf("\n\t\t\t Raiz = %7.5f",x0); printf("\n\t\t\t Iteracion = %d\n", i-1); printf("\t\t-----------------------------------------"); getch(); }