# differential equation solver; # solve second order differential equation for function y with independent variable x; # e.g. dsolve2( y'' = x*y, y); # dsolve2( ds(y,x,2)=y^2 ); # dsolve2(eq,y,x); dsolve2(y_, y_,x_) := C_1*exp(x)+C_2*exp(-x); dsolve2(b_*y_, y_,x_) := if(isfree(b,y),if(isfree(b,x), if(b<0, C_1*cos(sqrt(-b)*x)+C_2*sin(sqrt(-b)*x), C_1*exp(sqrt(b)*x)+C_2*exp(-sqrt(b)*x) ),y*log(y)-y=d(b,x,-2)+C_1*x+C_2 )); dsolve2(x_*y_, y_,x_) := C_1*AiryAi(x)+C_2*AiryBi(x); dsolve2(a_*x_*y_, y_,x_) := if(isfree(a,x) and isfree(a,y), C_1*AiryAi(cbrt(a)*x)+C_2*AiryBi(cbrt(a)*x)); dsolve2(a_+y_, y_,x_) := 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)+1/2*exp(x)*int(exp(-x)*a) )); dsolve2(x_+y_, y_,x_) := C_1*exp(x)+C_2*exp(-x)-x; dsolve2(a_+b_*y_, y_,x_) := if(isfree(a,b,x) and isfree(a,b,y), if(b<0, C_1*cos(sqrt(-b)*x)+C_2*sin(sqrt(-b)*x)-a/b, C_1*exp(sqrt(b)*x)+C_2*exp(-sqrt(b)*x)-a/b )); dsolve2(ds(y_)+d_,y_,x_):=if(isfree(d,x) and isfree(d,y), C_1+C_2*e^x-d*x); dsolve2(b_*ds(y_),y_,x_):=if(isfree(b,x) and isfree(b,y), C_1+C_2*e^(b*x)); dsolve2(b_*ds(y_)+d_,y_,x_):=if(isfree(b,d,x) and isfree(b,d,y), C_1+C_2*e^(b*x)/b-d*x/b); dsolve2(ds(y_)+y_,y_,x_):= C_1*e^((1-sqrt(5))/2*x)+C_2*e^((1+sqrt(5))/2*x); dsolve2(b_*ds(y_)+y_,y_,x_):=if(isfree(b,x) and isfree(b,y), C_1*e^((b-sqrt(b^2+4))/2*x)+C_2*e^((b+sqrt(b^2+4))/2*x)); dsolve2(ds(y_)+c_*y_,y_,x_):=if(isfree(c,x) and isfree(c,y), C_1*e^((1-sqrt(1+4c))/2*x)+C_2*e^((1+sqrt(1+4c))/2*x)); dsolve2(b_*ds(y_)+c_*y_,y_,x_):=if(isfree(b,c,x) and isfree(b,c,y), C_1*e^((b-sqrt(b^2+4c))/2*x)+C_2*e^((b+sqrt(b^2+4c))/2*x));