# linear differential solver; #ldsolve(b_,1,c_,e^x_,y_,x_,2):=if(isfree(b,c,y) and isfree(b,c,x), if(1-b-c==0,e^x*x/(2-b), e^x/(1-b-c) )); #ldsolve(b_,1,c_,e^(a_*x_),y_,x_,2):=if(isfree(b,c,y) and isfree(b,c,x), if(a^2-b*a-c==0,e^(a*x)*x/(2a-b), e^(a*x)/(a^2-b*a-c) )); #ldsolve(b_,1,c_,d_*e^x_,y_,x_,2):=if(isfree(b,c,d,y) and isfree(b,c,d,x), if(1-b-c==0,d*e^x*x/(2-b), d*e^x/(1-b-c) )); #ldsolve(b_,1,c_,d_*e^(a_*x_),y_,x_,2):=if(isfree(b,c,d,y) and isfree(b,c,d,x), if(a^2-b*a-c==0,d*e^(a*x)*x/(2a-b), d*e^(a*x)/(a^2-b*a-c) )); ldsolve(b_,c_,y_,x_,2):=if(isfree(b,c,y) and isfree(b,c,x), if(b*b+4c==0, C_1*exp(b*x/2)+C_2*exp(b*x/2)*x, if(b*b+4c<0, C_1*e^(b*x/2)*cos(sqrt(-b^2-4c)/2*x)+C_2*e^(b*x/2)*sin(sqrt(-b^2-4c)/2*x), C_1*e^((b-sqrt(b^2+4c))/2*x)+C_2*e^((b+sqrt(b^2+4c))/2*x) ))); ldsolve(b_,m_,c_,c1_+c2_,y_,x_,n_):=if(isfree(c1,x), ldsolve(b,m,c_,c2_,y_,x_,n_)-c1/c, ldsolve(b_,m_,c_,c1,y_,x_,n_)+ldsolve(b_,m_,c_,c2_,y_,x_,n_) ); ldsolve(b_,m_,c_,c1_*c2_,y_,x_,n_):=if(isfree(c1,x), ldsolve(b,m,c,c2,y,x,n)*c1 ); ldsolve(b_,m_,c_,e^x_,y_,x_,n_):=if(isfree(b,c,y) and isfree(b,c,x), if(1-b-c==0,e^x*x/(n-b*m), e^x/(1-b-c) )); ldsolve(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) )); ldsolve(b_,m_,c_,x_,y_,x_,n_):=if(isfree(b,c,y) and isfree(b,c,x) and m>=1, -x/c-1/c); ldsolve(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) ); ldsolve(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) ); ldsolve(c_,c1_+c2_,y_,x_,n_):=if(isfree(c1,x), ldsolve(c_,c2_,y_,x_,n_)-c1/c, ldsolve(c_,c1,y_,x_,n_)+ldsolve(c_,c2_,y_,x_,n_) ); ldsolve(c_,c1_*c2_,y_,x_,n_):=if(isfree(c1,x), ldsolve(c,c2,y,x,n)*c1); ldsolve(c_,e^x_,y_,x_,n_):=if(isfree(c,y) and isfree(c,x), if(1==c,e^(x)*x/n, e^(x)/(1-c) )); ldsolve(c_,e^(a_*x_),y_,x_,n_):=if(isfree(c,y) and isfree(c,x), if(a^n==c,e^(a*x)*x/n/a^(n-1), e^(a*x)/(a^n-c) )); ldsolve(c_,x_^n_,y_,x_,n_):=if(isfree(c,y) and isfree(c,x) and n>0, -x^n/c-n!/c/c); ldsolve(c_,x_,y_,x_,n_):=if(isfree(c,y) and isfree(c,x) and n>=1, -x/c-1/c, -x^n/n!/c^2-x/c-1/c^3); ldsolve(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) )); ldsolve(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) ));