MAPLE Worksheet: MAPLE_Lab1.mw 

Math 115 

LAB 1:  Verifying and Visualizing Solutions to PDE's 

Andrew J. Bernoff 

Harvey Mudd College 

 

A Solution to the Convection Equation 

 

> restart:
 

> with(plots):
 

> F:=x->exp(-x^2);
 

proc (x) options operator, arrow; exp(`+`(`-`(`*`(`^`(x, 2))))) end proc
 

> plot(F(x),x=-2..2);
 

Plot_2d
 

> u:=F(x-c*t);
 

exp(`+`(`-`(`*`(`^`(`+`(x, `-`(`*`(c, `*`(t)))), 2)))))
 

> ut:=diff(u,t);ux:=diff(u,x);
 

 

`+`(`*`(2, `*`(`+`(x, `-`(`*`(c, `*`(t)))), `*`(c, `*`(exp(`+`(`-`(`*`(`^`(`+`(x, `-`(`*`(c, `*`(t)))), 2))))))))))
`*`(`+`(`-`(`*`(2, `*`(x))), `*`(2, `*`(c, `*`(t)))), `*`(exp(`+`(`-`(`*`(`^`(`+`(x, `-`(`*`(c, `*`(t)))), 2)))))))
 

> PDE:=ut+c*ux;simplify(PDE);
 

 

`+`(`*`(2, `*`(`+`(x, `-`(`*`(c, `*`(t)))), `*`(c, `*`(exp(`+`(`-`(`*`(`^`(`+`(x, `-`(`*`(c, `*`(t)))), 2))))))))), `*`(c, `*`(`+`(`-`(`*`(2, `*`(x))), `*`(2, `*`(c, `*`(t)))), `*`(exp(`+`(`-`(`*`(`^`...
0
 

> c:=1;u;
 

 

1
exp(`+`(`-`(`*`(`^`(`+`(x, `-`(t)), 2)))))
 

> u1:=subs(t=0,u);u2:=subs(t=1,u);u3:=subs(t=2,u);
 

 

 

exp(`+`(`-`(`*`(`^`(x, 2)))))
exp(`+`(`-`(`*`(`^`(`+`(x, `-`(1)), 2)))))
exp(`+`(`-`(`*`(`^`(`+`(x, `-`(2)), 2)))))
 

> plot({u1,u2,u3},x=-5..5,color=[red,blue,green]);
 

Plot_2d
 

> plot3d(u,x=-6..6,t=0..2,axes=boxed);
 

Plot_2d
 

> animate(u,x=-6..6,t=0..2);
 

Plot_2d
 

A Solution to Laplace's Equation 

 

> restart:
 

> with(plots):
 

> Phi:=exp(-x)*cos(y);
 

`*`(exp(`+`(`-`(x))), `*`(cos(y)))
 

> Phi_xx:=diff(Phi,x$2);Phi_yy:=diff(Phi,y$2);
 

 

`*`(exp(`+`(`-`(x))), `*`(cos(y)))
`+`(`-`(`*`(exp(`+`(`-`(x))), `*`(cos(y)))))
 

> PDE:=Phi_xx+Phi_yy;
 

0
 

> plot3d(Phi,x=0..1,y=0..2*Pi,axes=frame);
 

Plot_2d
 

A Fourier Series 

 

> restart:
 

> with(plots):
 

> h:=N->2*sum((-1)^(m+1)*sin(m*x)/m,m=1..N);
 

proc (N) options operator, arrow; `+`(`*`(2, `*`(sum(`/`(`*`(`^`(-1, `+`(m, 1)), `*`(sin(`*`(m, `*`(x))))), `*`(m)), m = 1 .. N)))) end proc
 

> h2:=h(2);h4:=h(4);h8:=h(8);h16:=h(16);h32:=h(32);
 

 

 

 

 

`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))))
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))))
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
`+`(`*`(2, `*`(sin(x))), `-`(sin(`+`(`*`(2, `*`(x))))), `*`(`/`(2, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(4, `*`(x))))))), `*`(`/`(2, 5), `*`(sin(`+`(`*`(5, `*`(x))))))...
 

> plot({x,h2,h4,h8,h16,h32},x=0..Pi);
 

Plot_2d
 

>