# d(y,x,n,a) is fractional differentiation of y with x in n order at x = a; d(a_ and b_,x_,n_):=d(a,x,n) and d(b,x,n); d(a_ and b_,x_):=d(a,x) and d(b,x); d(x_=>a_ and b_,x_,n_):=d(x=>a,x,n) and d(x=>b,x,n); d(x_=>a_ and b_,x_):=d(x=>a,x) and d(x=>b,x); d(a_=b_,x_,n_):=d(a,x,n)=d(b,x,n); d(a_+b_,x_,n_):=d(a,x,n)+d(b,x,n); d(a_*b_,x_,n_):= if(n>0 and n<=1, a*d(b,x,n)+b*d(a,x,n) ); d(1/b_,x_,n_):= if(n>0 and n<=1, -d(b,x,n)/b^2 ); d(a_/b_,x_,n_):= if(n>0 and n<=1, d(a,x,n)/b-d(b,x,n)*a/b^2 ); d(b_/a_,x_,n_):= if(n>0 and n<=1, d(b,x,n)/a-d(a,x,n)*b/a^2 ); d(-y_,x_,n_):= -d(y,x,n); d(a_=b_,x_):=d(a,x)=d(b,x); d(a_+b_,x_):=d(a,x)+d(b,x); d(a_*b_,x_):=If(isfree(a,x), a*d(b,x) ); d(gsolution(b_,m_,d_,y_,x_,n_),x_,m_):= -d/b*gsolution(b_,m_,d_,y_,x_,n_); d(gsolution(b_,m_,d_,y_,x_,n_),x_,n_):=0; d(gsolution(b_,1,d_,y_,x_,n_),x_):= -d/b*gsolution(b_,1,d_,y_,x_,n_); d(gsolution(b_,d_,y_,x_,n_),x_,n_):=0; d(gsolution(b_,d_,y_,x_,n_),x_):= -d/b*gsolution(b_,d_,y_,x_,n_); d(psolution(c_,d_,y_,x_,n_),x_,n_):= d+c*psolution(c,d,y,x,n); d(psolution(b_,1,c_,n_,y_,x_,p_),x_):= -c/b*psolution(b,1,c,n,y,x,p); d(psolution(b_,1,c_,n_,y_,x_,p_),x_,p_):= n; d(nsolve(y_),x_,n_):=0; d(nsolve(y_),x_):=0; d(ds(y_,x_,n_),x_,m_) := ds(y,x,n+m); d(d(y_,x_,n_),x_,m_) := d(y,x,n+m); d(d(y_,x_),x_,n_) := d(y,x,n+1); d(d(y_,x_,n_),x_) := d(y,x,n+1); d(d(y_,x_),x_) := d(y,x,2); d(integrate(y_,x_),x_, p_) := d(y,x,p-1); d(integrate(y_,x_,n_),x_) := d(y,x,1-n); d(a_*integrate(y_,x_,n_),x_) := if(hasnot(a,x), a*d(y,x,1-n) ); d(a_*integrate(y_,x_,n_),x_,p_) := if(hasnot(a,x), a*d(y,x,p-n) ); d(integrate(y_,x_,n_),x_,p_) := d(y,x,p-n); d(vector(a_,b_),x_,n_):=vector(d(a,x,n),d(b,x,n)); d(vector(a_,b_,c_),x_,n_):=vector(d(a,x,n),d(b,x,n),d(c,x,n)); d(x_*y_,x_,n_):=If(isfree(y,x),If(n>1,0), if(abs(n)<=1,x*d(y,x,n)+n*d(y,x,n-1) )); d(a_*x_,x_,n_):=If(isfree(a,x),If(n>1,0), if(abs(n)<=1,x*d(a,x,n)+n*d(a,x,n-1) )); d((tx_)^m_,x_,n_) := If(isfree(m,x) and d(tx,x,2)==0, if(isinteger(m) and m>0 and re(n)>m, 0, If(n<0 and n==m, 1/(-1-n)!*(-1)^(1+n)*log(tx)*d(tx,x)^n, if(n<0 and m== -1, ln(1+n,tx), if(n>-1, fallingfactorial(m,n)*tx^(m-n)*d(tx,x)^n ))))); #d(y_^a_,x_,n_):= If(n>0 and isfree(a,x), a*d(y,x,n)*y^(a-n)/n! ); d(a_^x_,x_,n_):= If(n>0 and isfree(a,x), log(a)^n*a^x ); d((a_+x_^m_)^b_,x_,n_):= if(hasnot(a,b,x) and n>0 and n<=1, fallingfactorial(b,n)*(a+x^m)^(b-n)*m^n*x^(m*n-n)); d((a_+c_*x_^m_)^b_,x_,n_):= if(hasnot(a,b,c,x) and n>0 and n<=1, fallingfactorial(b,n)*(a+c*x^m)^(b-n)*c^n*m^n*x^(m*n-n)); d(c_^(a_*x_),x_,n_) := If(isfree(c,a,x),(a*log(c))^n*c^(a*x)); d(c_^(x_+b_),x_,n_) := If(isfree(c,b,x), log(c)^n*c^(x+b)); d(c_^(b_+a_*x_),x_,n_) := If(isfree(c,b,a,x), (a*log(c))^n*c^(a*x+b)); #d(e^f_*y_,x_,p_):= If(p<=0 and p>= -1 and isfree(y*d(f,x)^p,x), e^f*y*d(f,x)^p, If(p>=0 and p<=1 and f<>x, d(f,x)^p*replace(d(e^x*y,x,p),x,f) )); #d(exp(x_)*y_,x_,p_):= If(p>=0 and p<=1, exp(x)*(p*d(y,x,p)+y)); #d(exp(a_+x_)*y_,x_,p_):= If(isfree(a,x), e^a*d(e^x*y,x,p)); #d(exp(a_+x_)*y_,x_,p_):= If(isfree(a,x), exp(a)*d(e^x*y,x,p)); d(a_*sinh(x_),x_,p_):= d(a*e^x/2-a*exp(-x)/2,x,p); d(a_*cosh(x_),x_,p_):= d(a*e^x/2+a*exp(-x)/2,x,p); #d(sinh(x_)*f_^(x_),x_,n_):= If(isfree(f,x), exp((log(f)+1)*x)*(log(f)+1)^n/2-d(exp((log(f)-1)*x),x,n)/2 ); #d(cosh(x_)*f_^(x_),x_,n_):= If(isfree(f,x), exp((log(f)+1)*x)*(log(f)+1)^n/2+d(exp((log(f)-1)*x),x,n)/2 ); #d(sinh(x_)*f_^(-x_),x_,n_):= If(isfree(f,x), d(exp((1-log(f))*x),x,n)/2-exp((-log(f)-1)*x)*(-log(f)-1)^n/2 ); #d(cosh(x_)*f_^(-x_),x_,n_):= If(isfree(f,x), d(exp((1-log(f))*x),x,n)/2+exp((-log(f)-1)*x)*(-log(f)-1)^n/2 ); d(sinh(x_)*exp(x_),x_,n_):= exp(2x)*2^n/2; d(cosh(x_)*exp(x_),x_,n_):= exp(2x)*2^n/2; d(sinh(x_)*exp(b_*x_),x_,n_):= if(hasnot(b,x),exp((1+b)*x)*(1+b)^n/2-exp((b-1)*x)*(b-1)^n/2 ); d(cosh(x_)*exp(b_*x_),x_,n_):= if(hasnot(b,x),exp((1+b)*x)*(1+b)^n/2+exp((b-1)*x)*(b-1)^n/2 ); d(sinh(a_*x_)*exp(b_*x_),x_,n_):= if(hasnot(a,b,x),exp((a+b)*x)*(a+b)^n/2-exp((b-a)*x)*(b-a)^n/2 ); d(cosh(a_*x_)*exp(b_*x_),x_,n_):= if(hasnot(a,b,x),exp((a+b)*x)*(a+b)^n/2+exp((b-a)*x)*(b-a)^n/2 ); d(mittag(a_,a_,c_*x_^a2_),x_,a_) := If(isfree(c,x) and a2== -a, c*x^(-2a)*mittag(a,a,c*x^a2) ); d(mittag(a_,a_,x_^a2_),x_,a_) := If( a2== -a, x^(-2a)*mittag(a,a,x^a2) ); d(mittag(a_,b_,x_^a_),x_,a_) := 1/x^a/Gamma(b-a)+mittag(a,b,x^a); d(mittag(a_,b_,c_*x_^a_),x_,a_) := If(isfree(c,x), 1/x^a/Gamma(b-a)+c*mittag(a,b,c*x^a) ); d(mittag(a_,b_,x_^a_)*x_^d_,x_,a2_) := If(d==b-1, If(a2==a,x^(b-a-1)/Gamma(b-a)+x^d*mittag(a,b,x^a),If(a2== -a,x^(a+b-1)*mittag(a,a+b,x^a),x^(d-a)*mittag(a,b-a,x^a) ))); d(mittag(a_,b_,c_*x_^a_)*x_^d_,x_,a2_) := If(isfree(c,x) and d==b-1, If(a2==a,x^(b-a-1)/Gamma(b-a)+c*x^d*mittag(a,b,c*x^a), If(a2== -a,x^(a+b-1)*mittag(a,a+b,c*x^a),c*x^(d-a)*mittag(a,b-a,c*x^a) ))); #d(mittag(p_,f_)*y_,x_, p2_):= If(p2<0 and p2> -1 and isfree(d(f,x,p)/y,x), mittag(p,f)/d(f,x,p)*y*p!, if(p2==p, y*d(f,x,p)*mittag(p,f)/(p!)+d(y,x,p2)*mittag(p,f) )); #d(c_*mittag(p_,f_),x_, p2_):= If(p2<0 and p2> -1 and isfree(d(f,x,p)/c,x), mittag(p,f)/d(f,x,p)*c*p!,if(p2==p, c*p^(-p)*d(f^(1/p-1),x)^p*mittag(p,f)+d(c,x,p2)*mittag(p,f) )); d(c_*mittag(p_,f_),x_, p2_):= If(p2<0 and p2> -1 and isfree(d(f,x,p)/c,x), mittag(p,f)/d(f,x,p)*c*p!,if(p2==p, c*d(f,x,p)*mittag(p,f)/(p!)+d(c,x,p2)*mittag(p,f) )); d(exp(x_)/mittag(p_,x_^p_)/x_,x_, p2_):= If(p==p2, ln(p,x)*exp(x)/mittag(p,x^p), if(p+p2==0, ln(p,x)*exp(x)/mittag(p,x^p) )); d(exp(x_)/mittag(p_,x_^p_),x_, p2_):= If(p==p2, 2*exp(x)/mittag(p,x^p), if(p+p2==0, 1/2*exp(x)/mittag(p,x^p) )); d(exp(x_)/mittag(p_,b_*x_^p_),x_, p2_):= If(p==p2, 2b*exp(x)/mittag(p,b*x^p), if(p+p2==0, 1/2/b*exp(x)/mittag(p,b*x^p) )); d(exp(x_)*mittag(p_,b_*x_^p_),x_, p2_):= If(p==p2, 2b*exp(x)*mittag(p,b*x^p), if(p+p2==0, 1/2/b*exp(x)*mittag(p,b*x^p) )); d(exp(x_)*mittag(p_,x_^p_),x_, p2_):= If(p==p2, 2*exp(x)*mittag(p,x^p), if(p+p2==0, 1/2*exp(x)*mittag(p,x^p) )); d(exp(x_)*mittag(a_,-x_^a_)/x_,x_,a2_) := If(a+a2==0, exp(x)*ln(a,x)*mittag(a,-x^a) ); d(1/mittag(a_,x_^a_)*x_^n_, x_,q_) := If(re(n)>0,if(re(q-n)>0,-x^n, if(q==n,-x^n-n!, if(isinteger(2*(n-q)) and a+q==0,-sum(n!/(n-k)!*x^(n-k),k,0,n,q)/mittag(a,x^a) )))); #d(x_/mittag(a_,x_^a_),x_,n_):= if(n==1,-x-1, if(n== -0.5,1+x^(1+n)/(1+n)!, if(n==0.5,-x/c-x^n/n!-1, if(re(n)>1,-x ))))/mittag(a,x^a); #d(1/mittag(a_,x_^a_)*x_^a_,x_,a2_) := If(a2== -a, -1/E(a,x^a)*(x^a+a!),If(a2==a, 1/E(a,x^a)*(-x^a+a!) )); #d(1/mittag(a_,-x_^a_)*x_^a_,x_,a2_) := If(a2== -a, 1/E(a,-x^a)*(x^a-a!),If(a2==a, 1/E(a,-x^a)*(x^a+a!) )); #d(1/mittag(a_,x_^a_)*x_,x_,a2_) := If(a2== -a, -1/E(a,x^a)*(x+x^a/a!+1),If(a2==a, 1/E(a,x^a)*(-x+x^a/a!) )); #d(1/mittag(a_,-x_^a_)*x_,x_,a2_) := If(a2== -a, 1/E(a,-x^a)*(x-x^a/a!+1),If(a2==a, 1/E(a,-x^a)*(x+x^a/a!) )); d(1/mittag(a_,x_^a_)*x_^a_,x_,a2_) := if(a+a2==0, -1/E(a,x^a)*(x^a+a!) ); d(1/mittag(a_,b_*x_^a_)*x_^a_,x_,a2_) := if(a+a2==0, -1/E(a,b*x^a)*(x^a/b+a!/b^2) ); d(1/mittag(a_,x_^a_)*x_,x_,a2_) := if(a+a2==0, -1/E(a,x^a)*(1+x+x^a/a!) ); d(1/mittag(a_,b_*x_^a_)*x_,x_,a2_) := if(a+a2==0, -1/E(a,b*x^a)*(1/b^3+x/b+x^a/b^2/a!) ); d(1/mittag(a_,c_*x_^a_),x_,a3_) := If(hasnot(c,x), if(a+a3==0, -1/c/mittag(a,c*x^a), if(a==a3, -c/mittag(a,c*x^a) ))); #d(1/mittag(a_,-x_^a_),x_,a2_) := If(a==a2 or -a==a2, 1/mittag(a,-x^a)); d(1/mittag(a_,x_^a_),x_,a1_) := If(a==a1 or -a==a1, -1/mittag(a,x^a)); #d(mittag(p_,f_),x_,p_):= if(p>0 and p<1, d(f,x,p)*mittag(p,f)/(abs(p))!); #d(mittag(p_,f_),x_,p_):= if(p>0 and p<1, p^(-p)*d(f^(1/p-1),x)^p*mittag(p,f)); #d(mittag(p_,x_),x_,p_):= if(p>0 and p<1, p^(-p)*x^(1-p)*mittag(p,x)); #d(mittag(a_,c_*x_^a_*y_),x_,a2_) := If(isfree(c,y,x) and a==a2, c*mittag(a,c*x^a)*y, c^sgn(a2)*mittag(a,c*x^a)*y^sgn(a2) ); d(mittag(p_,f_),x_,p_):= if(p>0,d(f,x,p)*mittag(p,f)/(p)! ); d(mittag(a_,c_*x_^a_),x_,a3_) := If(hasnot(c,x), if(a+a3==0, 1/c*mittag(a,c*x^a), if(a==a3, c*mittag(a,c*x^a) ))); d(mittag(a_,x_^a_),x_,a1_) := If(a==a1 or a+a1==0, mittag(a,x^a) ); #d(Gamma(a_,f_), x_,p_) := if(p>0 and p<=1,-d(exp(-f)*f^(a-1),x,p-1)*d(f,x,p)/p! ); d(Gamma(a_,x_), x_,p_) := if(p>0 and p<=1,exp(-x)*x^(a-p),-d(exp(-x)*x^(a-1),x,p-1) ); #d(Gamma(a_,b_*x_), x_,p_) := if(hasnot(b,x), -b^a*d(exp(-b*x)*(x)^(a-1),x,p-1) ); d(Gamma(n_,a_*x_),x_,p_) := If(p>= -1 and p<0, d(x^n/n+exp(-p*x)*Gamma(n, a*x),x,1+p), If(p>0 and p<=1, (-a)^(n-p)*exp(-a*x)*x^(n-p) )); #d(Gamma(a_,x_), x_,n_) := if(n>0 and (n)<1,(-1)^n* x^(-n)* sum(binomial(n, k) *Gamma(a - k + n, x)* risingfactorial(a,k),k,0,n)); #d(Gamma(a_,x_), x_,n_) := if(abs(n)<1, Gamma(n,a,x)); #d(Gamma(x_), x_,p_) := if(p>0 and p<1, Gamma(x)*sum(binomial(p-1,k)*psi(x)^(p-1)*psi(k,x)^(k),k,0,p)); #d(Gamma(x_), x_,p_) := Gamma(p,x,0); #d(Gamma(n_,a_*log(x_)),x_,p_) := If(a+p<>0 and ((p> -1 and p<=0) or n==p), Gamma(n-p, (a+p)*log(x)) ); #d(Gamma(n_,a_*log(c_+x_)),x_,p_) := If(a+p<>0 and ((p> -1 and p<=0) or n==p), Gamma(n-p, (a+p)*log(c+x)) ); #d(Gamma(n_,log(x_)),x_,p_) := If(p> -1 and p<=0, Gamma(n-p, (1+p)*log(x)), If(p>=0 and p<=1, (-1)^(n-p)*x^(-1-p)*log(x)^(n-p) )); d(Gamma(n_,a_*log(x_)),x_,p_) := If(p>= -1 and p<0, d(log(x)^n/n+x^(-p)*Gamma(n, a*log(x)),x,1+p), If(p>0 and p<=1, (-1)^(a+n)*x^(-p-a)*log(x)^(n-p) )); #d(Gamma(n_,a_*log(x_)),x_,p_) := If(abs(p)<=1, d(log(x)^n/n+x^(-p)*Gamma(n, a*log(x)),x,1+p) ); d(Gamma(n_,log(x_)),x_,p_) := If(p>= -1 and p<0, d(log(x)^n/n+x^(-p)*Gamma(n, log(x)),x,1+p), If(p>0 and p<=1, -x^(-2p)*log(x)^(n-p) )); #d(Gamma(n_,a_*x_^m_),x_,p_):= If(p>= -1 and p<0, a^(-1/m)*(-m)^p*Gamma(n+p-p/m,a*x^m), If(p>0 and p<=1 and isfree(a,x) and n+p-p/m==1, (a)^(p/m-p)*(-a*m)^p*exp(-a*x^m) )); #d(Gamma(n_,a_*x_^m_),x_,p_):= If(p>= -1 and p<0, 1/a*(-m)^p*Gamma(n+p-p/m,a*x^m) ); d(Gamma(n_,x_^m_),x_,p_):= If(p>= -1 and p<0, (-m)^p*Gamma(n+p-p/m,x^m) ); d(Gamma(x_), x_,p_) := Gamma(x)*R(p,x); d(factorial(x_), x_,p_) := factorial(x)*R(p,x); #d(factorial(x_), x_,p_) := infints(exp((-t))*t^x*log(x)^p,t); d(inverseli(q_,f_), x_,p_) := if(p>0 and not(isinteger(p)),log(inverseli(q,f))^(p+q)*d(f,x,p)/p! ); d(inverseli(q_,f_), x_) := if(p>0 and p<=1,log(inverseli(q,f))*d(f,x) ); d(inverseli(p_,f_), x_,p_) := if(p>0 and not(isinteger(p)),log(inverseli(p,f))*d(f,x,p)/p! ); d(inverseEi(p_,f_), x_,p_) := if(p>0 and not(isinteger(p)),exp(-inverseEi(p,f))*inverseEi(p,f)*d(f,x,p)/p! ); d(inverseerfi(p_,f_), x_,p_) := if(p>0 and not(isinteger(p)),1/2*sqrt(pi)*exp(-inverseerfi(p,f)^2)*d(f,x,p)/p! ); d(inverseerf(p_,f_), x_,p_) := if(p>0 and not(isinteger(p)),1/2*sqrt(pi)*exp(inverseerf(p,f)^2)*d(f,x,p)/p! ); d(Ai(p_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*AiPrime(p,f)/p! ); d(AiPrime(p_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*Ai(p,f)*f/p! ); d(ln(p_,f_),x_,p_):= if(p>0 and has(f,c_1),exp(ln(p,f))*d(f,x,p)/p! ); d(sin(x_)*exp(x_),x_,n_):=sin(x+n*pi/4)*exp(x)*2^(n/2); d(cos(x_)*exp(x_),x_,n_):=cos(x+n*pi/4)*exp(x)*2^(n/2); d(sin(a_*x_)*exp(x_),x_,n_):=If(isfree(a,x), sin(a*x+n*atan(a))*exp(x)*(a^2+1)^(n/2)); d(cos(a_*x_)*exp(x_),x_,n_):=If(isfree(a,x), cos(a*x+n*atan(a))*exp(x)*(a^2+1)^(n/2)); d(sin(x_)*exp(b_*x_),x_,n_):=If(isfree(b,x), sin(x+n*atan(1/b))*exp(b*x)*(1+b^2)^(n/2)); d(cos(x_)*exp(b_*x_),x_,n_):=If(isfree(b,x), cos(x+n*atan(1/b))*exp(b*x)*(1+b^2)^(n/2)); d(sin(a_*x_)*exp(b_*x_),x_,n_):=If(isfree(a,b,x), sin(a*x+n*atan(a/b))*exp(b*x)*(a^2+b^2)^(n/2)); d(cos(a_*x_)*exp(b_*x_),x_,n_):=If(isfree(a,b,x), cos(a*x+n*atan(a/b))*exp(b*x)*(a^2+b^2)^(n/2)); d(sin(x_+b_)*exp(x_),x_,n_):=If(isfree(b,x), sin(x+n*pi/4+b)*exp(x)*2^(n/2)); d(cos(x_+b_)*exp(x_),x_,n_):=If(isfree(b,x), cos(x+n*pi/4+b)*exp(x)*2^(n/2)); d(sin(x_+c_)*exp(b_*x_),x_,n_):=If(isfree(c,b,x), sin(c+x+n*atan(1/b))*exp(b*x)*(1+b^2)^(n/2)); d(cos(x_+c_)*exp(b_*x_),x_,n_):=If(isfree(c,b,x), cos(c+x+n*atan(1/b))*exp(b*x)*(1+b^2)^(n/2)); d(exp(x_)*sin(a_*x_+b_),x_,n_):=If(isfree(a,b,x), sin(a*x+n*atan(a)+b)*exp(x)*(a^2+1)^(n/2) ); d(exp(x_)*cos(a_*x_+b_),x_,n_):=If(isfree(a,b,x), cos(a*x+n*atan(a)+b)*exp(x)*(a^2+1)^(n/2) ); d(exp(c_*x_)*sin(a_*x_+b_),x_,n_):=If(isfree(a,b,c,x), sin(a*x+b+n*atan(a/c))*exp(c*x)*(a^2+c^2)^(n/2) ); d(exp(c_*x_)*cos(a_*x_+b_),x_,n_):=If(isfree(a,b,c,x), cos(a*x+b+n*atan(a/c))*exp(c*x)*(a^2+c^2)^(n/2) ); d((x_+b_)^k_*(x_+d_)^m_,x_,n_):= If(isfree(b,k,d,m,x), sum(fallingfactorial(k,n-r)*fallingfactorial(m,r)*binomial(n,r)*(x+b)^(k-n+r)*(x+d)^(m-r),r,0,ceil(abs(m)))); d((a_*x_+b_)^k_*(c_*x_+d_)^m_,x_,n_):= If(isfree(a,b,k,c,d,m,x), sum(binomial(n,r)*a^(r-n)*c^r*fallingfactorial(k,n-r)*fallingfactorial(m,r)*(a*x+b)^(k-n+r)*(c*x+d)^(m-r),r,0,ceil(abs(m)))); d((x_+b_)^k_*(c_*x_+d_)^m_,x_,n_):= If(isfree(b,k,c,d,m,x), sum(binomial(n,r)*c^r*fallingfactorial(k,n-r)*fallingfactorial(m,r)*(x+b)^(k-n+r)*(c*x+d)^(m-r),r,0,ceil(abs(m)))); d(x_^k_*(x_+d_)^m_,x_,n_):= If(isfree(k,d,m,x), sum(binomial(n,r)*fallingfactorial(k,n-r)*fallingfactorial(m,r)*x^(k-n+r)*(x+d)^(m-r),r,0,ceil(abs(m)))); d(x_^k_*(c_*x_+d_)^m_,x_,n_):= If(isfree(k,c,d,m,x), sum(binomial(n,r)*c^r*fallingfactorial(k,n-r)*fallingfactorial(m,r)*x^(k-n+r)*(c*x+d)^(m-r),r,0,ceil(abs(m)))); #d((c_+x_^2)^k_,x_,n_) := If(isfree(c,x), d((sqrt(-c)+x)^k*(-sqrt(-c)+x)^k,x,n)); #d((c_-x_^2)^k_,x_,n_) := If(isfree(c,x), d((sqrt(c)+x)^k*(sqrt(c)-x)^k,x,n)); d((k_+x_^2)^(-0.5),x_,n_) := If(isfree(k,x), asinh(n+1,x/sqrt(k)) ); d(1/(k_+x_^2),x_,n_) := If(isfree(k,x), If(k<0, -atanh(1+n,x/sqrt(-k))/sqrt(-k), atan(1+n,x/sqrt(k))/sqrt(k) )); d(1/(k_+b_*x_^2),x_,n_) := If(isfree(k,b,x), If(b*k<0, sgn(k)*atanh(1+n,x/sqrt(abs(k/b)))/sqrt(abs(k*b)), sgn(k)*atan(1+n,x/sqrt(abs(k/b)))/sqrt(abs(k*b)) )); d(1/(c_+b_*x_+x_^2), x_,n_) := If(isfree(b,c,x), If(4c==b*b, -d(1/(x+b/2),x,1+n), if(4c>b*b, 2atan(1+n,(2*x+b)/sqrt(4c-b*b))/sqrt(4c-b*b), -2*atanh(1+n,(2x+b)/sqrt(-4c+b*b))/sqrt(-4c+b*b) ))); d(1/(c_+b_*x_+a_*x_^2), x_,n_) := If(isfree(a,b,c,x), If(4a*c==b*b, -d(1/(x+b/2/a),x,1+n)/a, if(4a*c>b*b,2*atan(1+n,(2a*x+b)/sqrt(4a*c-b*b))/sqrt(4a*c-b*b), -2*atanh(1+n,(2a*x+b)/sqrt(-4a*c+b*b))/sqrt(-4a*c+b*b) ))); d(log(x_)^m_*x_^n_,x_,p_):= if(n== -1 and m==p, log(log(x))^(-p), if(n==-1 and m==-1,ln(1+p,log(x)), If(p>= -1 and p<=0, If(n== -1, 1/(m+1)*d(log(x)^(m+1),x,p+1), If(n==p, (-1)^(m-p)*(-n-1)^(-m)/(n+1)*log(x)^(m-p), (-n-1)^(-m)/(n+1)*Gamma(m-p, (-n+p)*log(x)) )), (-n-1)^(-m)/(n+1)*d(Gamma(m+1, (-n-1)*log(x)),x,1+p) ))); #d(x_^n_*log(x_)^m_,x_,p_):= If(p>= -1 and p<=0, If(n==-1, 1/(m+1)*d(log(x)^(m+1),x,p+1), If(n==p, (-1)^(-m)*(-n-1)^(-m)/(n+1)*log(x)^(m-p), 1/(1+n)*d(Gamma(m+1, (-n-1)*log(x)),x,p+1) ))); d(log(x_)*x_^m_,x_,n_) := If(n>= -1 and n<=0, If(n==m,log(x)^(1-m), If(m== -1, 1/2*d(log(x)^2,x,n+1), -(m+1)^(-2)*Gamma(1-n, (-m+n)*log(x)) )), If(isinteger(n-m) and n>m, -(-1)^(n-m)*(n-m-1)!*Gamma(1+m)*x^(m-n), If(m> -1, fallingfactorial(m,n)*(psi(1+m)-psi(1+m-n)+log(x))*x^(m-n), If(m< -1, fallingfactorial(m,n)*(psi(abs(m))-psi(abs(m-n))+log(x))*x^(m-n) )))); d(log(x_)*x_,x_,n_) := If(n>1, (-1)^n*(n-2)!*x^(1-n), (psi(2)-psi(2-n)+log(x))/Gamma(2-n)*x^(1-n)); #d(log(x_)*x_^m_,x_,n_) := If(n>= -1 and n<=0, If(n==m, -(-1)^n*(m+1)^(-2)*log(x)^(1-m), If(m== -1, 1/2*d(log(x)^2,x,n+1), -(m+1)^(-2)*Gamma(1-n, (-m+n)*log(x)) )), -(m+1)^(-2)*d(Gamma(2, -(m+1)*log(x)),x,1+n)); d(log(x_)/x_,x_,n_):=If(n<0,1/2*d(log(x)^2,x,n+1)); #d(x_^m_*log(x_),x_,n_) := If(m== -1, 1/2*d(log(x)^2,x,n+1), If(n>= -1 and n<=0, If(n==m, -(-1)^n*(m+1)^(-2)*log(x)^(1-m), -(m+1)^(-2)*Gamma(1-n, (-m+n)*log(x)) )), -(m+1)^(-2)*d(Gamma(2, -(m+1)*log(x)),x,1+n)); d(log(x_)^m_,x_,p_):= If(m== -1, li(p+1,x), If(p> -1 and p<=0, (-1)^(-m)*Gamma(m-p, p*log(x)),If(abs(m)==abs(p), (-1)^(-m)*d(Gamma(m+1, -log(x)),x,1+p) ))); d(log(x_+c_)^m_,x_,p_):= If(isfree(c,x),If(m== -1, li(p+1,x+c), If(p> -1 and p<=0, (-1)^(-m)*Gamma(m-p, p*log(x+c)) ))); d(exp(x_)*log(x_),x_,n_):= If(n>1, exp(x)*log(x)+exp(x)*sum((-1)^(1+k)*binomial(n,k)*Gamma(k)*x^(-k), k,1,n), if(n>0, exp(x)*log(x)+exp(x)*d(log(x),x,n))); d(exp(-x_)*log(x_),x_,n_):= if(n>1, (-1)^n*exp(-x)*(log(x)-sum(binomial(n,k)*Gamma(k)*x^(-k), k,1,n)) ); d(exp(x_)*x_^m_,x_,n_):= If(m== -1, Ei(1+n,x), If(m== -n and abs(n)<=1, exp(x)*x^m-m!*exp(x), If(m==n,if(abs(n)<=1, exp(x)*x^m+m!*exp(x),n!*exp(x)*laguerreplus(n,x)), If(n>0 and isinteger(m), exp(x)*sum(binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,abs(m)), (-1)^(-m)*gamma(m-n,(-x)) )))); #d(exp(a_*x_)*x_^m_,x_,n_):= If(isfree(m,a,x), If(n>0 and isinteger(n), exp(a*x)*sum(a^(n-k)*binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,n), If(m>0 and n> -1 and isinteger(m), exp(a*x)*sum(a^(n-k)*binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,abs(m)), If(m== -1, Ei(1+n,a*x), (-a)^(-m)*Gamma(n+1,m+1, -a*x) )))); d(exp(a_*x_)*x_^m_,x_,n_):= If(isfree(m,a,x), If(m== -1, Ei(1+n,a*x), If(n>0 and isinteger(m), exp(a*x)*sum(a^(n-k)*binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,abs(m)), (-1)^m*(a)^(n-m)*gamma(m-n,(-a)*x) ))); d(exp(-x_)*x_^n_,x_,n_):=exp(-x)*laguerre(n,x); #d(exp(c_+x_)*x_^m_,x_,n_):= If(m== -1, exp(c)*Ei(1+n,x), If((n>0 or m>0) and isinteger(m), exp(c+x)*sum(binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,abs(m)), If(isfree(m,c,x), If(n>0 and isinteger(n), exp(c+x)*sum(binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,n) )))); d(exp(c_+a_*x_)*x_^m_,x_,n_):= If(isfree(m,c,a,x), If(m== -1, exp(c)*Ei(1+n,a*x), If((n>0 or m>0) and isinteger(m), exp(c+a*x)*sum(a^(n-k)*binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,abs(m)), If(n>0 and isinteger(n), exp(c+a*x)*sum(a^(n-k)*binomial(n,k)*fallingfactorial(m,k)*x^(m-k), k,0,n) )))); d(exp(x_)*(c_+x_)^m_,x_,n_):= If(isfree(c,m,x), If((n>0 or m>0) and isinteger(m), exp(x)*sum(binomial(n,k)*fallingfactorial(m,k)*(c+x)^(m-k), k,0,abs(m)), if(n>0 and isinteger(n), exp(x)*sum(binomial(n,k)*fallingfactorial(m,k)*(c+x)^(m-k), k,0,n) ))); d(exp(x_)*(c_+b_*x_)^m_,x_,n_):= If(isfree(b,c,m,x), If((n>0 or m>0) and isinteger(m), b^m*exp(x)*sum(binomial(n,k)*fallingfactorial(m,k)*(c/b+x)^(m-k), k,0,abs(m)), if(n>0 and isinteger(n), b^m*exp(x)*sum(binomial(n,k)*fallingfactorial(m,k)*(c/b+x)^(m-k), k,0,n) ))); d(exp(a_*x_)*x_,x_,p_) := if(hasnot(a,x) and abs(p)<1,a^p*exp(a*x)*x+p/a*a^p*exp(a*x) ); d(exp(-x_)*x_,x_,p_) := (-1)^p*exp(-x)*x-p*(-1)^p*exp(-x); d(exp(x_+c_)*x_,x_,p_) := if(hasnot(c,x),exp(x+c)*x+p*exp(c+x) ); d(exp(a_*x_+c_)*x_,x_,p_) := if(hasnot(a,c,x) and abs(p)<1,a^p*exp(a*x+c)*x+p/a*a^p*exp(a*x+c) ); d(exp(x_)*x_,x_,p_) := exp(x)*x+p*exp(x); d(exp(x_)/x_,x_,p_) := Ei(1+p,x); d(exp(a_*x_)/x_,x_,p_) := Ei(1+p,a*x); d(exp(x_)/(c_+x_),x_,p_) := if(hasnot(c,x), exp(-c)*Ei(1+p,c+x) ); d(exp(x_)/(c_+b_*x_),x_,p_) := if(hasnot(b,c,x), exp(-c/b)/b*Ei(1+p,c/b+x) ); d(sin(a_*x_)*x_^m_,x_,p_):= if(isconstant(a) and isinteger(m),sum(a^(p-k)*binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*sin(a*x+(p-k)*pi/2), k,0,abs(m)), If(p>-1 and p<0, -(-i)^(-m)* d(Gamma(1 + m, (-a*i)* x),x,1+p)/2 - d(Gamma(1 + m, a*i* x),x,p+1)*i^(-m)/2 )); d(cos(a_*x_)*x_^m_,x_,p_):= if(isconstant(a) and isinteger(m),sum(a^(p-k)*binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*cos(a*x+(p-k)*pi/2), k,0,abs(m)), If(p>-1 and p<0, -(-i)^(-m)* d(Gamma(1 + m, (-a*i)* x),x,1+p)/2 + d(Gamma(1 + m, a*i* x),x,p+1)*i^(-m)/2 )); d(sin(x_)*x_^m_,x_,p_):= if(isinteger(m),sum(binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*sin(x+(p-k)*pi/2), k,0,abs(m)), If(p>-1 and p<0, -(-i)^(-m)* d(Gamma(1 + m, (-i)* x),x,1+p)/2 - d(Gamma(1 + m, i* x),x,p+1)*i^(-m)/2 )); d(cos(x_)*x_^m_,x_,p_):= if(isinteger(m),sum(binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*cos(x+(p-k)*pi/2), k,0,abs(m)), If(p>-1 and p<0, -(-i)^(-m)* d(Gamma(1 + m, (-i)* x),x,1+p)/2 + d(Gamma(1 + m, i* x),x,p+1)*i^(-m)/2 )); d(sinh(x_)*x_^m_,x_,p_):= if(isinteger(m),sum(binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*sinh(x+(p-k)*pi*i/2), k,0,abs(m)) , If(p>-1 and p<0, (-1)^(-m)* d(Gamma(1 + m, -x),x,1+p)/2 + d(Gamma(1 + m, x),x,p+1)/2 )); #d(cosh(x_)*x_^m_,x_,p_):= If(m<0, (-1)^(-m)* d(Gamma(1 + m, -x),x,1+p)/2 - d(Gamma(1 + m, x),x,p+1)/2, sum(binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*cosh(x+(p-k)*pi*i/2), k,0,m)); d(cosh(x_)*x_^m_,x_,p_):= if(isinteger(m),sum(binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*cosh(x+(p-k)*pi*i/2), k,0,abs(m)), If(p>-1 and p<0, (-1)^(-m)*d(Gamma(1 + m, -x),x,1+p)/2 - d(Gamma(1 + m, x),x,p+1)/2 )); #d(cosh(x_)*x_^m_,x_,p_):= if(p>0, if(isinteger(p), sum(binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*cosh(x+(p-k)*pi*i/2), k,0,p), If(isinteger(m),sum(binomial(p,k)*fallingfactorial(m,k)*x^(m-k)*cosh(x+(p-k)*pi*i/2), k,0,abs(m)) ))); d(exp(x_^m_)*x_,x_,n_):=If(n>= -1 and n<0 and m*n==(n-1), exp(x^m)*m^n); d(exp(-x_^m_)*x_,x_,n_):=If(n>= -1 and n<0 and m*n==(n-1), exp(-x^m)*(-m)^n); #d(exp(x_^m_)*x_^n_,x_,p_):= If(p>= -1 and p<0, If(n==p*(1-m), exp(x^m)*m^p )); d(exp(x_^m_)*x_^n_,x_,p_):= If(p>= -1 and p<0, If(n==p*(1-m), exp(x^m)*m^p, -(-1)^((n-p)/(p*m))*m^p*Gamma((n-p)/(-p*m),-x^m) )); #d(exp(x_^m_)*x_^n_,x_,p_):= If(p>= -1 and p<0 and n==p*(1-m), exp(x^m)*m^p, -(-1)^((-1-n)/m)/m*Gamma(p+1,(n+1)/m,-x^m) ); #d(exp(a_*x_^m_)*x_^n_,x_,p_):= If(isfree(a,x), If(p>= -1 and p<0 and n==p*(1-m), exp(a*x^m)*(a*m)^p, -(-a)^((-1-n)/m)/m*Gamma(p+1,(1+n)/m, -a*x^m) )); d(exp(a_*x_^m_)*x_^n_,x_,p_):= If(isfree(a,x), If(p>= -1 and p<0, if(n==p*(1-m), exp(a*x^m)*(a*m)^p, -(-a)^((n-p)/(p*m))*m^p*Gamma((n-p)/(-p*m),-a*x^m) ))); #d(exp(a_*x_^m_)*x_^n_,x_,p_):= If(isfree(a,x), If(p>= -1 and p<0, if(n==p*(1-m), exp(a*x^m)*(a*m)^p ))); d(x_/log(a_*x_),x_,p_):=if(isfree(a,x),li(1+p,a*x^(1-p))/a); d(x_/log(x_),x_,p_):= li(1+p,x^(1-p)); d(x_^n_/log(x_),x_,p_):= li(1+p,x^(n-p)); d(x_^2/log(x_),x_,p_):= 4/3li(1+p,x^(2-p)); d(1/(a_+log(x_)),x_,n_):=exp(-a)*li(1+n,exp(a)*x); d(1/log(a_*x_),x_,n_):=if(isfree(a,x),li(1+n,a*x)/a); d(1/log(a_+x_),x_,n_):=if(isfree(a,x),li(1+n,a+x)); d(1/log(a_*x_+b_),x_,n_):=if(isfree(a,b,x),li(1+n,a*x+b)/a); d(1/log(x_),x_,p_):=li(p+1,x); d(sin(x_)/x_,x_,n_):=si(1+n,x); d(cos(x_)/x_,x_,n_):=ci(1+n,x); d(sin(a_*x_)/x_,x_,n_):=if(isfree(a,x),si(1+n,a*x)); d(cos(a_*x_)/x_,x_,n_):=if(isfree(a,x),ci(1+n,a*x)); d(sinh(x_)/x_,x_,n_):=shi(1+n,x); d(cosh(x_)/x_,x_,n_):=chi(1+n,x); d(sinh(a_*x_)/x_,x_,n_):=if(isfree(a,x),shi(1+n,a*x)); d(cosh(a_*x_)/x_,x_,n_):=if(isfree(a,x),chi(1+n,a*x)); d(Sophomore(a_,x_),x_,p_):=Sophomore(p,a,x); d(Sophomore(x_),x_,p_):=Sophomore(p,1,x); d(zeta(x_),x_,p_):= If(p>0,(-1)^p*sum(log(k)^p/k^x,k,2,oo)); d(zeta(m_,x_),x_,p_):= (-1)^p*risingfactorial(m,p)*zeta(m+p,x); d(li(p_,f_),x_,p_):= 1/log(f)*d(f,x,p)/p!; d(li(x_),x_,p_):= If(abs(p)<= 1,(-1)^p*Gamma(-p, (p-1)*log(x)) ); d(En(x_),x_,p_):= (-1)^p*En(1-p, x); d(En(m_, x_), x_,p_) := (-1)^p*En(m-p,x); d(erf(x_),x_,p_):= If(abs(p)<= 1, -(-2)^p*Gamma((p+1)/2,x^2)/sqrt(pi), -2*(-1)^p/sqrt(pi)*hermite(p-1,x)*exp(-x^2) ); d(erfi(x_),x_,p_):= If(abs(p)<= 1, (-2)^p*Gamma((p+1)/2,-x^2)/sqrt(pi), 2*(-1)^p/sqrt(pi)*hermite(p-1,x)*exp(x^2) ); d(logGamma(x_),x_,p_) := psi(p-1,x); d(abs(y_),x_,n_) := d(y,x,n)/sgn(y); d(abs(x_),x_,n_) := If(n>1,0, If(n<0, 1/sgn(x)/(-n)!*x^(1-n), 1/sgn(x)*(1-n)!*x^(1-n) )); d(sgn(y_),x_,n_) := If(n>0,0, If(n<0, 1/Gamma(1-n)*sgn(y)*x^(-n) )); d(csgn(y_),x_,n_) := If(n>0,0, If(n<0, csgn(y)*x^(-n)/(-n)! )); #d(delta(y_),x_,n_):=If(n>0,0, If(n<0, theta(y)*x^(-n)/(-n)! )); d(theta(y_),x_,n_):= delta(n-1,y); #d(log(xx_),x_,n_):= If(n>0 and n<1, d(xx,x,n)*ln(n,xx)/n! ); #d(log(y_),x_,n_):= If(n>0 and n<1, -(-1)^n*(n-1)!/y*d(y,x,n)/n! ); d(log(c_+x_^2),x_,n_):= if(hasnot(c,x),If(n>0, -(-1)^n*(n-1)!/(sqrt(-c)+x)^n-(-1)^n*(n-1)!/(sqrt(-c)-x)^n )); d(log(c_+x_),x_,n_):= if(hasnot(c,x),If(n>0, -(-1)^n*(n-1)!/(c+x)^n, If(abs(n)<1,expand((log(c+x)+psi(1)-psi(1-n))/Gamma(1-n)/(c+x)^n) ))); d(log(x_),x_,n_):= If(n>0, -(-1)^n*(n-1)!/x^n, If(abs(n)<1,expand((log(x)+psi(1)-psi(1-n))/Gamma(1-n)/x^n),ln(n,x) )); #d(ln(m_,x_),x_,n_):= If(n>1, -(-1)^n*(n-1)!/x^n, If(abs(n)<1,expand((log(x)+psi(1)-psi(1-n))/Gamma(1-n)/x^n),ln(n,x) )); #d(log(x_),x_,n_):= If(n>0, -(-1)^n*(n-1)!/x^n, If(n>= -1 and n<0, -Gamma(1-n, n*log(x)) )); #d(log(x_),x_,n_):= If(n>0 and isinteger(n), (-1)^(n+1)*(n-1)!/x^n, If(n>= -1 and n<0, -Gamma(1-n, n*log(x)) )); #d(log(x_+b_),x_,n_):= If(isfree(b,x),If(n>0, -(-1)^n*(n-1)!/(x+b)^n,If(abs(n)<=1,(log(x+b)+psi(1)-psi(1-n))/Gamma(1-n)/(x+b)^n ) )); d(gauss(x_),x_,p_) := If(p>=0 and p<=1,(-x)^p*gauss(x)); d(sinh(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*cosh(q,f)/p!, sinh(q+p,f) ); d(cosh(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*sqrt(-1+cosh(q,f)^2)/p!, cosh(q+p,f) ); d(tanh(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*(1-tanh(q,f)^2)/p!, d(f,x,p)*tanh(q+p,f) ); d(coth(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*(1-coth(q,f)^2)/p!, d(f,x,p)*coth(q+p,f) ); d(sinh(inversechi(q_,f_)),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*inversechi(q,f)/p! ); d(cosh(inverseshi(q_,f_)),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*inverseshi(q,f)/p! ); d(coth(x_),x_,p_):= if(has(f,c_1), coth(p,x) ); d(tanh(x_),x_,p_):= if(has(f,c_1), tanh(p,x) ); d(cosh(x_),x_,n_) :=If(isodd(n), sinh(x),If(iseven(n), cosh(x), cosh(x+pi*i/2*n) )); d(sinh(x_),x_,n_) :=If(isodd(n), cosh(x),If(iseven(n), sinh(x), sinh(x+pi*i/2*n) )); d(asinh(x_),x_,n_):=if(n>0 and isinteger(n), (-1)^(n-1)*sum((-1)^k*binomial(n-1,n-1-2k)*(2k-1)!!*(2n-2k-3)!!*x^(n-2k-1)*(x^2-1)^(k-n+1/2),k,0,floor(n/2)),asinh(n,x) ); d(acosh(x_),x_,n_):=if(n>0 and isinteger(n), (-1/2)^(n-1)*sum(binomial(n-1,k)*(2k-1)!!*(2n-2k-3)!!/(1+x)^(-k-1/2)*(x-1)^(k-n+1/2),k,0,n-1),acosh(n,x) ); #d(atanh(x_),x_,n_):= if(n>0, (1-n)!*(-i*(1 + x)^(-n) - (1 - x)^(-n)), if(n<0 and isinteger(n),(psi(1)-psi(-n)+log(x+1))*(x+1)^(-n)/(-n)!/2+(psi(1)-psi(-n)+log(1-x))*(1-x)^(-n)/(-n)!/2, atanh(n,x) )); #d(atanh(x_),x_,n_):= if(n>0, 1/2*(-1)^n *((-1 + x)^(-n) - (1 + x)^(-n))* (-1 + n)!, if(n<0 and isinteger(n),(-1)^n*(n-1)!/(x^2+1)^n*sum(binomial(n,n+1-2k)*x^(n+1-2k),k,1,ceil(n/2)), atanh(n,x) )); #d(atanh(x_),x_,n_):= if(n>0, d(log(1+x)-log(1-x),x,n)/2 ); #d(acoth(x_),x_,n_):= if(n>0, d(log(1+x)-log(-1+x),x,n)/2 ); d(1/asinh(x_),x_,p_):=chi(1+p,asinh(x)); d(1/acosh(x_),x_,p_):=shi(1+p,acosh(x)); d(inversecsch(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*(sinh(inversecsch(q,f)))/p! ); d(inversesech(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*(cosh(inversesech(q,f)))/p! ); d(inversetanh(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*(coth(inversetanh(q,f)))/p! ); d(inversecoth(q_,f_),x_,p_) := if(p>0 and has(f,c_1),d(f,x,p)*(tanh(inversecoth(q,f)))/p! ); d(inversecsc(q_,f_),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*sin(inversecsc(q,f))/p! ); d(inversesec(q_,f_),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*cos(inversesec(q,f))/p! ); d(inversetan(q_,f_),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*cot(inversetan(q,f))/p! ); d(inversecot(q_,f_),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*tan(inversecot(q,f))/p! ); d(sin(q_,f_),x_,p_) := if(p>0, if(has(f,c_1),d(f,x,p)*sqrt(1-sin(q,f)^2)/p!, sin(q+p,f) )); d(cos(q_,f_),x_,p_) := if(p>0, if(has(f,c_1),-d(f,x,p)*sqrt(1-cos(q,f)^2)/p!,cos(q+p,f) )); d(tan(q_,f_),x_,p_) := if(p>0, if(has(f,c_1), d(f,x,p)*(1+tan(q,f)^2)/p!, tan(q+p,f) )); d(cot(q_,f_),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*(1+cot(q,f)^2)/p! ); d(sin(inverseci(q_,f_)),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*inverseci(q,f)/p! ); d(cos(inversesi(q_,f_)),x_,p_) := if(p>0 and has(f,c_1), d(f,x,p)*inversesi(q,f)/p! ); d(cot(x_),x_,p_):= if(not(isinteger(p)), cot(p,x) ); d(tan(x_),x_,p_):= if(not(isinteger(p)), tan(p,x) ); d(cos(x_),x_,n_) :=If(iseven(n/2), cos(x),If(iseven(n), -cos(x), cos(x+pi/2*n) )); d(sin(x_),x_,n_) :=If(iseven(n/2), sin(x),If(iseven(n), -sin(x), sin(x+pi/2*n) )); d(asin(x_),x_,n_):=if(n>0 and isinteger(n), sum(binomial(n-1,n-1-2k)*(2k-1)!!*(2n-2k-3)!!*x^(n-2k-1)*(1-x^2)^(k-n+1/2),k,0,floor(n/2)),asin(n,x) ); d(acos(x_),x_,n_):=if(n>0 and isinteger(n), -sum((-1)^k*binomial(n-1,k)*(2k-1)!!*(2n-2k-3)!!/(1+x)^k*(1-x)^(k-n+1),k,0,n-1)/2^(n-1)/sqrt(1-x^2),acos(n,x) ); #d(atan(x_),x_,n_):= if(n>0, 1/2 i *(-1)^n *((-i + x)^(-n) - (i + x)^(-n))* (-1 + n)!, if(n<0 and isinteger(n),(psi(1)-psi(-n)+log(x-i))*(x-i)^(-n)/(-n)!/2-(psi(1)-psi(-n)+log(i+x))*(i+x)^(-n)/(-n)!/2, atan(n,x) )); #d(acot(x_),x_,n_):= if(n>0, 1/2 i *(-1)^n *(-(-i + x)^(-n) + (i + x)^(-n))* (-1 + n)!,if(n<0 and isinteger(n),(psi(1)-psi(-n)+log(x+i))*(x+i)^(-n)/(-n)!/2-(psi(1)-psi(-n)+log(x-i))*(x-i)^(-n)/(-n)!/2, acot(n,x) )); d(1/asin(x_),x_,p_):=ci(1+p,asin(x)); d(1/acos(x_),x_,p_):=si(1+p,acos(x)); d(exp(x_^m_),x_,p_):= If(p>= -1 and p<=0, (-1)^(p/m-p)*m^p*Gamma(1+p-p/m, -x^m), If(p>=0 and p<=1, (m*x^(m-1))^p*exp(x^m) )); d(exp(a_*x_^m_),x_,p_):= If(p>= -1 and p<=0, (-a)^(p/m-p)*(a*m)^p*Gamma(1+p-p/m, -a*x^m), If(p>=0 and p<=1, (a*m*x^(m-1))^p*exp(a*x^m) )); #d(exp(-x_^2),x_,n_):= if(n>0,(-1)^n*hermite(n,x)*exp(-x^2)); #d(exp(x_^2),x_,n_):= if(n>0,hermite(n,x)*exp(x^2)); d(exp(x_^2),x_,n_):=1/2*sqrt(pi)*erfi(1+n,x); d(exp(-x_^2),x_,n_):=1/2*sqrt(pi)*erf(1+n,x); d(exp(a_*x_),x_,n_) := If(isfree(a,x), a^n*exp(a*x)); d(exp(x_+b_),x_,n_) := If(isfree(b,x), exp(x+b)); d(exp(b_+a_*x_),x_,n_) := If(isfree(b,a,x), a^n*exp(a*x+b)); d(exp(b_*inversegamma(a_,xx_)),x_,n_):= if(has(xx,c_1), d(xx,x,n)/n!*(-b*inversegamma(a_,xx_))^(n-a) ); d(exp(x_),x_,n_):=exp(x); #d(x_^m_,x_,n_) := If(isfree(m,x), If(m<0 and isinteger(m) and (m>=n or n0 and re(n)>m,0, If(isinteger(n-m) and m<0 and n<0,(-1)^(1+m)*a^m*ln(n-m,x), fallingfactorial(m,n)*x^(m-n)*a^m ))); #d((c_+x_)^m_,x_,n_) := If(isfree(c,m,x), if(isinteger(m) and m>0 and re(n)>m,0, If(isinteger(n-m) and m<0 and n<0,(-1)^(1+m)*ln(n-m,c+x), fallingfactorial(m,n)*(c+x)^(m-n) ))); #d((c_+a_*x_)^m_,x_,n_) := If(isfree(c,a,m,x), if(isinteger(m) and m>0 and re(n)>m,0, If(isinteger(n-m) and m<0 and n<0,(-1)^(1+m)*a^n*ln(n-m,c+a*x), fallingfactorial(m,n)*(c+a*x)^(m-n)*a^n ))); #d(x_^m_,x_,n_) := If(isfree(m,x), If(m== -1 and n<=0, ln(1+n,x), If(m<0 and (m>=n or n0 and re(n)>m,0, If(m== -1 and n<0,(-1)^(1+m)*ln(n-m,x), If(m<0 and m==n,(-1)^(1+n)/(-1-n)!*log(x), fallingfactorial(m,n)*x^(m-n) )))); #d((c_+x_)^m_,x_,n_) := If(isfree(c,m,x), if(isinteger(m) and m>0 and re(n)>m,0, If(isinteger(n-m) and m<0 and n<0,if(m-n>=1,(-1)^(1+m)*ln(n-m,c+x), (-1)^(1+n)/(-1-n)!*ln(n-m,c+x)), fallingfactorial(m,n)*(c+x)^(m-n) ))); #d((c_-x_)^m_,x_,n_) := If(isfree(c,m,x), if(isinteger(m) and m>0 and re(n)>m,0, If(isinteger(n-m) and m<0 and n<0,if(m-n>=1,(-1)^(1+m)*ln(n-m,c-x), 1/(-1-n)!*ln(n-m,c-x)), (-1)^n*fallingfactorial(m,n)*(c-x)^(m-n) ))); #d((x_+z_)^m_,x_,n_) := If(isfree(m,z,x), if(isinteger(m) and m>0 and re(n)>m,0, If(isinteger(n-m) and m<0 and n<0,if(m-n>=1,(-1)^(1+m)*ln(n-m,x+z), (-1)^(1+n)/(-1-n)!*ln(n-m,x+z)), fallingfactorial(m,n)*(x+z)^(m-n) ))); #d((c_+x_+z_)^m_,x_,n_) := If(isfree(c,m,z,x), if(isinteger(m) and m>0 and re(n)>m,0, If(isinteger(n-m) and m<0 and n<0,if(m-n>=1,(-1)^(1+m)*ln(n-m,c+x+z), (-1)^(1+n)/(-1-n)!*ln(n-m,c+x+z)), fallingfactorial(m,n)*(c+x+z)^(m-n) ))); #d(x_^m_,x_,n_) := If(isfree(m,x), if(isinteger(m) and m>0 and re(n)>m,0, If(n==m and n<0,if(n==-1,log(x),1/(-1-n)!*(-1)^(1+n)*log(x)), fallingfactorial(m,n)*x^(m-n) ))); d(x_^m_,x_,n_) := If(isfree(m,x), if(isinteger(m) and m>0 and re(n)>m, 0, If(n<0 and n==m, 1/(-1-n)!*(-1)^(1+n)*log(x), if(n<0 and m== -1, ln(1+n,x), if(n>-1, fallingfactorial(m,n)*x^(m-n) ))))); d(x_^x_,x_,n_) := Sophomore(n+1,1,x); d(x_^(a_*x_),x_,n_) := Sophomore(n+1,a,x); d(sqrt(x_),x_, n_):= sqrt(pi)/2/(1/2-n)!*x^(1/2-n); d(x_,x_,n_) := If(re(n)>1,0, x^(1-n)/(1-n)!); d(y_, x_=x0_, n_) := d(y,x,x0,n); d(a_*b_*c_,x_,p_):=If(isfree(a,x), a*d(b*c,x,p), If(isfree(b,x), b*d(a*c,x,p) )); d(weierstrassP(xx_, g2_, g3_ ),x_,2):= if(d(xx,x,2)==0, d(xx,x)*(weierstrassP(xx,g2,g3)^2-g2/2) ); d(am(a_,c_),x_,2):= if(d(a,x,2)==0,-c/2*sin(2am(a,c))*d(a,x)^2 ); d(am(a_,c_*d_),x_,2):= if(d(a,x,2)==0,-c/2*sin(2am(a,c*d))*d(a,x)^2 ); d(Ai(x_),x_,2):=Ai(x)*x; d(Bi(x_),x_,2):=Bi(x)*x; d(Ai(c_*x_),x_,2):=if(hasnot(x), c^3*Ai(c*x)*x); d(Bi(c_*x_),x_,2):=if(hasnot(x), c^3*Bi(c*x)*x); d(y_,x_,1) := d(y,x); d(y_,x_,0) := y; d(y_,x_=a_) := d(y,x,a,1); d(integrate(y_,x_),x_) := y; d(integrates(y_,x_),x_) := y; #d(integrates(y_,t_,a_,b_),x_) := block(f(t)=y,replace(f(t),t,b)*d(b,x)-replace(f(t),t,a)*d(a,x)+integrate(d(f(t),x),t,a,b)); d(integrates(y_,t_,a_,b_),x_) := replace(y,t,b)*d(b,x)-replace(y,t,a)*d(a,x)+integrate(d(y,x),t,a,b); d(integrate(y_,t_,a_,b_),x_) := replace(y,t,b)*d(b,x)-replace(y,t,a)*d(a,x)+integrate(d(y,x),t,a,b); d(integrate(y(t_-x_),t_,a_,b_),x_) := y(b-x)*(d(b,x)-1)-y(a-x)*(d(a,x)-1); d(integrate(y(x_-t_),t_,a_,b_),x_) := y(x-a)*(1-d(a,x))-y(x-b)*(1-d(b,x)); d(infsums(x_^k_/k_!,k_),x_,n_) := infsums(x^k/k!,k); d(infsums(x_^k_/k_!,k_),x_) := infsums(x^k/k!,k); d(infsums(x_^(2k_)/(2k_)!,k_),x_) := infsums(x^(2k+1)/(2k+1)!,k); d(infsums(1/(1+2k_)!*x_^(1+2k_),k_),x_) := infsums(x^(2k)/(2k)!,k); d(infsums((-1)^k_/(2k_)!*x_^(2k_),k_),x_) := -infsums((-1)^k*x^(2k+1)/(2k+1)!,k); d(infsums((-1)^k_/(1+2k_)!*x_^(1+2k_),k_),x_) := infsums((-1)^k*x^(2k)/(2k)!,k); d(Sophomore(x_,xx_),x_):=x^(xx); d(Sophomore(x_),x_):=x^x; d(laguerre(n_,x_),x_):= n*(laguerre(n,x)-laguerre(n-1,x))/x; d(hermite(n_,x_),x_):= 2n*hermite(n-1,x); d(besselK(m_,x_),x_):= -besselK(m-1,x)/2-besselK(m+1,x)/2; d(besselI(m_,x_),x_):= besselI(m-1,x)/2+besselI(m+1,x)/2; d(besselJ(m_,x_),x_):= besselJ(m-1,x)/2-besselJ(m+1,x)/2; d(besselY(m_,x_),x_):= besselY(m-1,x)/2-besselY(m+1,x)/2; d(weierstrassP(x_, g2_, g3_ ),x_):= weierstrassPPrime(x,g2,g3); d(weierstrassPPrime(x_,g2_,g3_),x_):= 6weierstrassP(x,g2,g3)^2-g2/2; d(weierstrassP(x_+c_, g2_, g3_ ),x_):= weierstrassPPrime(x+c,g2,g3); d(weierstrassPPrime(x_+c_,g2_,g3_),x_):= 6weierstrassP(x+c,g2,g3)^2-g2/2; d(Ai(x_),x_):=AiPrime(x); d(AiPrime(x_),x_):=Ai(x)*x; d(Bi(x_),x_):=BiPrime(x); d(BiPrime(x_),x_):=Bi(x)*x; d(mittag(a_,b_,x_), x_) := (mittag(a,b-1,x)-(b-1)*mittag(a,b,x))/(a*x); d(mittag(a_,x_), x_) := mittag(a,a,x)/a; d(mittag(0.5,x_^0.5),x_):=mittag(0.5,x^0.5)+pi^(-1/2)*x^(-0.5); d(Gamma(n_,0, x_), x_) := exp(-x)*x^(n-1); d(Gamma(n_, x_), x_) := -exp(-x)*x^(n-1); d(zeta(x_), x_) := -sum(log(k)/k^x,k,2,oo); d(zeta(n_,x_), x_) := -n*zeta(1+n,x); d(zeta(n_,b_,x_), x_) := exp((1-b)*x)*x^(n-1)/(e^x-1)/Gamma(n); d(eta(x_), x_) := -sum((-1)^k*log(k)/k^x,k,2,oo); d(eta(n_,b_,x_), x_) := exp((1-b)*x)*x^(n-1)/(e^x+1)/Gamma(n); d(eta(n_,x_), x_) := -n*eta(1+n,x); d(En(n_,x_), x_) := -En(n-1,x); #d(En(n_,x_), x_) := exp(-x)/(-x)^n; #d(erf(n_,x_), x_) := n!/sqrt(pi)*exp(-x^n); d(polylog(n_,x_), x_) := polylog(n-1,x)/x; d(polylog(a_,n_,x_), x_) := -n*x^(a-1)/(e^x-n)/Gamma(a); d(L(a_,b_,c_,x_), x_) := exp((1-c)*x)/(-a+exp(x))*x^(b-1)/Gamma(b); d(when(a_,y_),x_):=when(a,d(y,x)); d(beta(a_,b_,x_),x_):=x^(a-1)*(1-x)^(b-1); d(beta(x_,y_),x_):=beta(x,y)*(psi(x)-psi(x+y)); d(beta(x_,y_),y_):=beta(x,y)*(psi(y)-psi(x+y)); d(beta(s_,x_),x_):=x^(s-1)/(exp(-x)+e^x)/Gamma(s); d(harmonic(n_,1,x_),x_):=(1-x^n)/(1-x); d(harmonic(n_,x_),x_):= -n*zeta(1+n,x+1); d(Cl(a_,x_),x_):= (-1)^a*Cl(a-1,x); d(tan(a_,x_),x_):=tan(1+a,x); d(tanh(a_,x_),x_):=tanh(1+a,x); #d(exp(b_*inversegamma(a_,xx_)),x_):= if(has(xx,c_1), d(xx,x)*(-b*inversegamma(a,xx))^(1-a) ); d(inversegamma(n_,x_),x_):= -exp(inversegamma(n,x))*inversegamma(n,x)^(1-n); d(inversef(x_), x_) := 1/d(f(x),x=inversef(x)); d(inversechi(x_), x_) := inversechi(x)/cosh(inversechi(x)); d(inverseshi(x_), x_) := inverseshi(x)/sinh(inverseshi(x)); d(inverseci(x_), x_) := inverseci(x)/cos(inverseci(x)); d(inversesi(x_), x_) := inversesi(x)/sin(inversesi(x)); d(inverseEi(x_), x_) := exp(-inverseEi(x))*inverseEi(x); d(inverseli(x_), x_) := log(inverseli(x)); d(inverseerf(x_), x_) := 1/2*sqrt(pi)*exp(inverseerf(x)^2); d(inverseerfi(x_), x_) := 1/2*sqrt(pi)*exp(-inverseerfi(x)^2); d(Dawson(x_),x_):= 1-2Dawson(x)*x; d(Dawsonminus(x_),x_):= 1+2Dawsonminus(x)*x; d(F(x_),x_):=f(x); d(W(x_),x_):=W(x)/(1+W(x))/x; d(harmonic(x_),x_):= psi(1,x+1); d(psi(x_),x_,p_):= psi(p,x); d(fresnelS(x_),x_):=sin(pi/2*x^2); d(fresnelC(x_),x_):=cos(pi/2*x^2); d(theta(y_),x_) := delta(x); d(gauss(x_), x_) := -x*gauss(x); d(Phi(x_),x_):=gauss(x); d(erf(x_), x_) := 2/sqrt(pi)*exp(-x^2); d(erfi(x_), x_) := 2/sqrt(pi)*exp(x^2); d(Gamma(x_), x_) := Gamma(x)*psi(x); d((x_)!, x_) := x!*psi(x+1); d(logGamma(x_), x_) := psi(x); d(li(x_),x_) := 1/log(x); d(Ei(x_),x_) := exp(x)/x; d(Ein(x_),x_) := 1/x-exp(-x)/x; d(sinc(x_),x_) :=(-sin(x))*x^(-2)+cos(x)*1/x; d(si(x_),x_) := sinc(x); d(ci(x_),x_) := cos(x)/x; d(tani(x_),x_) := tan(x)/x; d(coti(x_),x_) := cot(x)/x; d(csci(x_),x_) := csc(x)/x; d(seci(x_),x_) := sec(x)/x; d(asini(x_),x_) := asin(x)/x; d(acosi(x_),x_) := acos(x)/x; d(atani(x_),x_) := atan(x)/x; d(shi(x_),x_) := sinh(x)/x; d(chi(x_),x_) := cosh(x)/x; d(tanhi(x_),x_) := tanh(x)/x; d(cothi(x_),x_) := coth(x)/x; d(sqrt(x_),x_):= 1/2*x^(-1/2); d(cbrt(x_),x_):= 1/3*x^(-2/3); d(ln(x_),x_):=1/x; d(log(y_),x_):=d(y,x)/y; d(log(x_),x_):=1/x; d(log(abs(y_)),x_):=d(y,x)/y; d(abs(x_),x_):=1/sgn(x); d(exp(x_),x_):=exp(x); d(pow(x_,n_),x_):=if(hasnot(n,x),pow(x,n-1)*n); d(root(x_,n_),x_):=if(hasnot(n,x),root(x,n-1)*n); d(nthRoot(x_,n_),x_):=if(hasnot(n,x),nthRoot(x,n-1)*n); d(sin(x_),x_):= cos(x); d(cos(x_),x_):= -sin(x); d(tan(x_),x_):= 1+tan(x)^2; d(cot(x_),x_):= -csc(x)^2; d(sec(x_),x_) := tan(x)*sec(x); d(csc(x_),x_) := -cot(x)*csc(x); d(asin(x_),x_) := (1-x^2)^(-1/2); d(acos(x_),x_) := -(1-x^2)^(-1/2); d(atan(x_),x_):= 1/(x^2+1); d(atan2(x_,y_),y_) := -x/(x^2+y^2); d(atan2(x_,y_),x_) := y/(x^2+y^2); d(acot(x_),x_) := -1/(x^2+1); d(asec(x_),x_) := 1/(x*sqrt(x^2-1)); d(acsc(x_),x_) := -1/(x*sqrt(x^2-1)); d(sinh(x_),x_):= cosh(x); d(cosh(x_),x_):= sinh(x); d(tanh(x_),x_) := sech(x)^2; d(coth(x_),x_) := -csch(x)^2; d(sech(x_),x_) := -tanh(x)*sech(x); d(csch(x_),x_) := -coth(x)*csch(x); d(asinh(x_),x_) := (x^2+1)^(-1/2); d(acosh(x_),x_) := (x^2-1)^(-1/2); d(atanh(x_),x_) := 1/(1-x^2); d(acoth(x_),x_) := 1/(1-x^2); d(asech(x_),x_) := -1/(x*sqrt(1-x^2)); d(acsch(x_),x_) := -1/(x*sqrt(1+x^2)); d(sgn(y_),x_) := 0; d(csgn(y_),x_) := 0; d(step(x_),x_):=0; d(x_,x_):=1; d(y_):=d(y,x);