# Laplace transform; laplace(y_,x_,s_,c_):=replace(laplace(y,x,s),s,c); laplace(a_ and b_,x_,s_):=laplace(a,x,s) and laplace(b,x,s); laplace(a_=b_,x_,s_):=laplace(a,x,s)=laplace(b,x,s); laplace(a_+b_,x_,s_):=laplace(a,x,s)+laplace(b,x,s); laplace(x(n_,x_), x_,s_) := s^n*x(s)-if(n==-1,x(0)/s,sum(s^(n-k-1)*x(k,0),k,0,ceil(n)-1) ); laplace(x(x_), x_,s_) := x(s); laplace(y(n_,x_), x_,s_) := s^n*y(s)-if(n==-1,y(0)/s,sum(s^(n-k-1)*y(k,0),k,0,ceil(n)-1) ); laplace(y(x_), x_,s_) := y(s); laplace(int(y(x_),x_),x_,s_):=y(s)/s-y(0)/s; laplace(integrate(y(t_),t_,0,x_),x_,s_):=y(s)/s; laplace(e^x_*y_, x_,s_) := replace(laplace(y,x,s),s,(s-1)); laplace(e^(a_*x_)*y_, x_,s_) := replace(laplace(y,x,s),s,(s-a)); laplace(e^x_*c_, x_,s_) := replace(laplace(c,x,s),s,(s-1)); laplace(e^(a_*x_)*c_, x_,s_) := replace(laplace(c,x,s),s,(s-a)); laplace(x_*y(x_), x_,s_) := -ds(y(s),s); laplace(x_^n_*y(x_), x_,s_) := (-1)^n*d(y(s),s,n); laplace(E(a_,x_^a_),x_,s_):=s^(a-1)/(s^a-1); laplace(E(a_,c_*x_^a_),x_,s_):=if(hasnot(c,x), s^(a-1)/(s^a-c)); laplace(E(a_,b_,x_^a_)*x_^p_,x_,s_):=if(p==b-1, s^(a-1)/(s^a-1)); laplace(E(a_,b_,c_*x_^a_)*x_^p_,x_,s_):=if(hasnot(c,x) and p==b-1, s^(a-1)/(s^a-c)); laplace(1/(1+x_), x_,s_) := -exp(s)*Ei(-s); laplace(1/(1+a_*x_), x_,s_) := -exp(s/a)*Ei(-s/a)/a; laplace(sinh(a_*x_), x_,s_) := if(isfree(a,x),a/(s^2-a^2)); laplace(cosh(a_*x_), x_,s_) := if(isfree(a,x),s/(s^2-a^2)); laplace(sinh(x_), x_,s_) := 1/(-1+s^2); laplace(cosh(x_), x_,s_) := s/(-1+s^2); #laplace(sin(x_)*e^x_, x_,s_) := 1/(s^2 -2s+2); #laplace(cos(x_)*e^x_, x_,s_) := (s-1)/(s^2 -2s+2); #laplace(sin(x_)*e^(b_*x_), x_,s_) := 1/(s^2 -2b*s+b+1); #laplace(cos(x_)*e^(b_*x_), x_,s_) := (s-b)/(s^2 -2b*s+b+1); laplace(sin(x_)*x_, x_,s_) := 2s/(s^2 + 1)^2; laplace(cos(x_)*x_, x_,s_) := (s^2-1)/(s^2 + 1)^2; laplace(sin(a_*x_), x_,s_) := if(isfree(a,x),a/(s^2+a^2)); laplace(cos(a_*x_), x_,s_) := if(isfree(a,x),s/(s^2+a^2)); laplace(sin(x_), x_,s_) := 1/(1+s^2); laplace(cos(x_), x_,s_) := s/(1+s^2); laplace(log(x_), x_,s_) := -(log(s)+gamma)/s; laplace(x_^n_, x_,s_) := if(n > -1, n!/s^(n+1)); laplace(sqrt(x_), x_,s_) := sqrt(pi)/2/s^(3/2); laplace(1/sqrt(x_), x_,s_) := sqrt(pi/s); laplace(e^(a_*x_), x_,s_) := if(isfree(a,x),1/(s-a)); laplace(e^(a_*x_)*x_, x_,s_) := if(isfree(a,x),1/(s-a)^2); laplace(e^(a_*x_)*x_^n_, x_,s_) := if(n> -1 and isfree(a,x),n!/(s-a)^(1+n)); laplace(e^x_, x_,s_) := 1/(s-1); laplace(e^x_*x_, x_,s_) := 1/(s-1)^2; laplace(e^x_*x_^n_, x_,s_) := if(n> -1,n!/(s-1)^(1+n)); laplace(e^(-x_^2),x_,s_):= sqrt(pi)/2*exp(s^2/4)*erfc(s/2); laplace(delta(x_+c_),x_,s_) := exp(c*s); laplace(delta(x_),x_,s_) := 1; laplace(x_,x_,s_) := 1/s^2; laplace(y_,x_):=laplace(y,x,s); laplace(y_,x_=c_):=replace(laplace(y,x,s),s,c); laplace(y_):=laplace(y,x,x);