# differential equation solver; # solve differential equation and fractional differential equation for unknown y with independent variable x; # dsolve(eq,y) # there are 3 way to input derivative y: y', y(1,x), or ds(y,x,1) # there are 3 way to input second order derivative y: y'', y(2,x), or ds(y,x,2) # e.g. dsolve( y' = x*y, y) # dsolve( y(0.5,x)=y^2 ) # dsolve(a_,y_,x_,q_) = If(isfree(a,y),d(a,x,-q), If(isfree(a/y,y),mittag(q,d(a/y,x,-q)), If(isfree(a,x), solve(d(1/a, y,-q)=x^q/q!,y) ))); # dsolve(a_+b_, y_,x_,q_) := If(isfree(a,b,y), d(a+b,x,-q)+c_1+if(q>1, c_2*x,0), If(isfree(a,b,x), solve(d(1/(a+b),y,-q)=x^q/q!,y)+if(q>1, c_2*x^2+c_1*x,c_1+x), If(isfree(a,y) and isfree(d(b,y),y), block(dsolve:=d(d(b,y),x,-q),simplify(mittag(q,dsolve)*d(a*mittag(q,-dsolve),x,-q))+mittag(q,dsolve)), If(isfree(b,y) and isfree(d(a,y),y), block(dsolve:=d(d(a,y),x,-q),simplify(mittag(q,dsolve)*d(b*mittag(q,-dsolve),x,-q))+mittag(q,dsolve)) )))); dsolve(a_+y_, y_,x_,q_) := If(isfree(a,y), If(isfree(a,x), If(q>0, c_1*exp(x)-a, c_1*mittag(q,x^q) ), c_1*exp(x)+psolution(1,a,y,x,q) )); #dsolve(a_+b_*y, y_,x_,q_) := If(isfree(a,b,y), if(isfree(a,x), If(b>0, c_1*exp(b^(1/q)*x)-a/b,c_1*mittag(q,b^sgn(q)*x^abs(q)/(abs(q))!))-a/b, If(b>0, c_1*exp(b^(1/q)*x)+psolution(b,a,y,x,q) ,c_1*mittag(abs(q),d(b,x,-q)) +psolution(b,a,y,x,q) ))); dsolve(a_+b_*y_, y_,x_,q_) := If(isfree(a,b,y), If(b>0, c_1*exp(b^(1/q)*x)+if(isfree(a,x),-a/b,psolution(b,a,y,x,q)), gsolution(b,y,x,q)+psolution(b,a,y,x,q) )); dsolve(a_*y_+b_*y_, y_,x_,q_) := If(isfree(a,b,y), c_1*mittag(q,d(a+b,x,-q)*q!) ); dsolve(a_*y_+y_, y_,x_,q_) := If(isfree(a,y), c_1*mittag(q,d(a+1,x,-q)*q!) ); #dsolve(a_+a_*y_, y_,x_,q_) := If(isfree(a,y), If(isfree(a,x), If(q>0, c_1*exp(a^(1/q)*x)-1, c_1*mittag(-q,1/a*x^(-q)/(-q)!) ), If(q>0,c_1*mittag(q,d(a,x,-q))-1, c_1*mittag(-q,d(a,x,-q))*d(a,x,-q) ) )); #dsolve(x_^q_+y_, y_,x_,q_) := -x^q-q!; #dsolve(x_^n_+b_*y_, 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)) ))); #dsolve(x_^n_+b_*y_, y_,x_,q_) := If(isfree(b,x) and isfree(b,y), If(n==q, -x^n/b-q!/b^2, n!*x^(n+q)*mittag(q,1+n+q,b*x^q) )); #dsolve(a_*x_^n_+b_*y_, y_,x_,q_) := If(isfree(a,b,x) and isfree(a,b,y), If(n==q, -a*x^n/b-a*q!/b^2, a*n!*x^(n+q)*mittag(q,1+n+q,b*x^q) )); #dsolve(x_^n_+y, y_,x_,q_) := If(n==q, -x^n-n!, n!*x^(n+q)*mittag(q,1+n+q,x^q)); #dsolve(a_*x_^n_+y, y_,x_,q_) := If(isfree(a,x) and isfree(a,y), If(n==q, -a*x^n-a*n!, a*n!*x^(n+q)*mittag(q,1+n+q,x^q) )); #dsolve(x_^n_+y+c_, y_,x_,q_) := If(isfree(c,x) and isfree(c,y), If(n==q, -x^n-n!-c, n!*x^(n+q)*mittag(q,1+n+q,x^q)-c)); #dsolve(a_*x_^n_+y+c_, y_,x_,q_) := If(isfree(a,c,x) and isfree(a,c,y), If(n==q, -a*x^n-a*n!-c, a*n!*x^(n+q)*mittag(q,1+n+q,x^q)-c )); #dsolve(x_^n_+b_*y_+c_, y_,x_,q_) := If(isfree(b,c,x) and isfree(b,c,y), If(n==q, -x^n/b-q!/b^2-c/b, n!*x^(n+q)*mittag(q,1+n+q,b*x^q)-c/b )); #dsolve(a_*x_^n_+b_*y_+c_, y_,x_,q_) := If(isfree(a,b,c,x) and isfree(a,b,c,y), If(n==q, -a*x^n/b-a*q!/b^2-c/b, a*n!*x^(n+q)*mittag(q,1+n+q,b*x^q)-c/b )); #dsolve(a_*x_+b_*y_, y_,x_,q_) := If(isfree(a,b,x) and isfree(a,b,y), a*x^(1+q)*mittag(q,2+q,b*x^q)); #dsolve(a_*x_+y_, y_,x_,q_) := If(isfree(a,x) and isfree(a,y), a*x^(1+q)*mittag(q,2+q,x^q)); #dsolve(x_+b_*y_, y_,x_,q_) := If(isfree(b,x) and isfree(b,y), x^(1+q)*mittag(q,2+q,b*x^q) ); #dsolve(x_+y, y_,x_,q_) := x^(1+q)*mittag(q,2+q,x^q); #dsolve(a_*x_+y_+c_, y_,x_,q_) := If(isfree(a,c,x) and isfree(a,c,y), If(q>0,a*x^(1+q)*mittag(q,2+q,x^q)-c,a*x^(1+q)*mittag(q,2+q,x^q) )); #dsolve(x_+b_*y_+c_, y_,x_,q_) := If(isfree(b,c,x) and isfree(c,b,y), If(q>0,x^(1+q)*mittag(q,2+q,b*x^q)-c/b,x^(1+q)*mittag(q,2+q,b*x^q) )); #dsolve(x_+y_+c_, y_,x_,q_) := If(isfree(c,x) and isfree(c,y), If(q>0,x^(1+q)*mittag(q,2+q,x^q)-c,x^(1+q)*mittag(q,2+q,x^q) )); #dsolve(a_*x_+b_*y_+c_, y_,x_,q_) := If(isfree(a,b,c,x) and isfree(a,b,c,y), If(q>0, a*x^(1+q)*mittag(q,2+q,b*x^q)-c/b,a*x^(1+q)*mittag(q,2+q,b*x^q) )); #dsolve(a_*x_+x_*y_, y_,x_,q_) := If(isfree(a,x) and isfree(a,y), c_1*mittag(q,x^(1+q)/(1+q)!)-a); #dsolve(x_+b_*x_*y_, y_,x_,q_) := if(isfree(b,x) and isfree(a,y), c_1*mittag(abs(q),b*x^(1+abs(q))/(1+abs(q))!)-1/b); dsolve(a_*x_+b_*x_*y(p_,x_), y_,x_,q_) := If(isfree(a,b,x) and isfree(a,b,y), c_1*d(mittag(q-p,b*x^(1+q-p)/(1+q-p)!)-a/b,x,-p)); #dsolve(b_*y^n_, y_,x_,q_) := If(isfree(b,y), If(isfree(b,x), b^(1-n)*fallingfactorial(q/(1-n),q)^(1/(n-1))*(x+c_1)^(q/(1-n)), (1/fallingfactorial(-n,q)*d(b,x,-q))^(1/(q-n)) )); dsolve(y_^n_, y_,x_,q_) := fallingfactorial(q/(1-n),q)^(1/(n-1))*(x+c_1)^(q/(1-n)) ; #dsolve(b_*y_, y_,x_,q_) := if(isfree(b,y), If(b>0, c_1*exp(b^(1/q)*x)+if(iseven(q), c_2*exp(-b^(1/q)*x),0), If(b<0, c_1*mittag(q,b*x^q), c_1*mittag(q,d(b,x,-q)*q!) ))); dsolve(b_*y_, y_,x_,n_) := gsolution(b,y,x,n); #dsolve(b_*x_*y_, y_,x_,q_) := If(isfree(b,y), c_1*mittag(q,b*x^(q+1)/(1+q)), c_1*mittag(q,d(b*x,x,-q)*q!) ); #dsolve(x_*y_, y_,x_,q_) := c_1*mittag(q,x^(1+q)/(1+q)); dsolve(y_, y_,x_,q_) := if(q==3, c_1*exp(x)+c_2*cos(x)+C_3*sin(x), if(iseven(q),c_1*exp(-x)+c_2*exp(x), c_1*exp(x) )); dsolve(e^x_, y_,x_,q_) := exp(x)+if(q>0, sum(c(k+1)*x^k,k,0,ceil(q)-1,1),0 ); dsolve(0, y_,x_,q_) := if(q>0, sum(c(k+1)*x^k,k,0,ceil(q)-1,1) ); #dsolve(f_, y_,x_,1) :=dsolve(f, y,x); dsolve(y(p_,x_),y_,x_,q_):= c_1*e^x+if(p>0,c_2,0); dsolve(b_*y(p_,x_),y_,x_,q_):=if(isfree(b,y), if(b>0, c_1*exp(b^(1/(q-p))*x)+if(p>0,c_2,0), c_1*d(mittag(q-p,d(b,x,p-q)),x,-p)+if(p>0,c_2,0) )); dsolve(y(p_,x_)+c_,y_,x_,q_):= d(dsolve(c+y,y,x,q-p),x,-p); dsolve(b_*y(p_,x_)+c_,y_,x_,q_):=if(isfree(b,y), d(dsolve(c+b*y,y,x,q-p),x,-p)); dsolve(y(p_,x_)+c_*y, y_,x_,q_) := if(isfree(c,y) and isfree(c,x), if(q==2p, c_1*e^(((1-sqrt(1+4c))/2)^(1/p)*x)+c_2*e^(((1+sqrt(1+4c))/2)^(1/p)*x),c_1*exp(nsolve(y^q-y^p-c,y)*x) )); dsolve(y(p_,x_)+y, y_,x_,q_) := if(q==2p, c_1*e^(((1-sqrt(5))/2)^(1/p)*x)+c_2*e^(((1+sqrt(5))/2)^(1/p)*x),c_1*exp(nsolve(y^q-y^p-1,y)*x) ); dsolve(b_*y(p_,x_)+c_*y, y_,x_,q_) := if(isfree(b,c,y) and isfree(b,c,x), if(q==2p, if(b*b+4c==0, c_1*exp((b/2)^(1/p)*x)+c_2*exp((b/2)^(1/p)*x)*x, c_1*e^(((b-sqrt(b^2+4c))/2)^(1/p)*x)+c_2*e^(((b+sqrt(b^2+4c))/2)^(1/p)*x)), if(b+c==1, c_1*e^(x),c_1*exp(nsolve(y^q-b*y^p-c,y)*x) ))); dsolve(b_*y(p_,x_)+y, y_,x_,q_) := if(isfree(b,y) and isfree(b,x), if(q==2p, c_1*e^(((b-sqrt(b^2+4))/2)^(1/p)*x)+c_2*e^(((b+sqrt(b^2+4))/2)^(1/p)*x),c_1*exp(nsolve(y^q-b*y^p-1,y)*x) )); dsolve(b_*y(p_,x_)+c_*y+d_, y_,x_,q_) := if(isfree(b,c,d,y) and isfree(b,c,d,x), dsolve(b*y(p,x)+c*y, y,x,q)-d/c, dsolve(b*y(p,x)+c*y, y,x,q)+psolution(b,p,c,d,y,x,q) ); dsolve(b_*y(p_,x_)+y+d_, y_,x_,q_) := if(isfree(b,d,y) and isfree(b,d,x), dsolve(b*y(p,x)+y, y,x,q)-d, dsolve(b*y(p,x)+y, y,x,q)+psolution(b,p,1,d,y,x,q) ); dsolve(y(p_,x_)+c_*y+d_, y_,x_,q_) := if(isfree(c,d,y) and isfree(c,d,x), dsolve(y(p,x)+c*y, y,x,q)-d/c, dsolve(y(p,x)+c*y, y,x,q)+psolution(1,p,c,d,y,x,q) ); dsolve(y(p_,x_)+y+d_, y_,x_,q_) := if(isfree(d,y) and isfree(d,x), dsolve(y(p,x)+y, y,x,q)-d, dsolve(y(p,x)+y, y,x,q)+psolution(1,p,1,d,y,x,q) ); dsolve(a_ and b_, y_,x_,p_) := dsolve(a, y,x,p) and dsolve(b, y,x,p); dsolve(a_+b_*y_, y_,x_,-1) := if(isfree(a,b,y), if(isfree(b,x), c_1*exp(integrate((1-d(b,x))/b,x)), c_1*exp(integrate((1-d(b,x))/b,x))+psolution((1-d(b,x))/b,-d(a,x)/b,y,x,1) )); dsolve(y(1,x_),y_,x_,3):=c_1+c_2*e^(x)+C_3*e^(-x); dsolve(y(2,x_),y_,x_,3):=c_1+c_2*e^(x)+C_3*x; dsolve(b_*y(1,x_),y_,x_,3):=gsolution(0,b,y,x,2)+C_3; dsolve(b_*y(2,x_),y_,x_,3):=c_1+c_2*e^(int(b,x))+C_3*x; dsolve(a_+b_*y_, y_,x_,2) := if(isfree(a,b,y), if(isfree(a,b,x), gsolution(0,b,y,x,2)-a/b, if(a==b, gsolution(0,b,y,x,2), gsolution(0,b,y,x,2)+psolution(b,a,y,x,2) ))); #dsolve(a_+y_, y_,x_,2) := if(isfree(a,y),if(isfree(a,x), c_1*exp(x)+c_2*exp(-x)-a, c_1*exp(x)+c_2*exp(-x)-1/2*exp(-x)*int(exp(x)*a,x)+1/2*exp(x)*int(exp(-x)*a,x) )); dsolve(a_+y_, y_,x_,2) := if(isfree(a,y),if(isfree(a,x), c_1*exp(x)+c_2*exp(-x)-a, c_1*exp(x)+c_2*exp(-x)+psolution(1,a,y,x,2) )); dsolve(x_+y_, y_,x_,2) := c_1*exp(x)+c_2*exp(-x)-x; dsolve(x_+b_*y_, y_,x_,2) := if(isfree(b,x), gsolution(0,b,y,x,2)-x/b, gsolution(0,b,y,x,2)+psolution(b,x,y,x,2) ); dsolve(a_*x_+b_*y_, y_,x_,2) := if(isfree(a,b,x), gsolution(0,b,y,x,2)-a*x/b, gsolution(0,b,y,x,2)+psolution(b,a*x,y,x,2) ); dsolve(a_*x_+b_*y_+c_, y_,x_,2) := if(isfree(a,b,c,x), gsolution(0,b,y,x,2)-a*x/b-c/b, gsolution(0,b,y,x,2)-a*x/b+psolution(b,c,y,x,2) ); dsolve(b_*y_, y_,x_,2) := if(isfree(b,y), gsolution(0,b,y,x,2) ); dsolve(x_*y_, y_,x_,2) := c_1*AiryAi(x)+c_2*AiryBi(x); #dsolve(a_*x_*y_, y_,x_,2) := if(isfree(a,x) and isfree(a,y), c_1*AiryAi(cbrt(a)*x)+c_2*AiryBi(cbrt(a)*x)); dsolve(a_*x_*y_, y_,x_,2) := if(isfree(a,x) and isfree(a,y), gsolution(a*x,y,x,2) ); dsolve(c_/x_^2*y_, y_,x_,2) := if(isfree(c,x), gsolution(0,c/x^2,y,x,2) ); dsolve(b_*y(1,x_),y_,x_,2):=if(isfree(b,y),if(isfree(b,x), c_1+c_2*e^(b*x), c_2*integrate(exp(int(b,x)),x)+c_1 )); dsolve(xy_*y(1,x_),xy_,x_,2):= sqrt(2)*tan(sqrt(2)/2*x+c_1); dsolve(b_*xy_*y(1,x_),xy_,x_,2):=if(isfree(b,xy) and isfree(b,x), sqrt(2)* sqrt(c_1)* tan(1/2 *(sqrt(2)* sqrt(b)* sqrt(c_1)* x + sqrt(2)* sqrt(b)* sqrt(c_1))) ); dsolve(-y*y(1,x_),y_,x_,2):= sqrt(2)*tanh(sqrt(2)/2*x+c_1); dsolve(y(1,x_)^n_,y_,x_,2):= if(n==2, c_2 - log(c_1 + x), c_2 - (-(n - 1)* (c_1 + x))^(1/(1 - n) + 1)/(n - 2)); dsolve(b_*y(1,x_)^n_,y_,x_,2):= if(isfree(b,y) and isfree(b,x), if(n==2, c_2 - log(c_1 + b*x)/b,c_2 - (-(n - 1)* (c_1 + b*x))^(1/(1 - n) + 1)/(n - 2)/b )); dsolve(c_+y(1,x_),y_,x_,2):=if(isfree(c,y),if(isfree(c,x), c_1+c_2*e^x-c*x, c_1+c_2*e^(x)+integrate(exp(x)*int(exp(-x)*c,x),x) )); #dsolve(c_+b_*y(1,x_),y_,x_,2):=if(isfree(b,c,y),if(isfree(b,c,x), c_1+c_2*e^(b*x)-c*x/b, integrate(dsolve(c+b*y,y,x),x)+c_2 )); #dsolve(c_+b_*y(1,x_),y_,x_,2):=if(isfree(b,c,y),if(isfree(b,c,x), c_1+c_2*e^(b*x)-c*x/b, c_1+c_2*e^(b*x)+integrate(exp(b*x)*int(exp(-b*x)*c,x),x) )); dsolve(c_+b_*y(1,x_),y_,x_,2):=if(isfree(b,c,y),if(isfree(b,c,x), c_1+c_2*e^(b*x)-c*x/b, c_2+int(c_1*e^(int(b,x))+psolution(b,c,y,x,1),x) )); dsolve(xy+y(1,x_),xy_,x_,2):= c_1*e^((1-sqrt(5))/2*x)+c_2*e^((1+sqrt(5))/2*x); dsolve(b_*y(1,x_)+xy_,xy_,x_,2):=if(isfree(b,xy), gsolution(b,1,xy,x,2) ); dsolve(y(1,x_)+c_*xy_,xy_,x_,2):=if(isfree(c,xy), gsolution(1,c,xy,x,2) ); dsolve(b_*y(1,x_)+c_*xy_,xy_,x_,2):=if(isfree(b,c,xy), gsolution(b,c,xy,x,2) ); dsolve(y(1,x_)+xy_+d_,xy_,x_,2):=if(isfree(d,xy) and isfree(d,x), gsolution(1,1,xy,x,2)-d*x-d, gsolution(1,1,xy,x,2)+psolution(1,1,1,d,xy,x,2)); dsolve(b_*y(1,x_)+xy_+d_,xy_,x_,2):=if(isfree(b,d,xy) and isfree(b,d,x), gsolution(b,1,xy,x,2)-d*x-d*b, gsolution(b,1,xy,x,2) +psolution(b,1,1,d,xy,x,2)); dsolve(y(1,x_)+c_*xy_+d_,xy_,x_,2):=if(isfree(c,d,xy) and isfree(c,d,x), gsolution(1,c,xy,x,2)-d*x/c-d/c^2, gsolution(1,c,xy,x,2)+psolution(1,1,c,d,xy,x,2)); dsolve(b_*y(1,x_)+c_*xy_+d_,xy_,x_,2):=if(isfree(b,c,d,xy),if(isfree(b,c,d,x), gsolution(b,c,xy,x,2)-d*x/b-d/c*b, gsolution(b,c,xy,x,2)+psolution(b,1,c,d,xy,x,2) )); #dsolve(b_*y(1,x_)+c_*xy_+d_,xy_,x_,2):=if(isfree(b,c,d,xy) and isfree(b,c,d,x), gsolution(b,c,xy,x,2)-d*x/b-d/c/b, if(b*b+4c==0, c_1*exp(b/2*x)+c_2*exp(b/2*x)*x+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)), gsolution(b,c,xy,x,2)+ 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)) )); dsolve(y_, y_,x_,2) := c_1*exp(-x)+c_2*exp(x); dsolve(y_, y_,x_,4) := c_1*exp(-x)+c_2*exp(x)+c(3)*cos(x)+c(4)*sin(x); #dsolve(a_+b_, y_,x_) := If(isfree(a,b,y), integrate(a+b,x)+c_1, If(has(a,y) and has(b,y) and isfree(d(a+b,y),y), exp(integrate(d(a+b,y),x))*c_1, If(isfree(b,y) and isfree(d(a,y),y), block(dsolve:=int(d(a,y),x),exp(dsolve)*int(b*exp(-dsolve),x)+exp(dsolve)*c_1), If(isfree(a,y) and isfree(d(b,y),y), block(dsolve:=int(d(b,y),x),exp(dsolve)*int(a*exp(-dsolve),x)+exp(dsolve)*c_1) )))); #dsolve(a_+b_*y_,y_,x_):=If(isfree(a,b,y), If(isfree(a,b,x), c_1*exp(b*x)-a/b, block(dsolve:=integrate(b,x), expand(exp(dsolve)*integrate(a*exp(-dsolve),x))+exp(dsolve)*c_1 ) )); dsolve(a_+b_*y_,y_,x_,1):=If(isfree(a,b,y), If(isfree(a,b,x), c_1*exp(b*x)-a/b, c_1*exp(integrate(b,x))+psolution(b,a,y,x,1) )); dsolve(a_+a_*y_,y_,x_,1):=If(isfree(a,y), c_1*exp(integrate(a,x))-1); dsolve(a_+y_,y_,x_,1):=If(isfree(a,y), If(isfree(a,x), c_1*exp(x)-a, expand(exp(x)*integrate(a*exp(-x),x))+exp(x)*c_1 )); dsolve(a_*y_+y_,y_,x_,1):=If(isfree(a,y), c_1*exp(integrate(1+a,x)) ); dsolve(a_*y_+b_*y_,y_,x_,1):=If(isfree(a,b,y), c_1*exp(integrate(a+b,x)) ); dsolve(a_*y_+b_*y_^n_,y_,x_,1):=If(isfree(a,b,y) , block(dsolve:=integrate(a,x), exp(dsolve)*(c_1+(1-n)*integrate(b*exp((n-1)*dsolve),x))^(1/(1-n)) ) ); dsolve(a_*y_+y_^n_,y_,x_,1):=If(isfree(a,n,y) , block(dsolve:=integrate(a,x), exp(dsolve)*(c_1+(1-n)*integrate(exp((n-1)*dsolve),x))^(1/(1-n)) ) ); dsolve(y_+y_^n_,y_,x_,1):= exp(x)*(c_1-exp((n-1)*x))^(1/(1-n)); dsolve(x_+y_, y_,x_,1) := c_1*exp(x)-x-1; #dsolve(a_*x_+y_, y_,x_) := If(isfree(a, x) and isfree(a, y), -a*x-a); #dsolve(x_+b_*y_,y_,x_) := If(isfree(b, x) and isfree(b, y), -1/b*x-1/b^2); #dsolve(a_*x_+b_*y_,y_,x_):=If(isfree(a,b, x) and isfree(a,b, y), -a/b*x-a/b^2); #dsolve(x_+y_+c_, y_,x_) := If(isfree(c,x) and isfree(c,y), -x-1-c); #dsolve(x_+b_*y_+c_, y_,x_) := If(isfree(b,c,x) and isfree(b,c,y), -1/b*x-1/b^2-c/b); #dsolve(a_*x_+y_+c_, y_,x_) := If(isfree(a,c,x) and isfree(a,c,y), -a*x-a-c); #dsolve(a_*x_+b_*y_+c_, y_,x_) := If(isfree(a,b,c,x) and isfree(a,b,c,y), -a/b*x-a/b^2-c/b); dsolve(b_*y_, y_,x_,1) := If(isfree(b,y), c_1*exp(integrate(b,x))); dsolve(b_*y_^n_, y_,x_,1) := If(isfree(b,y), ((1-n)*integrate(b,x)+c_1)^(1/(1-n)) ); dsolve(y_/(x_+y_), y_,x_,1) := x/W(c_1*x); dsolve(y_^2/(x_+y_), y_,x_,1) := x=c_1*exp(-1/y)-exp(-1/y)*Ei(1/y); dsolve(y_,y_,x_,1) := c_1*exp(x); #dsolve(y(n_,x_),y_,x_) := c_1*exp(x); #dsolve(f_,y(x_)) := dsolve(replace(d(y(x),x)-f,y(x),y),y); #dsolve(a_=b_,y_):= if(has(a,ds(y,x,2)),dsolve(ds(y,x,2)-a+b,y,x,2), if(has(a,ds(y)),dsolve(ds(y)-a+b,y,x), if(has(a,dy),dsolve(dy/dx-a+b,y,x), dsolve(a-b,y) ))); #dsolve(y'=f_,y) := dsolve(f,y,x); #dsolve(y''=f_,y) := dsolve(f,y,x,2); #dsolve(dy/dx=f_,y) := dsolve(f,y,x); #dsolve(d(y(x_),x_)=f_,y(x_)) := dsolve(replace(f,y(x),y),y,x); #dsolve(ds(y_)=a_,y_) := dsolve(a,y,x); #dsolve(ds(y_,x_)=a_,y_) := dsolve(a,y,x); #dsolve(ds(y_,x_,q_)=a_,y_):= dsolve(a,y,x,q); #dsolve(a_+ds(y_,x_,q_),y_):= dsolve(-a,y,x,q); #dsolve(ds(y_,x_,q_)+z_,y_):= dsolve(-z,y,x,q); #dsolve(ds(y_,x_,q_)+f_+z_,y_):= dsolve(-f-z,y,x,q); #dsolve(a_+ds(y_,x_,q_)+z_,y_):= dsolve(-a-z,y,x,q); dsolve(a_+y(q_,x_),y_):= dsolve(-a,y,x,q); dsolve(a_+b_*y(q_,x_),y_):= dsolve(-expand(a/b),y,x,q); dsolve(a_+y(q_,x_),y(x_)):= dsolve(-replace(a,y(x),y),y,x,q); dsolve(y(p_,x_)^n_+b_,y_):= dsolve(solve(replace(b,y(p,x),yy)+yy^n,yy),y,x,p); dsolve(a_*y(p_,x_)^n_+b_,y_):= dsolve(solve(expand(replace(b,y(p,x),yy)/a)+yy^n,yy),y,x,p); #dsolve(x_^2*y(2,x_)+b_*x_*y(1,x_)+c_*xy_+d_,xy_):= if(isfree(b,c,d,xy), gsolution(b-1,c,xy,x,2)+int(replace(d,x,e^x),x) ); dsolve(a_=b_,y_):=dsolve(toy(a-b),y); dsolve(y(n_,t_)=a_,y_) := dsolve(toy(a),y,t,n); dsolve(x(n_,t_)=a_,y_) := dsolve(tox(a),y,t,n); #dsolve(b_+x(n_,t_),d_+y(n_,t_)):= (x=dsolve(-b,x,t,n) and y=dsolve(-d,y,t,n)); #dsolve(b_+x(n_,t_),d_+x_+y(n_,t_)):= block(xx:=dsolve(-b,x,t,n), x=xx and y=dsolve(-d-xx,y,t,n)); dsolve(b_+x(n_,t_),d_+y(m_,t_)):= if(hasnot(b,y(t)) and hasnot(d,x(t)), (x=dsolve(-b,x(t),t,n), y=dsolve(-d,y(t),t,m)), if(hasnot(b,y(t)),block(xx:=dsolve(-b,x(t),t,n), (x=xx, y=dsolve(-replace(d,x(t),xx),y(t),t,m))), if(hasnot(d,x(t)),block(xx:=dsolve(-d,y(t),t,m), (y=xx, x=dsolve(-replace(b,y(t),xx),x(t),t,n))) ))); dsolve(a_=b_,c_=d_):= dsolve(tox(a=b),toyt(c-d)); dsolve(x(n_,t_)=b_,d_+y(m_,t_)):= block(bb:=replace(replace(b,x(t),x),y(t),y),dd:= replace(replace(-d,x(t),x),y(t),y), if(hasnot(bb,y),block(xx:=dsolve(bb,x,t,n), (x=xx, y=dsolve(replace(dd,x,xx),y,t,m))), if(hasnot(dd,x),block(xx:=dsolve(dd,y,t,m), (y=xx, x=dsolve(replace(bb,y,xx),x,t,n))) ))); dsolve(a_):=dsolve(replace(toy(a),y(x),y),y);