# 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_+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_+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_*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_^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==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*E(q,x^q) )); 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(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) ); 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(y_, y_,x_,-1) :=e^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)*sin(sqrt(3)/2x)+C_3*exp(-x/2)*cos(sqrt(3)/2x); 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_):= 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_):= 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_)+c_*xy_+d_, xy_,x_,q_) := if(isfree(c,d,xy) and 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(y(p_,x_)+xy_+d_, xy_,x_,q_) := if(isfree(d,xy) and 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(b_*y(p_,x_)+xy_+d_, xy_,x_,q_) := if(isfree(b,d,xy) and 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) and 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), (integrate(b,x)+C_1) ); dsolve(b_*y_^n_, y_,x_,1) := If(isfree(b,y), (integrate(b,x)+C_1)^(1/(1-n)) ); dsolve(x_/y_, y_,x_,1) :=x; dsolve(z_/(b_+c_), y_,x_,n_) := if(has(b,x) and has(c,y), dsolve(b/z+c/z,x,y,n)=x); dsolve(a_/(b_+c_), y_,x_,n_) := if(has(b,x) and has(c,y), dsolve(expand(b/a+c/a),x,y,n)=x); dsolve(a_*1/(b_+c_)*z_, y_,x_,n_) := if(has(b,x) and has(c,y), dsolve(b/a/z+c/a/z,x,y,n)=x); dsolve(1/b_, y_,x_,n_) := if(has(b,y), dsolve(b,x,y,n)=x); dsolve(x_+y_, x_,y_,n_) := C_1*exp(y)-y-1; dsolve(x_+b_*y_, x_,y_,n_) := C_1*exp(y)-b*y-b; dsolve(a_+x_+y_, x_,y_,n_) := if(hasnot(a,x) and hasnot(a,y),C_1*exp(y)-y-a-1); dsolve(a_*x_+b_*y_, x_,y_,1) := if(hasnot(a,b,x) and hasnot(a,b,y), C_1*exp(a*y)-b/a*y-b/a^2); dsolve(x_+b_*y_+c_, x_,y_,1) := if(hasnot(b,c,x) and hasnot(b,c,y), C_1*exp(y)-c-b-b*y); dsolve(a_*x_+b_*y_+c_, x_,y_,1) := if(hasnot(a,b,c,x) and hasnot(a,b,c,y), C_1*exp(a*y)-1/a*c-b*a^(-2)-b/a*y); dsolve(x_+x_*y_, x_,y_,q_) := C_1*mittag(q,d(1+y,y,-q)*q!); dsolve(x_+b_*x_*y_, x_,y_,q_) := If(isfree(b,x), C_1*mittag(q,d(1+b*y,y,-q)*q!) ); dsolve(a_*x_+b_*x_*y_, x_,y_,q_) := If(isfree(a,b,x), C_1*mittag(q,d(a+b*y,y,-q)*q!) ); 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(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(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(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):= 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):= gsolution(b,c,xy,x,2)+psolution(b,1,c,d,xy,x,2); 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((x_+(-1)*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_+y(q_,x_),y_):= if(q<0 and hasno(a,y), -d(a,x,-q),dsolve(-a,y,x,q) ); dsolve(a_+b_*y(q_,x_),y_):= if(hasnot(a,y) and hasnot(a,y(x)) 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(a_=b_,y_):=dsolve(toy(a-b),y); dsolve(integrates(f_,t_,a_,b_)=c_,y_) := dsolve(toy(d(integrates(f,t,a,b)-c,x))); dsolve(c_+integrates(f_,t_,a_,b_)+z_,y_) := dsolve(toy(d(integrates(f,t,a,b)+c+z,x)),y,x,1); dsolve(y(n_,t_)=a_,y_) := dsolve(toy(a),y,t,n); dsolve(x(n_,t_)=a_,x_) := dsolve(tox(a),x,t,n); 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, 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))), 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:=dsolve(a,x,t,m), (x=xx, y=dsolve(replace(c,x,xx),y,t,n))), if(hasnot(c,x), block(yy:=dsolve(c,y,t,n), (y=yy, x=dsolve(replace(c,y,yy),x,t,m))), if(hasnot(a,c,t) and m==n, dsolve(c/a,y,x,n) ))); #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);