/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ /* [ Created with wxMaxima version 13.04.2 ] */ /* [wxMaxima: title start ] Problema [wxMaxima: title end ] */ /* [wxMaxima: comment start ] Viga simplemente apoyada de longitud H y momentos concentrados M en los extremos. Propiedades E, I. Condiciones de contorno y(0)=0, y(H)=0. La ecuación diferencial es E*I*d2y/dx2-M(x)=0 [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ /* Función de prueba y derivadas*/ y(x):=A*sin(%pi*x/H); dy(x):=diff(y(x),x); ddy(x):=diff(dy(x),x); ddy(x); dy(x); assume(H>0); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Solución exacta [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ yexa(x):=M*x/(2*E*I)*(x-H); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Variacional [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ /* Integrando formulación variacional*/ Vr(x):=E*I/2*(dy(x))^2+M*y(x); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Principio variacional*/ PI(A):=integrate(Vr(x),x,0,H); PI(A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Minimización respecto a coeficientes*/ dVar(A):=diff(PI(A),A); dVar(A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /*Resolver A*/ Avar:solve(dVar(A)=0,A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Avar:ev(A,Avar[1]); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Avar; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Aproximación variacional*/ yvar(x):=Avar*sin(%pi*x/H); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Residuo [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ R(x):=E*I*ddy(x)-M; R(x); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Colocación [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ Sub(A):=subst(H/2, x, R(x)); Sub(A); Acol:solve(Sub(A)=0,A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Acol:ev(A,Acol[1]); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Aproximación colocación*/ ycol(x):=Acol*sin(%pi*x/H); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Subdominio [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ Subdom(A):=integrate(R(x),x,0,H); Subdom(A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Asub:solve(Subdom(A)=0,A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Asub:ev(A,Asub[1]); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Aproximación subdominio*/ ysub(x):=Asub*sin(%pi*x/H); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Galerkin [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ Ga(A):=integrate(sin(%pi*x/H)*R(x),x,0,H); Aga:solve(Ga(A)=0,A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Aga:ev(A,Aga[1]); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Aproximación Galerkin*/ ygal(x):=Aga*sin(%pi*x/H); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Minimos cuadrados [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ Er(A):=integrate(R(x)^2,x,0,H);Er(A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ dEr(A):=diff(Er(A),A);dEr(A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Alsq:solve(dEr(A)=0,A); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ Alsq:ev(A,Alsq[1]); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Aproximación M.C.*/ ylsq(x):=Alsq*sin(%pi*x/H); /* [wxMaxima: input end ] */ /* [wxMaxima: title start ] Evaluar funciones [wxMaxima: title end ] */ /* [wxMaxima: input start ] */ E:2e6;M:1;I:5e-6;H:2; plot2d ([yexa(x),yvar(x),ycol(x),ysub(x),ygal(x),ylsq(x)], [x, 0, 2], [legend,"exacta","variacional","colocación","sub","gal","ls"], [style,lines])$ /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ yvar(x); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ ygal(x); /* [wxMaxima: input end ] */ /* Maxima can't load/batch files which end with a comment! */ "Created with wxMaxima"$