# convert to power e^x; topower(a_^b_):=pow(a,b); #topower(1/b_):= pow(b,-1); #topower(a_*b_):=If(isfree(a,x), a*topower(b), topower(a)*topower(b)); #topower(a_+b_):=If(isfree(a,x), a+topower(b), topower(a)+topower(b)); #topower(a_-b_):=If(isfree(a,x), a-topower(b), topower(a)-topower(b)); #topower(-b_):= -topower(b); topower(sqrt(x_)) := pow(x,1/2); topower(cbrt(x_)) := pow(x,1/3); topower(exp(x_)) := e^x; topower(sinh(x_)) := exp(x)/2-exp(-x)/2; topower(cosh(x_)) := exp(x)/2+exp(-x)/2; topower(tanh(x_)) := (exp(x)-exp(-x))/(exp(x)+exp(-x)); topower(coth(x_)) := (exp(x)+exp(-x))/(exp(x)-exp(-x)); topower(sin(x_)) := i*exp(-i*x)/2-i*exp(i*x)/2; topower(cos(x_)) := exp(i*x)/2+exp(-i*x)/2; topower(tan(x_)) := (i*exp(-i*x)-i*exp(i*x))/(exp(i*x)+exp(-i*x)); topower(cot(x_)) := (i*exp(i*x)+i*exp(-i*x))/(exp(i*x)-exp(-i*x)); topower(gamma(n_,x_)) := If(n>0, (n-1)*topower(gamma(n-1,x))+x^(n-1)*exp(-x), If(n <0, (topower(gamma(n+1,x))-x^n*exp(-x))/n) ); topower(ei(n_,x_)) := If(n>0.5, (-x*topower(ei(n-1,x))+exp(-x))/(n-1), If(n< -0.5, -n*topower(ei(n+1,x))/x+exp(-x)/x )); topower(li(n_,x_)) := If(n>=1, -n*li(n-1,x)+ln(x)^n*x, If(n<-1, (-li(n+1,x)+ln(x)^(n+1)*x)/(n+1) )); gamma(1/2,x_) := -sqrt(pi)*erf(sqrt(x)); gamma(1/2,-x_) := -sqrt(pi)*i*erfi(sqrt(x)); ei(0.5,x_) := sqrt(pi)*erfc(sqrt(x))/sqrt(x); ei(-0.5,x_) := sqrt(pi)*erf(sqrt(x))*x^(-1.5);