# integrate(y,x); integrate(y_,x_,a_):= if(a==0,y, if(a==1,int(y,x), d(y,x,-a) )); #integrate(y_,x_,a_,b_) := block(g(x):=integrate(y_,x_), g2:=g(x), g1:=g(x), replace(g2,x_,b_)-replace(g1,x_,a_)); #integrate(y_,x_,a1_,b1_) := If((a1 <= 0) and (b1 >= 0) , If(replace(y,x,0) == inf, inf)); #integrate(y_,x_,a2_,b2_) := If((a2 <= 0) and (b2 >= 0) and (replace(y,x,0) == -inf), -inf); #integrate(y_,x_,a3_,b3_) := If((a3 >= 0) and (b3 <= 0) and (replace(y,x,0) == inf), -inf); #integrate(y_,x_,a4_,b4_) := If((a4 >= 0) and (b4 <= 0) and (replace(y,x,0) == -inf), inf); 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_*y(n_,x_),x_,n_):=integrate(a,y,n); integrate(a_*y(1,x_),x_):=integrate(a,y); integrate(a_=b_,x_):= integrate(a,x)=integrate(b,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(-b_,x_) := -integrate(b,x); integrate(x_^x_+log(x_)*x_^x_, x_):= x^x; 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(inversef(x_),x_) := x*inversef(x)-F(inversef(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(x_^n_,x_):= If(isfree(n,x),If(n== -1, log(x), x^(1+n)/(1+n) )); 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(x_^x_,x_) := Sophomore(x); integrate(x_^(a_*x_),x_) := Sophomore(a,x); 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((1-x_^a_)/(1-x_),x_):=harmonic(a,1,x); #integrate((-1+x_^a_)/(-1+x_),x_):=harmonic(a,1,x); #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(exp(x_)*(t_-x_)^(-1/2),x_):= -sqrt(pi)*exp(t)*erf(sqrt(t-x)); #integrate(log(x_)*(t_-x_)^(-1/2), x_):= -4 sqrt(t)* atanh(sqrt(t-x)/sqrt(t))-2 sqrt(t-x)* (-2+log(x)); #integrate(sinh(x_)*(t_-x_)^(-1/2),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_)^(-1/2),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, atan(x^2/sqrt(b))/2/sqrt(b), atanh(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(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(1/log(x_),x_) := li(x); integrate(1/log(x_^n_),x_) := Ei(log(x^n)/n)/n; integrate(x_^a_*log(x_), x_) := If(a== -1,log(x)^2/2, -Gamma(2,-(1+a)*log(x))/(1+a)^2); integrate(x_^a_*log(x_)^b_, 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_)*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(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)) ); integrate(1/(c_+log(x_)),x_) := if(isfree(c,x),Ei(c+log(x))*exp(-c)); #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), if(isfree(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_^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_)*x_^n_,x_) := If(n>1, 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((x_-t_)^n_*exp(t_),t_) := If(isfree(t,x),exp(x)*Gamma(n+1,-t+x) ); integrate((x_-t_)^n_exp(-t_),t_) := If(isfree(t,x),(-1)^(-n)*exp(-x)*Gamma(n+1,t-x) ); #integrate(x_*exp(-x_),x_) := -x*exp(-x)-exp(-x); #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(a_*x_)*x_^n_,x_) := If(isfree(a,x), Gamma(n+1,-a*x)/a/(-a)^n ); integrate(x_*exp(x_^2),x_) := exp(x^2)/2; integrate(x_*exp(a_*x_^2),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_) := 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_/(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_+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_/(exp(c_*x_)-1),x_) := if(isfree(c,x), -polylog(2,1-exp(-c*x))/c); integrate(x_^n_/(exp(-x_)+exp(x_)),x_) := if(isfree(c,x), Gamma(n+1)*beta(n+1,x)); integrate(x_/(exp(-x_)+exp(x_)),x_) := beta(2,x); integrate(x_*sech(x_),x_) := 2beta(2,x); integrate(sin(x_)*x_^n_,x_):= -1/2*i^n*(Gamma(1+n,i*x)+(-1)^n*Gamma(1+n,-i*x)); integrate(cos(x_)*x_^n_,x_):= 1/2*i^n*(Gamma(1+n,i*x)+Gamma(1+n,-i*x)); integrate(sinh(x_^n_),x_):= -1/2*Gamma(1/n, -x^n)/n*(-1)^(-1/n)+(1/2)*Gamma(1/n, x^n)/n; integrate(cosh(x_^n_),x_):= (-1/2)*Gamma(1/n, -x^n)/n*(-1)^(-1/n)+(-1/2)*Gamma(1/n, x^n)/n; integrate(sin(x_^n_),x_):= If(n==0.5, 2*sin(sqrt(x))-2*sqrt(x)*cos(sqrt(x)), If(n==2, sqrt(pi/2)*S(sqrt(2/pi)*x), 1/2*i*Gamma(1/n, (-i)*x^n)/n*(-i)^(-1/n)+(-0.5*i)*Gamma(1/n, i*x^n)/n*i^(-1/n) )); integrate(cos(x_^n_),x_):= If(n==0.5, 2*cos(sqrt(x))+2*sqrt(x)*sin(sqrt(x)), If(n==2, sqrt(pi/2)*C(sqrt(2/pi)*x), (-1/2)*Gamma(1/n, (-i)*x^n)/n*(-i)^(-1/n)+(-1/2)*Gamma(1/n, i*x^n)/n*i^(-1/n) )); 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(sech(x_)^2, x_) := tanh(x); integrate(csch(x_)^2, x_) := -coth(x); integrate(sech(x_)*tanh(x_),x_):= -sech(x); integrate(csch(x_)*coth(x_),x_):= -csch(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(x_/asin(x_), x_) := si(2asin(x))/2; integrate(x_/acos(x_), x_) := -si(2acos(x))/2; #integrate(atan(x_)/x_, x_) := atani(x); integrate(atan(x_)/x_, x_) := i*polylog(2,i*x)/2-i*polylog(2,-i*x)/2; #integrate(sin(a_*x_)/x_, x_) := If(isfree(a,x),si(a*x)); #integrate(cos(a_*x_)/x_, x_) := If(isfree(a,x),ci(a*x)); 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(sinh(x_)/x_, x_) := shi(x); integrate(cosh(x_)/x_, x_) := chi(x); integrate(tanh(x_)/x_, x_) := thi(x); integrate(sinh(x_^n_)/x_, x_) := If(isfree(n,x),shi(x^n)/n); integrate(cosh(x_^n_)/x_, x_) := If(isfree(n,x),chi(x^n)/n); integrate(atanh(x_)/x_, x_) := polylog(2,x)/2-polylog(2,-x)/2; 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(sinh(x1_)*exp(x2_), x_) := int(exp(x1+x2)/2,x)-int(exp(x1-x2)/2,x); integrate(cosh(x1_)*exp(x2_), x_) := int(exp(x1+x2)/2,x)+int(exp(x1-x2)/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(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_)*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(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(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(exp(x_)/(1-x_^2),x_):= -1/2 *exp(1) *Ei(-1 + x) + Ei(1 + x)/(2 exp(1)); #integrate(log(x_)*exp(x_),x_):= log(x)*exp(x)-Ei(x); #integrate(log(x_)*exp(-x_),x_):= Ei(-x)-log(x)*exp(-x); 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((c_+x_)^0.5/x_, 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_) := If(isfree(c,x),x*sqrt(c+x^2)/2+asinh(x+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((x_^2-c_)^0.5, x_) := If(isfree(c,x),x*sqrt(x^2-c)/2-acosh(x-c)/2 ); integrate((c_+x_^2)^(-0.5), x_) := If(isfree(c,x), asinh(x/sqrt(c)) ); integrate((c_-x_^2)^(-0.5), x_) := If(isfree(c,x), asin(x/sqrt(c)) ); integrate((c_-x_^2)^(0.5), x_) := If(isfree(c,x), (sqrt(c-x^2)*x+c*asin(x/sqrt(c)))/2 ); integrate((x_^2-c_)^(-0.5), x_) := If(isfree(c,x), acosh(x/sqrt(c)) ); 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(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((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((c_ + b_* x_ + x_^2)^(-0.5),x_) := if(isfree(b,c,x),if(b*b==4c, log(x+b/2),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_/sgn(y_),x_) := integrate(a,x)/sgn(y); integrate(a_*theta(y_),x_) := theta(y)*integrate(a,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^(1/2)-2/3*pi^(-1/2)*x^1.5, mittag(a,2,x^a)*x^2-int(mittag(a,2,x^a)*x,x) ); 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/(c_+exp(x_)),x_) := if(isfree(c,x),x/c-log(c+exp(x))/c); #integrate(1/(a_+b_*exp(x_)),x_) := if(isfree(a,b,x), x/a-log(a+b*exp(x))/a); integrate(1/(a_+exp(x_)),x_) := if(isfree(a,x), x/a-log(a+exp(x))/a); #integrate(1/(a_+exp(x_)),x_) := if(isfree(a,x),polylog(1,-a,x)/a); integrate(1/(a_+b_*exp(x_)),x_) := if(isfree(a,b,x), polylog(1,-a/b,x)/a); integrate(1/(a_+exp(c_*x_)),x_) := if(isfree(a,c,x), polylog(1,-a,c*x)/a/c); integrate(1/(a_+b_*exp(c_*x_)),x_) := if(isfree(a,b,c,x), polylog(1,-a/b,c*x)/a/c); #integrate(1/(exp(-x_)+exp(x_)),x_) := atan(sinh(x)); #integrate(1/(exp(x_)-exp(-x_)),x_) := log(tanh(1/2*x)); 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(isfree(a,x),(2 atan((a* tan(x/2) + 1)/sqrt(a^2 - 1)))/sqrt(a^2 - 1) ))); integrate(1/(a_+cos(x_)),x_):= if(a==1, tan(x/2), if(a==-1, cot(x/2), if(isfree(a,x),-(2 atanh(((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(a>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(a>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/(cos(x_)+sin(x_)),x_):=log(tan(pi/8+x/2))/sqrt(2); 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/(1+x_^n_),x_) := if(n<0,x+B(-1/n,1/n-1,x)/n,B(1/n,1-1/n,x)/n); integrate(1/(a_+x_^2),x_) := If(isfree(a,x), If(a>0, atan(x/sqrt(a))/sqrt(a), -atanh(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, atan(x*sqrt(b/a))/sqrt(a)/sqrt(b), atanh(x*sqrt(-b/a))/sqrt(-b*a) )); 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), 2atanh((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, -2/(2*x+b), if(4c>b*b, 2atan((2*x+b)/sqrt(4c-b*b))/sqrt(4c-b*b), 2atanh((2*x+b)/sqrt(-4c+b*b))/sqrt(-4c+b*b) ))); 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(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/(x_+x_^2),x_) :=log(x/(1+x)); 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_):= -x* log(1-exp(2* i *x))+x* log(sin(x))+1/2 *i* (x^2+polylog(2,(exp(2* i *x)))); #integrate(log(cos(x_)),x_):= 1/2* i* (x* (x+2* i* log(1+exp(2* i* x))-2* i* log(cos(x)))+polylog(2,(-exp(2* i* 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(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(a_*delta(x_),x_) := replace(a,x,0)*theta(x); integrate(a_*delta(x_+c_),x_) := replace(a,x,-c)*theta(x+c); 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(mittag(a_,c_*x_^a_), x_) := if(hasnot(c,x), mittag(a,2,c*x^a)*x ); integrate(mittag(a_,x_^a_), x_) := if(a==0.5, mittag(0.5,x^0.5)-2/sqrt(pi)*sqrt(x),mittag(a,2,x^a)*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(gauss(x_),x_) := gaussi(x); integrate(gaussi(x_),x_) := x*gaussi(x)+gauss(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)*step(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_) := root(x,1+n)/(1+n); integrate(pow(x_,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(y_), x_) := x*asin(y)-int(d(y,x)*x/sqrt(1-y^2),x); integrate(acos(y_), x_) := x*acos(y)-int(d(y,x)*x/sqrt(1-y^2),x); #integrate(atan(y_), x_) := x*atan(y)-int(d(y,x)*x/(1+y^2),x); #integrate(acot(y_), x_) := x*acot(y)-int(d(y,x)*x/(1+y^2),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_) := atan(sinh(x)); 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(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(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))/e^x/2; integrate(sin(x_)*exp(x_)*x_,x_):= (x*sin(x)-x*cos(x)+cos(x))*e^x/2; integrate(cos(x_)*exp(x_)*x_,x_):= (x*sin(x)+x*cos(x)-sin(x))*e^x/2; integrate(x_,x_) := 1/2*x^2; integrate(y_) := integrate(y, x);