# Oct. 22, 2002 # Solutions to the wave equation u_tt=4u_xx using D'Alembert's solution. # # > f:=x->piecewise(x<-Pi,0,x plot(f(x),x=-10..10); # # The function u below solves the wave equation, and has initial # velocity equal to zero. # > u:=(x,t)->(f(x+2*t)+f(x-2*t))/2; > plot([u(x,0),u(x,2),u(x,15)],x=-40..40,color=[red,green,blue]); # # The function uu below solves the wave equation, and has initial # position equal to zero. # > uu:=(x,t)->(0.25)*Int(f(s),s=x-2*t..x+2*t); > plot([uu(x,0),uu(x,2),uu(x,15),uu(x,0.25)],x=-40..40,color=[red,green, > blue,black]); # # The following lines were used to compute the Rayleigh quotient for the # function h, with p(x) being k. # > k:=x->piecewise(x<0,0,x<1/2,1,x<1,2,0); > h:=(1-x)*x^2; > Int(k(x)*diff(h,x)^2,x=0..1)/Int(h^2,x=0..1):evalf(%); >