# integrate(y,x); integrate(y_,a_,b_):= if(isconstant(a), integrate(y,x,a,b), if(b==0,y, if(b==1,int(y,a), d(y,a,-b) ))); integrate(y_,x_,0):=y; integrate(y_,x_,1):=integrate(y,x); integrate(y_,x_=a_,b_):=integrate(y,x,a,b); integrate(f_+g_,x_,a_,b_) := integrate(f,x,a,b)+integrate(g,x,a,b); integrate(abs(y_),x_,a_,b_) := if(a==-b,2*int(step(y)*y,x,0,b)); integrate(1/x_,x_,a_,b_) := if(isreal(b/a),log(abs(b/a)),log(b/a) ); integrate(1/(c_+x_),x_,a_,b_) := if(isreal(b/a),log(abs((b+c)/(a+c))),log((b+c)/(a+c)) ); integrate(integrate(y_,x_),x_):= d(y,x, -2); integrate(integrate(y_,x_,n_),x_):= d(y,x, -1-n); integrate(y',x_) := y; integrate(d(y_,x_,n_),x_) := d(y,x,n-1); integrate(ds(y_,x_,n_),x_) := ds(y,x,n-1); integrate(d(y_,x_),x_) := y; integrate(ds(y_,x_),x_) := y; integrate(a_=b_,x_):= integrate(replace(a,dy,1),y)=integrate(replace(b,dx,1),x); integrate(a_ and b_,x_) := integrate(a,x) and integrate(b,x); integrate(a_+b_,x_) := integrate(a,x)+integrate(b,x); integrate(a_-b_,x_) := integrate(a,x)-integrate(b,x); integrate(a_*b_,x_):= if(hasnot(a,x),a*int(b,x),if(d(a,x)-b==0,a^2/2,if(d(a,x)+b==0,-a^2/2, if(d(b,x)-a==0,b^2/2,if(d(b,x)+a==0,-b^2/2 ))))); integrate(a_*y(n_,x_),x_,n_):=integrate(a,y,n); integrate(a_*y(1,x_),x_):=integrate(a,y); integrate(infsums(1/k_!*x_^k_,k_),x_) := infsums(x^k/k!,k); integrate(infsums(x_^(2*k_)/(2*k_)!,k_),x_) := infsums(x^(2*k+1)/(2*k+1)!,k); integrate(infsums(x_^(1+2*k_)/(1+2*k_)!,k_),x_) := infsums(x^(2*k)/(2*k)!,k); integrate(infsums(x_^(2*k_)/(2*k_)! *(-1)^k_,k_),x_) := infsums((-1)^k*x^(2*k+1)/(2*k+1)!,k); integrate(infsums(x_^(1+2*k_)/(1+2*k_)! *(-1)^k_,k_),x_) := infsums((-1)^k*x^(2*k)/(2*k)!,k); #integrate(b_^n_*a_,x_):=If(has(b,x) and isfree(n,d(b,x)/a,x), b^(1+n)/(n+1)/d(b,x)*a); #integrate(a_^n_*b_,x_):=If(has(a,x) and isfree(n,d(a,x)/b,x), a^(1+n)/(n+1)/d(a,x)*b); #integrate(a_/b_,x_):= If(has(a,x) and isfree(b,x), integrate(a,x)/b, If(isfree(d(b,x)/a,x), log(b)/d(b,x)*a )); #integrate(a_^(-1)*b_,x_):= If(isfree(a,x) and has(b,x), integrate(b,x)/a, If(isfree(d(a,x)/b,x), log(a)/d(a,x)*b )); #integrate(x_^n_/b_,x_) := block(p:=d(b,x)*x^(-n), If(isfree(p,x), log(b)/p)); integrate(k_^x_,x_) := If(isfree(k,x),k^x/log(k)); #integrate(k_^(b_+c_),x_) := If(isfree(k,b,x),k^b*integrate(k^c,x)); integrate(k_^(b_+x_),x_) := If(isfree(k,b,x),k^(b+x)/log(k)); integrate(k_^(a_*x_),x_) := If(isfree(k,a,x),k^(a*x)/a/log(k)); integrate(k_^(a_*x_+b_),x_) := If(isfree(k,a,b,x),k^(b+a*x)/a/log(k)); integrate(f_^x_/x_, x_) := If(isfree(f,x),Ei(x)/log(f)); integrate(k_^(b_+x_)/(c_+x_),x_) := If(isfree(k,b,c,x),k^(b-c)*Ei(c+x)/log(k)); integrate(1/W(x_),x_) := Ei(W(x))+x/W(x); integrate(W(x_),x_) := W(x)*x+x/W(x)-x; integrate(inversef(x_),x_) := x*inversef(x)-F(inversef(x)); integrate(inverseerf(x_),x_) := -exp(-inverseerf(x)^2)/sqrt(pi); integrate(inverseerfi(x_),x_) := exp(inverseerfi(x)^2)/sqrt(pi); integrate(inverseli(x_),x_) := Ei(2log(inverseli(x))); integrate(Sophomore(a_,x_),x_):=Sophomore(-1,a,x); integrate(li(x_),x_) := x*li(x)-li(x^2); integrate(li(x_)/x_,x_) := polylog(2,x); integrate(polylog(n_,x_)/x_,x_) := polylog(n+1,x); integrate(Gamma(x_)*psi(x_),x_) := Gamma(x); integrate(logGamma(x_), x_) := psi(-2,x); integrate(psi(x_), x_) := logGamma(x); integrate(Gamma(n_,x_),x_) := x*Gamma(n,x)-Gamma(1+n,x); integrate(Gamma(a_,n_,x_),x_) := Gamma(a,n,x)*x+Gamma(1+a,x); integrate(Gamma(a_,x_,0),x_):= Gamma(a-1,x,0); integrate(Gamma(n_,x_)*x_^k_,x_) := (x^(1+k)*Gamma(n,x)-Gamma(1+k+n,x))/(1+k); integrate(Gamma(x_),x_) := factorial(-1,x-1); integrate(factorial(x_),x_) := factorial(-1,x); integrate(mittag(a_,a_,x_^a_)*x_^b_, x_) := if(b==-1+a, mittag(a,x^a)); integrate(mittag(a_,x_^a_)*x_, x_) :=if(a==0.5, mittag(0.5,x^0.5)*x-mittag(0.5,x^0.5)+2*pi^(-1/2)*x^(0.5)-2/3*pi^(-1/2)*x^1.5, mittag(a,2,x^a)*x^2-int(mittag(a,2,x^a)*x,x) ); integrate(mittag(a_,c_*x_^a_), x_) := if(hasnot(c,x), mittag(a,2,c*x^a)*x ); integrate(mittag(a_,x_^a_), x_) := mittag(a,2,x^a)*x; integrate(mittag(0.5,x_)*x_, x_) := mittag(0.5,x)/2-x/sqrt(pi); integrate(mittag(0.5,x_^0.5), x_):= mittag(0.5,x^0.5)-2x^0.5/sqrt(pi); integrate(x_^n_,x_):= If(isfree(n,x),If(n== -1, log(x), x^(1+n)/(1+n) ), Sophomore(x,n) ); integrate(x_^x_,x_):= Sophomore(x); integrate((b_+x_)^n_,x_):= If(isfree(b,n,x), If(n == (-1), log(b+x), (b+x)^(1+n)/(1+n) )); integrate((x_+y_)^n_,x_):= If(isfree(y,n,x), If(n == (-1), log(y+x), (y+x)^(1+n)/(1+n) )); integrate((b_+a_*x_)^n_,x_):= If(isfree(b,a,n,x), If(n == (-1), log(b+a*x)/a, (b+a*x)^(1+n)/(1+n)/a )); integrate((a_*x_+y_)^n_,x_):= If(isfree(y,a,n,x), If(n == (-1), log(y+a*x)/a, (y+a*x)^(1+n)/(1+n)/a )); integrate((1-x_^c_)^b_,x_):=if(hasnot(b,c,x),beta(1/c,1+b,x)/c); integrate(x_^a_*(1+x_)^b_,x_):=if(a> -1 and b> -1,(-1)^a*beta(1+a,1+b,x)); integrate(x_^a_*(-1+x_)^b_,x_):=if(a> -1 and b> -1,(-1)^b*beta(1+a,1+b,x)); integrate(x_^a_*(1-x_)^b_,x_):=if(a> -1 and b> -1,beta(1+a,1+b,x)); integrate(x_^a_*(1-x_^c_)^b_,x_):=if(a> -1 and b> -1,beta((1+a)/c,1+b,x)/c); #integrate((x_-p_)^a_*(q_-x_)^b_,x_,p_,q_):=beta(1+a,1+b)*(p-q)^(a+b+1); integrate(x_*(a_ + x_)^n_,x_) := if(hasnot(a,x), if(n==-1, x-log(x+a), ((a + x)^(n + 1)* ( (n + 1)* x - a))/((n + 1) *(n + 2)) )); integrate(x_*(a_ + b_* x_)^n_,x_) := if(hasnot(a,b,x), if(n==-1, x/b-a*log(a+b*x)/b^2, ((a + b* x)^(n + 1)* (b* (n + 1)* x - a))/(b^2 *(n + 1) *(n + 2)) )); #integrate(a_*(t_-x_)^n_,x_):= n!*d(a,x,n); #integrate(a_*(-t_+x_)^n_,x_):= (-1)^n*n!*d(a,x,n); #integrate((t_-x_)^n_*y_,x_):= n!*d(y,x,n); #integrate((-t_+x_)^n_*y_,x_):= (-1)^n*n!*d(y,x,n); integrate((1-x_^a_)/(1-x_),x_):=harmonic(a,1,x); integrate((-1+x_^a_)/(-1+x_),x_):=harmonic(a,1,x); integrate(a_*(1+b_^2)^(-0.5),x_):= if(d(b,x)==a, asinh(b), if(d(b,x)==-a, -asinh(b) )); integrate(a_/(1+b_^2),x_):= if(d(b,x)==a, atan(b),if(d(b,x)==-a, -atan(b) )); integrate(a_*(1+b_*x_^2)^(-0.5),x_):= if(d(b^0.5*x,x)==a, asinh(sqrt(b)*x), if(d(b^0.5*x,x)+a==0, -asinh(sqrt(b)*x) )); integrate(a_/(1+b_*x_^2),x_):= if(d(b^0.5*x,x)==a, atan(sqrt(b)*x), if(d(b^0.5*x,x)+a==0, -atan(sqrt(b)*x) )); integrate(exp(x_)*(t_-x_)^(-0.5),x_):= -sqrt(pi)*exp(t)*erf(sqrt(t-x)); integrate(log(x_)*(t_-x_)^(-0.5), x_):= -4 sqrt(t)* atanh(sqrt(t-x)/sqrt(t))-2 sqrt(t-x)* (-2+log(x)); #integrate(sinh(x_)*(t_-x_)^(-0.5),x_):= -1/2 sqrt(pi)*(erfi(sqrt(t-x))*(-cosh(t)+sinh(t))+erf(sqrt(t-x))*(cosh(t)+sinh(t))); #integrate(cosh(x_)*(t_-x_)^(-0.5),x_):= -1/2 sqrt(pi)*(erfi(sqrt(t-x))*(cosh(t)-sinh(t))+erf(sqrt(t-x))*(cosh(t)+sinh(t))); integrate(x_/(c_+x_^3),x_) := If(isfree(c,x),(log(c^(2/3)-c^(1/3)* x+x^2)-2 log(c^(1/3)+x)-2 sqrt(3)* atan((1-(2 x)/c^(1/3))/sqrt(3)))/(6 c^(1/3)) ); integrate(x_/(b_+x_^4),x_) := If(isfree(b,x), If(b<0, -atanh(x^2/sqrt(-b))/2/sqrt(-b), atan(x^2/sqrt(b))/2/sqrt(b) )); integrate(x_/(b_+a_*x_),x_) := If(isfree(a,b,x), x/a-b/a^2*log(a*x+b)); integrate(x_/(b_+a_*x_)^2,x_) := If(isfree(a,b,x), b/a^2/(a*x+b)+1/a^2*log(a*x+b)); integrate(x_/(c_+b_*x_+x_^2), x_) := If(isfree(b,c,x), log(c+b*x+x^2)/2-b/2 * integrate(1/(c+b*x+x^2),x) ); integrate(x_/(c_+b_*x_+a_*x_^2), x_) := If(isfree(a,b,c,x), log(c+b*x+a*x^2)/2/a-b/2/a * integrate(1/(c+b*x+a*x^2),x) ); integrate(x_*(c_+x_^2)^(-0.5), x_) := If(isfree(c,x), sqrt(c+x^2) ); integrate(x_*(c_-x_^2)^(-0.5), x_) := If(isfree(c,x), -sqrt(c-x^2) ); integrate(log(x_)^b_*x_^a_, x_) := If(a== -1,If(b== -1, log(log(x)), log(x)^(1+b)/(1+b) ),(-1)^(-b)*Gamma(1+b,-(1+a)*log(x))/(1+a)^(1+b) ); integrate(log(x_)^b_*x_, x_) := (-1)^(-b)*Gamma(1+b,-2log(x))/2^(1+b); integrate(log(x_)^n_, x_) := (-1)^(-n)*Gamma(1+n,-log(x)); integrate(log(a_*x_+b_)^n_,x_):= if(isfree(a,b,x),(-1)^(-n)*Gamma(1+n,-log(a*x+b))/a); integrate(log(b_+x_)^n_, x_) := if(isfree(b,x),(-1)^(-n)*Gamma(1+n,-log(b+x))); integrate(x_^n_/log(x_),x_) := li(x^(1+n)); integrate(1/log(x_)*1/x_,x_) := log(log(x)); integrate(1/log(x_),x_) := li(x); integrate(1/log(b_*x_),x_) := if(hasnot(b,x), li(b*x)/b ); integrate(1/log(x_^n_),x_) := Ei(log(x^n)/n)/n; integrate(1/(c_+log(x_)),x_) := if(isfree(c,x),Ei(c+log(x))*exp(-c) ); integrate(1/(b_+a_*log(x_)),x_) := if(isfree(a,b,x),(exp(-b/a)*Ei(b/a+log(x)))/a ); integrate(log(x_)^(-0.5)*x_^(-0.5),x_):= sqrt(2pi) * erfi(sqrt(log(x)/2)); integrate((log(x_)*x_ - x_)^(-0.5),x_):= sqrt(2e *pi) * erfi(sqrt(log(x)/2 - 1/2)); integrate(log(x_)*x_^a_, x_) := If(a== -1,log(x)^2/2, -Gamma(2,-(1+a)*log(x))/(1+a)^2); integrate(log(x_)*x_^x_, x_) := x^x-Sophomore(x); integrate(log(x_)*x_, x_) := 1/2*x^2*log(x)-1/4*x^2; integrate(log(x_+c_)*x_,x_):= If(isfree(c,x), 1/2* ( c*x - x^2/2 - (c^2 - x^2)* log(c + x)) ); integrate(log(x_)/x_,x_):= log(x)^2/2; integrate(log(b_*x_)/x_,x_):= if(hasnot(b,x), log(b*x)^2/2); integrate(log(x_)/(1-x_),x_):= polylog(2,1-x); integrate(log(x_)/(x_+c_),x_):= If(isfree(c,x), polylog(2, -x/c)+log(x)*log(1+x/c) ); integrate(log(x_+c_)/x_,x_):= If(isfree(c,x), log(x)*log(c)-polylog(2, -x/c) ); integrate(log(a_*x_+c_)/x_,x_):= If(isfree(a,c,x), log(x)*log(c)-polylog(2, -a*x/c) ); integrate(log(a_+x_)/(b_+x_),x_) := If(isfree(a,b,x), polylog(2,(a+x)/(a-b))+log(a+x)*log(-(b+x)/(a-b)) ); integrate(log(a_+c_* x_)/(b_+x_),x_) := If(isfree(a,b,c,x), polylog(2,(a+c* x)/(a-b* c))+log(a+c* x)* log((c* (b+x))/(b* c-a)) ); #integrate2(a_*exp(x_),x_):=a*exp(x)-integrate(d(a,x)*exp(x),x); #integrate2(exp(x_)*y_,x_):=exp(x)*y-integrate(d(y,x)*exp(x),x); #integrate2(exp(b_*x_)*y_,x_):=if(hasnot(b,x),exp(b*x)*y-integrate(d(y,x)*exp(b*x),x)/b); integrate(c_*exp(a_+b_),x_):= If(isfree(a,x), exp(a)*integrate(c*e^b,x)); integrate(exp(a_+b_)*y_,x_):= If(isfree(a,x), exp(a)*integrate(e^b*y,x)); integrate(exp(a_+b_),x_):= If(isfree(a,x), exp(a)*integrate(e^b,x), If(isfree(b,x), exp(b)*integrate(e^a,x) )); integrate(exp(a_*x_+b_*x_),x_):= If(isfree(a,b,x), exp(a*x+b*x)/(a+b)); integrate(exp(x_^m_), x_) := -(-1)^(-1/m)*Gamma(1/m,-x^m)/m; integrate(exp((x_+c_)^m_), x_) := If(isfree(c,x), -(-1)^(-1/m)*Gamma(1/m,-(x+c)^m)/m); integrate(exp(k_*x_^m_), x_) := If(isfree(k,x), -(-k)^(-1/m)*Gamma(1/m,-k*x^m)/m); integrate(exp(a_*x_^2),x_) := If(a<0, 1/2*sqrt(-pi/a)*erf(sqrt(-a)*x), 1/2*sqrt(pi/a)*erfi(sqrt(a)*x) ); integrate(exp(-a_*x_^2),x_) := If(isfree(a,x), 1/2*sqrt(pi/a)*erf(sqrt(a)*x)); integrate(exp(x_^2), x_) := sqrt(pi)/2*erfi(x); integrate(exp(-x_^2),x_) := sqrt(pi)/2*erf(x); integrate(exp(x_+x_^2),x_) := sqrt(pi)/2*exp(-1/4)*erfi(x+1/2); integrate(exp(b_*x_+x_^2),x_) := If(isfree(b,x), exp(-b^2/4)*sqrt(pi)*erfi(x+b/2)/2); integrate(exp(x_+a_*x_^2),x_) := if(hasnot(a,x), exp(-1/4/a)*sqrt(pi)*erfi((1+2 a *x)/(2 sqrt(a)))/(2 sqrt(a)) ); integrate(exp(b_*x_+a_*x_^2),x_) := If(isfree(a,b,x), (exp(-b^2/(4 a)) *sqrt(pi) *erfi((b+2 a *x)/(2 sqrt(a))))/(2 sqrt(a)) ); integrate(exp(c_+b_*x_+x_^2),x_) := If(isfree(b,c,x), (exp(-b^2/4 +c) *sqrt(pi) *erfi((b+2 x)/2 ))/2 ); integrate(exp(c_+b_*x_+a_*x_^2),x_) := If(isfree(a,b,c,x), (exp(-b^2/(4 a)+c) *sqrt(pi) *erfi((b+2 a *x)/(2 sqrt(a))))/(2 sqrt(a)) ); integrate(exp(k_*x_^m_)*x_^n_,x_) := If(isfree(k,x),-(-k)^((-n-1)/m)*Gamma((n+1)/m,-k*x^m)/m); integrate(exp(k_*x_^m_)*x_,x_) := If(isfree(k,x),-(-k)^(-2/m)*Gamma(2/m,-k*x^m)/m); #integrate(exp(k_*x_^m_)*x_^n_,x_) := If(isfree(k,x),-x^(n+1)*(-k*x^m)^((-n-1)/m)*Gamma((n+1)/m,-k*x^m)/m); #integrate(exp(-x_^m_)*x_^n_,x_) := -x^(n+1)*(x^m)^((-n-1)/m)*Gamma((n+1)/m,x^m)/m; #integrate(exp(x_^m_)*x_^n_,x_) := -x^(n+1)*(-x^m)^((-n-1)/m)*Gamma((n+1)/m,-x^m)/m; integrate(exp(x_^m_)*x_^n_,x_) := -(-1)^((-n-1)/m)*Gamma((n+1)/m,-x^m)/m; integrate(exp(x_^m_)*x_,x_) := -(-1)^(-2/m)*Gamma(2/m,-x^m)/m; integrate(exp(x_)*x_^n_,x_) := If(n>1 and isinteger(n), x^n*exp(x)-n*integrate(exp(x)*x^(n-1),x),(-1)^n*Gamma(n+1,-x)); #integrate(exp(x_)*x_^n_,x_) := (-1)^(-n)*Gamma(n+1,-x); integrate(exp(a_*x_)*x_^n_,x_) := If(isfree(a,x), Gamma(n+1,-a*x)/a/(-a)^n ); #integrate(exp(-x_)*x_^n_,x_) := If(n>1, -x^n*exp(-x)-n*integrate(exp(-x)*x^(n-1),x), -Gamma(n+1,x)); integrate(exp(x_^2)*x_,x_) := exp(x^2)/2; integrate(exp(a_*x_^2)*x_,x_) := If(isfree(a,x), exp(a*x^2)/(2a)); integrate(exp(a_*x_)*x_,x_) := If(isfree(a,x), exp(a*x)*x/a-exp(a*x)/a^2); #integrate(exp(-x_)*x_,x_) := -x*exp(-x)-exp(-x); integrate(exp(x_)*x_,x_) := exp(x)*x-exp(x); integrate(exp(exp(a_*x_)),x_) := if(isfree(a,x),Ei(exp(a*x))/a); integrate(exp(c_*exp(x_)),x_):= if(isfree(c,x),Ei(c*exp(x)) ); integrate(exp(c_*exp(a_*x_)),x_):= if(isfree(a,c,x),Ei(c*exp(a*x))/a ); integrate(exp(exp(x_)),x_):= Ei(exp(x)); integrate((x_-y_)^n_*exp(y_),y_) := If(isfree(y,x),exp(x)*Gamma(n+1,-y+x) ); integrate((x_-y_)^n_exp(-y_),y_) := If(isfree(y,x),(-1)^(-n)*exp(-x)*Gamma(n+1,y-x) ); integrate((x_+b_)^n_*exp(x_),x_) := If(isfree(b,x),((-1)^(-n)*exp(-b) *Gamma(1 + n, -b - x)) ); integrate((x_+b_)^n_*exp(c_*x_),x_) := If(isfree(b,c,x), (-c)^(-n)/c*exp(-b*c) *Gamma(1 + n, -c*b -c*x) ); integrate((a_*x_+b_)^n_*exp(x_),x_) := If(isfree(a,b,x),((-1/a)^(-n)*exp(-b/a) *Gamma(1 + n, -b/a - x)) ); integrate((a_*x_+b_)^n_*exp(c_*x_),x_) := If(isfree(a,b,c,x), (-c/a)^(-n)/c*exp(-b*c/a) *Gamma(1 + n, -c*b/a -c*x) ); integrate(exp(x_)/x_,x_) := Ei(x); integrate(exp(x_)/(a_+x_),x_) := if(hasnot(a,x), Ei(a+x)*exp(-a)); integrate(exp(-x_)/(a_+x_),x_) := if(hasnot(a,x), Ei(-a-x)*exp(a)); integrate(x_^n_/(a_+exp(x_)),x_) := if(isfree(a,n,x), Gamma(n+1)*polylog(n+1,-a,x)/a); integrate(x_^n_/(a_+exp(c_*x_)),x_) := if(isfree(a,c,x), Gamma(n+1)*polylog(n+1,-a,c*x)/a/c^(n+1)); integrate(x_^n_/(a_+b_*exp(x_)),x_) := if(isfree(a,b,x), Gamma(n+1)*polylog(n+1,-a/b,x)/a); integrate(x_^n_/(a_+b_*exp(c_*x_)),x_) := if(isfree(a,b,c,x), Gamma(n+1)*polylog(n+1,-a/b,c*x)/a/c^(n+1)); integrate(x_^n_/(exp(-x_)+exp(x_)),x_) := if(isfree(c,x), Gamma(n+1)*beta(n+1,x)); integrate(x_/(a_+exp(x_)),x_) := if(isfree(a,x), polylog(2,-a,x)/a); integrate(x_/(a_+b_*exp(x_)),x_) := if(isfree(a,b,x), polylog(2,-a/b,x)/a); integrate(x_/(a_+exp(c_*x_)),x_) := if(isfree(a,c,x), polylog(2,-a,c*x)/a/c); integrate(x_/(a_+b_*exp(c_*x_)),x_) := if(isfree(a,b,c,x), polylog(2,-a/b,c*x)/a/c); integrate(x_/(exp(c_*x_)-1),x_) := if(isfree(c,x), -polylog(2,1-exp(-c*x))/c^2); integrate(x_/(exp(-x_)+exp(x_)),x_) := beta(2,x); integrate(x_*sech(x_),x_) := 2beta(2,x); integrate(x_/asin(x_), x_) := si(2asin(x))/2; integrate(x_/acos(x_), x_) := -si(2acos(x))/2; integrate(sinh(x_)*x_^(-2), x_) := shi(x)-cosh(x)/x; integrate(cosh(x_)*x_^(-2), x_) := chi(x)-sinh(x)/x; #integrate(sinh(x_)/x_, x_) := shi(x); #integrate(cosh(x_)/x_, x_) := chi(x); #integrate(tanh(x_)/x_, x_) := thi(x); integrate(atanh(x_)/x_, x_) := polylog(2,x)/2-polylog(2,-x)/2; integrate(sinh(x1_)*exp(x2_), x_) := int(exp(x1+x2)/2,x)-int(exp(x2-x1)/2,x); integrate(cosh(x1_)*exp(x2_), x_) := int(exp(x1+x2)/2,x)+int(exp(x2-x1)/2,x); integrate(sinh(x_)*exp(a_*x_), x_) := if(hasnot(a,x), exp((1+a)* x)/(1+a)/2 - exp((a-1)* x)/(a-1)/2 ); integrate(cosh(x_)*exp(a_*x_), x_) := if(hasnot(a,x), exp((1+a)* x)/(1+a)/2 + exp((a-1)* x)/(a-1)/2 ); integrate(sinh(x_)*exp(-x_), x_) := exp(-2 x)/4 + x/2; integrate(cosh(x_)*exp(-x_), x_) := x/2-exp(-2 x)/4; integrate(sinh(x_)*exp(x_), x_) := exp(2*x)/4-x/2; integrate(cosh(x_)*exp(x_), x_) := exp(2*x)/4+x/2; integrate(sinh(x_)*exp(x_^2), x_) := sqrt(pi)/exp(1/4)*(erfi(1/2-x)+erfi(1/2+x))/4; integrate(cosh(x_)*exp(x_^2), x_) := sqrt(pi)/exp(1/4)*(erfi(x-1/2)+erfi(1/2+x))/4; integrate(sinh(x_)*exp(-x_^2), x_) := -sqrt(pi)*exp(1/4)*(erf(1/2-x)+erf(1/2+x))/4; integrate(cosh(x_)*exp(-x_^2), x_) := sqrt(pi)*exp(1/4)*(erf(x-1/2)+erf(1/2+x))/4; integrate(sech(x_)*tanh(x_),x_):= -sech(x); integrate(csch(x_)*coth(x_),x_):= -csch(x); integrate(sech(x_)^2, x_) := tanh(x); integrate(csch(x_)^2, x_) := -coth(x); integrate(sin(x_^0.5),x_):= 2*sin(sqrt(x))-2*sqrt(x)*cos(sqrt(x)); integrate(sin(x_^2),x_):= sqrt(pi/2)*fresnelS(sqrt(2/pi)*x); integrate(cos(x_^0.5),x_):= 2*cos(sqrt(x))+2*sqrt(x)*sin(sqrt(x)); integrate(cos(x_^2),x_):= sqrt(pi/2)*fresnelC(sqrt(2/pi)*x); integrate(sin(exp(x_)),x_):= si(exp(x)); integrate(cos(exp(x_)),x_):= ci(exp(x)); integrate(tan(exp(x_)),x_):= tani(exp(x)); integrate(cot(exp(x_)),x_):= coti(exp(x)); integrate(csc(exp(x_)),x_):= csci(exp(x)); integrate(sec(exp(x_)),x_):= seci(exp(x)); integrate(tan(x_)^n_, x_) := if(n>1,tan(x)^(n-1)/(n-1)-integrate(tan(x)^(n-2),x)); integrate(cot(x_)^n_, x_) := if(n>1,cot(x)^(n-1)/(1-n)-integrate(cot(x)^(n-2),x)); integrate(sin(x_)^2, x_) := x/2+sin(2*x)/4; integrate(cos(x_)^2, x_) := x/2-sin(2*x)/4; integrate(tan(x_)^2, x_) := tan(x)-x; integrate(cot(x_)^2, x_) := -cot(x)-x; integrate(sec(x_)^2, x_) := tan(x); integrate(csc(x_)^2, x_) := -cot(x); integrate(sin(x_)*x_^(-2), x_) := ci(x)-sin(x)/x; integrate(cos(x_)*x_^(-2), x_) := -si(x)-cos(x)/x; #integrate(sin(x_)/x_, x_) := si(x); #integrate(cos(x_)/x_, x_) := ci(x); #integrate(tan(x_)/x_, x_) := tani(x); #integrate(cot(x_)/x_, x_) := coti(x); #integrate(csc(x_)/x_, x_) := csci(x); #integrate(sec(x_)/x_, x_) := seci(x); integrate(sin(x_)/(x_+c_),x_):=If(isfree(c,x), cos(c)*si(x+c)-sin(c)*ci(x+c) ); integrate(cos(x_)/(x_+c_),x_):=If(isfree(c,x), cos(c)*ci(x+c)+sin(c)*si(x+c) ); integrate(atan(x_)/x_, x_) := i*polylog(2,i*x)/2-i*polylog(2,-i*x)/2; integrate(sin(x_^n_)/x_, x_) := If(isfree(n,x),si(x^n)/n); integrate(cos(x_^n_)/x_, x_) := If(isfree(n,x),ci(x^n)/n); integrate(sin(a_*x_^n_)/x_, x_) := If(isfree(a,x),si(a*x)/n); integrate(cos(a_*x_^n_)/x_, x_) := If(isfree(a,x),ci(a*x)/n); integrate(cos(x_)*sin(x_), x):= (-1/4)*cos(2*x); integrate(sin(x_)*log(x_),x_) := ci(x)-cos(x)*log(x); integrate(cos(x_)*log(x_),x_) := sin(x)*log(x)-si(x); integrate(sin(x_)*exp(x_), x_) := (sin(x)-cos(x))*exp(x)/2; integrate(cos(x_)*exp(x_), x_) := (sin(x)+cos(x))*exp(x)/2; integrate(sin(x_)*exp(a_*x_), x_) := if(hasnot(a,x),(a*sin(x)-cos(x))*exp(a*x)/(1+a*a)); integrate(cos(x_)*exp(a_*x_), x_) := if(hasnot(a,x),(sin(x)+a*cos(x))*exp(a*x)/(1+a*a)); integrate(sin(x_+c_)*exp(x_), x_) := if(hasnot(c,x),(sin(x+c)-cos(x+c))*exp(x)/2); integrate(cos(x_+c_)*exp(x_), x_) := if(hasnot(c,x),(sin(x+c)+cos(x+c))*exp(x)/2); integrate(sin(x_+c_)*exp(a_*x_), x_) := if(hasnot(a,c,x),(a*sin(x+c)-cos(x+c))*exp(a*x)/(1+a*a)); integrate(cos(x_+c_)*exp(a_*x_), x_) := if(hasnot(a,c,x),(sin(x+c)+a*cos(x+c))*exp(a*x)/(1+a*a)); integrate(sin(b_*x_)*exp(x_), x_) := If(isfree(b,x),(sin(b*x)-b*cos(b*x))/(1+b^2)*exp(x) ); integrate(cos(b_*x_)*exp(x_), x_) := If(isfree(b,x),(cos(b*x)+b*sin(b*x))/(1+b^2)*exp(x) ); integrate(sin(b_*x_+c_)*exp(x_), x_) := If(isfree(b,c,x),(sin(b*x+c)-b*cos(b*x+c))/(1+b^2)*exp(x) ); integrate(cos(b_*x_+c_)*exp(x_), x_) := If(isfree(b,c,x),(cos(b*x+c)+b*sin(b*x+c))/(1+b^2)*exp(x) ); integrate(sin(b_*x_)*exp(a_*x_), x_) := If(isfree(a,b,x),(a*sin(b*x)-b*cos(b*x))/(a^2+b^2)*exp(a*x) ); integrate(cos(b_*x_)*exp(a_*x_), x_) := If(isfree(a,b,x),(a*cos(b*x)+b*sin(b*x))/(a^2+b^2)*exp(a*x) ); integrate(sin(b_*x_+c_)*exp(a_*x_), x_) := If(isfree(a,b,c,x),(a*sin(b*x+c)-b*cos(b*x+c))/(a^2+b^2)*exp(a*x) ); integrate(cos(b_*x_+c_)*exp(a_*x_), x_) := If(isfree(a,b,c,x),(a*cos(b*x+c)+b*sin(b*x+c))/(a^2+b^2)*exp(a*x) ); integrate(atan(x_)*exp(x_),x_):= 1/2 *i *e^i *Ei(x - i) - 1/2 *i *exp(-i) *Ei(x + i) + exp(x) *atan(x); integrate(acot(x_)*exp(x_),x_):= exp(x) *acot(x) - 1/2 *i *e^i *Ei(-i + x) + 1/2 *i *exp(-i)* Ei(i + x); integrate(atan(x_)*exp(-x_),x_):= -exp(-x)*atan(x) + 1/2 *i *e^i *Ei(-i - x) - 1/2 *i* exp(-i)* Ei(i - x); integrate(acot(x_)*exp(-x_),x_):= -exp(-x)*acot(x) - 1/2 *i *e^i *Ei(-i - x) + 1/2 *i *exp(-i)* Ei(i - x); integrate(Ei(x_)*exp(-x_),x_):= log(x)-exp(-x)*Ei(x); integrate(log(c_+x_)*exp(x_),x_):= if(hasnot(a,x), log(c+x)*exp(x)-Ei(x+c)*exp(-c) ) ; integrate(log(c_+x_)*exp(b_*x_),x_):= if(hasnot(a,b,x), -exp(-b*c)*Ei(b*c+b*x)/b+log(c+x)*exp(b*x)/b ); integrate(log(x_)*exp(b_*x_),x_):= if(hasnot(b,x), log(x)*exp(b*x)/b-Ei(b*x)/b ); integrate(log(x_)*exp(x_),x_):= log(x)*exp(x)-Ei(x); integrate(exp(-x_)/(1-x_^2),x_):= 1/2 *exp(1)*Ei(-1 -x) - Ei(1 - x)/(2 exp(1)); integrate(exp(-x_)/(-1+x_^2),x_):= -1/2 *exp(1)*Ei(-1 -x) + Ei(1 - x)/(2 exp(1)); integrate(exp(-x_)/(1+x_^2),x_):= 1/2 *i *(exp(i) *Ei(-i - x) - exp(-i)*Ei(i - x)); integrate(exp(x_)/(1+x_^2),x_):= -1/2 *i *(exp(i) *Ei(-i + x) - exp(-i)*Ei(i + x)); integrate(exp(x_)/(-1+x_^2),x_):= 1/2 *exp(1) *Ei(-1 + x) - Ei(1 + x)/(2 exp(1)); integrate(exp(x_)/(1-x_^2),x_):= -1/2 *exp(1) *Ei(-1 + x) + Ei(1 + x)/(2 exp(1)); integrate(1/x_*(c_+x_)^0.5, x_) := If(isfree(c,x),2*sqrt(c+x)-2sqrt(c)*atanh(sqrt(1+x/c)) ); integrate((c_+x_^2)^0.5/x_, x_) := If(isfree(c,x),sqrt(c+x^2)-sqrt(c)*log(sqrt(c)*sqrt(c+x^2)+c)+sqrt(c)*log(x) ); integrate((c_+x_^2)^(-0.5)/x_, x_) := If(isfree(c,x), -acsch(x/sqrt(c))/sqrt(c) ); integrate((c_-x_^2)^(-0.5)/x_, x_) := If(isfree(c,x), -asech(x/sqrt(c))/sqrt(c) ); integrate((x_^2-c_)^(-0.5)/x_, x_) := If(isfree(c,x), asec(x/sqrt(c))/sqrt(c) ); integrate(1/x_*(c_+x_)^(-0.5), x_) := If(isfree(c,x), -2acsch(sqrt(x/c))/sqrt(c) ); integrate(1/x_*(c_-x_)^(-0.5), x_) := If(isfree(c,x), -2asech(sqrt(x/c))/sqrt(c) ); integrate(1/x_*(x_-c_)^(-0.5), x_) := If(isfree(c,x), 2asec(sqrt(x/c))/sqrt(c) ); integrate((c_+x_^2)^0.5, x_) := if(c<0,x*sqrt(x^2+c)/2-acosh(x+c)/2, If(isfree(c,x),x*sqrt(c+x^2)/2+asinh(x/sqrt(c))/2 )); integrate((c_+b_*x_^2)^0.5, x_) := If(isfree(b,c,x), 1/2* x* sqrt(b* x^2 + c) + 1/2*(c* log(sqrt(b)* sqrt(b* x^2 + c) + b* x))/sqrt(b) ); integrate((c_-x_^2)^(0.5), x_) := If(isfree(c,x), (sqrt(c-x^2)*x+c*asin(x/sqrt(c)))/2 ); integrate((c_+b_*x_^(-2))^(-0.5), x_) := If(isfree(b,c,x), sqrt(b+c*x^2)/c ); integrate((c_+b_*x_^2)^(-0.5), x_) := if(c<0,acosh(x*sqrt(-b/c))/sqrt(b),If(isfree(c,x), asinh(x*sqrt(b/c))/sqrt(b) )); integrate((c_+x_^2)^(-0.5), x_) := if(c<0,acosh(x/sqrt(-c)),If(isfree(c,x), asinh(x/sqrt(c)) )); integrate((c_-x_^2)^(-0.5), x_) := If(isfree(c,x), asin(x/sqrt(c)) ); integrate((b_* x_ + x_^2)^(-0.5),x_) := if(isfree(b,x),log(2* (sqrt(x* b + x^2 ) + x) + b) ); integrate((b_* x_ + a_*x_^2)^(-0.5),x_) := if(isfree(a,b,x),1/sqrt(a)*log(2* (sqrt(x* b/a + x^2) + x) + b/a) ); integrate((x_^2+x_)^(-0.5), x_) := 2asinh(sqrt(x)); integrate((x_^2+x_^3)^(-0.5), x_) := -2acsch(sqrt(x)); integrate((x_^2+x_^4)^(-0.5), x_) := -acsch(x); integrate((x_^2+x_^3)^(0.5), x_) := (2 *(x + 1)^(3/2)* (3 x - 2))/(15 sgn(x)); integrate((x_^2+x_)^(0.5), x_) := sqrt(x+x^2)/4*(2x+1)-asinh(sqrt(x))/4; integrate((c_ + x_ + x_^2)^(-0.5),x_) := if(isfree(c,x),if(c==1/4, log(x+1/2),if(c>1/4,asinh((2x+1)/sqrt(4c-1)), log(2* (sqrt(x + x^2 + c) + x) + 1) ))); integrate((c_ + b_* x_ + x_^2)^(-0.5),x_) := if(isfree(b,c,x),if(b*b==4c, log(x+b/2), if(b*b<4c, asinh((2x+b)/sqrt(4c-b*b)), log(2* (sqrt(x* b + x^2 + c) + x) + b) ))); integrate((c_ + b_* x_ + a_*x_^2)^(-0.5),x_) := if(isfree(a,b,c,x),if(b*b==4a*c, log(x+b/2/a)/sqrt(a), 1/sqrt(a)*log(2* (sqrt(x* b/a + x^2 + c/a) + x) + b/a) )); integrate((a_ + exp(x_))^(-0.5),x_) := if(hasnot(a,x), -2 atan(sqrt(-1 + exp(x)/a))/sqrt(a) ); integrate((a_ + exp(c_+x_))^(-0.5),x_) := if(hasnot(a,c,x), -2 atan(sqrt(-1 + exp(c+x)/a))/sqrt(a) ); integrate((a_ + b_*exp(x_))^(-0.5),x_) := if(hasnot(a,b,x), -2 atan(sqrt(-1 + b/a* exp(x)))/sqrt(a) ); integrate((a_ + b_*exp(c_+x_))^(-0.5),x_) := if(hasnot(a,b,c,x), -2 atan(sqrt(-1 + b/a* exp(c+x)))/sqrt(a) ); integrate((a_ + exp(x_))^0.5,x_) := if(hasnot(a,x),2 sqrt(a + exp(x)) - 2 sqrt(a)* atanh(sqrt(1 + exp(x)/a)) ); integrate((a_ + exp(c_+x_))^0.5,x_) := if(hasnot(a,c,x),2 sqrt(a + exp(c+x)) - 2 sqrt(a)* atanh(sqrt(1 + exp(c+x)/a)) ); integrate((a_ + b_*exp(x_))^0.5,x_) := if(hasnot(a,b,x), 2 sqrt(a + b*exp(x)) - 2 sqrt(a)* atanh(sqrt(1 + b/a* exp(x))) ); integrate((a_ + b_*exp(c_+x_))^0.5,x_) := if(hasnot(a,b,c,x), 2 sqrt(a + b*exp(c+x)) - 2 sqrt(a)* atanh(sqrt(1 + b/a* exp(c+x))) ); integrate(sin(x_)*(1+cos(x_)^2)^(-0.5),x_):= -asinh(cos(x)); integrate(sin(x_)/(1+cos(x_)^2),x_):= -atan(cos(x)); integrate((sin(x_)+cos(x_)*x_)*(1+sin(x_)^2*x_^2)^(-0.5),x_):= asinh(sin(x)*x); integrate((sin(x_)+cos(x_)*x_)/(1+sin(x_)^2*x_^2),x_):= atan(sin(x)*x); integrate(a_/sgn(y_),x_) := integrate(a,x)/sgn(y); integrate(a_*theta(y_),x_) := theta(y)*integrate(a,x); integrate(a_*delta(x_),x_) := replace(a,x,0)*theta(x); integrate(a_*delta(x_+c_),x_) := replace(a,x,-c)*theta(x+c); integrate(delta(x_)*y_,x_) := replace(y,x,0)*theta(x); integrate(delta(x_+c_)*y_,x_) := replace(y,x,-c)*theta(x+c); integrate(delta(x_+c_)*x_,x_) := -c*theta(x+c); integrate(x_*asin(x_),x_) := 1/4*x*(1-x^2)^(1/2)+1/4*asin(x)*(-1+2*x^2); integrate(x_*acos(x_),x_) := x^2*acos(x)/2+asin(x)/4-x*sqrt(1-x^2)/4; integrate(x_*atan(x_),x_) := (x^2+1)*atan(x)/2-x/2; integrate(x_*acot(x_),x_) := x^2*acot(x)/2-atan(x)/2+x/2; integrate(x_*asinh(x_),x_) := (-1/4)*x*(1+x^2)^(1/2)+1/4*asinh(x)*(1+2*x^2); integrate(x_*acosh(x_),x_) := x^2*acosh(x)/2-asinh(x)/4-x*sqrt(-1+x^2)/4; integrate(x_*erf(x_),x_) := 1/4 *((2 *exp(-x^2) *x)/sqrt(pi)+(-1+2 *x^2) *erf(x)); integrate(x_*si(x_),x_) := (x^2*si(x)-sin(x)+x*cos(x))/2; integrate(x_*ci(x_),x_) := (x^2*ci(x)-x*sin(x)-cos(x))/2; integrate(x_*Ei(x_),x_) := (x^2*Ei(x)+exp(x)-x*exp(x))/2; #integrate(x_*sinh(x_),x_) := cosh(x)*x-sinh(x); #integrate(x_*cosh(x_),x_) := sinh(x)*x-cosh(x); #integrate(x_*sin(x_),x_) := sin(x)-cos(x)*x; #integrate(x_*cos(x_),x_) := cos(x)+sin(x)*x; integrate(1/asin(x_), x_) := ci(asin(x)); integrate(1/acos(x_), x_) := -si(acos(x)); integrate(1/asinh(x_), x_) := chi(asinh(x)); integrate(1/acosh(x_), x_) := shi(acosh(x)); integrate(1/(a_+exp(x_)),x_) := if(isfree(a,x), x/a-log(a+exp(x))/a); integrate(1/(a_+exp(c_+x_)),x_) := if(isfree(a,c,x), x/a-log(a+exp(c+x))/a); integrate(1/(a_+exp(c_*x_)),x_) := if(isfree(a,c,x), x/a-log(a+exp(c*x))/c/a); integrate(1/(a_+exp(c_*x_+f_)),x_) := if(isfree(a,c,f,x), x/a-log(a+exp(c*x+f))/c/a); integrate(1/(a_+b_*exp(x_)),x_) := if(isfree(a,b,x), x/a-log(a+b*exp(x))/a); integrate(1/(a_+b_*exp(c_+x_)),x_) := if(isfree(a,b,c,x), x/a-log(a+b*exp(c+x))/a); integrate(1/(a_+b_*exp(c_*x_)),x_) := if(isfree(a,b,c,x), x/a-log(a+b*exp(c*x))/c/a); integrate(1/(a_+b_*exp(c_*x_+f_)),x_) := if(isfree(a,b,c,f,x), x/a-log(a+b*exp(c*x+f))/c/a); integrate(1/(a_+sinh(x_)),x_):= 2atanh((a*tanh(x/2)-1)/sqrt(a^2+1))/sqrt(a^2+1); integrate(1/(a_+sin(x_)),x_):= if(a==1, -tan(pi/4-x/2), if(a==-1, -cot(pi/4-x/2), if(abs(a)>1,2 atan((a* tan(x/2) + 1)/sqrt(a^2 - 1))/sqrt(a^2 - 1), -2 atanh((a* tan(x/2) + 1)/sqrt(1 - a^2))/sqrt(1 - a^2) ))); integrate(1/(a_+cos(x_)),x_):= if(a==1, tan(x/2), if(a==-1, cot(x/2), if(abs(a)<1,-2 atanh(((a - 1)* tan(x/2))/sqrt(1-a^2))/sqrt(1-a^2), 2 atan(((a - 1)* tan(x/2))/sqrt(a^2-1))/sqrt(a^2-1) ))); integrate(1/(a_+tan(x_)),x_):= if(hasnot(a,x),log(a*cos(x)+sin(x))/(1+a^2)+a*x/(1+a^2)); integrate(1/(a_+b_*sin(x_)),x_):= if(a==b, -tan(pi/4-x/2)/b, if(a==-b,cot(pi/4-x/2)/a, if(abs(a)>abs(b),2 atan((a* tan(x/2) + b)/sqrt(a^2 - b^2))/sqrt(a^2 - b^2),-2 atanh((a* tan(x/2) + b)/sqrt(b^2 - a^2))/sqrt(b^2 - a^2) ))); integrate(1/(a_+b_*cos(x_)),x_):= if(a==b, tan(x/2)/b, if(a==-b, cot(x/2)/b, if(abs(a)>abs(b),2 atan(((a - b)* tan(x/2))/sqrt(a^2 - b^2))/sqrt(a^2 - b^2),-2 atanh(((a - b)* tan(x/2))/sqrt(b^2 - a^2))/sqrt(b^2 - a^2) ))); integrate(1/(a_+b_*tan(x_)),x_):= if(hasnot(a,b,x),b*log(a*cos(x)+b*sin(x))/(a^2+b^2)+a*x/(a^2+b^2)); integrate(1/(-log(x_)*x_+x_),x_):= -log(log(x)-1); integrate(1/(log(x_)*x_-x_),x_):=log(log(x)-1); integrate(1/(exp(-x_)+exp(x_)),x_) := atan(exp(x)); integrate(1/(-exp(x_)+exp(-x_)),x_) := atanh(exp(x)); integrate(1/(exp(x_)-exp(-x_)),x_) := -atanh(exp(x)); integrate(1/(cos(x_)+sin(x_)),x_):=log(tan(pi/8+x/2))/sqrt(2); integrate(1/(1+x_^n_),x_) := if(n<0,x+beta(-1/n,1/n-1,x)/n,beta(1/n,1-1/n,x)/n); integrate(1/(a_+b_/x_),x_):= if(hasnot(a,b,x), (-a)*b^(-2)*log(a+b*x)+1/b*x); integrate(1/(a_+1/x_),x_):= if(hasnot(a,x),(-a)*log(a+x)+x); integrate(1/(a_+x_^2),x_) := If(isfree(a,x), If(a<0, -atanh(x/sqrt(-a))/sqrt(-a), atan(x/sqrt(a))/sqrt(a) )); integrate(1/(c_+x_^3),x_) := If(isfree(c,x), (-log(c^(2/3)-c^(1/3)* x+x^2)+2* log(c^(1/3)+x)-2* sqrt(3)* atan((1-2x/c^(1/3))/sqrt(3)))/(6* c^(2/3)) ); integrate(1/(c_+x_^4),x_) := If(isfree(c,x), (-log(-sqrt(2)* c^(1/4)* x+sqrt(c)+x^2)+log(sqrt(2)* c^(1/4)* x+sqrt(c)+x^2)-2 atan(1-(sqrt(2)* x)/c^(1/4))+2 atan((sqrt(2)* x)/c^(1/4)+1))/(4 sqrt(2)* c^(3/4)) ); integrate(1/(a_+b_*x_^2), x_) := If(isfree(a,b,x), If(a*b<0, sgn(a)*atanh(x*sqrt(-b/a))/sqrt(-b*a), sgn(a)*atan(x*sqrt(b/a))/sqrt(a*b) )); integrate(1/(a_*x_+b_*x_^(0.5)),x_):= if(hasnot(a,b,x), 2/a*log(a*sqrt(x)+b)); integrate(1/(b_*x_+a_*x_^2),x_) :=if(hasnot(a,b,x),log(x/(b+a*x))/b); integrate(1/(b_*x_+x_^2),x_) :=if(hasnot(b,x),log(x/(b+x))/b); integrate(1/(x_+x_^2),x_) :=log(x/(1+x)); integrate(1/(x_+x_^3),x_) := 1/2*log(x^2/(x^2+1)); integrate(1/(x_^4+x_^2),x_) := -atan(x)-1/x; integrate(1/(c_+x_+x_^2), x_) := If(isfree(c,x), If(4c==1, -2/(2*x+1), if(4c>1, 2atan((2*x+1)/sqrt(4c-1))/sqrt(4c-1), -2*atanh((2*x+1)/sqrt(-4c+1))/sqrt(-4c+1) ))); integrate(1/(c_+b_*x_+x_^2), x_) := If(isfree(b,c,x), If(4c==b*b, -1/(x+b/2), if(4c>b*b, 2atan((2*x+b)/sqrt(4c-b*b))/sqrt(4c-b*b), -2*atanh((2x+b)/sqrt(-4c+b*b))/sqrt(-4c+b*b) ))); integrate(1/(c_+x_+a_*x_^2), x_) := If(isfree(a,c,x), If(4a*c==1, -2/(2a*x+1), if(4a*c>1,2*atan((2a*x+1)/sqrt(4a*c-1))/sqrt(4a*c-1), -2*atanh((2a*x+1)/sqrt(-4a*c+1))/sqrt(-4a*c+1) ))); integrate(1/(c_+b_*x_+a_*x_^2), x_) := If(isfree(a,b,c,x), If(4a*c==b*b, -2/(2a*x+b), if(4a*c>b*b,2*atan((2a*x+b)/sqrt(4a*c-b*b))/sqrt(4a*c-b*b), -2*atanh((2a*x+b)/sqrt(-4a*c+b*b))/sqrt(-4a*c+b*b) ))); integrate(sin(log(x_)),x_) := 1/2* x*(sin(log(x))-cos(log(x))); integrate(cos(log(x_)),x_) := 1/2* x*(sin(log(x))+cos(log(x))); integrate(log(log(x_)),x_) := log(log(x))*x-li(x); integrate(log(sin(x_)),x_):= -Cl(2,2x)/2-log(2)*x; integrate(log(cos(x_)),x_):=Cl(2,2*(pi/2-x))/2-log(2)*x; integrate(log(tan(x_)),x_):= -Cl(2,2x)/2-Cl(2,2*(pi/2-x))/2; integrate(log(cot(x_)),x_):= Cl(2,2x)/2+Cl(2,2*(pi/2-x))/2; integrate(log(1+cos(x_)),x_):= 2*Cl(2,2*(pi/2-x))-log(2)*x; integrate(log(1-cos(x_)),x_):= -2*Cl(2,x)-log(2)*x; integrate(log(c_+exp(x_)), x_) := if(isfree(c,x), log(c)*x-polylog(2, -exp(x)/c)); integrate(log(c_+a_*exp(x_)), x_) := if(isfree(a,c,x), log(c)*x-polylog(2,-a*exp(x)/c)); integrate(log(c_+exp(b_*x_)), x_) := if(isfree(b,c,x), log(c)*x+polylog(2, -exp(b*x)/c)/b); integrate(log(c_+a_*exp(b_*x_)), x_) := if(isfree(a,b,c,x), log(c)*x+polylog(2,-a*exp(b*x)/c)/b); integrate(log(c_+x_^2), x_) := If(isfree(c,x), x*log(c+x^2)+2*atan(x/sqrt(c))*sqrt(c)-2*x); integrate(log(c_-x_^2), x_) := If(isfree(c,x), log(sqrt(c)+x)*(sqrt(c)+x)+log(c-x)*(sqrt(c)-x)-2sqrt(c)); integrate(log(x_+x_^2), x_) := log(1+x)+x*log(x)+x*log(1+x)-2*x; integrate(erfi(x_)*exp((-x_^2)),x_):= 2Dawson(-1,x)/sqrt(pi); integrate(erf(x_)*exp((x_^2)),x_):= 2Dawsonminus(-1,x)/sqrt(pi); integrate(exp(a_*x_)/(c_+exp(x_)),x_) := if(isfree(a,c,x),L(-c,1,1-a,x)); integrate(exp(a_*x_)/(c_-exp(x_)),x_) := if(isfree(a,c,x),-L(c,1,1-a,x)); integrate(exp(a_*x_)/(c_+exp(x_)),x_) := if(isfree(a,c,x),L(-c,1,1-a,x)); integrate(exp(a_*x_)/(c_+exp(b_*x_)),x_) := if(isfree(a,b,c,x),L(-c,1,b-a+1,x)); integrate(exp(x_)/(1+x_)^2*x_,x_):= exp(x)/(1+x); integrate(exp(x_)/(1+x_^2)*x_,x_):= exp(i)*Ei(x-i)/2+exp(-i)*Ei(x+i)/2; integrate(exp(a_*x_)/(c_+exp(x_))*x_^n_,x_) := if(isfree(a,c,x),Gamma(n+1)*L(-c,n+1,1-a,x)); integrate(exp(x_)/(c_+exp(x_))*x_^n_,x_) := if(isfree(c,x),Gamma(n+1)*L(-c,n+1,0,x)); integrate(exp(a_*x_)/(c_+exp(x_))*x_,x_) := if(isfree(a,c,x),L(-c,2,1-a,x)); integrate(exp(x_)/(c_+exp(x_))*x_,x_) := if(isfree(c,x),L(-c,2,0,x)); integrate(exp(x_)*log(x_)*x_,x_) := Ei(x) + exp(x)*(x - 1) *log(x) - exp(x); integrate(sin(x_)*exp(b_*x_)*x_,x_):= ((b^3*x-b^2+b*x+1)*sin(x)-(b^2*x-2b+x)*cos(x))*exp(b*x)/(b^2+1)^2; integrate(cos(x_)*exp(b_*x_)*x_,x_):= ((b^3*x-b^2+b*x+1)*cos(x)+(b^2*x-2b+x)*sin(x))*exp(b*x)/(b^2+1)^2; integrate(cos(x_)*exp(-x_)*x_,x_):= (x*sin(x)-x*cos(x)+sin(x))*exp(-x)/2; integrate(sin(x_)*exp(x_)*x_,x_):= (x*sin(x)-x*cos(x)+cos(x))*exp(x)/2; integrate(cos(x_)*exp(x_)*x_,x_):= (x*sin(x)+x*cos(x)-sin(x))*exp(x)/2; integrate(erf(c_*x_^0.5),x_) := (x-1/2/c^2)*erf(c*sqrt(x)) + exp(-c^2*x)*sqrt(x)/sqrt(pi)/c; integrate(f(x_),x_):=F(x); integrate(Dawson(x_),x_) := Dawson(-1,x); integrate(Dawsonminus(x_),x_):= Dawsonminus(-1,x); integrate(si(x_),x_) := x*si(x)+cos(x); integrate(ci(x_),x_) := x*ci(x)-sin(x); integrate(tani(x_),x_) := x*tani(x)+log(cos(x)); integrate(shi(x_),x_) := x*shi(x)-cosh(x); integrate(chi(x_),x_) := x*chi(x)-sinh(x); integrate(Ei(x_),x_) := x*Ei(x)-exp(x); integrate(gaussian(x_),x_) := Phi(x); integrate(Phi(x_),x_) := x*Phi(x)+gaussian(x); integrate(erf(x_),x_) := x*erf(x) + exp(-x^2)/sqrt(pi); integrate(erfi(x_),x_) := x*erfi(x) - exp(x^2)/sqrt(pi); integrate(delta(x_),x_) := theta(x); integrate(theta(y_),x_) := x*theta(y); integrate(sgn(y_),x_) := x*sgn(y); integrate(abs(y_),x_) := integrate(y,x)*sgn(y); integrate(abs(x_)^n_,x_) := If(n== -1, log(abs(x))*sgn(x),sgn(x)*abs(x)^(n+1)/(n+1) ); integrate(log(x_), x_) := x*log(x)-x; integrate(exp(x_),x_) := exp(x); integrate(sqrt(x_),x_) := 2/3*x^(3/2); integrate(cbrt(x_),x_) := 3/4*x^(4/3); integrate(root(x_,n_),x_) := if(hasnot(n,x),root(x,1+n)/(1+n) ); integrate(pow(x_,n_),x_) := if(hasnot(n,x),pow(x,1+n)/(1+n) ); integrate(sin(x_), x_) := -cos(x); integrate(cos(x_), x_) := sin(x); integrate(tan(x_), x_) := -log(cos(x)); integrate(cot(x_), x_) := log(sin(x)); integrate(sec(x_), x_) := log(tan(x/2+pi/4)); integrate(csc(x_), x_) := log(tan(x/2)); integrate(sinc(x_), x_) := si(x); integrate(asin(x_), x_) := x*asin(x)+sqrt(1-x^2); integrate(acos(x_), x_) := x*acos(x)-sqrt(1-x^2); integrate(atan(x_), x_) := x*atan(x)-log(1+x^2)/2; integrate(acot(x_), x_) := x*acot(x)+log(1+x^2)/2; integrate(asec(x_), x_) := x*asec(x)-acosh(x); integrate(acsc(x_), x_) := x*acsc(x)+acosh(x); integrate(sinh(x_), x_) := cosh(x); integrate(cosh(x_), x_) := sinh(x); integrate(tanh(x_), x_) := log(cosh(x)); integrate(coth(x_), x_) := log(sinh(x)); integrate(sech(x_), x_) := 2atan(tanh(x/2)); integrate(csch(x_), x_) := log(tanh(x/2)); integrate(asinh(x_), x_) := x*asinh(x)-sqrt(1+x^2); integrate(acosh(x_), x_) := x*acosh(x)-sqrt(-1+x^2); integrate(atanh(x_), x_) := x*atanh(x)+log((1-x^2))/2; integrate(acoth(x_), x_) := x*acoth(x)+log((1-x^2))/2; integrate(asech(x_), x_) := x*asech(x)+asin(x); integrate(acsch(x_), x_) := x*acsch(x)+asinh(x); integrate(x_,x_) := 1/2*x^2; integrate(y_) := integrate(y, x);