kill(all)$

solve pde (part 7), use laplace transform. 'version 1.0'
peter.vlasschaert@gmail.com,11/12/2018

load 'packages'
------------------------

load(orthopoly)$
load(lrats)$
load(facexp)$
load(odes)$

load("C:/math/laplaceInv.mac");

assume(s>0);

pde : diff(u(x,t),x,2) - diff(u(x,t),t,2) =0, t > 0
           =========================================
           domain : x >0 , t > 0
           =========================================

 ==============================================

BC :   u(0,t)  =0
IC   :   u(x,0) =0

  =============================================

eq:diff(u(x,t),t,2) - diff(u(x,t),x,2) = 0;
ic : [u(x,0) = 0,at(diff(u(x,t),t),t=0) =0];
bc :[u(0,t)  =sin(%pi*t)];

bc[1];

assume(x>0,t>0);

solve : pde with bc,ic
--------------------------------

1e) laplace transformation 'eq'
=========================

p1:laplace(eq,t,s);

p1a:laplace(u(x,t),t,s) =v;

2e) subst ic into 'p1'
=================

p2:subst([ic[1],ic[2],p1a],p1);

3e) solve ode2 , 'p2'
================

p3:ode2(p2,v,x);

find : %c
-----------------------------------------------------------------------
BC:   u(0,t)  =0    x=0  => v=laplace(rhs(bc[1]),t,s)
-----------------------------------------------------------------------

p3a:subst([x=0,v=laplace(rhs(bc[1]),t,s)],p3);

?  What now : BC  
=> {%k1 = 0, %k2 ≠ 0} or {%k1 ≠ 0,%k2 = 0}

p3b:rhs(p3a) = lhs(p3a);

4e) inverse laplace transform 'p3d'
=============================

a)  {%k1 = 0, %k2 ≠ 0} 

p4:subst([%k1=0],p3b);

p4a:subst([%k1=0,p4],p3);

p4b:u(x,t)=laplaceInv(rhs(p4a),s,t);

b)  {%k1 ≠ 0,%k2 = 0}

p5:subst([%k2=0],p3b);
p5a:subst([%k2=0,p5],p3);
p5b:u(x,t)=laplaceInv(rhs(p5a),s,t);

5e) check the solution
===================

check a ?
========

p6:subst([p4b],eq);

p6a:ev(p6,nouns);

I can't check the solution :easy way.

check b ?

p7:subst([p5b],eq);
p7a:ev(p7,nouns);
p7b:is(p7a);

draw solution : 'wxplot3d'
======================

=> a)
====

sol:rhs(p4b);

wxplot3d(sol,[x,0,2*π],[t,0,2*π],[azimuth,150],[elevation,45]);

=>  b)
====

sol1:rhs(p5b);
wxplot3d(sol1,[x,0,2*π],[t,0,2*π],[azimuth,150],[elevation,45]);

draw 2d
=======

a =>
====

define(u(x,t),sol);

set_draw_defaults(
xrange=[0,2*π],yrange=[-1,1],ytics = 1/2,color = red,grid = true)$

s1:gr2d(title="u(x,1)",explicit(u(x,1),x,0,2*π))$
s2:gr2d(title="u(x,2)",explicit(u(x,2),x,0,2*π))$
s3:gr2d(title="u(x,3)",explicit(u(x,3),x,0,2*π))$
s4:gr2d(title="u(x,4)",explicit(u(x,4),x,0,2*π))$

wxdraw(s1,s2,s3,s4,columns=2)$

b =>
====

define(uu(x,t),sol1);

set_draw_defaults(
xrange=[0,2*π],yrange=[-1,1],ytics = 1/2,color = blue,grid = true)$

ss1:gr2d(title="uu(x,1)",explicit(uu(x,1),x,0,2*π))$
ss2:gr2d(title="uu(x,2)",explicit(uu(x,2),x,0,2*π))$
ss3:gr2d(title="uu(x,3)",explicit(uu(x,3),x,0,2*π))$
ss4:gr2d(title="uu(x,4)",explicit(uu(x,4),x,0,2*π))$

wxdraw(ss1,ss2,ss3,ss4,columns=2)$

u(1,2);uu(1,2);

remfunction(u,uu);

test  ?

u(1,2);uu(1,2);

'-------------------------------------------------------------------------------------------------------------------------------------------'