# inverse Laplace transform; inverselaplace(a_ and b_,s_,x_):=inverselaplace(a,s,x) and inverselaplace(b,s,x); inverselaplace(a_ = b_,s_,x_):=inverselaplace(a,s,x) = inverselaplace(b,s,x); inverselaplace(a_ + b_,s_,x_):=inverselaplace(a,s,x) + inverselaplace(b,s,x); inverselaplace(laplace(a_,x_,s_)*s_^m_, s_,x_) := d(a,x,m); inverselaplace(laplace(a_,x_,s_)*s_, s_,x_) := d(a,x); inverselaplace(x(s_),s_,x_):= x(x); inverselaplace(x(s_)*s_,s_,x_):= d(x(x),x); inverselaplace(x(s_)*s_^n_,s_,x_):= d(x(x),x,n); inverselaplace(y(s_),s_,x_):= y(x); inverselaplace(y(a_+s_),s_,x_):= y(x)*exp(-a*x); inverselaplace(y(s_)*s_,s_,x_):= d(y(x),x); inverselaplace(y(s_)*s_^n_,s_,x_):= d(y(x),x,n); inverselaplace(y(a_+s_)*s_^n_,s_,x_):= E(-n,(-n)!*d(exp(-a*x),x,n)); inverselaplace(log(s_),s_,x_):= -1/x; inverselaplace(log(s_+a_),s_,x_):= -exp(-a*x)/x; inverselaplace(log(s_)*s_^n_,s_,x_):=if(n<0, (-log(x)+logGamma(-n))*x^(-1-n)/gamma(-n)); inverselaplace(log(s_)*s_^(-2),s_,x_):= -log(x)*x-gamma*x+x; inverselaplace(log(s_)/(s_+a_),s_,x_):=if(a<0, exp(-a*x)*(log(-a)-Ei(a*x)) ); inverselaplace((a_+s_)^n_, s_,x_) := if(isfree(a,n,s), exp(-a*x)*x^(-1-n)/(-n-1)!); inverselaplace((a_-s_)^n_, s_,x_) := if(isfree(a,n,s), (-1)^n*exp(a*x)*x^(-1-n)/(-n-1)!); inverselaplace(s_^n_, s_,x_) := if(n==-1, 1,x^(-n-1)/(-n-1)!); inverselaplace(sqrt(s_), s_,x_) := 1/sqrt(pi*x); inverselaplace(sqrt(a_*s_), s_,x_) := if(isfree(a,s), sqrt(a)/sqrt(pi*x) ); inverselaplace(sqrt(a_+s_), s_,x_) := if(isfree(a,s), -1/2*1/sqrt(pi*x^3)*exp(-a*x) ); inverselaplace((a_+s_)^n_*s_, s_,x_) := if(isfree(a,n,s), (-a)*exp(-a*x)*x^(-1-n)/(-n-1)!+exp(-a*x)*x^(-2-n)/(-2-n)!); inverselaplace((a_+s_)^n_*s_^m_, s_,x_) := if(isfree(a,n,m,s), if(n>0 and n==-m-1, exp(-a*x)/n!*d(exp(a*x)*x^n,x,n), d(exp(a*x)*x^n,x,n)/(-n-1)! )); inverselaplace((1+a_/s_)^n_/s_, s_,x_) := if(isfree(a,n,s) and n>0, exp(-a*x)/n!*d(exp(a*x)*x^n,x,n) ); #inverselaplace(s_^b_/(s_^a_+c_),s_,x_) :=if(b==-a, mittag(abs(a),-c*x^abs(a)), x^(-1-b)*mittag(abs(a),-b,-c*x^abs(a))); inverselaplace(s_^b_/(s_^a_+c_),s_,x_) := mittag(abs(a),-c*x^abs(a)); inverselaplace(s_^n_/(a_+s_^2), s_,x_) := if(isfree(a,s), a^((n-1)/2)*sin(n,sqrt(a)*x)); inverselaplace(s_/(a_+s_^2), s_,x_) := if(isfree(a,s), cos(sqrt(a)*x)); inverselaplace(s_/(s_+a_)/(s_+b_), s_,x_) := if(isfree(a,b,s), b*exp(-b*x)/(a-b)-a*exp(-a*x)/(a-b) ); inverselaplace(s_/(c_+b_*s_+s_^2),s_,x_):=if(b*b==4c, exp(-b/2*x)*(1-x),exp(-b/2*x)*(cosh(sqrt(b*b-4c)*x/2)-b*sinh(sqrt(b*b-4c)*x/2)/sqrt(b*b-4c))); inverselaplace((b_+s_)/(a_+(b_+s_)^2),s_,x_):=if(hasnot(a,b,s), cos(sqrt(a)*x)*exp(-b*x)); inverselaplace(1/(c_+s_^a_),s_,x_) := mittag(a,-c*x^a); inverselaplace(1/(c_+b_*s_^a_),s_,x_) := mittag(a,-c/b*x^a)/b; inverselaplace(1/(a_+s_^2), s_,x_) := if(isfree(a,s), sin(sqrt(a)*x)/sqrt(a)); inverselaplace(1/s_/(a_+s_^2), s_,x_) := if(isfree(a,s), -1/a*cos(sqrt(a)*x)); inverselaplace(1/(a_+(b_+s_)^2),s_,x_):=if(hasnot(a,b,s), sin(sqrt(a)*x)/sqrt(a)*exp(-b*x)); inverselaplace(1/(b_*s_+a_), s_,x_) := if(isfree(a,b,s), exp(-a/b*x)/b); inverselaplace(1/(s_+z_), s_,x_) := if(isfree(z,s), exp(-x*z)); #inverselaplace(1/(-s_+a_), s_,x_) := if(isfree(a,s), -exp(a*x)); inverselaplace(1/(s_+a_)/s_, s_,x_) := if(isfree(a,s), 1/a-exp(-a*x)/a ); inverselaplace(1/(a_+s_^0.5), s_,x_) := if(isfree(a,s), 1/sqrt(pi*x)-a*exp(a^2*x)*erfc(a*sqrt(x)) ); inverselaplace(1/(a_+s_)/s_^0.5, s_,x_) := if(isfree(a,s), exp(-a*x)*erf(sqrt(-a*x))/sqrt(-a) ); inverselaplace(1/(a_+s_)/s_^2, s_,x_) := if(isfree(a,s), exp(-a*x)/a^2+x/a-1/a^2); inverselaplace(1/(s_+a_)/(s_+b_), s_,x_) := if(isfree(a,b,s), exp(-b*x)/(a-b)-exp(-a*x)/(a-b) ); inverselaplace(1/(s_+a_)/(s_^2+b_), s_,x_) := if(isfree(a,b,s), exp(-a*x)/(a^2+b)+a*sin(sqrt(b)*x)/(a^2+b)/sqrt(b)-cos(sqrt(b)*x)/(a^2+b) ); inverselaplace(1/(a_+s_)*1/(b_+s_^0.5), s_,x_) := if(isfree(a,b,s), 2E(0.5,-b*sqrt(x)) ); inverselaplace(1/(c_+b_*s_+s_^2),s_,x_):= if(b*b==4c, exp(-b/2*x)*x,2exp(-b/2*x)*sinh(sqrt(b*b - 4 c)*x/2)/sqrt(b*b - 4 c)); inverselaplace(1/s_/(c_+b_*s_+s_^2),s_,x_):= if(b*b==4c, -exp(-b/2*x)*(4/b*b+2/b*x),2cosh(sqrt(b*b - 4 c)*x/2)/sqrt(b*b - 4 c)); inverselaplace(s_,s_,x_) := 0; inverselaplace(y_,s_):=inverselaplace(y,s,x); inverselaplace(y_):=inverselaplace(y,x,x);