# psolution is particular solution of linear differential equation; psolution2(b_,1,c_,d_,y_,x_,2):=if(isfree(c,d,y) and isfree(c,d,x) or isfree(c/d,x), -d/c, if(b*b+4c==0, expand(exp(b/2*x)*x*int(exp(-b/2*x)*d,x)-exp(b/2*x)*int(d*exp(-b/2*x)*x,x)), expand((-e^((b-sqrt(b^2+4c))/2*x)*int(d*e^((-b+sqrt(b^2+4c))/2*x),x)+e^((b+sqrt(b^2+4c))/2*x)*int(d*e^((-b-sqrt(b^2+4c))/2*x),x))/sqrt(b*b+4c)) )); psolution(b_,m_,c_,c1_+c2_,y_,x_,n_):=if(isfree(c1,x), psolution(b,m,c,c2,y,x,n)-c1/c, psolution(b,m,c,c1,y,x,n)+psolution(b,m,c,c2,y,x,n) ); psolution(b_,m_,c_,c1_*c2_,y_,x_,n_):=if(isfree(c1,x), psolution(b,m,c,c2,y,x,n)*c1, if(isfree(c2,x), psolution(b,m,c,c1,y,x,n)*c2 )); psolution(b_,m_,c_,e^x_,y_,x_,n_):=if(isfree(b,c,y) and isfree(b,c,x), if(n==b*m, 1/2*exp(x)*x^2, if(1-b-c==0, exp(x)*x/(n-b*m), exp(x)/(1-b-c) ))); psolution(b_,m_,c_,e^(a_*x_),y_,x_,n_):=if(isfree(b,c,y) and isfree(b,c,x), if(a^n-b*a^m==c, e^(a*x)*x/(n*a^(n-1)-b*m*a^(m-1)), e^(a*x)/(a^n-b*a^m-c) )); psolution(b_,n_,c_,x_,y_,x_,p_):=if(isfree(b,c,y) and isfree(b,c,x), if(n==1, -x/c+b/c^2, if(n>1, -x/c, b*x^n/n!/c^2-x/c-b^2/c^3 ))); psolution(b_,1,c_,sin(x_),y_,x_,2):=if(isfree(b,c,y) and isfree(b,c,x), - (c+1)*sin(x)/(b^2 + (c + 1)^2) + b*cos(x)/(b^2 + (c + 1)^2) ); psolution(b_,1,c_,cos(x_),y_,x_,2):=if(isfree(b,c,y) and isfree(b,c,x), - b*sin(x)/(b^2 + (c + 1)^2) - (c+1)*cos(x)/(b^2 + (c + 1)^2) ); psolution(b_/x_,1,x_^(-2),d_,y_,x_,2):=if(isfree(d,y), int(replace(d*x^2,x,exp(x)),x) ); psolution(1/x_,1,c_*x_^(-2),d_,y_,x_,2):=if(isfree(d,y), int(replace(d*x^2,x,exp(x)),x) ); psolution(b_/x_,1,c_*x_^(-2),d_,y_,x_,2):=if(isfree(d,y), int(replace(d*x^2,x,exp(x)),x) ); psolution(b_,1,c_*x_^(-2),d_*x_^(-2),y_,x_,2):=if(isfree(c,d,x), -d/c); psolution(b_,1,c_*x_^(-2),x_^(-2),y_,x_,2):=if(isfree(c,x), -1/c); psolution(b_,1,x_^(-2),d_*x_^(-2),y_,x_,2):=if(isfree(d,x), -d); psolution(b_,m_,c_,c_,y_,x_,n_):= -1; psolution2(c_,d_,y_,x_,n_):=if(isfree(c,d,y), if(isfree(c,d,x), -d/c, if(n==2, if(isfree(c,x), if(c<0, expand((cos(sqrt(-c)*x)*int(d*sin(sqrt(-c)*x),x)-sin(sqrt(-c)*x)*int(d*cos(sqrt(-c)*x),x))/2/sqrt(-c)), expand((exp(sqrt(c)*x)*int(d*exp(-sqrt(c)*x),x)-exp(-sqrt(c)*x)*int(d*exp(sqrt(c)*x),x))/2/sqrt(c)) )), if(isinteger(n), block(dsolve:=integrate(c,x), expand(exp(dsolve)*integrate(d*exp(-dsolve),x))), block(gs:=mittag(n,d(c,x,-n)*n!), d(simplify(d/gs),x,-n)*gs) )))); #psolution2(c_,d_,y_,x_,n_):=if(isfree(c,d,y) and n<1, block(gs:=gsolution(c,y,x,n)/C_1, d(simplify(d/gs),x,-n)*gsolution(c,y,x,n)/C_1) ); #psolution2(c_,d_,y_,x_,n_):=if(isfree(c,d,y) and n<=1, block(gs:=gsolution(c,y,x,n)/C_1, d(simplify(d/gs),x,-n)*gs) ); #psolution(c_,d_,y_,x_,1):=if(isfree(c,d,y), block(dsolve:=integrate(c,x), expand(exp(dsolve)*integrate(d*exp(-dsolve),x))) ); #psolution(c_,d_,y_,x_,2):=if(isfree(c,d,y) and isfree(c,x),if(c<0, cos(sqrt(-c)*x)*int(d*sin(sqrt(-c)*x),x)/2/sqrt(-c)-sin(sqrt(-c)*x)*int(d*cos(sqrt(-c)*x),x)/2/sqrt(-c), expand(exp(sqrt(c)*x)*int(d*exp(-sqrt(c)*x),x)/2/sqrt(c)-exp(-sqrt(c)*x)*int(d*exp(sqrt(c)*x),x)/2/sqrt(c)) )); psolution(c_,c1_+c2_,y_,x_,n_):=if(isfree(c1,x), psolution(c_,c2_,y_,x_,n_)-c1/c, psolution(c_,c1,y_,x_,n_)+psolution(c_,c2_,y_,x_,n_) ); psolution(c_,c1_*c2_,y_,x_,n_):=if(isfree(c1,x), psolution(c,c2,y,x,n)*c1, if(isfree(c2,x), psolution(c,c1,y,x,n)*c2 )); psolution(c_,e^x_,y_,x_,n_):=if(isfree(c,y) and isfree(c,x), if(c==1, exp(x)*x/n, exp(x)/(1-c) )); psolution(c_,e^(a_*x_),y_,x_,n_):=if(isfree(c,y) and isfree(c,x), if(a^n==c, exp(a*x)*x/n/a^(n-1), exp(a*x)/(a^n-c) )); psolution(c_,e^x_*x_,y_,x_,n_):=if(isfree(c,y) and isfree(c,x), if(c==1, exp(x)*x^2/2/n-(n-1)*exp(x)*x/2/n, -n*exp(x)/(c-1)^2-exp(x)*x/(c-1) )); psolution(c_,d_*e^x_*x_,y_,x_,n_):=if(isfree(c,d,y) and isfree(c,d,x), if(c==1, d*e^x*x^2/2/n-d*(n-1)*e^x*x/2/n, -d*n*e^x/(c-1)^2-d*e^x*x/(c-1) )); #psolution(b_,x_^n_, y_,x_,q_) := If(isfree(b,x) and isfree(b,y), If(n==q, -x^q/b-q!/b^2, If(q>0, n!*x^(n+q)*mittag(q,1+n+q,b*x^q), Gamma(n+1)*x^n*mittag(-q,n+1,1/b*x^(-q)) ))); psolution(c_,x_,y_,x_,n_):=if(isfree(c,y) and isfree(c,x), if(n==1, -x/c-1/c^2, if(n>1, -x/c, -x/c-x^n/n!/c^2-1/c^3 ))); psolution(b_,x_^n_, y_,x_,q_) := If(isfree(b,x) and isfree(b,y) and n>0 and q>0, if(q>n, -x^n/b, if(q==n, -x^n/b-n, if(n(remainder(n,q))==0, -sum(b^(-1-k/q)*n!/(n-k)!*x^(n-k),k,0,n,q) )))); psolution(-1,d_,y_,x_,2):= expand(int(d*cos(x),x)*sin(x)-int(d*sin(x),x)*cos(x)); psolution(c_,sin(x_),y_,x_,2):=if(isfree(c,y) and isfree(c,x), if(c== -1, -cos(x)*x/2, -sin(x)/(c + 1) )); psolution(c_,cos(x_),y_,x_,2):=if(isfree(c,y) and isfree(c,x), if(c== -1, sin(x)*x/2, -cos(x)/(c + 1) )); psolution(c_,tan(x_),y_,x_,2):=if(isfree(c,y) and isfree(c,x), if(c== -1, -cos(x)*log(sec(x)+tan(x)) )); psolution(c_,cot(x_),y_,x_,2):=if(isfree(c,y) and isfree(c,x), if(c== -1, sin(x)*log(sec(x)+tan(x)) )); psolution(c_,sin(d_*x_),y_,x_,2):=if(isfree(c,d,y) and isfree(c,d,x), sin(d*x)/(-c-d^2) ); psolution(c_,cos(d_*x_),y_,x_,2):=if(isfree(c,d,y) and isfree(c,d,x), cos(d*x)/(-c-d^2) ); psolution(c_,c_,y_,x_,n_):=if(isfree(c,y), -1); psolution(c_,b_*c_,y_,x_,n_):=if(isfree(b,c,y) and isfree(b,x), -b); psolution(a_*c_,c_,y_,x_,n_):=if(isfree(a,c,y) and isfree(a,x), -1/a); psolution(a_*c_,b_*c_,y_,x_,n_):=if(isfree(a,b,c,y) and isfree(a,b,x), -b/a); psolution(1/x_,c_,y_,x_,1):= int(c/x,x)*x; psolution(b_/x_,c_,y_,x_,1):= int(c/x^b,x)*x^b;