# 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_ and b_, y_,x_,p_) := dsolve(a, y,x,p) and dsolve(b, y,x,p); dsolve(a_ and b_ and c_ and d_, y_,x_,p_) := dsolve(a, y,x,p) and dsolve(b, y,x,p) and dsolve(c, y,x,p) and dsolve(d, y,x,p); dsolve(a_+y_, y_,x_,q_) := gsolution(1,y,x,q)+If(isfree(a,x),-a,psolution(1,a,y,x,q)); #dsolve(a_+y_, y_,x_,q_) := If(isfree(a,y), gsolution(1,y,x,q)+If(isfree(a,x),-a,psolution(1,a,y,x,q))); dsolve(a_+b_*y_, y_,x_,q_) := gsolution(b,y,x,q)+psolution(b,a,y,x,q); dsolve(a_*y_+y_, y_,x_,q_) := If(isfree(a,y), C_1*mittag(q,d(a+1,x,-q)*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_*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(f_^n_,y_,x_,q_) := if(has(f,x) and has(f,y) and isnumber(n), dsolve(pow(f,n),y,x,q) ); #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_) := if(n<>q,((n-q)!/n!/(q)!)^(1/(q-n))*(x)^(q/(1-n)),((n-q)!/n!/(q)!)*(x)^(q/(1-n)) ); #dsolve(y_^n_, y_,x_,q_) := if(n==q, (n-q)!/n!/(q)!*(x)^(q/(1-n)) ); #dsolve(y_^0.5,y_,x_,0.5):=0.7855x; dsolve(b_*y_, y_,x_,n_) := gsolution(b,y,x,n); dsolve(y_, y_,x_,q_) := if(q==4, C_1*exp(x)+C_4*exp(-x)+C_2*cos(x)+C_3*sin(x), 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(a_, y_,x_,-1) := if(isfree(a,y),d(a,x), dsolve(d(replace(a,y,y(x)),x)-y)); #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(y*y(1,x),y,x_,3):= -(-2)^(2/3)* cbrt(3)* weierstrass(cbrt(-1/3)/2^(2/3)*(x + C_1),2 *(-2)^(2/3)* cbrt(3)* C_1, C_2); dsolve(a_+b_*y_, y_,x_,2) := if(isfree(a,b,y), if(a==b, gsolution(0,b,y,x,2)-1, gsolution(0,b,y,x,2)+psolution(b,a,y,x,2) )); dsolve(z_+b_*y_, y_,x_,2) := if(isfree(z,b,y), if(z==b, gsolution(0,b,y,x,2)-1, gsolution(0,b,y,x,2)+psolution(b,z,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),E(2,2*int(b,x,2)) ); dsolve(x_*y_, y_,x_,2) := C_1*Ai(x)+C_2*Bi(x); dsolve(a_*x_*y_, y_,x_,2) := if(isfree(a,x) and isfree(a,y), C_1*Ai(cbrt(a)*x)+C_2*Bi(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(x_*y_, y_,x_,-1) :=C_1; dsolve(y_, y_,x_,-1) :=C_1*exp(x); dsolve(y_, y_,x_,1) := C_1*exp(x); dsolve(y_, y_,x_,2) := C_1*exp(x)+C_2*exp(-x); #dsolve(y_, y_,x_,3) := C_1*exp(x)+C_2*exp(-x/2)*cos(sqrt(3)/2x)+C_3*exp(-x/2)*sin(sqrt(3)/2x); dsolve(y_, y_,x_,3) := C_1*exp(x)+C_2*exp(-(-1)^(1/3)*x)+C_3*exp((-1)^(2/3)*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_+y_*z_,y_,x_,1):=If(isfree(a,z,y), If(isfree(a,z,x), C_1*exp(z*x)-a/z, C_1*exp(integrate(z,x))+psolution(z,a,y,x,1) )); #dsolve(b_*y_+z_,b_,x_,1):=If(isfree(z,y,b), If(isfree(z,y,x), C_1*exp(y*x)-z/y, C_1*exp(integrate(y,x))+psolution(y,z,b,x,1) )); #dsolve(b_*y_+z_,y_,x_,1):=If(isfree(z,b,y), If(isfree(z,b,x), C_1*exp(b*x)-z/b, C_1*exp(integrate(b,x))+psolution(b,z,y,x,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(y_+z_,y_,x_,1):=If(isfree(z,y), If(isfree(z,x), C_1*exp(x)-z, expand(exp(x)*integrate(z*exp(-x),x))+exp(x)*C_1 )); #dsolve(a_+y_+z_,y_,x_,1):=If(isfree(a,z,y), If(isfree(a,z,x), C_1*exp(x)-a-z, expand(exp(x)*integrate((a+z)*exp(-x),x))+exp(x)*C_1 )); #dsolve(a_+b_*y_+z_,y_,x_,1):=If(isfree(a,b,z,y), If(isfree(a,b,z,x), C_1*exp(b*x)-a/b-z/b, expand(exp(b*x)*integrate((a+z)*exp(-b*x),x))+exp(b*x)*C_1 )); dsolve(a_*y_+y_,y_,x_,q):=If(isfree(a,y), C_1*mittag(q,d(a+1,y,-q)*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(y(p_,x_),y_,x_,q_):= C_1*e^x+if(p>0,C_2,0); dsolve(b_*y(p_,x_),y_,x_,q_):= C_1*exp(b^(1/(q-p))*x)+if(p>0,C_2,0); dsolve(y(p_,x_)+c_,y_,x_,q_):= if(hasnot(c,y),C_1*exp(x)+if(p>0,C_2,0)+psolution(1,p,0,c,y,x,q) ); dsolve(b_*y(p_,x_)+c_,y_,x_,q_):= if(hasnot(b,c,y),C_1*exp(b^(1/(q-p))*x)+if(p>0,C_2,0)+psolution(b,p,0,c,y,x,q) ); dsolve(y(p_,x_)+xy_, xy_,x_,q_) := gsolution(1,p,1,xy,x,q); dsolve(y(p_,x_)+c_*xy_, xy_,x_,q_) := gsolution(1,p,c,xy,x,q); dsolve(b_*y(p_,x_)+xy_, xy_,x_,q_) := gsolution(b,p,1,xy,x,q); dsolve(b_*y(p_,x_)+c_*xy_, xy_,x_,q_) := gsolution(b,p,c,xy,x,q); dsolve(y(p_,x_)+xy_+d_, xy_,x_,q_) := if(isfree(d,xy),if(isfree(d,x), gsolution(1,p,1,xy,x,q)-d, gsolution(1,p,1,xy,x,q)+psolution(1,p,1,d,xy,x,q) )); dsolve(y(p_,x_)+c_*xy_+d_, xy_,x_,q_) := if(isfree(c,d,xy),if(isfree(c,d,x), gsolution(1,p,c,xy,x,q)-d/c, gsolution(1,p,c,xy,x,q)+psolution(1,p,c,d,xy,x,q) )); dsolve(b_*y(p_,x_)+xy_+d_, xy_,x_,q_) := if(isfree(b,d,xy),if(isfree(b,d,x), gsolution(b,p,1,xy,x,q)-d, gsolution(b,p,1,xy,x,q)+psolution(b,p,1,d,xy,x,q) )); dsolve(b_*y(p_,x_)+c_*xy_+d_, xy_,x_,q_) := if(isfree(b,c,d,xy),if(isfree(b,c,d,x), gsolution(b,p,c,xy,x,q)-d/c, gsolution(b,p,c,xy,x,q)+psolution(b,p,c,d,xy,x,q) )); 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), block(_b:=(C_1-(n-1)*integrate(b,x)),_b^(-1/(n-1))) ); #dsolve(b_*y_^n_, y_,x_,1) := If(isfree(b,y), (C_1-(n-1)*integrate(b,x)+C_1)^(-1/(n-1)) ); dsolve(x_/y_, y_,x_,1) :=x; dsolve(z_/(b_+c_), y_,x_,n_) := if(has(b,x) and has(c,y), dsolve(replace(b/z+c/z,x,zz),zz,y,n)=x); dsolve(a_/(b_+c_), y_,x_,n_) := if(has(b,x) and has(c,y), dsolve(replace(expand(b/a+c/a),x,zz),zz,y,n)=x); dsolve(a_*1/(b_+c_)*z_, y_,x_,n_) := if(has(b,x) and has(c,y), dsolve(replace(b/a/z+c/a/z,x,zz),zz,y,n)=x); dsolve(1/b_, y_,x_,n_) := if(has(b,y), dsolve(replace(b,x,zz),zz,y,n)=x); 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(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(xy_*y(1,x_)^2,xy_,x_,2):=sqrt(2)* inverseerf((sqrt(2 pi) *C_1* x + sqrt(2 pi)* C_2 )/pi); 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(b_*xy_*y(1,x_),xy_,x_,2):=if(b<0, 2C_1/sqrt(-b)*tanh(C_1*sqrt(-b)*(x+C_2)), if(isfree(b,xy) and isfree(b,x), 2C_1/sqrt(b)*tan(C_1*sqrt(b)*(x+C_2)) )); dsolve(xy_*y(1,x_),xy_,x_,2):= 2C_1*tan(C_1*(x+C_2)); dsolve((x_+n_)/x_*y(1,x_),y_,x_,2):= if(isconstant(n), C_1*Gamma(1+n,-x)+C_2); dsolve(-(x_+n_)/x_*y(1,x_),y_,x_,2):= if(isconstant(n), C_1*Gamma(1-n,x)+C_2); #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_+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*exp(x)+psolution(1,1,0,c,y,x,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, 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_1+C_2*int(exp(int(b*exp(-x),x)),x)+psolution(b,1,0,c,y,x,2) )); 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(y(1,x_)+c_*xy_,xy_,x_,2):=if(isfree(c,xy), gsolution(1,c,xy,x,2) ); dsolve(b_*y(1,x_)+xy_,xy_,x_,2):=if(isfree(b,xy), gsolution(b,1,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(n_/x_*y(1,x_)+y(1,x_),y_,x_,2):= if(isconstant(n), C_1*Gamma(1+n,-x)+C_2); dsolve(a_*y(1,x_)+n_/x_*y(1,x_),y_,x_,2):= if(isconstant(a,n), C_1*(-a)^(-1-n)*Gamma(1+n,-a*x)+C_2); dsolve(y(1,x_)+xy_+d_,xy_,x_,2):= gsolution(1,1,xy,x,2)+psolution(1,1,1,d,xy,x,2); dsolve(y(1,x_)+c_*xy_+d_,xy_,x_,2):= gsolution(1,c,xy,x,2)+psolution(1,1,c,d,xy,x,2); dsolve(b_*y(1,x_)+xy_+d_,xy_,x_,2):= if(hasnot(b,y),gsolution(b,1,xy,x,2) +psolution(b,1,1,d,xy,x,2)); dsolve(b_*y(1,x_)+c_*xy_+d_,xy_,x_,2):= if(hasnot(b,y),gsolution(b,c,xy,x,2)+psolution(b,1,c,d,xy,x,2)); dsolve(x_+y_, y_,x_,1) := C_1*exp(x)-x-1; dsolve(y_+y_^n_,y_,x_,1):= exp(x)*(C_1-exp((n-1)*x))^(1/(1-n)); #dsolve(a_*y_+y_^n_,y_,x_,1):=If(isfree(a,y), exp(integrate(a,x))*(C_1+(1-n)*integrate(exp((n-1)*integrate(a,x)),x))^(1/(1-n)) ); dsolve(a_*y_+y_^n_,y_,x_,1):=If(isfree(a,y), block(dsolve:=integrate(a,x),p:=(C_1+(1-n)*integrate(exp((n-1)*dsolve),x)),exp(dsolve)*p^(1/(1-n)) )); dsolve(y_+b_*y_^n_,y_,x_,1):=If(isfree(b,y), block(p:=(C_1+(1-n)*integrate(b*exp((n-1)*x),x)),exp(x)*p^(1/(1-n)) )); dsolve(a_*y_+b_*y_^n_,y_,x_,1):=If(isfree(a,b,y), block(dsolve:=integrate(a,x),p:=(C_1+(1-n)*integrate(b*exp((n-1)*dsolve),x)),exp(dsolve)*p^(1/(1-n)) )); dsolve(1/(c_*x_+d_*y_)*(a_*x_+b_*y_),y_,x_,1) := if(isconstant(a,b,c,d), replace(int(expand((c+d*yx)/(a+(b-c)*yx-d*yx^2)),yx),yx,y/x)=log(x)); dsolve(1/(x_-y)*(x_+y_),y_,x_,1):=sqrt(C_1+2x^2)-x and -sqrt(C_1+2x^2)-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_+b_*y(q_,x_),y_):= dsolve(-expand(a/b),y,x,q); dsolve(a_+y(q_,x_),y_):= dsolve(expand(-a),y,x,q); #dsolve(a_+b_*y(q_,x_),y_):= if(hasnot(a,y) and hasnot(b,x), d(b,y,-q)=gsolution(0,y,x,q)-d(a,x,-q), if(q<0, dsolve(y+expand(d(a/b,x,-q)),y), dsolve(-expand(a/b),y,x,q) )); dsolve(c_+a_*xy_+b_*y(1,x_),xy_):= if(hasnot(c,xy) and a==d(b,x), C_1/b-int(c,x)/b, dsolve(-expand(c/b+a/b*xy),xy,x,1) ); 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(a_+y(q_,x_),y(x_)):= if(q<0, dsolve(y+replace(toy(d(a,x,-q)),y(x),y),y),dsolve(-replace(a,y(x),y),y,x,q)); #dsolve(a_+b_*y(q_,x_),y(x_)):= if(q<0, dsolve(y+expand(replace(toy(d(a/b,x,-q)),y(x),y)),y),dsolve(-expand(replace(a,y(x),y)/b),y,x,q)); dsolve(y(p_,x_)^2+b_*xy_*y(p_,x_)+c_*xy_^2,xy_):= if(b*b==4c, C_1*E(p,p!*int(-b/2,x,p)), C_1*E(p,p!*int((-b/2+sqrt(b*b-4c)/2),x,p)) and C_2*E(p,p!*int((-b/2-sqrt(b*b-4c)/2),x,p)) ); dsolve(c_+integrate(f_,t_,a_,b_),y_) := rsolve(toy(d(integrates(f,t,a,b)+c,x))); dsolve(integrate(f_,t_,a_,b_)=z_,y_) := rsolve(toy(d(integrates(f,t,a,b)-z,x))); dsolve(integrate(f_,t_,a_,b_)+z_,y_) := rsolve(toy(d(integrates(f,t,a,b)+z,x))); dsolve(c_+integrate(f_,t_,a_,b_)+z_,y_) := rsolve(toy(d(integrates(f,t,a,b)+c+z,x))); dsolve(c_+integrates(f_,t_,a_,b_),y_) := dsolve(toy(d(integrates(f,t,a,b)+c,x))); dsolve(integrates(f_,t_,a_,b_)+z_,y_) := dsolve(toy(d(integrates(f,t,a,b)+z,x))); dsolve(c_+integrates(f_,t_,a_,b_)+z_,y_) := dsolve(toy(d(integrates(f,t,a,b)+c+z,x))); dsolve(a_=b_,y_):=dsolve(toy(a-(b)),y); dsolve(y(n_,x)=b_,y_):=dsolve(b,y,x,n); dsolve(a_*y(n_,x_)^m_=b_,y_):=dsolve((b/a)^(1/m),y,x,n); dsolve(a_*y(n_,x_)=b_,y_):=dsolve(expand(b/a),y,x,n); dsolve(x(n_,t_)=a_,x_) := dsolve(tox(a),x,t,n); dsolve(y(n_,t)=a_,y_) := if(hasnot(a,x), dsolve(toyt(a),y,t,n), dsolve(y(n,t)-(a),y) ); dsolve(y(p_,t)=y(q_,x),y):= C_1+C_2*(t^p/p!+x^q/q!); #dsolve(y(p_,t)+a_*y(q_,x),y):= if(isconstant(a), C_1+C_2*(t^p/p!-x^q/q!/a) ); dsolve(y(p_,t)=y(q_,x)+d_,y):= if(hasnot(d,y), C_1+C_2*(1/p!*t^p+x^q/q!)+if(has(d,t), if(has(d,x), psolution(0,-d,p,x,q), int(d,t,p) ),-int(d,x,q) )); #dsolve(y(p_,t)=a_*y(q_,x)+d_,y):= if(isconstant(a) and hasnot(d,y), C_1+C_2*(a*t^p/p!+x^q/q!)+if(has(d,t),if(has(d,x), psolution(a,-d,p,x,q), int(d,t,p) ), -int(d/a,x,q) )); dsolve(y(p_,t)+a_*y(q_,x)+d_,y):= if( hasnot(d,y), C_1+C_2*(t^p/p!-int(1/a,x,q))-if(has(d,t),if(has(d,x), psolution(0,d,p,x,q)/a, int(d,t,p) ), int(d/a,x,q) )); #dsolve(y(1,t)=y(1,x)+c_*d_,y):= if(hasnot(c,x) and has(d,x) and hasnot(d,t), C_2+C_1*(t+x)-int(replace(c,t,t+x-z)*replace(d,x,z),z,0,x), if(has(d,t) and hasnot(d,x) and has(c,x) and hasnot(c,t), C_2+C_1*(t+x)-int(replace(d,t,t+x-z)*replace(c,x,z),z,0,x) )); #dsolve(y(1,t)=a_*y(1,x)+c_*d_,y):= if(hasnot(c,x) and has(d,x) and hasnot(d,t), C_1+C_2*(t+x/a)-expand(int(replace(c,t,t+x/a-z/a)*replace(d,x,z),z,0,x)/a) ); #dsolve(y(1,t)+a_*y(1,x)+c_*d_,y):= if(hasnot(c,x) and has(d,x) and hasnot(d,t), C_1+C_2*(t-x/a)+expand(int(replace(-c,t,t-x/a+z/a)*replace(-d,x,z),z,0,x)/a) ); #dsolve(y(p_,t)=y(1,x)+b_*exp(x)*t,y):= if(isconstant(b), C_1*(1/p!*t^p+x)-b*(1+t^p/p!)*exp(x) ); #dsolve(y(p_,t)=y(1,x)+b_*t*x,y):= if(isconstant(b), C_1*(1/p!*t^p+x)-b*x^(2+p)/(2+p)!-b*x^(1+p)*t^p/p!/(1+p)!); dsolve(y(p_,t)+a_*y(1,x)+b_*exp(t),y):= if(isconstant(a,b), C_1*(t^p/p!-x/a)-b*exp(t) ); #dsolve(y(p_,t)=y(q_,x)+b_*y+d_,y):= if(hasnot(d,y), C_1*exp(-b*x)*(t^p/p!+x^q/q!)+if(has(d,t), if(has(d,x), psolution(-b,-d,p,x,q), psolution(b,d,y,t,p) ), psolution(-b,-d,y,x,q) )); #dsolve(y(p_,t)=a_*y(q_,x)+b_*y+d_,y):= if(hasnot(d,y), C_1*exp(-b/a*x)*(a*t^p/p!+x^q/q!)+if(has(d,t), if(has(d,x), psolution(-b/a,-d/a,p,x,q),psolution(b,d,y,t,p) ), psolution(-b/a,-d/a,y,x,q) )); dsolve(y(p_,t)+y(q_,x)+b_*y+d_,y):= if(hasnot(d,y), if(isconstant(b), C_3*(exp((-b)^(1/p)*t)+exp((-b)^(1/q)*x))*(t^p/p!-x^q/q!),0)+gsolution(-b,y,t,p)+gsolution(-b,y,x,q)+if(has(d,t), if(has(d,x), psolution(1,-1,q,-b,-d,p,x,q),psolution(-b,-d,y,t,p) ), psolution(-b,-d,y,x,q) )); dsolve(y(p_,t)+a_*y(q_,x)+y+d_,y):= if(hasnot(d,y), if(isconstant(a), C_3*(exp(-t)+exp((-1/a)^(1/q)*x))*(t^p/p!-x^q/q!/a),0)+gsolution(-1,y,t,p)+gsolution(-1/a,y,x,q)+if(has(d,t), if(has(d,x), psolution(-1/a,-d/a,p,x,q),psolution(-1,-d,y,t,p) ), psolution(-1/a,-d/a,y,x,q) )); dsolve(y(p_,t)+a_*y(q_,x)+b_*y+d_,y):=if(hasnot(d,y), if(isconstant(a,b), C_3*(exp((-b)^(1/p)*t)+exp((-b/a)^(1/q)*x))*(t^p/p!-x^q/q!/a),0)+gsolution(-b,y,t,p)+gsolution(-b/a,y,x,q)+if(has(d,t), if(has(d,x), psolution(-b/a,-d/a,p,x,q),psolution(-b,-d,y,t,p) ), psolution(-b/a,-d/a,y,x,q) )); #dsolve(y(p_,t)=y(1,x)+b_*y+exp(t),y):= C_1*exp(-b*x)+1/(1-b)*exp(t); #dsolve(y(p_,t)=y(1,x)+y+d_*exp(t),y):= if(isconstant(d), C_1*exp(-x)+d/(1-b)*exp(t) ); #dsolve(y(p_,t)=y(1,x)+b_*y+d_*exp(t),y):= if(isconstant(b,d), C_1*exp(-b*x)+d/(1-b)*exp(t) ); #dsolve(y(p_,t)=a_*y(1,x)+b_*y+exp(t),y):= if(isconstant(a,b), C_1*exp(-b/a*x)+1/(1-b)*exp(t) ); #dsolve(y(p_,t)=a_*y(1,x)+b_*y+d_*exp(t),y):= if(isconstant(a,b,d), C_1*exp(-b/a*x)+d/(1-b)*exp(t) ); #dsolve(y(1,t)=y(1,x)+b_*y+c_*d_,y):= if(hasnot(c,x) and has(d,x) and hasnot(d,t), C_1*(t+x)*exp(-b*x)-int(exp(b*z)*replace(c,t,t+x-z)*replace(d,x,z),z,0,x)*exp(-b*x)); #dsolve(y(1,t)=a_*y(1,x)+b_*y+c_*d_,y):= if(hasnot(c,x) and has(d,x) and hasnot(d,t), C_1*(t+x/a)*exp(-b*x/a)-int(exp(b*z/a)*replace(c,t,t+x/a-z/a)*replace(d,x,z),z,0,x)*exp(-b*x/a)); dsolve(y(1,t)=a_*y(2,x),y_):=if(isconstant(a), C_3+C_1*(t+x^2/2/a)+C_2*erf(x/2/sqrt(a*t)) ); #dsolve(y(p_,t)=y(2,x)+b_*y(1,x),y):= if(isconstant(b), C_1*(1/p!*t^p+x/b)+C_2*exp(-b*x) ); #dsolve(y(p_,t)=a_*y(2,x)+y(1,x),y):= if(isconstant(a), C_1*(1/p!*t^p+x)+C_2*exp(-1/a*x) ); #dsolve(y(p_,t)=a_*y(2,x)+b_*y(1,x),y):= if(isconstant(a,b), C_1*(1/p!*t^p+x/b)+C_2*exp(-b/a*x) ); #dsolve(y(p_,t)=y(2,x)+b_*y(1,x)+c_*y,y):= dsolve(y(2,x)+b_*y(1,x)+c_*y,y); #dsolve(y(p_,t)=a_*y(2,x)+b_*y(1,x)+c_*y,y):= dsolve(a_*y(2,x)+b_*y(1,x)+c_*y,y); #dsolve(y(p_,t)=a_*y(2,x)+b_*y(1,x)+d_,y):= if(a== -b and has(d,t) and hasnot(d,y), C_1*(b/p!*t^p+x)+C_2*exp(x)+psolution(1,1,0,-d/a,y,x,p), C_1*(b/p!*t^p+x)+dsolve(a*y(2,x)+b*y(1,x)+d) ); #dsolve(y(p_,t)=a_*y(2,x)+b_*y(1,x)+d_,y):= if(hasnot(d,y), C_1*(1/p!*t^p+x/b)+C_2*exp(-b/a*x)+if(has(d,t),if(has(d,x), psolution(-b/a,1,0,-d/a,p,x,2), int(d,t,p)), psolution(-b/a,1,0,-d/a,y,x,2)) ); dsolve(y(p_,t)+a_*y(n_,x)+y(m_,x)+d_,y):= if(hasnot(d,y), C_1*(1/p!*t^p-x)+C_2*exp(-1/a*x)+if(has(d,t),if(has(d,x), psolution(a,-1,m,0,-d,p,x,n), -int(d,t,p)), psolution(-1/a,m,0,-d/a,y,x,n)) ); dsolve(y(p_,t)+y(n_,x)+b_*y(m_,x)+d_,y):= if(hasnot(d,y), C_1*(1/p!*t^p-x/b)+C_2*exp(-b*x)+if(has(d,t),if(has(d,x), psolution(1,-b,m,0,-d,p,x,n), -int(d,t,p)), psolution(-b,m,0,-d,y,x,n)) ); dsolve(y(p_,t)+a_*y(n_,x)+b_*y(m_,x)+d_,y):= if(hasnot(d,y), C_1*(1/p!*t^p-x/b)+C_2*exp(-b/a*x)+if(has(d,t),if(has(d,x), psolution(a,-b,m,0,-d,p,x,n), -int(d,t,p)), psolution(-b/a,m,0,-d/a,y,x,n) )); #dsolve(y(p_,t)=y(2,x)+b_*y(1,x)+d_,y):= if(hasnot(d,y), C_1*(b/p!*t^p+x)+if(has(d,t), C_2*exp(-b*x)+int(d,t,p),dsolve(y(2,x)+b*y(1,x)+d) )); #dsolve(y(p_,t)=y(2,x)+b_*y(1,x)+d_,y):= if(hasnot(d,y), C_1*(1/p!*t^p+x/b)+C_2*exp(-b*x)+if(has(d,x), if(has(d,t), psolution(-b,1,0,-d,p,x,2), psolution(-b,1,0,-d,y,x,2)), int(d,t,p) )); #dsolve(y(p_,t)=y(2,x) -y(1,x)+d_,y):= if(hasnot(d,y), C_1*(1/p!*t^p-x) +C_2*exp(x) +if(has(d,x), if(has(d,t), psolution(1,1,1,d,y,x,2), int(d,t,p)), psolution(1,1,0,-d,y,x,2) )); #dsolve(y(p_,t)=y(2,x) -y(1,x)+exp(x)*tt_,y):= if(has(tt,t) and hasnot(tt,x), C_1*(1/p!*t^p-x)+C_2*exp(x)+exp(x)*int(tt,t,p) ); #dsolve(y(p_,t)=y(2,x)+b_*y(1,x)+d_*exp(t)*x,y):= if(isconstant(b,d), C_1*(b/p!*t^p+x)+C_2*exp(-b*x)+d*exp(t)*(b+x) ); #dsolve(y(p_,t)=y(2,x)+b_*y(1,x)+d_*exp(x)*tt_,y):= if(isconstant(b,d) and hasnot(tt,x), C_1*(b/p!*t^p+x)+C_2*exp(-b*x)+d*exp(x)*int(tt,t,p) ); dsolve(y(p_,t)+y(n_,x)+b_*y(m_,x)+c_*y,y):= gsolution(-c,y,t,p)+gsolution(-b,m,-c,y,x,n); dsolve(y(p_,t)+a_*y(n_,x)+b_*y(m_,x)+c_*y,y):= gsolution(-c,y,t,p)+gsolution(-b/a,m,-c/a,y,x,n); dsolve(y(p_,t)+y(n_,x)+b_*y(m_,x)+c_*y+d_,y):= gsolution(-c,y,t,p)+gsolution(-b,m,-c,y,x,n)+if(has(d,x), if(has(d,t), psolution(1,-b,m,-c,-d,p,x,n), psolution(-b,m,-c,-d,y,x,n)), psolution(-c,-d,y,t,p) ); dsolve(y(p_,t)+a_*y(n_,x)+b_*y(m_,x)+c_*y+d_,y):= gsolution(-c,y,t,p)+gsolution(-b/a,m,-c/a,y,x,n)+if(has(d,x), if(has(d,t), psolution(a,-b,m,-c,-d,p,x,n),psolution(-b/a,m,-c/a,-d/a,y,x,n)), psolution(-c,-d,y,t,p) ); #dsolve(y(p_,t)+a_*y(2,x)+b_*y(1,x)+c_*y+d_*exp(x)*tt_,y):= if(isconstant(b,c,d) and hasnot(tt,x), gsolution(-b/a,-c/a,y,x,2)-d*exp(x)*int(tt,t,p) ); dsolve(y(p_,t)+y(q_,x),y_):= C_1+C_2*(t^p/p!-x^q/q!)+C_3*exp(t-x); dsolve(y(p_,t)+a_*y(q_,x),y_):= if(hasnot(a,t) and hasnot(a,x), C_1+C_2*(t^p/p!-x^q/q!/a)+if(a<0 or isinteger(q), C_3*exp(t+x/(-a)^(1/q)),0) ); dsolve(y(p_,t)+y(q_,x)+b_*y,y):=if(isconstant(b) and p<2, (C_3+t^p/p!-x^q/q!),1)*if(hasnot(b,x),gsolution(-b,y,t,p),0)+if(isconstant(b) and q<2, (C_3+t^p/p!-x^q/q!),1)*if(hasnot(b,t),gsolution(-b,y,x,q),0); dsolve(y(p_,t)+a_*y(q_,x)+y,y):=if(isconstant(a) and p<2, (C_3+t^p/p!-x^q/q!/a),1)*gsolution(-1,y,t,p)+if(isconstant(a) and q<2, (C_3+t^p/p!-x^q/q!),1)*if(hasnot(a,t),gsolution(-1/a,y,x,q),0); dsolve(y(p_,t)+a_*y(q_,x)+b_*y,y):=if(isconstant(a,b) and p<2, (C_3+t^p/p!-x^q/q!/a),1)*if(hasnot(b,x),gsolution(-b,y,t,p),0)+if(isconstant(a,b) and q<2, (C_3+t^p/p!-x^q/q!/a),1)*if(hasnot(b,t),gsolution(-b/a,y,x,q),0); dsolve(y(p_,t)+y(2,x)+b_*y(1,x),y):= if(isconstant(b), C_1*(1/p!*t^p-x/b)+C_2*exp(-b*x)+C_3,C_1+C_2*int(exp(-int(b,x))) ); dsolve(y(p_,t)+a_*y(2,x)+y(1,x),y):= if(isconstant(a), C_1*(1/p!*t^p-x)+C_2*exp(-1/a*x)+C_3,C_1+C_2*int(exp(-int(1/a,x))) ); dsolve(y(p_,t)+a_*y(2,x)+b_*y(1,x),y):= if(isconstant(a,b), C_1*(1/p!*t^p-x/b)+C_2*exp(-b/a*x)+C_3,C_1+C_2*int(exp(-int(b/a,x))) ); dsolve(y(1,t)+y(2,x),y):= C_1+C_2*(t-x^2/2)+C_3*erfi(x/2/sqrt(t)); dsolve(y(1,t)+a_*y(2,x),y):= if(hasnot(a,t) and hasnot(a,x), C_1+C_2*(t-x^2/2/a)+C_3*erf(x/2/sqrt(-a*t)) ); dsolve(y(1,t)+a_*y(1,x),y):= if(hasnot(a,t) and hasnot(a,x), C_1+C_2*F(t-x/a)); dsolve(y(1,t)+y(3,x)+xy_*y(1,x),xy_):= -12 C_1^2 *tanh(C_2 *t + C_1 *x + C_3)^2 + 8 C_1^2 - C_2/C_1; dsolve(y(1,t)+y(2,x)+xy_*y(1,x),xy_):= 2 C_1 *tanh(C_2 *t + C_1 *x + C_3) - C_2/C_1; dsolve(y(1,t)+y(2,x)+b_*xy_*y(1,x),xy_):= if(isconstant(a,b), 2a/b* C_1 *tanh(C_2 *t + C_1 *x + C_3) - 1/b*C_2/C_1 ); dsolve(y(1,t)+a_*y(2,x)+b_*xy_*y(1,x),xy_):= if(isconstant(b), 2/b* C_1 *tanh(C_2 *t + C_1 *x + C_3) - 1/b*C_2/C_1 ); dsolve(y(1,t)+xy_*y(1,x),xy_):= C_1*x/(1+C_1*t); dsolve(y(1,t)+b_*xy_*y(1,x),xy_):= C_1*x/(1+C_1*b*t); dsolve(x(n_,t_)=b_,d_+y(m_,t_),x_,y_):= 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 and y=dsolve(replace(dd,x,xx),y,t,m))), if(hasnot(dd,x),block(xx:=dsolve(dd,y,t,m), (y=xx and x=dsolve(replace(bb,y,xx),x,t,n))), if(hasnot(a,c,t) and m==n,y=dsolve(c/a,y,x,n) )))); dsolve(x(m_,t_)=a_,y(n_,t_)=c_,x_,y_):= if(hasnot(a,y), block(xx:=solve(dsolve(a,x,t,m),x), (x=xx and y=dsolve(replace(c,x,xx),y,t,n))), if(hasnot(c,x), block(yy:=solve(dsolve(c,y,t,n),y), (y=yy and x=dsolve(replace(c,y,yy),x,t,m))), if(hasnot(a,c,t) and m==n, (x=dsolve(replace(a,y,dsolve(c/a,y,x,n)),x,t,m),y=dsolve(c/a,y,x,m)) ))); dsolve(x(m_,t_)=c1_+y_,y(n_,t_)=c2_+x_,x_,y_):= if(isconstant(c1,c2), (x=exp(t)-c2 and y=exp(t)-c1)); dsolve(x(m_,t_)=a_*x_+b_*y_,y(m_,t_)=c_*x_+d_*y_,x_,y_):= if(isconstant(a,b,c,d) and (a+d)^2==4*(a*d-b*c),(x=C_1*E(m,(a+d)/2*t^m) and y=C_1*E(m,(a+d)/2*t^m))); dsolve(x(m_,t_)=a_*x_+y_,y(m_,t_)=x_+a_*y_,x_,y_):= if(isconstant(a),(x=C_1*E(m,(a+1)*t^m) and y=C_1*E(m,(a+1)*t^m))); dsolve(x(m_,t_)=x_+b_*y_,y(m_,t_)=b_*x_+y_,x_,y_):= if(isconstant(b),(x=C_1*E(m,(1+b)*t^m) and y=C_1*E(m,(1+b)*t^m))); dsolve(x(m_,t_)=a_*x_+b_*y_,y(m_,t_)=b_*x_+a_*y_,x_,y_):= if(isconstant(a,b),(x=C_1*E(m,(a+b)*t^m) and y=C_1*E(m,(a+b)*t^m))); #dsolve(x(1,t_)=a_*y_,y(1,t_)=c_,x_,y_):=if(hasnot(a,x), block(xx:=dsolve(expand(a*replace(c,y,x(1,t)/a)),x,t,2), (x=xx, y=d(xx,t)/a))); #dsolve(x(1,t_)=a_+y_,y(1,t_)=c_,x_,y_):=if(hasnot(a,x), block(xx:=dsolve(expand(replace(c,y,x(1,t))),x,t,2), (x=xx, y=d(xx,t)-a))); #dsolve(x(1,t_)=a_*y_+b_,y(1,t_)=c_,x_,y_):=if(hasnot(a,b,x), block(xx:=dsolve(expand(a*replace(c,y,x(1,t)/a)),x,t,2), (x=xx, y=d(xx,t)/a-b/a))); #dsolve(x(1,t_)=a_,y(1,t_)=c_*x_,x_,y_):=if(hasnot(c,x), block(yy:=dsolve(expand(c*replace(a,x,y(1,t)/c)),y,t,2), (y=yy, x=d(yy,t)/c))); #dsolve(x(1,t_)=a_,y(1,t_)=c_+x_,x_,y_):=if(hasnot(c,x), block(yy:=dsolve(expand(replace(a,x,y(1,t))),y,t,2), (y=yy, x=d(yy,t)-c))); #dsolve(x(1,t_)=a_,y(1,t_)=b_+c_*x_,x_,y_):=if(hasnot(b,c,x), block(yy:=dsolve(expand(c*replace(a,x,y(1,t)/c)),y,t,2), (y=yy, x=d(yy,t)/c-b/c))); #dsolve(x(1,t_)=x_+y_,y(1,t_)=x_+(-1)*y_,x_,y_):= (x=1/4 *c_1* e^(-sqrt(2)* t)* ((2 + sqrt(2))* e^(2 sqrt(2)* t) + 2 - sqrt(2)) + (c_2 *e^(-sqrt(2) *t) *(e^(2 sqrt(2)* t) - 1))/(2 sqrt(2)), y=(c_1 *e^(-sqrt(2) *t) *(e^(2 sqrt(2) *t) - 1))/(2 sqrt(2)) - 1/4 *c_2 *e^(-sqrt(2)* t)* ((sqrt(2) - 2)* e^(2 sqrt(2)* t) - 2 - sqrt(2))); #dsolve(b_+x(n_,t_),d_+y(n_,t_)):= (x=dsolve(-b,x,t,n), 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, 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),x,y); dsolve(ds(x_,t_)=f_,ds(y_,t_)=g_):= dsolve(x(1,t)=f,y(1,t)=g,x,y); dsolve(a_):=dsolve(replace(toy(a),y(x),y),y);