#	differential equation solver;
#	solve differential equation and fractional differential equation for unknown y with independent variable x;
#	dsolve(eq,y);
#	e.g. dsolve( y' = x*y);


#1;
dsolve((c_+y_)^n_, y_,x_,q_) := if(d(c,x,q)==0, dsolve(y^n, y,x,q)-c );
dsolve((c_+b_*y_)^n_, y_,x_,q_) := if(d(c,x,q)==0,block(f1:=fallingfactorial(q/(1-n),q)^(1/(n-1))*b^(n/(1-n)),
	f2:=(if(n+q-1==0,0,C_1)+x)^(q/(1-n)),
	if(iseven(q),f1*(C_1-x)^(q/(1-n))-c/b and f1*f2-c/b, 
	f1*f2-c/b and if(isodd(n),-f1*f2-c/b ))));

dsolve(1/b_, y_,x_,n_) := if(abs(n)<=1 and has(b,y),if(has(b,x), dsolve(replace(b,x,zz),zz,y,n)=x, C_1+int(b,y,n)=x^n/n! ));

dsolve(_f(y(m_,x_)),y_,x_,p_):= int(dsolve(_f(y),y,x,p-m),y,m)=gsolution(0,y,x,m);
dsolve(_f(b_*y_),y_,x_,1):= if(hasnot(b,x), int(1/_f(z),z,1,b*y)=C_1+x );
dsolve(_f(a_+y_),y_,x_,1):= if(hasnot(d(a,x),x), int(1/(d(a,x)+_f(z)),z,1,a+y)=C_1+x );
dsolve(_f(a_+b_*y_),y_,x_,1):= if(hasnot(b,x), int(1/(d(a,x)+b*_f(z)),z,1,a+b*y)=C_1+x );
dsolve(_f(y_/(a_+x_)),y_,x_,1):=  if(hasnot(a,x) and hasnot(a,y), int(1/(_f(z)-z),z,1,y/x)=C_1+log(a+x) );
dsolve(_f(y_/x_),y_,x_,1):=int(1/(_f(z)-z),z,1,y/x)=C_1+log(x);
dsolve(_f(x_/y_),y_,x_,1):=int(1/(_f(1/z)-z),z,1,y/x)=C_1-log(x);
dsolve(_f(y(1,x_)),y_,x_,3):= int(1/sqrt(C_3+int(_f(y),y)),y,2)=C_2*(C_1+x)+sqrt(2)*x^2/2;
dsolve(_f(y(1,x_)),y_,x_,2):= int(1/_f(y),y,2)=C_2*(C_1+x);
dsolve(_f(y),y_,x_,2):= int(1/sqrt(C_2+2int(_f(y),y)),y)=C_1+x;
dsolve(_f(y),y_,x_,1):= int(1/_f(y),y)=C_1+x;

dsolve(y_^n_, y_,x_,q_) := block(f1:=fallingfactorial(q/(1-n),q)^(1/(n-1)),f2:=(C_1+x)^(q/(1-n)),
	if(iseven(q),f1*(C_1-x)^(q/(1-n)) and f1*f2, 
	f1*f2 and if(isodd(n),-f1*f2 )));
dsolve(1/y_, y_,x_,2):= i*exp(-inverseerf(sqrt(2)/sqrt(pi)*(C_1+x))^2) and -i*exp(-inverseerf(sqrt(2)/sqrt(pi)*(C_1+x))^2);
dsolve(y_^2, y_,x_,2):= weierstrassP(C_1+x,0,C_2);
dsolve(y_, y_,x_,p_) := gsolution(1,y,x,p);

dsolve(exp(b_*y_+c_), y_,x_,p_) := if(hasnot(b,x),
	if(isinteger(p) and d(c,x,p)==0, log((-1)^p/b*p!/(C_1+x)^p)/b-c/b,
	ln(p,gsolution(0,y,x,p)+b*p!*int(exp(c),x,p))/b ));
dsolve(exp(y_+c_), y_,x_,p_) := if(d(c,x,p)==0, dsolve(exp(y),y,x,p)-c,ln(p,int(exp(c),x,p)*p!+gsolution(0,y,x,p)) );
dsolve(exp(b_*y_), y_,x_,p_) := if(hasnot(b,x), if(isinteger(p), log((-1)^p/b*p!/(C_1+x)^p)/b and if(iseven(p), log((-1)^p/b*p!/(C_1-x)^p)/b ),
	ln(p,C_1+b*x^p)/b ));
dsolve(exp(y_), y_,x_,p_) := if(isinteger(p), log((-1)^p*p!/(C_1+x)^p) and if(iseven(p),log((-1)^p*p!/(C_1-x)^p) ),
	ln(p,x^p+gsolution(0,y,x,p)) );

dsolve(sinh(y_), y_,x_,2) := 2i*am(C_2*(C_1+x),-1/C_2^2);
dsolve(cosh(y_), y_,x_,2) := 2i*am(C_2*(C_1+x),i/C_2^2)-i*pi/2;
dsolve(sinh(a_*y_), y_,x_,2) := if(isconstant(a), 2i/a*am(sqrt(a)*C_2*(C_1+x),-1/C_2^2) );
dsolve(cosh(a_*y_), y_,x_,2) := if(isconstant(a), 2i/a*am(sqrt(a)*C_2*(C_1+x),i/C_2^2)-i*pi/2 );
dsolve(sin(y_), y_,x_,2) := 2am(C_2*(C_1+x),-1/C_2^2);
dsolve(cos(y_), y_,x_,2) := 2am(C_2*(C_1+x),1/C_2^2)+pi/2;
dsolve(sin(a_*y_), y_,x_,2) := if(hasnot(a,x), 2/a*am(sqrt(a)*C_2*(C_1+x),-1/C_2^2) );
dsolve(cos(a_*y_), y_,x_,2) := if(hasnot(a,x), 2/a*am(sqrt(a)*C_2*(C_1+x),1/C_2^2)+pi/2 );
dsolve(exp(y_), y_,x_,2) := log(-C_2^2/2+C_2^2/2*tanh(1/2*C_2*(C_1+x))^2);

dsolve(tanh(x_+y_), y_,x_,1) := 1/2* (W(exp(-4 x - C_1)) + C_1 + 2 x);
dsolve(coth(x_+y_), y_,x_,1) := 1/2* (W(-exp(-4 x - C_1)) + C_1 + 2 x);
dsolve(tan(x_*y_), y_,x_,1):= erfi((y-i*x)*sqrt(2)/2)+erfi((y+i*x)*sqrt(2)/2)+C_1=0;
dsolve(exp(x_/y_),y_,x_,1):= int(1/(exp(1/z)-z),z,1,y/x)=C_1+log(x);
dsolve(exp(y_), y_,x_,1) := -log(C_1-x);
dsolve(exp(y_+c_), y_,x_,1) := if(hasnot(c,x), -c-log(C_1-x),  -log(C_1-int(exp(c),x)) );
dsolve(exp(b_*y_+c_), y_,x_,1) := if(hasnot(b,x),if(hasnot(c,x), -c/b-log(C_1-b*x)/b, -log(C_1-b*int(exp(c),x))/b ));  

#dsolve(y(p_,x_)^n_,y_,x_,q_):= if(n== -1, C_2+1/sqrt(fallingfactorial((p+q)/2,p)*fallingfactorial((p+q)/2,q))*(C_1+x)^((p+q)/2),
	int(dsolve(y^n,y,x,q-p),x,p)+gsolution(0,y,x,p));
dsolve(y(p_,x_)^n_,y_,x_,q_):= 	int(dsolve(y^n,y,x,q-p),x,p)+gsolution(0,y,x,p);
#dsolve(y(p_,x_)^n_,y_,x_,q_):= if(n>0,gsolution(0,y,x,min(p,q)) and gsolution(0,y,x,min(p,q))+int(dsolve(y^(n^(sgn(q-p))),y,x,abs(q-p)),x,min(p,q)), gsolution(0,y,x,min(p,q))+int(dsolve(y^(n^(sgn(q-p))),y,x,abs(q-p)),x,min(p,q)) );
#dsolve(y(p_,x_)^n_,y_,x_,p_):= if(n>0,gsolution(0,y,x,p)+(C_2+x)^p/p!, gsolution(0,y,x,p)+(C_2+x)^p/p!);
#dsolve(y(1,x_)^n_,y_,x_,2) := C_2 - ((1-n)* (C_1 + x))^(1/(1 - n) + 1)/(n - 2);
#dsolve(y(1,x_)^2,y_,x_,2):= C_2 - log(C_1 + x) and C_2 - log(C_1 - x);
dsolve(y(1,x_)^p_,y_,x_,p_):= C_2 -(p-1)!^(1/(p-1))* log(C_1 + x) and C_2 -(p-1)!^(1/(p-1))* log(C_1 - x);
#dsolve(1/y(p_,x_),y_,x_,q_) := C_2+1/sqrt(fallingfactorial((p+q)/2,p)*fallingfactorial((p+q)/2,q))*(C_1+x)^((p+q)/2);
dsolve(y(p_,x_),y_,x_,q_):= exp(C_1+x)+gsolution(0,y,x,p);

dsolve((y(p_,x_)+b_*x_*y(q_,x_))^n_,y_,x_,q_):= if(q-p==1 and hasnot(b,x), -b*int(C_1^n+C_1*x,x,p) );

dsolve(1/y(1,x_),y_,x_,3):= C_2-i*sqrt(pi)/2erf(sqrt(2)*inverseerf(C_1+x*sqrt(-2)/sqrt(pi))) and C_2+i*sqrt(pi)/2erf(sqrt(2)*inverseerf(C_1+x*sqrt(-2)/sqrt(pi)));
dsolve(y(1,x_),y_,x_,3):= C_2+exp(C_1+x)+C_3*exp(-x);
dsolve(y(2,x_),y_,x_,3):= C_2+exp(C_1+x)+C_3*x;
dsolve(y(1,x_),y_,x_,2):= C_2+exp(C_1+x);

dsolve((y_-x_*y(1,x_))^n_,y_,x_,1):= -C_1^n-C_1*x;
dsolve((-y_+x_*y(1,x_))^n_,y_,x_,1):= C_1*x-C_1^n;
dsolve((c_+y_-x_*y(1,x_))^n_,y_,x_,1):= if(isconstant(c),-C_1^n-C_1*x-c);
dsolve((c_-y_+x_*y(1,x_))^n_,y_,x_,1):= if(isconstant(c),C_1*x-C_1^n+c);


#2x;
dsolve(c_*_f(b_*y_),y_,x_,1):= if(hasnot(b,x) and hasnot(c,y), int(1/_f(z),z,1,b*y)=C_1+b*int(c,x) );
dsolve(c_*_f(a_+y_),y_,x_,1):= if(hasnot(c,y), int(1/(d(a,x)+_f(z)),z,1,a+y)=C_1+int(c,x) );
dsolve(c_*_f(a_+b_*y_),y_,x_,1):= if(hasnot(c,y), int(1/(d(a,x)+b*_f(z)),z,1,a+b*y)=C_1+int(c,x) );
dsolve(_f(b_*y_)*g_,y_,x_,1):= if(hasnot(b,x) and hasnot(g,y), int(1/_f(z),z,1,b*y)=C_1+b*int(g,x) );
dsolve(_f(a_+y_)*g_,y_,x_,1):= if(hasnot(g,y), int(1/(d(a,x)+_f(z)),z,1,a+y)=C_1+int(g,x) );
dsolve(_f(a_+b_*y_)*g_,y_,x_,1):= if(hasnot(b,x) and hasnot(g,y), int(1/(d(a,x)+b*_f(z)),z,1,a+b*y)=C_1+int(g,x) );

#dsolve1(m_/n_,y_,x_,p_) :=if(p>0 and p<=1 and has(n,x) and has(n,y), 
	block(f2:=(d(m,y,p)+d(n,x,p)), 
	if(f2==0,block(f1:=int(n,y,p),f1-int(m+d(f1,x,p),x,p)=C_1), 
	if(hasnot(simplify(-f2/n),y),block(f1:=exp(int(simplify(-f2/n),x,p)),pp:=int(f1*n,y), pp-int(f1*m+d(pp,x,p),x,p)=C_1), 
	if(hasnot(simplify(-f2/m),x),block(f1:=exp(int(simplify(-f2/m),y,p)),pp:=int(f1*n,y), pp-int(f1*m+d(pp,x,p),x,p)=C_1) 
	)) )));
#dsolve1(n_/m_,y_,x_,p_) :=if(p>0 and p<=1 and has(m,x) and has(m,y), 
	block(f2:=(d(n,y,p)+d(m,x,p)), 
	if(f2==0,block(f1:=int(m,y,p),f1-int(n+d(f1,x,p),x,p)=C_1), 
	if(hasnot(simplify(-f2/m),y),block(f1:=exp(int(simplify(-f2/m),x,p)),pp:=int(f1*m,y), pp-int(f1*n+d(pp,x,p),x)=C_1), 
	if(hasnot(simplify(-f2/n),x),block(f1:=exp(int(simplify(-f2/n),y,p)),pp:=int(f1*m,y), pp-int(f1*n+d(pp,x,p),x)=C_1) 
	)) )));

#dsolve(b_*exp(c_+y_), y_,x_,p_) := if(hasnot(b,c,y), 	
	if(p==1, -log(C_1-int(b*exp(c),x)),  
	if(p<1, ln(p,C_1+p!*int(b*exp(c),x,p)), 
	if(d(b,x,p)==0 and d(c,x,p)==0, log((-1)^p*p!/b/(C_1+x)^p)-c and if(iseven(p),log((-1)^p*p!/b/(C_1-x)^p)-c)
	))));
#dsolve(b_*exp(c_+y_), y_,x_,p_) := if(hasnot(b,c,y), 	
	if(p<1, ln(p,C_1+p!*int(b*exp(c),x,p)), 
	if(d(b,x,p)==0 and d(c,x,p)==0, log((-1)^p*p!/b/(C_1+x)^p)-c and if(iseven(p),log((-1)^p*p!/b/(C_1-x)^p)-c)
	)));

dsolve(a_*log(x_/y_),y_,x_,1):=if(isconstant(a),int(1/(a*log(1/z)-z),z,1,y/x)=C_1+log(x) and a*W(1/a)*x );
dsolve(a_*log(y_/x_),y_,x_,1):=if(isconstant(a),int(1/(a*log(z)-z),z,1,y/x)=C_1+log(x) and -a*W(-1/a)*x );
dsolve(a_*log(b_*y_/x_),y_,x_,1):=if(hasnot(a,b,x),int(1/(a*log(z)-z),z,1,b*y/x)=C_1+log(x) and -a*W(-1/a/b)*x );

dsolve(a_*exp(y_/x_),y_,x_,1):=if(isconstant(a),int(1/(a*exp(z)-z),z,1,y/x)=C_1+log(x) and -W(-a)*x );
dsolve(a_*exp(x_/y_),y_,x_,1):=if(isconstant(a),int(1/(a*exp(1/z)-z),z,1,y/x)=C_1+log(x) and 1/W(1/a)*x );
dsolve(b_*exp(y_), y_,x_,p_) := if(p<>1 and hasnot(b,y),if(isinteger(p), log((-1)^p*p!/b/(C_1+x)^p) and if(iseven(p),log((-1)^p*p!/b/(C_1-x)^p)),
	ln(p,gsolution(0,y,x,p)+p!*int(b,x,p)) ));
#dsolve(exp(c_+y_)*z_, y_,x_,p_) := if(hasnot(c,z,y), 	
	if(p==1, -log(C_1-int(exp(c)*z,x)),  
	if(p<1, ln(p,C_1+p!*int(exp(c)*z,x,p)), 
	if(d(c,x,p)==0 and d(z,x,p)==0, log((-1)^p*p!/z/(C_1+x)^p)-c and if(iseven(p),log((-1)^p*p!/z/(C_1-x)^p)-c)
	))));
#dsolve(exp(c_+y_)*z_, y_,x_,p_) := if(hasnot(z,y) and d(c,x,p)==0, dsolve(exp(y)*z,y,x,p)-c);
#dsolve(exp(c_+b_*y_)*z_, y_,x_,p_) := if(hasnot(z,y) and d(c,x,p)==0, dsolve(exp(b*y)*z,y,x,p)-c/b);
#dsolve(exp(c_+x_)*z_, y_,x_,p_) :=  if(hasnot(z,x), replace(dsolve(exp(x)*z,y,x,p),x,x+c) );
dsolve(exp(y_)*z_, y_,x_,p_) := if(p<>1 and hasnot(z,y), ln(p,gsolution(0,y,x,p)+p!*int(z,x,p)) );
dsolve(exp(b_*y_)*z2_, y_,x_,p_) := if(p<>1 and hasnot(z2,y) and hasnot(b,x), 
	ln(p,gsolution(0,y,x,p)+b*p!*int(z2,x,p))/b );
#dsolve(exp(b_*y_)*x_, y_,x_,p_) := if(hasnot(b,x), if(isinteger(p),-log(if(p==1,C_1,0)+1/(-1)^p*b/((p-1)!+p!)*x^(1+p))/b,
	ln(p,gsolution(0,y,x,p)+p!*int(z,x,p)) ));
#dsolve(exp(b_*y_)*(c_+x_), y_,x_,p_) := if(isconstant(b,c), -log(if(p==1,C_1,0)+1/(-1)^p*b/((p-1)!+p!)*(c+x)^(p+1))/b );
#dsolve(exp(b_*y_)*(c_+f1_*x_), y_,x_,p_) := if(isconstant(b,c,f1), -log(if(p==1,C_1,0)+1/(-1)^p*b*f1/((p-1)!+p!)*(c/f1+x)^(p+1))/b );
#dsolve(exp(b_*y_)*x_^n_, y_,x_,p_) := if(p+n<>0 and hasnot(b,x), -log(if(p==1,C_1,0)+1/(-1)^p*b/(n*(p-1)!+p!)*x^(n+p))/b );
#dsolve(exp(b_*y_)*(c_+x_)^n_, y_,x_,p_) := if(p+n<>0 and isconstant(b,c), -log(if(p==1,C_1,0)+1/(-1)^p*b/(n*(p-1)!+p!)*(c+x)^(n+p))/b );
#dsolve(exp(b_*y_)*(c_+f1_*x_)^n_, y_,x_,p_) := if(p+n<>0 and isconstant(b,c,f1), -log(if(p==1,C_1,0)+1/(-1)^p*b*f1^n/(n*(p-1)!+p!)*(c/f1+x)^(p+n))/b );
#dsolve(exp(y_)*x_, y_,x_,p_) := if(p<1,ln(p,C_1+x^(1+p)),-log(if(p==1,C_1,0)+1/(-1)^p/((p-1)!+p!)*x^(p+1)) );
#dsolve(exp(y_)*x_^n_, y_,x_,p_) := if(p+n<>0, -log(if(p==1,C_1,0)+1/(-1)^p/(n*(p-1)!+p!)*x^(n+p)) );
#dsolve(exp(y_)*(c_+x_), y_,x_,p_) := if(isconstant(c), -log(if(p==1,C_1,0)+1/(-1)^p/((p-1)!+p!)*(c+x)^(p+1)) );
#dsolve(exp(y_)*(c_+f1_*x_), y_,x_,p_) := if(isconstant(c,f1), -log(if(p==1,C_1,0)+1/(-1)^p*f1/((p-1)!+p!)*(c/f1+x)^(p+1)) );
#dsolve(exp(y_)*(c_+x_)^n_, y_,x_,p_) := if(p+n<>0 and isconstant(c), -log(if(p==1,C_1,0)+1/(-1)^p/(n*(p-1)!+p!)*(c+x)^(n+p)) );

#dsolve(exp(xx_+yy_)*z_, y_,x_,1) := if(hasnot(xx,z,y) and hasnot(yy,x), solve(int(exp(-yy),y)=int(exp(xx)*z,x)-C_1,y), 
	if(hasnot(xx,y) and hasnot(yy,z,x), solve(int(exp(-yy)/z,y)=int(exp(xx),x)-C_1,y) ));
dsolve(a_*exp(xx_+yy_), y_,x_,1) := if(hasnot(a,xx,x) and yy==y, dsolve(a*exp(y),y,x,1)-xx, 
	if(hasnot(a,xx,y) and hasnot(yy,x), solve(int(exp(-yy),y)=int(a*exp(xx),x)-C_1,y), 
	if(hasnot(xx,y) and hasnot(a,yy,x), solve(int(exp(-yy)/a,y)=int(exp(xx),x)-C_1,y) )));

dsolve(b_*y_^n_, y_,x_,q_) := If(isfree(b,y),If(isfree(b,x), 
	if(n==-1 and q==2, sqrt(-b)*exp(-inverseerf(sqrt(2)/sqrt(pi)*(C_1+x))^2) and -sqrt(-b)*exp(-inverseerf(sqrt(2)/sqrt(pi)*(C_1+x))^2),
	block(f1:=(1/b*fallingfactorial(q/(1-n),q))^(1/(n-1)),f2:=(if(n+q-1==0,0,C_1)+x)^(q/(1-n)),
	if(iseven(q), f1*(C_1-x)^(q/(1-n)) and f1*f2, 
	f1*f2 and if(isodd(n), -f1*f2 )))), 
	if(n==-1, block(f2:=d(b,x,q),if(f2<>0 and hasnot(f2,x), b/sqrt(f2) and -b/sqrt(f2) )),
	block(f2:=int(simplify(1/b),x,q),pp:=simplify(b^2*f2^n),if(pp==1,f2,if(pp==-1,-f2 ))) 
	)));
dsolve(b_*y_^2, y_,x_,2) := If(isfree(b,y) and isfree(b,x), 1/b*weierstrassP(C_1+x,0,C_2) );

#dsolve(b_*y_^n_, y_,x_,2) := If(isfree(b,y),If(isfree(b,x),((2n+2)/b)^(1/(n-1))/((n-1)*(C_1-x))^(2/(n-1)) and ((2n+2)/b)^(1/(n-1))/((n-1)*(C_1+x))^(2/(n-1)), 
	(n/fallingfactorial(-n,2)*int(b,x,2))^(1/(2-n)) ));
#dsolve(b_*(c_+y_)^n_, y_,x_,p_) := if(hasnot(b,y) and d(c,x,p)==0,  block(f1:=dsolve(b*y^n,y,x,p), 
	if(-left(f1)==right(f1), left(f1)-c and right(f1)-c,f1-c  )));
dsolve(b_*(c_+a_*y_)^n_, y_,x_,p_) := if(hasnot(b,y) and hasnot(a,x) and d(c,x,p)==0,  block(f1:=dsolve(b*a^n*y^n,y,x,p), 
	if(-left(f1)==right(f1), left(f1)-c/a and right(f1)-c/a,f1-c/a  )));
#dsolve(b_*(c_+y_)^n_, y_,x_,q_) := if(q>1 and isconstant(b,c),block(p:=(1/b*fallingfactorial(q/(1-n),q))^(1/(n-1)),f2:=(x)^(q/(1-n)),
	if(iseven(q),p*(C_1-x)^(q/(1-n))-c and p*f2-c,  p*f2-c and if(isodd(n),-p*f2-c ))));
#dsolve(b_/y_, y_,x_,p_) := if(hasnot(b,y), block(f2:=d(b,x,p),if(f2<>0 and hasnot(f2,x), b/sqrt(f2) and -b/sqrt(f2) )));
#dsolve(b_/y_, y_,x_,2) := if(hasnot(b,x), sqrt(-b)*exp(-inverseerf(sqrt(2)/sqrt(pi)*C_1+x)^2) and -sqrt(-b)*exp(-inverseerf(sqrt(2)/sqrt(pi)*C_1+x)^2) );
dsolve(b_/(c_+y_), y_,x_,p_) := if(hasnot(b,y) and d(c,x,p)==0,block(f2:=d(b,x,p),if(f2<>0 and hasnot(f2,x), b/sqrt(f2)-c and -b/sqrt(f2)-c,
	dsolve(b/y,y,x,p)-c )));
dsolve(b_/(c_+a_*y_), y_,x_,p_) := if(hasnot(b,y) and isconstant(a) and d(c,x,p)==0,block(f2:=d(b,x,p),if(f2<>0 and hasnot(f2,x), b/sqrt(a*f2)-c/a and -b/sqrt(a*f2)-c/a,
	dsolve(b/y,y,x,p)-c/a) ));
dsolve(b_*(c_+y_), y_,x_,p_) := if(hasnot(b,y) and d(c,x,p)==0,  block(f1:=dsolve(b*y,y,x,p), 
	if(-left(f1)==right(f1), left(f1)-c and right(f1)-c,f1-c  )));
dsolve(b*(c_+a_*y_), y_,x_,p_) := if(hasnot(b,y) and hasnot(a,x) and d(c,x,p)==0,  block(f1:=dsolve(b*y,y,x,p), 
	if(-left(f1)==right(f1), left(f1)/sqrt(a)-c/a and right(f1)/sqrt(a)-c/a,f1/sqrt(a)-c/a )));
dsolve(b_*y_, y_,x_,p_) := if(hasnot(b,y), gsolution(b,y,x,p) );

dsolve((c_+y_)*z_,y_,x_,q_) := if(isconstant(c) and hasnot(z,y), dsolve(y*z,y,x,q)-c);
dsolve((c_+b_*y_)*z_,y_,x_,q_) := if(hasnot(b,c,x) and hasnot(z,y), dsolve(y*z,y,x,q)-c/b);
dsolve((c_+y_)^n_*z_,y_,x_,q_) := if(isconstant(c) and hasnot(z,y), dsolve(y^n*z,y,x,q)-c);
dsolve((c_+b_*y_)^n_*z_,y_,x_,q_) := if(hasnot(b,c,x) and hasnot(z,y), dsolve(y^n*z,y,x,q)-c/b);

dsolve(exp(xx_)*y_^n_, y_,x_,q_) := if(q<>1 and hasnot(xx,y) and d(xx,x,2)==0, 
	block(f1:=(d(xx,x)/(1-n))^(q/(n-1))*exp(xx/(1-n)), f1 and if(isodd(n), -f1 )) );
dsolve(exp(b_*y_)*y_,y_,x_,p_):= if(isconstant(b), (-1/b)*inverseEi(p,C_1+x^p) );
dsolve(exp(y_+a_)*y_,y_,x_p_):= if(isconstant(a), -inverseEi(p,C_1+exp(a)*x^p) );
dsolve(exp(b_*y_+a_)*y_,y_,x_,1p_):= if(isconstant(a,b), (-1/b)*inverseEi(p,C_1+exp(a)*x^p) );
dsolve(exp(y_)*y_,y_,x_,p_):=  -inverseEi(p,C_1+x^p);

dsolve(log(y_)^p_*y_, y_,x_,p_) := if(p<1, exp(exp(C_1+x)) );
dsolve(b_*log(y_)^p_*y_, y_,x_,p_) := if(p<1 and hasnot(b,x), exp(exp(b^(1/p)*(C_1+x))) );
dsolve(log(y_)*y_,y_,x_,1):=  exp(exp(C_1+x));
dsolve(b_*log(y_)*y_,y_,x_,1):=  if(hasnot(b,x), exp(exp(b*(C_1+x))) );

dsolve(x_^m_*y_^n_, y_,x_,q_) := if(q<>1 and isconstant(m,n),block(p:=(fallingfactorial((m+q)/(1-n),q))^(1/(n-1))*x^((m+q)/(1-n)), p and if(isodd(n),-p )));
dsolve(x_*y_^n_, y_,x_,q_) := if(q<>1 and isconstant(n),block(p:=(fallingfactorial((1+q)/(1-n),q))^(1/(n-1))*x^((1+q)/(1-n)), p and if(isodd(n),-p )));
dsolve((b_+x_)^m_*y_^n_, y_,x_,q_) := if(q<>1 and isfree(b,x), block(p:=(fallingfactorial((m+q)/(1-n),q))^(1/(n-1))/((b+x)^((m+q)/(n-1))), p and if(isodd(n),-p )));
dsolve((b_+a_*x_)*y_^n_, y_,x_,q_) := if(q<>1 and isfree(a,b,x), block(f2:=(fallingfactorial((1+q)/(1-n),q)/a)^(1/(n-1))/((b/a+x)^((1+q)/(n-1))), f2 and if(isodd(n),-f2 )));
dsolve((b_+x_)*y_^n_, y_,x_,q_) := if(q<>1 and isfree(b,x), block(p:=(fallingfactorial((1+q)/(1-n),q))^(1/(n-1))/((b+x)^((1+q)/(n-1))), p and if(isodd(n),-p )));
dsolve((b_+c_*x_)*y_^n_, y_,x_,q_) := if(q<>1 and isfree(b,c,x), block(p:=(1/c*fallingfactorial((1+q)/(1-n),q))^(1/(n-1))/((b/c+x)^((1+q)/(n-1))), p and if(isodd(n),-p )));
dsolve(1/(b_+c_)*y_^n_,y_,x_,p_):= if(has(b+c,x) and has(b+c,y) and d(b+c,x,2)==0 and abs(p)<=1, x=dsolve(replace(b/y^n+c/y^n,x,zz),zz,y,p) );
dsolve(1/(b_+c_)*y_,y_,x_,p_):=  if(has(b+c,x) and has(b+c,y) and d(b+c,x,2)==0 and abs(p)<=1, x=dsolve(replace(b/y+c/y,x,zz),zz,y,p) );
dsolve(y_^n_/(b_+z_),y_,x_,q_) := if(has(b+z,x) and has(b+z,y) and d(b+z,x,2)==0 and abs(q)<=1, dsolve(expand(b/y^n+z/y^n),x,y,q) );
dsolve(y_/(b_+z_), y_,x_,q_)  := if(has(b+z,x) and has(b+z,y) and d(b+z,x,2)==0 and abs(q)<=1, x=replace(dsolve(replace(b/y+z/y,x,zz),zz,y,q),zz,x) );


dsolve(exp(g_*y_)*(c_+x_^2), y_,x_,2) := if(hasnot(c,f2,x), log(4/f2/(c-x^2)^2)/f2 );
dsolve(exp(g_*y_)*(b_*x_+x_^2), y_,x_,2) := if(hasnot(b,f2,x), log(4/f2/(b^2/2+b*x+x^2)^2)/f2 );
dsolve(exp(g_*y_)*(c_+b_*x_+x_^2), y_,x_,2) := if(hasnot(b,c,f2,x), log(4/f2/(b^2/2-c+b*x+x^2)^2)/f2 );
dsolve(exp(y_)*(c_+x_^2), y_,x_,2) := if(hasnot(c,x), log(4/(c-x^2)^2) );
dsolve(exp(y_)*(b_*x_+x_^2), y_,x_,2) := if(hasnot(b,x), log(4/(b^2/2+b*x+x^2)^2) );
dsolve(exp(y_)*(c_+b_*x_+x_^2), y_,x_,2) := if(hasnot(b,c,x), log(4/(b^2/2-c+b*x+x^2)^2) );

dsolve((c_+x_^2)*y_^4,y_,x_,2):= if(hasnot(c,x), 1.459839713295963/(x^2-7/3c)^(2/3) );
dsolve((c_+x_^2)*y_^3,y_,x_,2):= if(hasnot(c,x), 2.449489742783178/(x^2-3c) and (-2.449489742783178)/(x^2-3c) );
dsolve((c_+x_^2)*y_^2,y_,x_,2):= if(hasnot(c,x), 20/(x^2-5c)^2 );
dsolve((c_+x_^2)*y_^(0.5),y_,x_,2):= if(hasnot(c,x), 3.1887755102040814*10^(-4)*(x^2+7c)^4 );
dsolve((c_+x_^2)*y_^(1/3),y_,x_,2):= if(hasnot(c,x), 0.006085806194501846*(x^2+5c)^3 );
dsolve((c_+x_^2)*y_^(-1/3),y_,x_,2):= if(hasnot(c,x), 0.26084743001221455*(x^2+2c)^(3/2) );
dsolve((c_+x_^2)*y_^(-0.5),y_,x_,2):= if(hasnot(c,x), 0.3699318111495706*(x^2+5/3c)^(4/3) );
dsolve((c_+x_^2)*y_^(-2),y_,x_,2):= if(hasnot(c,x), 1.3103706971044482*(x^2+c/3)^(2/3) );
dsolve((c_+x_^2)*y_^(-4),y_,x_,2):= if(hasnot(c,x), (1.1671687416620735-0.8479977281759988*i)*(x^2-c/5)^(2/5) );

dsolve((x_^2+b_*x_)*y_^2,y_,x_,2):= if(hasnot(b,x), 20/(x^2+b*x+3/2b^2)^2 );
dsolve((x_^2+b_*x_)*y_^0.5,y_,x_,2):= if(hasnot(b,x), 3.1887755102040814*10^(-4)*(x^2+b*x-3/2b^2)^4 );
dsolve((b_*x_+x_^2)*y_^(-0.5),y_,x_,2):= if(hasnot(b,x), 0.3699318111495706*(x^2+b*x-b^2/6)^(4/3) );
dsolve((x_^2+b_*x_)*y_^(-2),y_,x_,2):= if(hasnot(b,x), 1.3103706971044482*(x^2+b*x+b^2/6)^(2/3) );

dsolve((x_^2+b_*x_+c_)*y_^2,y_,x_,2):= if(hasnot(b,c,x), 20/(x^2+b*x+3/2b^2-5c)^2 );
dsolve((x_^2+b_*x_+c_)*y_^0.5,y_,x_,2):= if(hasnot(b,c,x), 3.1887755102040814*10^(-4)*(x^2+b*x-3/2b^2+7c)^4 );
dsolve((c_+b_*x_+x_^2)*y_^(-0.5),y_,x_,2):= if(hasnot(b,c,x), 0.3699318111495706*(x^2+b*x-b^2/6+5/3c)^(4/3) );
dsolve((x_^2+b_*x_+c_)*y_^(-2),y_,x_,2):= if(hasnot(b,c,x), 1.3103706971044482*(x^2+b*x+b^2/6+c/3)^(2/3) );

dsolve(a_*sinh(y_), y_,x_,2) := if(isconstant(a), 2i*am(C_2*(C_1+x),-a/C_2^2) );
dsolve(a_*cosh(y_), y_,x_,2) := if(isconstant(a), 2i*am(C_2*(C_1+x),a*i/C_2^2)-i*pi/2 );
dsolve(a_*sin(y_), y_,x_,2) := if(isconstant(a), 2am(C_2*(C_1+x),-a/C_2^2) );
dsolve(a_*cos(y_), y_,x_,2) := if(isconstant(a), 2am(C_2*(C_1+x),a/C_2^2)+pi/2 );
dsolve(a_*exp(y_), y_,x_,2) := if(isconstant(a), log(-C_2^2/2/a+C_2^2/2/a*tanh(1/2*C_2*(C_1+x))^2) );
dsolve(x_*y_, y_,x_,2) := C_1*Ai(x)+C_2*Bi(x);


dsolve(m_/n_,y_,x_,1) :=if(has(n,x) and has(m,y), if(hasnot(m,x),dsolve(expand(replace(n,x,zz)/m),zz,y,1)=x, 
	block(f2:=d(m,y)+d(n,x), 
	if(f2==0,block(f1:=int(n,y),f3:=d(f1,x),f1-int(m+f3,x)=C_1),
	if(hasnot(simplify(-f2/n),y),block(f1:=exp(int(simplify(-f2/n),x)),p:=int(f1*n,y),g:=d(p,x),expand(p-int(f1*m+g,x))=-C_1),
	if(hasnot(simplify(-f2/m),x),block(f1:=exp(int(simplify(-f2/m),y)),p:=int(f1*n,y),g:=d(p,x),expand(p-int(f1*m+g,x))=-C_1) 
	)) ))));
dsolve(1/m_*n_,y_,x_,1) :=if(has(m,x) and has(n,y), if(hasnot(n,x), dsolve(expand(replace(m,x,zz)/n),zz,y,1)=x,
	block(f2:=d(n,y)+d(m,x), 
	if(f2==0,block(f1:=int(m,y),f3:=d(f1,x),f1-int(n+f3,x)=C_1), 
	if(hasnot(simplify(-f2/m),y),block(f1:=exp(int(simplify(-f2/m),x)),p:=int(f1*m,y),g:=d(p,x),expand(p-int(f1*n+g,x))=-C_1), 
	if(hasnot(simplify(-f2/n),x),block(f1:=exp(int(simplify(-f2/n),y)),p:=int(f1*m,y),g:=d(p,x),expand(p-int(f1*n+g,x))=-C_1) 
	)) ))));

dsolve(_f(exp(c_*y_)*x_^m_)/x_,y_,x_,1):= if(isconstant(c), int(1/(c*_f(z)*z+m*z),z,1,exp(c*y)*x^m)=C_1+log(x) );
dsolve(_f(exp(c_*y_)*x_)/x_,y_,x_,1):= if(isconstant(c), int(1/(c*_f(z)*z+z),z,1,exp(c*y)*x)=C_1+log(x) );
dsolve(_f(exp(y_)*x_^m_)/x_,y_,x_,1):= int(1/(_f(z)*z+m*z),z,1,exp(y)*x^m)=C_1+log(x);
dsolve(_f(exp(y_)*x_)/x_,y_,x_,1):= int(1/(_f(z)*z+z),z,1,exp(y)*x)=C_1+log(x);
dsolve(_f(exp(c_*x_)*y_^m_)*y_,y_,x_,1):= if(isconstant(c), int(1/(m*_f(z)*z+c*z),z,1,exp(c*x)*y^m)=C_1+x );
dsolve(_f(exp(c_*x_)*y_)*y_,y_,x_,1):= if(isconstant(c), int(1/(_f(z)*z+c*z),z,1,exp(c*x)*y)=C_1+x );
dsolve(_f(exp(x_)*y_^m_)*y_,y_,x_,1):= int(1/(m*_f(z)*z+z),z,1,exp(x)*y^m)=C_1+x;
dsolve(_f(exp(x_)*y_)*y_,y_,x_,1):= int(1/(_f(z)*z+z),z,1,exp(x)*y)=C_1+x;
dsolve(exp(b_*x_)*_f(exp(c_*x_)*y_),y_,x_,1):= if(b+c==0, int(1/(_f(z)+c*z),z,1,exp(c*x)*y)=C_1+x );
dsolve(exp(-x_)*_f(exp(x_)*y_),y_,x_,1):=int(1/(_f(z)+z),z,1,exp(x)*y)=C_1+x;
dsolve(exp(x_)*_f(exp(-x_)*y_),y_,x_,1):=int(1/(_f(z)-z),z,1,exp(-x)*y)=C_1+x;
dsolve(exp(c_*y_)*_f(exp(c_*y_)*x_),y_,x_,1):= if(isconstant(c), int(1/(c*_f(z)*z^2+z),z,1,exp(c*y)*x)=C_1+log(x) );
dsolve(exp(y_)*_f(exp(y_)*x_),y_,x_,1):=int(1/(_f(z)*z^2+z),z,1,exp(y)*x)=C_1+log(x);

dsolve((a_+y_)/(b_+y_),y_,x_,1):= if(isconstant(a,b), -a*W(-(exp(-x/(a-b) + C_1))/(a - b)) + b *W(-(exp(-x/(a-b) + C_1))/(a - b)) - a);
#dsolve(c_/(x_+y_), y_,x_,1) := if(isconstant(c), -c*W(exp(C_1-x/c)) - x - c);
dsolve(1/(x_+y_), y_,x_,1) :=  -W(exp(C_1-x)) - x-1;
dsolve(y_*(a_+b_*y_^n_),y_,x_,1):=If(isfree(a,b,y), exp(integrate(a,x))*(C_1-n*integrate(b*exp(n*integrate(a,x)),x))^(-1/n) );
dsolve(y_*(a_+y_^n_),y_,x_,1):=If(isfree(a,y), exp(integrate(a,x))*(C_1-n*integrate(exp(n*integrate(a,x)),x))^(-1/n) );
dsolve(y_*(a_+b_*y_),y_,x_,1):=If(isfree(a,b,y), exp(integrate(a,x))/(C_1-integrate(b*exp(integrate(a,x)),x)) );
dsolve(y_*(a_+y_),y_,x_,1):=If(isfree(a,y), exp(integrate(a,x))/(C_1-integrate(exp(integrate(a,x)),x)) );
#dsolve((c_+y_)^2,y_,x_,1):= block(f1:=d(c,x),if(f1==0,1/(C_1-x)-c,if(hasnot(f1,x), if(f1<0,sqrt(-f1)*tanh(C_1-sqrt(-f1)*x)-c, sqrt(f1)*tan(C_1+sqrt(f1)*x)-c))));
dsolve((a_*x_+b_*y_)/(c_*x_+d_*y_),y_,x_,1) := if(isconstant(a,b,c,d), if(b+c==0,block(p:=c*x+d*y^2/2,p-int(a*x+b*y+d(p,x),x)=C_1), 
	replace(int(expand((c+d*yx)/(a+(b-c)*yx-d*yx^2)),yx),yx,y/x)=C_1-log(x) ));
dsolve((a_*x_+b_*y_)/(b_*x_+a_*y_),y_,x_,1) := x;
dsolve((a_*x_+a_*y_)/(c_*x_+c_*y_),y_,x_,q_) := int(a/c,x,q)+C_1;
dsolve((x_+y_)/(x_-y_),y_,x_,1):= log(x^2+y^2)/2-atan(y/x)+C_1=0;
dsolve((c_-y_^n_)/(x_+y_),y_,x_,1):= -int(c,x)+x*y+y^(1+n)/(1+n)=C_1;
dsolve((c_-y_^n_)/(b_+x_+y_),y_,x_,1):= -int(c,x)+x*y+y^(1+n)/(1+n)+b*y=C_1;
dsolve((f_*y_-y_^n_)/(a_*x_+y_),y_,x_,1):= if(f+a-1==0, a*x*y+y^(1+n)/(1+n)=C_1 );
dsolve((f_*y_-y_^n_)/(b_+a_*x_+y_),y_,x_,1):= if(f+a-1==0, a*x*y+y^(1+n)/(1+n)+b*y=C_1 );
dsolve((c_+f_*y_-y_^n_)/(a_*x_+y_),y_,x_,1):= if(f+a-1==0, -int(c,x)+a*x*y+y^(1+n)/(1+n)=C_1 );
dsolve((c_+f_*y_-y_^n_)/(b_+a_*x_+y_),y_,x_,1):= if(f+a-1==0, -int(c,x)+a*x*y+y^(1+n)/(1+n)+b*y=C_1 );
dsolve((a_*x_+b_*x_*y_)/(x_+d_*x_*y_),y_,x_,1) := if(isconstant(a,b,d), int((a+b*y)/(1+d*y),y)=C_1+x );
dsolve((x_+b_*x_*y_)/(c_*x_+d_*x_*y_),y_,x_,1) := if(isconstant(b,c,d), int((1+b*y)/(c+d*y),y)=C_1+x );
dsolve((a_*x_+b_*x_*y_)/(c_*x_+d_*x_*y_),y_,x_,1) := if(isconstant(a,b,c,d), int((a+b*y)/(c+d*y),y)=C_1+x );
dsolve((a_*y_+b_*x_*y_)/(x_+d_*x_*y_),y_,x_,1) := if(isconstant(a,b,d), log(y)+d*y=a*log(x)+b*C_1+x );
dsolve((y_+b_*x_*y_)/(c_*x_+d_*x_*y_),y_,x_,1) := if(isconstant(b,c,d), c*log(y)+d*y=log(x)+b*C_1+x );
dsolve((a_*y_+b_*x_*y_)/(c_*x_+d_*x_*y_),y_,x_,1) := if(isconstant(a,b,c,d), c*log(y)+d*y=a*log(x)+b*C_1+x );
dsolve(x_/y_, y_,x_,1) := sqrt(C_1+x^2) and -sqrt(C_1+x^2);

dsolve(b_*y(p_,x_),y_,x_,q_):= if(hasnot(b,y), gsolution(b,p,0,y,x,q) );
dsolve(exp(x_)*y(p_,x_)^n_,y_,x_,q_) := block(f1:=(1-n)^((q-n*p)/(1-n))*exp(x/(1-n)),f1+gsolution(0,y,x,p) and if(isodd(n),-f1+gsolution(0,y,x,p)) );
#dsolve(exp(b_*y_+c_)/y(p_,x_),y_,x_,q_) := if(hasnot(b,x) and d(c,x,p)==0, block(f1:=(-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!/b^2, log(f1/(C_1+x)^(p+q))/b-c/b and if(iseven(p+q), log(f1/(C_1-x)^(p+q))/b-c/b )));
#dsolve(exp(y_+c_)/y(p_,x_),y_,x_,q_) := if(d(c,x,p)==0, block(f1:=(-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!, log(f1/(C_1+x)^(p+q))-c and if(iseven(p+q), log(f1/(C_1-x)^(p+q))-c )));
#dsolve(exp(b_*y_)/y(p_,x_),y_,x_,q_) := if(hasnot(b,x), block(f1:=(-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!/b^2, log(f1/(C_1+x)^(p+q))/b and if(iseven(p+q), log(f1/(C_1-x)^(p+q))/b )));
dsolve(exp(y_)/y(p_,x_),y_,x_,q_) := block(f1:=(-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!, log(f1/(C_1+x)^(p+q)) and if(iseven(p+q), log(f1/(C_1-x)^(p+q)) ));

dsolve((c_+y_)/y(p_,x_),y_,x_,q_) := if(d(c,x,p)==0, block(f1:=1/(fallingfactorial(p+q,p)*fallingfactorial(p+q,q)), f1*(C_1+x)^(p+q)-c and if(iseven(p+q), f1*(C_1-x)^(p+q)-c)) );
dsolve((c_+y_)^m_/y(p_,x_),y_,x_,q_) := if(d(c,x,p)==0,if(m==2,exp(C_1+x)-c, (fallingfactorial((p+q)/(2-m),p)*fallingfactorial((p+q)/(2-m),q))^(1/(m-2))*(C_1+x)^((p+q)/(2-m))-c ));
dsolve((c_+y_)^m_*y(p_,x_),y_,x_,q_):=if(d(c,x,p)==0, dsolve(y^m*y(p,x),y,x,q)-c );
dsolve((c_+y_)*y(p_,x_),y_,x_,q_):=if(d(c,x,p)==0, dsolve(y*y(p,x),y,x,q)-c );
dsolve(y_^m_*y(p_,x_)^n_,y_,x_,q_) := if(m+n-1==0,exp(C_1+x), (fallingfactorial((n*p-q)/(n+m-1),p)^(-n)*fallingfactorial((n*p-q)/(n+m-1),q))^(1/(n+m-1))*(C_1+x)^((n*p-q)/(n+m-1)) );
dsolve(y_*y(p_,x_)^n_,y_,x_,q_) := (fallingfactorial((n*p-q)/(n),p)^(-n)*fallingfactorial((n*p-q)/(n),q))^(1/(n))*(C_1+x)^((n*p-q)/(n) );
dsolve(y_/y(p_,x_),y_,x_,q_) := block(f1:=1/(fallingfactorial(p+q,p)*fallingfactorial(p+q,q)), f1*(C_1+x)^(p+q) and if(iseven(p+q), f1*(C_1-x)^(p+q) ));

dsolve(y_*y(2,x_),y_,x_,3):= -C_2*log(cos(C_2*(C_1+x))) and -C_2*log(cosh(C_2*(C_1+x)));
dsolve(y_*y(1,x_),y_,x_,3):= 2^(2/3)* 3^(1/3)* weierstrassP((x + C_1)/(2^(2/3)* 3^(1/3)),-2* 2^(2/3)* 3^(1/3)* C_1, C_2);

dsolve(exp(y_)*y(1,x_)^2,y_,x_,2) := log(-inverseEi(C_2*(C_1+x)));
dsolve(exp(y_)*y(1,x_),y_,x_,2) := log(C_2/(1-exp(C_1+C_2*x)));
dsolve(log(y_)*y(1,x_),y_,x_,2) := exp(1+exp(C_1+x));
dsolve(1/y_/y(1,x_),y_,x_,2):= -cbrt(3)*exp((-inversegamma(2/3,x)));
dsolve(1/y_*y(1,x_)^2,y_,x_,2):=exp(C_1+C_2*x);
dsolve(y_*y(1,x_)^2,y_,x_,2):= sqrt(2)*inverseerf(C_2*(C_1+x));
dsolve(y_^n_*y(1,x_),y_,x_,2):=n^(-1/n)*(-1-n)^(1/n)*(C_1+x)^(-1/n);
dsolve(1/y_*y(1,x_),y_,x_,2):= inverseli(C_2*(C_1+x))/C_2;
dsolve(y_*y(1,x_),y_,x_,2):= 2C_2*tan(C_2*(C_1+x)) and -2C_2*tanh(C_2*(C_1+x));

dsolve(y(n_,x_)^a_*y(p_,x_)^b_,y_,x_,q_) := if(a+b-1==0, C_2*exp(C_1*x),int(dsolve(y^a*y(p-n,x)^b,y,x,q-n),x,n)+gsolution(0,y,x,n) );
dsolve(y(n_,x_)*y(p_,x_),y_,x_,q_) := int(dsolve(y*y(p-n,x),y,x,q-n),x,n)+gsolution(0,y,x,n);


#3x;
dsolve(a_/(b_+c_)*y_^n_,y_,x_,p_):= if(d(b+c,x,p)==a, C_1*x^p+p!*b/a*C_1, if(isconstant(a) and has(b+c,x) and has(b+c,y) and d(b+c,x,2)==0 and abs(p)<=1, x=dsolve(replace(b/a/y^n+c/a/y^n,x,zz),zz,y,p) ));
dsolve(a_/(b_+c_)*y_,y_,x_,p_):= if(d(b+c,x,p)==a, C_1*x^p+p!*b/a*C_1, if(isconstant(a) and has(b+c,x) and has(b+c,y) and d(b+c,x,2)==0 and abs(p)<=1, x=dsolve(replace(b/a/y+c/a/y,x,zz),zz,y,p) ));
dsolve(b_*x_*y_^n_, y_,x_,q_) := if(q<>1 and isconstant(b), block(f2:=(1/b*fallingfactorial((1+q)/(1-n),q))^(1/(n-1))/(x^((1+q)/(n-1))), f2 and if(isodd(n),-f2 )));
dsolve(b_*x_^m_*y_^n_, y_,x_,q_) := if(q<>1 and isconstant(b), block(f2:=(1/b*fallingfactorial((m+q)/(1-n),q))^(1/(n-1))/(x^((m+q)/(n-1))), f2 and if(isodd(n),-f2 )));
#dsolve(b_*x_^m_*y_^n_, y_,x_,q_) := if(q<>1 and isconstant(b), block(f2:=(1/b*fallingfactorial((m+q)/(1-n),q))^(1/(n-1))*(x)^((m+q)/(1-n)), f2 and if(isodd(n),-f2 )) );
dsolve(b_*(c_+x_)^m_*y_^n_, y_,x_,q_) := if(q<>1 and isconstant(b,c), block(f2:=(1/b*fallingfactorial((m+q)/(1-n),q))^(1/(n-1))/(C_1+(c+x)^((m+q)/(n-1))), f2 and if(isodd(n),-f2 )) );

dsolve(a_*exp(y_)*z_, y_,x_,p_) := if(hasnot(a,x) and hasnot(z,y) and p<>1, ln(p,gsolution(0,y,x,p)+a*p!*int(z,x,p)) );
dsolve(a_*exp(b_*y_)*z_, y_,x_,p_) := if(hasnot(a,b,x) and hasnot(z,y), dsolve(exp(b*y)*z,y,x,p)-log(a)/b );
dsolve(a_*exp(c_+y_)*z_, y_,x_,p_) := if(hasnot(a,x) and hasnot(z,y) and d(c,x,p)==0, ln(p,gsolution(0,y,x,p)+a*p!*int(z,x,p))-c );
dsolve(a_*exp(c_+b_*y_)*z_, y_,x_,p_) := if(hasnot(a,x) and hasnot(z,y) and d(c,x,p)==0, dsolve(exp(b*y)*z,y,x,p)-c/b-log(a)/b );
dsolve(a_*exp(c_+x_)*z_, y_,x_,p_) :=  if(hasnot(a,c,z,x), replace(dsolve(a*exp(x)*z,y,x,p),x,x+c) );
dsolve(a_*exp(xx_)*y_^n_, y_,x_,q_) := if(q<>1 and hasnot(a,x) and hasnot(xx,y) and d(xx,x,2)==0, 
	block(f1:=a^(1/(1-n))*(d(xx,x)/(1-n))^(q/(n-1))*exp(xx/(1-n)), f1 and if(isodd(n), -f1 )));

#dsolve(a_*exp(y_)*x_, y_,x_,p_) := if(p<>-1 and isconstant(a), -log((-1)^(-p)*a/((p-1)!+p!)*x^(p+1)) );
#dsolve(a_*exp(y_)*x_^n_, y_,x_,p_) := if(p<>-n and isconstant(a), -log((-1)^(-p)*a/(n*(p-1)!+p!)*x^(n+p)) );
#dsolve(b_*exp(c_*y_), y_,x_,n_) := if(n>0 and isconstant(b,c), log((-1)^(n)/b/c*n!/(C_1+x)^n)/c and if(iseven(n),log((-1)^(n)*n!/b/c/(C_1-x)^n)/c ));
#dsolve(b_*exp(c_+y_), y_,x_,n_) := if(n>0 and hasnot(b,x) and d(c,x,n)==0, log((-1)^(n)*n!/b/(C_1+x)^n)-c,if(n==1 and d(c,x,2)==0, -log(C_1-b*exp(c)/d(c,x)) ));
#dsolve(b_*exp(c_+f1_*y_), y_,x_,n_) := if(n>0 and isconstant(b,f1) and d(c,x,n)==0, log((-1)^(n)*n!/b/f1/(C_1+x)^n)/f1-c/f1 );
#dsolve(a_*exp(b_*y_)*x_^n_, y_,x_,p_) := if(p<>-n and hasnot(a,b,x), -log((-1)^(-p)*a*b/(n*(p-1)!+p!)*x^(n+p))/b );
#dsolve(a_*exp(b_*y_)*(c_+x_)^n_, y_,x_,p_) := if(p<>-n and hasnot(a,b,c,x), -log((-1)^(-p)*a*b/(n*(p-1)!+p!)*(c+x)^(n+p))/b );
#dsolve(a_*exp(y_)*(c_+x_), y_,x_,p_) := if(p<>-1 and hasnot(a,c,x), -log((-1)^(-p)*a/((p-1)!+p!)*(c+x)^(p+1)) );
#dsolve(a_*exp(b_*y_)*x_, y_,x_,p_) := if(p<>-1 and hasnot(a,b,x), -log((-1)^(-p)*a*b/((p-1)!+p!)*x^(1+p))/b );
#dsolve(a_*exp(b_*y_)*(c_+x_), y_,x_,p_) := if(p<>-1 and hasnot(a,b,c,x), -log((-1)^(-p)*a*b/((p-1)!+p!)*(c+x)^(1+p))/b );

dsolve(c_*exp(b_*y_)*y_,y_,x_,p_):= if(isconstant(b,c), (-1/b)*inverseEi(p,C_1+c*x^p) );
dsolve(c_*exp(y_+a_)*y_,y_,x_p_):= if(isconstant(a,c), -inverseEi(p,C_1+c*exp(a)*x^p) );
dsolve(c_*exp(b_*y_+a_)*y_,y_,x_,1p_):= if(isconstant(a,b,c), (-1/b)*inverseEi(p,C_1+c*exp(a)*x^p) );
dsolve(c_*exp(y_)*y_,y_,x_,p_):=  if(isconstant(c), -inverseEi(p,C_1+c*x^p) );


dsolve(c_*_f(b_*y_)*g_,y_,x_,1):= if(hasnot(b,x) and hasnot(c,g,y), int(1/(b*_f(z)),z,1,b*y)=C_1+int(c*g,x) );
dsolve(c_*_f(a_+y_)*g_,y_,x_,1):= if(hasnot(c,g,y), int(1/(d(a,x)+_f(z)),z,1,a+y)=C_1+int(c*g,x) );
dsolve(c_*_f(a_+b_*y_)*g_,y_,x_,1):= if(hasnot(b,x) and hasnot(c,g,y), int(1/(d(a,x)+b*_f(z)),z,1,a+b*y)=C_1+int(c*g,x) );
dsolve(a_*exp(xx_+y_)*z_, y_,x_,1) := if(hasnot(a,xx,z,y) and hasnot(xx,x), solve(int(exp(-y),y)=int(a*exp(xx)*z,x)-C_1,y), 
	if(hasnot(xx,y) and hasnot(a,xx,z,x), solve(int(exp(-y)/a/z,y)=int(exp(xx),x)-C_1,y) ));

dsolve(y_/x_*_f(x_^n_*y_^m_),y_,x_,1):=int(1/(m*z*_f(z)+n*z),z,1,x^n*y^m)=C_1+log(x);
dsolve(y_/x_*_f(x_^n_*y_),y_,x_,1):=int(1/(z*_f(z)+n*z),z,1,x^n*y)=C_1+log(x);
dsolve(y_/x_*_f(x_*y_^m_),y_,x_,1):=int(1/(m*z*_f(z)+z),z,1,x*y^m)=C_1+log(x);
dsolve(y_/x_*_f(x_*y_),y_,x_,1):=int(1/(z*_f(z)+z),z,1,x*y)=C_1+log(x);


dsolve(b_*exp(y_+c_)/y(p_,x_),y_,x_,q_) := if(hasnot(b,x) and d(c,x,p)==0, log((-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!/b/(C_1+x)^(p+q))-c and if(iseven(p+q), log((-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!/b/(C_1-x)^(p+q))-c ));
dsolve(b_*exp(y_)/y(p_,x_),y_,x_,q_) := if(hasnot(b,x), log((-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!/b/(C_1+x)^(p+q)) and if(iseven(p+q), log((-1)^(p+q)*(p+q)^2*(p-1)!*(q-1)!/b/(C_1-x)^(p+q)) ));
dsolve(b_*y_/y(p_,x_),y_,x_,q_) := if(hasnot(b,x), block(f1:=b/(fallingfactorial(p+q,p)*fallingfactorial(p+q,q)), f1*(C_1+x)^(p+q) and if(iseven(p+q), f1*(C_1-x)^(p+q) )));
dsolve(b_*y_^m_*y(p_,x_)^n_,y_,x_,q_) := if(m+n-1==0,exp(C_1+cbrt(b)*x), (b*fallingfactorial((n*p-q)/(n+m-1),p)^(-n)*fallingfactorial((n*p-q)/(n+m-1),q))^(1/(n+m-1))*(C_1+x)^((n*p-q)/(n+m-1)) );

dsolve(b_/y_*y(1,x_)^2,y_,x_,2) := if(hasnot(b,x), (C_2 + C_1 *x)^(1/(1 - b)) );
dsolve(b_*y_*y(1,x_)^2,y_,x_,2):= if(hasnot(b,x), (2/b)^0.5* inverseerf(C_1+x) );
dsolve(b_/y_/y(1,x_),y_,x_,2):= if(hasnot(b,x), -cbrt(3b)*exp((-inversegamma(2/3,x))) );
dsolve(b_/y_*y(1,x_),y_,x_,2):= if(hasnot(b,x), b/C_2*inverseli(C_2*(C_1+x)) );
dsolve(b_*y_*y(1,x_),y_,x_,2):= if(hasnot(b,x), 2/b*C_2*tan(C_2*(C_1+x)) and -2/b*C_2*tanh(C_2*(C_1+x)) );
dsolve(b_*log(y_)*y(1,x_),y_,x_,2) := if(isconstant(b), exp(1+exp(C_1+b*x)) );
dsolve(b_*exp(y_)*y(1,x_),y_,x_,2) := if(isconstant(b), log(C_2/(b-exp(C_2*(C_1+x)))) );

dsolve(-x_^n_*y_^m_/y(p_,x_),y_,x_,q_) := if(m<>2,-(fallingfactorial((n+p+q)/(2-m),p)*fallingfactorial((n+p+q)/(2-m),q))^(1/(m-2))*x^((n+p+q)/(2-m)) );
dsolve(-x_^n_*y_/y(p_,x_),y_,x_,q_) := -1/(fallingfactorial(n+p+q,p)*fallingfactorial(n+p+q,q))*x^(n+p+q);
dsolve(-x_*y_^m_/y(p_,x_),y_,x_,q_) := if(m<>2,(-fallingfactorial((1+p+q)/(2-m),p)*fallingfactorial((1+p+q)/(2-m),q))^(1/(m-2))*x^((1+p+q)/(2-m)) );
dsolve(-x_*y_/y(p_,x_),y_,x_,q_) := -1/(fallingfactorial(1+p+q,p)*fallingfactorial(1+p+q,q))*x^(1+p+q);
dsolve(x_^n_*y_^m_/y(p_,x_),y_,x_,q_) := if(m<>2,(fallingfactorial((n+p+q)/(2-m),p)*fallingfactorial((n+p+q)/(2-m),q))^(1/(m-2))*x^((n+p+q)/(2-m)) );
dsolve(x_^n_*y_/y(p_,x_),y_,x_,q_) := 1/(fallingfactorial(n+p+q,p)*fallingfactorial(n+p+q,q))*x^(n+p+q);
dsolve(x_*y_^m_/y(p_,x_),y_,x_,q_) := if(m<>2,(fallingfactorial((1+p+q)/(2-m),p)*fallingfactorial((1+p+q)/(2-m),q))^(1/(m-2))*x^((1+p+q)/(2-m)) );
dsolve(x_*y_/y(p_,x_),y_,x_,q_) := 1/(fallingfactorial(1+p+q,p)*fallingfactorial(1+p+q,q))*x^(1+p+q);
dsolve(exp(x_)/y_/y(p_,x_),y_,x_,q_)  := 3exp(x/3);
dsolve(exp(-x_)/y_/y(p_,x_),y_,x_,q_) := -3exp(-x/3);

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(a_*y(n_,x_)*y(p_,x_),y_,x_,q_) := if(hasnot(a,y), int(dsolve(a*y*y(p-n,x),y,x,q-n),x,n)+gsolution(0,y,x,n), gsolution(0,y,x,p) );
dsolve(c_*y(n_,x_)*y(p_,x_)^b_,y_,x_,q_) := int(dsolve(c*y*y(p-n,x)^b,y,x,q-n),x,n);
dsolve(c_*y(n_,x_)^a_*y(p_,x_)^b_,y_,x_,q_) := int(dsolve(c*y^a*y(p-n,x)^b,y,x,q-n),x,n);

dsolve(exp(x_)/y(m_,x_)/y(n_,x_),y_,x_,q_) := cbrt(C_1+3^(m+n+q)*exp(x))+gsolution(0,y,x,m);
dsolve(exp(-x_)/y(m_,x_)/y(n_,x_),y_,x_,q_):= cbrt(C_1+3^(m+n+q)*exp(-x))+gsolution(0,y,x,m);
dsolve(exp(x_)*y(n_,x_)*y(p_,x_),y_,x_,q_) :=  (-1)^(q-p-n)*exp(-x)+gsolution(0,y,x,n);

#dsolve(exp(x_)/y(p_,x_)*y(n_,x_),y_,x_,q_) :=  exp(x)+gsolution(0,y,x,min(p,n));
#dsolve(exp(x_)/y(m_,x_)*y(n_,x_),y_,x_,q_) :=  exp(x)+gsolution(0,y,x,min(m,n));

dsolve(1/y_*y(n_,x_)*y(p_,x_),y_,x_,q_) := exp(C_1+C_2*x) and gsolution(0,y,x,p);


#4x;
dsolve(a_*exp(x_)*y_/y(p_,x_),y_,x_,q_) := if(isconstant(a), a*exp(x) );
dsolve(a_*exp(x_)/y_/y(p_,x_),y_,x_,q_) := if(isconstant(a), 3cbrt(a)*exp(x/3) );
dsolve(a_*exp(x_)*y(n_,x_)*y(p_,x_),y_,x_,q_) := if(isconstant(a), (-1)^(q-p-n)/a*exp(-x)+gsolution(0,y,x,n) );
dsolve(a_*exp(x_)/y(m_,x_)/y(n_,x_),y_,x_,q_) := if(isconstant(a), cbrt(C_1+3^(m+n+q)*a*exp(x))+gsolution(0,y,x,m) );


#2+;	
dsolve(b_*_f(c_+y_)*g_+h_,y_,x_,1):= if(d(c,x)+h==0, int(1/_f(z),z,1,c+y)=C_1+int(b*g,x) );
dsolve(b_*_f(c_+y_)+h_,y_,x_,1):= if(d(c,x)+h==0, int(1/_f(z),z,1,c+y)=C_1+int(b,x) );
dsolve(a_+b_*_f(c_+y_)*g_,y_,x_,1):= if(d(c,x)+a==0, int(1/_f(z),z,1,c+y)=C_1+int(b*g,x) );
dsolve(a_+_f(c_+y_)*g_,y_,x_,1):= if(d(c,x)+a==0, int(1/_f(z),z,1,c+y)=C_1+int(g,x) );
dsolve(a_+b_*_f(c_+y_),y_,x_,1):= if(hasnot(b,x),int(1/(d(c,x)+a+b*_f(z)),z,1,c+y)=C_1+x,int(1/(d(c,x)+a+_f(z)),z,1,c+y)=C_1+int(b,x) );
dsolve(a_+_f(c_+y_),y_,x_,1):= if(hasnot(d(c,x)+a,x), int(1/(d(c,x)+a+_f(z)),z,1,c+y)=C_1+x );
dsolve(_f(c_+y_)*g_+h_,y_,x_,1):= if(d(c,x)+h==0, int(1/_f(z),z,1,c+y)=C_1+int(g,x) );
dsolve(_f(c_+y_)+h_,y_,x_,1):= if(hasnot(d(c,x)+h,x), int(1/(d(c,x)+h+_f(z)),z,1,c+y)=C_1+x );
dsolve(_f(exp(y_)*x_)*g_-1/x_,y_,x_,1):= int(1/(z*_f(z)),z,1,exp(y)*x)=C_1+int(g,x);
dsolve(_f(exp(y_)*x_^n_)*g_-n_/x_,y_,x_,1):= int(1/(z*_f(z)),z,1,exp(y)*x^n)=C_1+int(g,x);
dsolve(a_*_f(exp(y_)*x_)-1/x_,y_,x_,1):= int(1/(z*_f(z)),z,1,exp(y)*x)=C_1+int(a,x);
dsolve(a_*_f(exp(y_)*x_^n_)-n_/x_,y_,x_,1):= int(1/(z*_f(z)),z,1,exp(y)*x^n)=C_1+int(a,x);
dsolve(_f(exp(y_)*x_)-1/x_,y_,x_,1):= int(1/(z*_f(z)),z,1,exp(y)*x)=C_1+x;
dsolve(_f(exp(y_)*x_^n_)-n_/x_,y_,x_,1):= int(1/(z*_f(z)),z,1,exp(y)*x^n)=C_1+x;
dsolve(_f(y(1,x_))/x_+b_*y_/x_,y_,x_,1):= (x=C_1*t^(1/(b - 1)) - t^(1/(b - 1))* int(t^(-b/(b - 1))* d(_f(t),t),t)/(b - 1), y=(t* x - _f(t))/b);
dsolve(_f(y(1,x_))/x_+y_/x_,y_,x_,1):=C_1*x-_f(C_1);

dsolve(a_+y_, y_,x_,q_) := if(hasnot(a,y), gsolution(1,y,x,q)+If(q>0 and isfree(a,x),-a,psolution(1,a,y,x,q)) );
dsolve(a_+b_*y_, y_,x_,q_) := if(hasnot(a,y), gsolution(b,y,x,q)+psolution(b,a,y,x,q));
#dsolve(a_+y_^2, y_,x_,p_) := if(a>0 and p<>2, tan(p,sqrt(a)*x^p+C_1)*sqrt(a), if(a<0 and p<>2, -tanh(p,sqrt(-a)*x^p+C_1)*sqrt(-a) ));
dsolve(a_*x_^p_+y_^2,y_,x_,p_):= if(isconstant(a), cbrt(a)*AiPrime(p,-cbrt(a)*x^p)/Ai(p,-cbrt(a)*x^p) );
dsolve(a_*c_+c_*y_^2, y_,x_,p_) := if(isconstant(a), if(a<0,-tanh(p,sqrt(-a)*p!*int(c,x,p)+gsolution(0,y,x,p))*sqrt(-a), tan(p,sqrt(a)*p!*int(c,x,p)+gsolution(0,y,x,p))*sqrt(a) ));
dsolve(a_*c_+b_*c_*y_^2, y_,x_,p_) := if(hasnot(a,b,x), if(a*b<0,sgn(a)*tanh(p,(-a/b)*p!*int(c,x,p)+gsolution(0,y,x,p))*sqrt(-a/b), sgn(a)*tan(p,(a/b)*p!*int(c,x,p)+gsolution(0,y,x,p))*sqrt(a/b) ));
dsolve(a_*y_+y_^n_,y_,x_,p_):= if(p<=1, block(f2:=p!*integrate(a,x,p), (C_1+(1-n)*integrate(E(p,(n-1)*C_2+(n-1)*f2),x,p))^(1/(1-n))*E(p,C_2+f2)) );
dsolve(a_*y_+b_*y_^n_,y_,x_,p_):= if(p<=1, block(f2:=p!*integrate(a,x,p),(C_1+(1-n)*integrate(b*E(p,(n-1)*C_2+(n-1)*f2),x,p))^(1/(1-n))*E(p,C_2+f2)) );
dsolve(y_+b_*y_^n_,y_,x_,p_) := if(p<=1, -E(p,C_2+x^p)*(C_1+(n-1)*integrate(b*E(p,(n-1)*C_2+(n-1)*x^p),x,p))^(1/(1-n)) );
dsolve(y_+y_^n_,y_,x_,p_) := if(p<=1, -E(p,C_2+x^p)*(C_1+E(p,(n-1)*C_2+(n-1)*x^p))^(1/(1-n)) );
dsolve(x_^p_+y_^2,y_,x_,p_):= AiPrime(p,-x^p)/Ai(p,-x^p);

dsolve(a_+y_, y_,x_,2) := if(isfree(a,y),if(isfree(a,x), exp(C_1+x)+C_2*exp(-x)-a, exp(C_1+x)+C_2*exp(-x)+psolution(1,a,y,x,2) ));
dsolve(a_+y_^2,y_,x_,2):= if(hasnot(a,y), weierstrassP(C_1+x,-2a,C_2) );
dsolve(a_+c_*y_^2,y_,x_,2):= if(hasnot(a,y) and d(c,x)==0, weierstrassP(C_1+x,-2a*c,C_2)/c );
dsolve(a_*x_+b_*y_^0.5, y_,x_,p_):= if(hasnot(a,b,x) and p>2 and sgn(a*b)+1==0, (a/b)^2*x^2 );
dsolve(b_*x_+c_*y_^0.5, y_,x_,2) :=if(isconstant(b,c),if(b+c==0,(x+2/c)^2,(b/c)^2*(sgn(-b*c)*x+sgn(-b*c)*(-2b/c^2))^2 ));
dsolve(b_*x_+y_^0.5, y_,x_,2) :=if(hasnot(b,x),b^2*(sgn(-b)*x+2abs(b))^2 );
dsolve(x_+b_*y_^0.5,y_,x_,2):= if(hasnot(b,x), 1/b^2*(x-2/b^2)^2 );
dsolve(x_-y_^0.5,y_,x_,2):= (x-2)^2;
dsolve(x_+y_^0.5,y_,x_,2):= (-x+2)^2;
dsolve(x_+b_*y_, y_,x_,2) := if(isfree(b,x), gsolution(b,y,x,2)-x/b, gsolution(b,y,x,2)+psolution(b,x,y,x,2) );
dsolve(x_+y_, y_,x_,2) := exp(C_1+x)+C_2*exp(-x)-x;
dsolve(y_^3+b_*y_, y_,x_,2) := if(b<0,sqrt(-2b)*sec(Csqrt(-b)*(C_1+x)),sqrt(2b)*csch(sqrt(b)*(C_1+x)) );
dsolve(a_*y_^3+y_, y_,x_,2) := sqrt(2/a)*csch(C_1+x);
dsolve(a_*y_^3+b_*y_, y_,x_,2) := if(b<0,sqrt(-2b/a)*sec(sqrt(-b)*(C_1+x)),sqrt(2b/a)*csch(sqrt(b)*(C_1+x)) );
dsolve(-y_+y_^3, y_,x_,2) := sqrt(2)*sec(C_1+x);
dsolve(y_-y_^3, y_,x_,2) := sqrt(2)*sech(C_1+x);
dsolve(y_+y_^3, y_,x_,2) := sqrt(2)*csch(C_1+x);
dsolve(y_+y_^2, y_,x_,2) := weierstrassP(C_1+x,1/2,C_2)-1/2;
dsolve(b_*y_+y_^2, y_,x_,2) := weierstrassP(C_1+x,b^2/2,C_2)-b/2;
dsolve(y_+c_*y_^2, y_,x_,2) := if(d(c,x)==0, weierstrassP(C_1+x,1/2,C_2)/c-1/c/2 );
dsolve(b_*y_+c_*y_^2, y_,x_,2) := if(d(c,x)==0, weierstrassP(C_1+x,b^2/2,C_2)/c-b/c/2 );

dsolve(a_+y_^0.5,y_,x_,1):= if(isconstant(a),a^2 *(W(exp(C_1-x/(2a))) + 1)^2);
dsolve(a_+b_*y_^0.5,y_,x_,1):= if(hasnot(a,b,x),(-a/b*(W(exp(C_1-x*b^2/(2a)))+1))^2);
dsolve(a_*x_+y_^0.5,y_,x_,1):= if(isconstant(a),(sqrt(8a+1)+4a+1)/8*x^2);
dsolve(a_*x_+b_*y_^0.5,y_,x_,1):= if(hasnot(a,b,x),if(b>0,(sqrt(8a*b^2+b^4)+4a+b^2)/8*x^2,
	(-sqrt(8a*b^2+b^4)+4a+b^2)/8*x^2 ));

dsolve(a_+x_/y_,y_,x_,1):=if(has(x/y),replace(int(1/(zz-1/zz-replace(a,x/y,zz)),zz),zz,y/x)-log(x)=C_1 );
dsolve(x_+b_/y_, y_,x_,1) := if(hasnot(b,x),(cbrt(2)* x *Ai((x^2 - 2 y)/(2 *cbrt(2) *b^(2/3))) - 2 cbrt(b)* AiPrime((x^2 - 2 y)/(2 *cbrt(2)* b^(2/3))))/(cbrt(2) *x *Bi((x^2 - 2y )/(2 *cbrt(2) *b^(2/3))) - 2 cbrt(b) *BiPrime((x^2 - 2 *y)/(2 *cbrt(2) *b^(2/3)))) + C_1 = 0);
dsolve(b_+b_/y_, y_,x_,1) := -W(exp(C_1-int(b,x))) - 1;
dsolve(a_+1/y_, y_,x_,1) := if(isconstant(a),(-W(-exp(-(x + C_1)* a^2 - 1)) - 1)/a );
dsolve(x_+1/y_, y_,x_,1) :=  C_1 + ( cbrt(2)* x* Ai(1/2/cbrt(2)* (x^2 - 2 y)) + 2 AiPrime(1/2/cbrt(2) *(x^2 - 2 y)))/( cbrt(2)* x *Bi(1/2/cbrt(2) *(x^2 - 2 y)) + 2 BiPrime(1/2/cbrt(2)* (x^2 - 2 y))) = 0;
dsolve(1+x_/y_, y_,x_,1) := ((5 + sqrt(5))* log(-2 y/x + sqrt(5) + 1) - (sqrt(5) - 5) *log(2 y/x + sqrt(5) - 1)) = C_1 -10 log(x);

dsolve(a_+y_^2, y_,x_,1) := if(a>0, tan(sqrt(a)*C_1+x)*sqrt(a), if(a<0, -tanh(sqrt(-a)*C_1+x)*sqrt(-a), 
	if(hasnot(a,y),block(u:=gsolution(-a,y,x,2), -d(u,x)/u) )));
dsolve(a_+c_*y_^2, y_,x_,1) := if(hasnot(a,c,x), if(sgn(a*c)<0,tanh(sgn(a)*sqrt(-a*c)*C_1+x)*sqrt(-a/c),tan(sgn(a)*sqrt(a*c)*C_1+x)*sqrt(a/c)), 
	if(hasnot(a,y),block(u:=gsolution(d(c,x)/c,-a*c,y,x,2), -d(u,x)/u/c) ));
dsolve(c_+(x_+y_)^2, y_,x_,1) := if(isconstant(c), 1/(exp(C_1+2 sqrt(-c - 1)* x) + 1/(2 sqrt(-c - 1))) - sqrt(-c - 1) - x );
dsolve(c_+x_*y_^2, y_,x_,1) := if(isconstant(c), -Ai(-cbrt(c)*x)/AiPrime(-cbrt(c)*x)*abs(c)^(2/3) and -Bi(-cbrt(c)*x)/BiPrime(-cbrt(c)*x)*abs(c)^(2/3) );
dsolve(c_+b_*x_*y_^2, y_,x_,1) := if(isconstant(b,c), -Ai(-cbrt(b*c)*x)/AiPrime(-cbrt(b*c)*x)*abs(b*c)^(2/3)/b and -Bi(-cbrt(b*c)*x)/BiPrime(-cbrt(b*c)*x)*abs(b*c)^(2/3)/b );
dsolve(a_+a_*y_^2, y_,x_,1) := tan(int(a,x)+C_1);
#dsolve(a_+(-1)*a_*y_^2, y_,x_,1) := tanh(int(a,x)+C_1);
dsolve(x_^n_+y_^2, y_,x_,1) := if(n==-2, (-1 + i *sqrt(3)* (-1 + (2 C_1)/(C_1 + x^(i* sqrt(3)))))/(2 x),
	besselJ((-n-1)/(n+2),2/(n+2)*x^(n/2+1))/besselJ(1/(n+2),2/(n+2)*x^(n/2+1))*x^(n/2) and -besselJ((n+1)/(n+2),2/(n+2)*x^(n/2+1))/besselJ(-1/(n+2),2/(n+2)*x^(n/2+1))*x^(n/2) );
dsolve(x_^n_+b_*y_^2, y_,x_,1) := if(hasnot(b,x),if(n==-2,(sqrt(1 - 4 b) *((2 C_1)/(x^sqrt(1 - 4 b) + C_1) - 1) - 1)/(2 b* x),
	-sqrt(b)*besselJ((-n-1)/(n+2),2/(n+2)*sqrt(b)*x^(n/2+1))/besselJ(1/(n+2),2/(n+2)*sqrt(b)*x^(n/2+1))*x^(n/2) ));
dsolve(c_*x_^n_+y_^2, y_,x_,1) := if(isconstant(c),if(n==-2,(sqrt(1 - 4c) *((2 C_1)/(x^sqrt(1 - 4c) + C_1) - 1) - 1)/(2x),
	-sqrt(c)*besselJ((-n-1)/(n+2),2/(n+2)*sqrt(c)*x^(n/2+1))/besselJ(1/(n+2),2/(n+2)*sqrt(c)*x^(n/2+1))*x^(n/2) ));
dsolve(c_*x_^n_+b_*y_^2, y_,x_,1) := if(hasnot(b,c,x),if(n==-2,(sqrt(1 - 4 b *c) *((2 C_1)/(x^sqrt(1 - 4 b* c) + C_1) - 1) - 1)/(2 b* x),
	-sqrt(b*c)*besselJ((-n-1)/(n+2),2/(n+2)*sqrt(b*c)*x^(n/2+1))/besselJ(1/(n+2),2/(n+2)*sqrt(b*c)*x^(n/2+1))*x^(n/2) ));
dsolve(b_*x_^n_+a_*y_^3,y_,x_,1):=if(n+3/2==0 and hasnot(a,b,x), 2int(1/(2b+z+2a*z^3),z,1,sqrt(x)*y)=C+log(x) );
dsolve(x_^2+y_^2, y_,x_,1) := (x^2 *(-C_1* besselJ(-5/4,x^2/2) + C_1*besselJ(3/4,x^2/2) - 2 besselJ(-3/4,x^2/2)) - C_1*besselJ(-1/4,x^2/2))/(2 x *(C_1*besselJ(-1/4,x^2/2) + besselJ(1/4,x^2/2)));
dsolve(b_*x_+y_^2, y_,x_,1) := if(hasnot(b,x), cbrt(b)* AiPrime(cbrt(-b)*x)/Ai(cbrt(-b)*x) and  cbrt(b)*(AiPrime(cbrt(-b)*x)+C_1*BiPrime(cbrt(-b)*x))/(Ai(cbrt(-b)*x)+C_1*Bi(cbrt(-b)*x)) );
dsolve(x_+y_^2, y_,x_,1) := (AiPrime(-x)+C_1*BiPrime(-x))/(Ai(-x)+C_1*Bi(-x));
dsolve(1+y_^2, y_,x_,1) := tan(C_1+x);
dsolve(a_*x_*y_^3 + b_*y_^2,y_,x_,1):=( (-log((a* x* y* (a* x* y + b) + a)/(a^2 *x^2 *y^2))/2 - (atan((2 a* x *y + b)/(sqrt(4 a-b^2))))/sqrt((4 a)/b^2 - 1))) = log(x) + C_1;
#dsolve(a_*y_^3 + b_*x_*y_^2,y_,x_,1):=(cbrt(2)*  b^(2/3)* x *Ai((cbrt(b)  *(b* y* x^2 + 2))/(2 cbrt(2)*  a^(2/3)* y)) + 2 cbrt(a) * AiPrime((cbrt(b)*  (b* y* x^2 + 2))/(2 cbrt(2)*  a^(2/3)* y)))/(cbrt(2)*  b^(2/3)* x* Bi((cbrt(b)*  (b* y* x^2 + 2))/(2 cbrt(2)*  a^(2/3)* y)) + 2 cbrt(a) * BiPrime((cbrt(b)*  (b* y* x^2 + 2))/(2 cbrt(2)*  a^(2/3)* y))) + C_1 = 0;
dsolve(x_*y_^2+y_^3,y_,x_,1):=C_1 + (cbrt(2) *x *Ai((1/cbrt(2)* (x^2/2 + 1/y))) + 2 AiPrime((1/cbrt(2) *(x^2/2 + 1/y))))/(cbrt(2) *x *Bi((1/cbrt(2)* (x^2/2+1/y))) + 2 BiPrime((1/cbrt(2)* (x^2/2+1/y)))) = 0;

dsolve(a_+b_*y_,y_,x_,1):=If(isfree(a,b,y), If(isfree(a,b,x), exp(C_1+b*x)-a/b,	exp(C_1+integrate(b,x))+psolution(b,a,y,x,1) ));
#dsolve(a_+y_/x_,y_,x_,1):=replace(int(1/replace(a,y/x,zz),zz),zz,y/x)-log(x)=C_1;
dsolve(a_/x_+y_/x_,y_,x_,1):= if(isconstant(a),C_1*x-a, if(isfunction(a) and has(argument(a,1),y(1,x)),C_1*x-replace(a,y(1,x),C_1),if(hasnot(a,y), C_1*x+int(a/x^2,x)*x )));
dsolve(a_*b_/x_+y_/x_,y_,x_,1):= if(hasnot(a,b,x),C_1*x+a*b, if(isfunction(b) and has(argument(b,1),y(1,x)),C_1*x-a*replace(b,y(1,x),C_1),if(hasnot(a,b,y), C_1*x-int(a*b/x^2,x)*x )));

dsolve(1+(x_-y_)^n_, y_,x_,1) := -((1-n)*(C_1 - x))^(1/(1-n)) + x;
dsolve(-1+(x_+y_)^n_, y_,x_,1) := ((n-1)*(C_1 - x))^(1/(1-n)) - x;
dsolve(b_+b_*y_^n_,y_,x_,1):=if(hasnot(b,y),int(1/(1+y^n),y)=C_1+int(b,x) );
dsolve(1+y_^n_,y_,x_,1):=int(1/(1+y^n),y)=C_1+x;
dsolve(y_+y_^n_,y_,x_,1):= exp(x)*(C_1+(1-n)*integrate(exp((n-1)*x),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(y_+b_*y_^n_,y_,x_,1):=If(isfree(b,y), exp(x)*(C_1+(1-n)*integrate(b*exp((n-1)*x),x))^(1/(1-n)) );
dsolve(a_*y_+b_*y_^n_,y_,x_,1):=If(isfree(a,b,y), exp(integrate(a,x))*(C_1+(1-n)*integrate(b*exp((n-1)*integrate(a,x)),x))^(1/(1-n)) );

#dsolve(exp(y_+xx_)+z_, y_,x_,p_) := if(hasnot(z,y), int(z,x)-log(C_1-int(exp(int(z,x,p)+xx),x)) );
#dsolve(b_*exp(y_)+h_, y_,x_,p_) := if(hasnot(h,y), -log(dsolve(-1-h*y,y,x,1)) );
#dsolve(b_*exp(x_)+a_*exp(-x_)*y_^2,y_,x_,q_):= if(hasnot(a,b,x) and q<=1,(-2 atan(1-q,(-2 a *exp(-x)*y + 1)/sqrt(4 a *b - 1)))/sqrt(4 a *b - 1)=C_1+x^q );
#dsolve(b_*exp(x_)+exp(-x_)*y_^2,y_,x_,q_):= if(hasnot(b,x) and q<=1,(-2 atan(1-q,(-2exp(-x)*y + 1)/sqrt(4b - 1)))/sqrt(4b - 1)=C_1+x^q );
dsolve(a_+exp(y_),y_,x_,1):= if(hasnot(a,x), -log((-1/a)+exp(C_1-a*x)), -log(dsolve(-1-a*y,y,x,1)) );
dsolve(exp(y_)+h_,y_,x_,1):= if(hasnot(h,y), -log(dsolve(-1-h*y,y,x,1)) );
dsolve(b_*exp(-x_)+a_*exp(x_)*y_^2,y_,x_,1):= if(hasnot(a,b,x),(2 atan((2 a *exp(x)*y + 1)/sqrt(4 a *b - 1)))/sqrt(4 a *b - 1)=C_1+x );
dsolve(b_*exp(-x_)+exp(x_)*y_^2,y_,x_,1):= if(hasnot(b,x),(2 atan((2exp(x)*y + 1)/sqrt(4b - 1)))/sqrt(4b - 1)=C_1+x );
#dsolve(a_*exp(x_)+exp(x_+c_*y_),y_,x_,1):= if(hasnot(a,c,x), (-1/a)*1/c*log(a+exp(c*y))+1/a*y=exp(x)+C_1 );
dsolve(b_*exp(y_)+g_,y_,x_,1):=if(hasnot(g,y), -log(dsolve(-b-g*y,y,x,1)) );
dsolve(exp(y_)*f1_+f2_,y_,x_,1):=if(hasnot(f2,y), -log(dsolve(-f1-f2*y,y,x,1)) );
dsolve(a_+exp(y_)*f1_,y_,x_,1):= -log(dsolve(-f1-a*y,y,x,1));
dsolve(a_+b_*exp(y_),y_,x_,1):=if(hasnot(a,b,x), -log((-1/a)*b+exp(C_1-a*x)),	-log(dsolve(-b-a*y,y,x,1)) );
dsolve(a_+b_*exp(y_)*f_,y_,x_,1):= -log(dsolve(-b*f-a*y,y,x,1));
dsolve(b_*exp(y_)*f_+g_,y_,x_,1):= -log(dsolve(-b*f-g*y,y,x,1));
dsolve(b_*exp(x_*y_)/x_-y_/x_,y_,x_,1):= if(isconstant(b), -log(C_1-b*x)/x );
dsolve(a_+exp(y_/x_),y_,x_,1):=if(isconstant(a),int(1/(exp(z)-z+a),z,1,y/x)=C_1+log(x) );
dsolve(a_+exp(x_/y_),y_,x_,1):=if(isconstant(a),int(1/(exp(1/z)-z+a),z,1,y/x)=C_1+log(x) );
dsolve(a_+b_*exp(y_/x_),y_,x_,1):=if(hasnot(a,b,x),int(1/(b*exp(z)-z+a),z,1,y/x)=C_1+log(x) and (-a-W(-b*exp(-a)))*x );
dsolve(a_+b_*exp(x_/y_),y_,x_,1):=if(hasnot(a,b,x),int(1/(b*exp(1/z)-z+a),z,1,y/x)=C_1+log(x) );
dsolve(exp(x_)+exp(-x_)*y_^2,y_,x_,q_):= if(q<=1, -1.1547005383792515*atan(1-q,0.5773502691896257*(1-2*exp(-x)*y))=C_1+x^q);
dsolve(exp(-x_)+exp(x_)*y_^2,y_,x_,1):= 1.1547005383792515*atan(0.5773502691896257*(1+2*exp(x)*y))=C_1+x;
dsolve(exp(x_)+y_^2,y_,x_,1):= (C_1* sqrt(exp(x))*besselJ(1,2 sqrt(exp(x))) + 2 sqrt(exp(x))* besselY(1,2 sqrt(exp(x))))/(C_1*besselJ(0,2 sqrt(exp(x))) + 2besselY(0,2 sqrt(exp(x))));
dsolve(exp(x_)+exp(y_),y_,x_,1):= exp(x)-log(C_1-Ei(exp(x)));

dsolve(a_*log(y_)*y_+b_*x_*y_,y_,x_,1):= if(isconstant(a,b), exp(exp(C_1 + a *x)/a^2 - (a* b* x + b)/a^2) );
dsolve(a_*log(y_)*y_+x_*y_,y_,x_,1):= if(isconstant(a), exp(1/a^2*(-1-a*C_1+x*exp(a*x))) );
dsolve(log(y_)*y_+b_*x_*y_,y_,x_,1):= if(isconstant(b), exp(exp(C_1+x)-b-b*x) );
dsolve(log(y_)*y_+b_*x_^2*y_,y_,x_,1):= if(isconstant(b), exp(exp(C_1+x)-b*(2+2x+x^2)) );
dsolve(log(y_)*y_+x_*y_,y_,x_,1):= exp(-1-C_1+x*exp(x));
dsolve(log(y_)-log(x_),y_,x_,1):= -W(-1)*x;
dsolve(-log(y_)+log(x_),y_,x_,1):= W(1)*x;
dsolve(a_*log(y_)+b_*log(x_),y_,x_,1):= if(a+b==0, b*W(1/b)*x );

#dsolve(2cos(x_)^(-2)*sin(x_)-sin(x_)*y_^2,y_,x_,1):=sec(x)-3sec(x)/(C_1*sec(x)^3+1);
dsolve(2cosh(y_)+x_,y_,x_,1):= -log(-x);
dsolve(2sinh(y_)+x_,y_,x_,1):= -log(x);
dsolve(2cosh(y_)-x_,y_,x_,1):=log(x);
dsolve(2sinh(y_)-x_,y_,x_,1):= -log(-x);
dsolve(-2cosh(y_)-x_,y_,x_,1):=log(-x);
dsolve(-2sinh(y_)-x_,y_,x_,1):= -log(x);

#dsolve(b_/x_*y(1,x_)+y(1,x_),y_,x_,2):= if(hasnot(b,x), C_1*Gamma(1+b,-x)+C_2);
#dsolve(a_*y(1,x_)+b_/x_*y(1,x_),y_,x_,2):= if(hasnot(a,b,x), C_1*(-a)^(-1-b)*Gamma(1+b,-a*x)+C_2);
#dsolve(y_*y(1,x_)+x_, y_,x_,p_):= (-1)^(p+1)*(2*(p-1))!/(p-1)!/(C_1+x)^(p-1)-i*x and (-1)^(p+1)*(2*(p-1))!/(p-1)!/(C_1+x)^(p-1)+i*x;
#dsolve(y_*y(1,x_)+c_*x_, y_,x_,p_):= if(c<0,-sqrt(-c)*x and sqrt(-c)*x,  2C_1*tan(C_1*x+C_2)-sqrt(-c)*x  and -2C_2/(C_2*(C_1+x))  +sqrt(-c)*x );
#dsolve(y_*y(1,x_)+c_*x_, y_,x_,p_):= if(c<0,-sqrt(-c)*x and sqrt(-c)*x-2/x,  -2C_2/(C_2*(C_1+x))-sqrt(-c)*x  and -2C_2/(C_2*(C_1+x))  +sqrt(-c)*x );
#dsolve(b_*y_*y(1,x_)+x_, y_,x_,p_):= if(b<0,-sqrt(-1/b)*x and sqrt(-1/b)*x-2/b/x,  -2/b*C_2/(C_2*(C_1+x))-sqrt(-1/b)*x  and -2/b*C_2/(C_2*(C_1+x)) +sqrt(-1/b)*x );
#dsolve(b_*y_*y(1,x_)+c_*x_, y_,x_,p_):= if(isconstant(b,c),if(sgn(b)==sgn(c), (-1)^(p-1)*(2*(p-1))!/(p-1)!*(C_2/(C_2*(C_1+x)))^(p-1)/(b)-sqrt(-c/b)*x  and (-1)^(p-1)*(2*(p-1))!/(p-1)!*(C_2/(C_2*(C_1+x)))^(p-1)/(b)+sqrt(-c/b)*x, 
	-sqrt(-c/b)*x and sqrt(-c/b)*x-(-1)^p*(2*(p-1))!/(p-1)!/b/x^(p-1) ));

dsolve(y(p_,x_)^n_+c_,y_,x_,q_):= if(hasnot(c,y),int(dsolve(y^n+c,y,x,q-p),x,p)+gsolution(0,y,x,p) );
dsolve(b_*y(p_,x_)^n_+c_,y_,x_,q_):= if(isfree(b,c,y),if(isfree(b,x),int(dsolve(b*y^n+c,y,x,q-p),x,p)+gsolution(0,y,x,p) )); 
dsolve(y(p_,x_)+c_,y_,x_,q_):= if(hasnot(c,y), int(dsolve(y+c,y,x,q-p),x,p)+gsolution(0,y,x,p));
dsolve(b_*y(p_,x_)+c_,y_,x_,q_):=  if(hasnot(b,c,y), int(dsolve(b*y+c,y,x,q-p),x,p)+gsolution(0,y,x,p) );
dsolve(b_*y(1,x_)+c_,y_,x_,q_):=if(isfree(b,c,y),if(isfree(b,c,x), C_1+C_2*exp(b*x)-c*x/b, gsolution(b,1,0,y,x,q)+psolution(b,1,0,c,y,x,q)),
	if(hasnot(b,x) and hasnot(c,y),  dsolve(int(b,y)+int(c,x),y,x,q-1) ));
dsolve(a_*y(n_,x_)*y(p_,x_)+c_,y_,x_,q_) := if(hasnot(a,c,y), block(f2:=int(dsolve(a*y*y(p-n,x)+c,y,x,q-n),x,n),if(hasnot(f2,y) and hasnot(f2,C_1), gsolution(0,y,x,n)+f2) ));
dsolve(y(1,x_)+c_,y_,x_,q_):=if(isfree(c,y),if(isfree(c,x), C_1+C_2*exp(x)-c*x, C_1+C_2*exp(x)+psolution(1,1,0,c,y,x,q) ));
dsolve(1/x_*y(p_,x_)+c_,y_,x_,q_):= if(hasnot(c,y) and q-p==1, int(int(c/x,x)*x,x,p)+C_1*x^q+C_2 );
dsolve(y(n_,x_)*y(p_,x_)+c_,y_,x_,q_) := if(hasnot(c,y), block(f2:=int(dsolve(y*y(p-n,x)+c,y,x,q-n),x,n),if(hasnot(f2,y) and hasnot(f2,C_1), gsolution(0,y,x,n)+f2) ));

dsolve(b_*y_*y(1,x_)+c_, y_,x_,2):= if(hasnot(c,y), dsolve(b/2*y^2+int(c,x)+C_2,y,x,1) );
#dsolve(y_*y(1,x_)+c_, y_,x_,2):= if(hasnot(c,y), dsolve(1/2y^2+int(c,x)+C_2,y,x,1) );
dsolve(y_*y(1,x_)+c_, y_,x_,2):= if(hasnot(c,y), block(u:=gsolution(-int(c,x)/2+C_2,y,x,2), -2d(u,x)/u) );

dsolve(-y(1,x_)^2+c_*exp(-y_)*f1_, y_,x_,2):= log(int(c*f1,x,2));
dsolve(-y(1,x_)^2+c_*exp(-y_), y_,x_,2):= log(int(c,x,2));
dsolve(-y(1,x_)^2+c_*exp(a_-y_), y_,x_,2):= log(int(c*exp(a),x,2));
dsolve(-y(1,x_)^2*1/y_+c_/y_, y_,x_,2):= sqrt(2int(c,x,2)+C_2*(C_1+x)) and -sqrt(2int(c,x,2)+C_2*(C_1+x));
dsolve(y(1,x_)^2+c_*exp(y_)*f1_, y_,x_,2):= -log(-int(c*f1,x,2));
dsolve(y(1,x_)^2+c_*exp(y_), y_,x_,2):= -log(-int(c,x,2));
dsolve(y(1,x_)^2+c_*exp(a_+y_), y_,x_,2):= -log(-lint(c*exp(a),x,2));
dsolve(y(1,x_)^2+y_,y_,x_,2):= sqrt(2)*int(1/(C_2*exp(2y)-2y-1),y)=C_1+x and -sqrt(2)*int(1/(C_2*exp(2y)-2y-1),y)=C_1+x;
dsolve(y(1,x_)^2*1/y_+c_/y_, y_,x_,2):= if(c>0, sqrt(c)*cosh(C_2*(C_1+x))/C_2 and -sqrt(c)*cosh(C_2*(C_1+x))/C_2, if(c<0, sqrt(-c)*sinh(C_2*(C_1+x))/C_2 and sqrt(-c)*sin(C_2*(C_1+x))/C_2 and sqrt(-c)*cos(C_2*(C_1+x))/C_2 ));
dsolve(y(1,x_)^2*1/y_+exp(x_)/y_, y_,x_,2):= exp(x/2)*cosh(C_2*C_1+x)/C_2 and -exp(x/2)*cosh(C_2*C_1+x)/C_2;
dsolve(y(1,x_)^2*1/y_+exp(a_*x_)/y_, y_,x_,2):= if(hasnot(a,x),-exp(a*x/2)*cosh(C_2*C_1+x)/C_2 and exp(a*x/2)*cosh(C_2*C_1+x)/C_2);
dsolve(0.5y(1,x_)^2*1/y_+c_/y_, y_,x_,2):= dsolve(d(c,x)/y,y,x,3);
dsolve(y(1,x_)^2*1/y_+1/y_, y_,x_,2):= cosh(C_2*(C_1+x))/C_2 and -cosh(C_2*(C_1+x))/C_2;

dsolve(exp(y(1,x_))+c_*y_,y_,x_,1):= if(isconstant(c), int(1/(c*y-W(-exp(c*y))),y)=C_1+x);
dsolve(b_*exp(y(1,x_))+y_,y_,x_,1):= if(isconstant(b), int(1/(y-W(-b*exp(y))),y)=C_1+x);
dsolve(b_*exp(y(1,x_))+c_*y_,y_,x_,1):= if(isconstant(b,c), int(1/(c*y-W(-b*exp(c*y))),y)=C_1+x);

dsolve(g_*y(p_,x_)+c_*g_, y_,x_,q_):= if(isinteger(p) and d(c,x,q-p)==0,C_1-int(c,x,p) );
dsolve(a_*g_*y(p_,x_)+c_*g_, y_,x_,q_):= if(isconstant(a) and isinteger(p) and d(c,x,q-p)==0,C_1-int(c/a,x,p) );
#dsolve(b_*x_*y(p_,x_)+a_*x_, y_,x_,q_) := If(isfree(a,b,x) and isfree(a,b,y), C_1*int(mittag(q-p,b*x^(1+q-p)/(1+q-p)!)-a/b,x,p));
dsolve(b_*y_*y(1,x_)+x_, y_,x_,p_):= if(hasnot(b,x), if(p==2,sqrt(-1/b)*x and sqrt(-1/b)*x-2/b/x,  -sqrt(-1/b)*x and sqrt(-1/b)*x  ));
dsolve(b_*y_*y(1,x_)+c_*x_, y_,x_,p_):= if(isconstant(b,c), if(p==2,sqrt(-c/b)*x and sqrt(-c/b)*x-2/b/x,  -sqrt(-c/b)*x and sqrt(-c/b)*x ));

dsolve(y(p_,x_)+y_, y_,x_,q_) := gsolution(1,p,1,y,x,q);
dsolve(y(p_,x_)+c_*y_, y_,x_,q_) := if(p<0,gsolution(c,-p,b,y,x,q-p), gsolution(1,p,c,y,x,q) );
dsolve(b_*y(p_,x_)+y_, y_,x_,q_) := if(p<0,gsolution(1,-p,b,y,x,q-p), 	if(hasnot(b,y),gsolution(b,p,1,y,x,q) ));
dsolve(b_*y(p_,x_)+c_*y_, y_,x_,q_) := if(p<0,gsolution(c,-p,b,y,x,q-p), if(hasnot(b,y),gsolution(b,p,c,y,x,q) ));

#dsolve(y_*y(m_,x_)+c_, y_,x_,p_):= block(f1:=d(c,x,m),if(f1<>0 and isconstant(f1), c/sqrt(-f1) and -c/sqrt(-f1) ) );
dsolve(y_*y(1,x_)+c_*x_, y_,x_,p_):= if(isconstant(c), if(p==2,sqrt(-c)*x and sqrt(-c)*x-2/x, sqrt(-c)*x and -sqrt(-c)*x ));
dsolve(y_*y(1,x_)+x_, y_,x_,p_):= if(p==2, i*x and i*x-2/x, i*x and -i*x);

dsolve(y_*y(1,x_)+x_, y_,x_,2):=i*x and -i*x and i*x-2/x;
dsolve(b_*y(1,x_)+y_,y_,x_,2):= if(hasnot(b,y),gsolution(b,1,1,y,x,2) );
dsolve(b_*y(1,x_)+c_*y_,y_,x_,2):= if(hasnot(b,y),gsolution(b,1,c,y,x,2) );
dsolve(y(1,x_)*y_+y_,y_,x_,2):= -int(1/(W(exp(C_1-y^2/2))+1),y)=C_2+x;
dsolve(y(1,x_)+y_,y_,x_,2):= exp((1-sqrt(5))/2*(C_1+x))+C_2*exp((1+sqrt(5))/2*x);

dsolve(y(m_,x_)+y(n_,x_),y_,x_,p_):= gsolution(1,n,1,m,0,y,x,p);
dsolve(y(m_,x_)+c_*y(n_,x_),y_,x_,p_):= if(hasnot(c,y),gsolution(c,n,1,m,0,y,x,p) );
dsolve(b_*y(m_,x_)+y(n_,x_),y_,x_,p_):= if(hasnot(b,y),gsolution(1,n,b,m,0,y,x,p) );
dsolve(b_*y(m_,x_)+c_*y(n_,x_),y_,x_,p_):= if(hasnot(b,c,y),gsolution(c,n,b,m,0,y,x,p) );

dsolve(a_*y_*y(p_,x_)+b_*y(m_,x_)^2,y_,x_,q_):= if(a+b==0, exp(C_1+x)+1/a );
dsolve(a_*y_*y(m_,x_)+b_*y(p_,x_)^2,y_,x_,q_):= if(a+b==0, exp(C_1+x)+1/a );
dsolve(a_*y_*y(m_,x_)+b_*y(n_,x_)*y(p_,x_),y_,x_,q_):= if(a+b==0, exp(C_1+x)+1/a );
dsolve(-y_*y(p_,x_)+y(m_,x_)^2,y_,x_,q_):=exp(C_1+x)-1;
dsolve(-y_*y(m_,x_)+y(p_,x_)^2,y_,x_,q_):=exp(C_1+x)-1;
dsolve(-y_*y(m_,x_)+y(n_,x_)*y(p_,x_),y_,x_,q_):=exp(C_1+x)-1;
dsolve(y_*y(p_,x_)-y(m_,x_)^2,y_,x_,q_):=exp(C_1+x)+1;
dsolve(y_*y(m_,x_)-y(p_,x_)^2,y_,x_,q_):=exp(C_1+x)+1;
dsolve(y_*y(m_,x_)-y(n_,x_)*y(p_,x_),y_,x_,q_):=exp(C_1+x)+1;


#3+;
dsolve(a_+b_*_f(c_+y_)*g_+h_,y_,x_,1):= if(d(c,x)+a+h==0, int(1/_f(z),z,1,c+y)=C_1+int(b*g,x) );
dsolve(a_+b_*_f(c_+y_)+h_,y_,x_,1):= if(hasnot(b,x),int(1/(d(c,x)+a+b*_f(z)),z,1,c+y)=C_1+x,int(1/(d(c,x)+a+_f(z)),z,1,c+y)=C_1+int(b,x) );
dsolve(a_+_f(c_+y_)*g_+h_,y_,x_,1):= if(d(c,x)+a+h==0, int(1/_f(z),z,1,c+y)=C_1+int(g,x) );
dsolve(a_+_f(c_+y_)+h_,y_,x_,1):= if(hasnot(d(c,x)+a+h,x), int(1/(d(c,x)+a+h+_f(z)),z,1,c+y)=C_1+x );

dsolve(b_+a_*x_+c_*y_^n_,y_,x_,p_):= if(hasnot(a,b,c,x),replace(dsolve(a*x+c*y^n,y,x,p),x,x+b/a) );
dsolve(b_+a_*x_+y_^n_,y_,x_,p_):= if(hasnot(a,b,x),replace(dsolve(a*x+y^n,y,x,p),x,x+b/a) );
dsolve(b_+x_+y_^n_,y_,x_,p_):= if(hasnot(b,x),replace(dsolve(x+y^n,y,x,p),x,x+b) );
dsolve(b_+x_^p_+y_^2,y_,x_,p_):= if(hasnot(b,x), AiPrime(p,-b-x^p)/Ai(p,-b-x^p) );
dsolve(b_+a_*x_^p_+y_^2,y_,x_,p_):= if(hasnot(a,b,x), cbrt(a)*AiPrime(p,-b-cbrt(a)*x^p)/Ai(p,-b-cbrt(a)*x^p) );

dsolve(a_+b_*y_+y_^2, y_,x_,p_) := if(b*b==4a, dsolve((y+b/2)^2,y,x,p) );
dsolve(a_+y_+c_*y_^2, y_,x_,p_) := if(4a*c-1==0, dsolve(c*(y+1/2/c)^2,y,x,p) );
dsolve(a_+b_*y_+c_*y_^2, y_,x_,p_) := if(b*b==4a*c, dsolve(c*(y+b/2/c)^2,y,x,p), 
	if(p==1 and hasnot(a,y), block(u:=gsolution(b+d(c,x)/c,-a*c,y,x,2), -d(u,x)/u/c) ));


dsolve(a_+b_*x_+c_*y_^0.5, y_,x_,2) :=if(hasnot(a,b,c,x),if(b+c==0,(x+(2-a)/c)^2,(b/c)^2*(sgn(-b*c)*x+sgn(-b*c)*(-2b/c^2+a/b))^2 ));
dsolve(a_+b_*x_+y_^0.5, y_,x_,2) :=if(hasnot(a,b,x),b^2*(sgn(-b)*x+sgn(-b)*(-2b+a/b))^2 );
dsolve(a_+x_-y_^0.5, y_,x_,2) :=if(isconstant(a),(x+2+a)^2 );
dsolve(a_+x_+y_^0.5, y_,x_,2) :=if(isconstant(a),(-x+2-a)^2 );
dsolve(a_+y_+y_^2, y_,x_,2) := weierstrassP(C_1+x,1/2-2a,C_2)-1/2;
dsolve(a_+b_*y_+y_^2, y_,x_,2) := if(b*b-4a==0, 6/(C_1+x)^2-b/2 and 6/(C_1-x)^2-b/2, 
	if(d(b,x,2)==0, weierstrassP(C_1+x,b^2/2-2a,C_2)-b/2 ));
dsolve(a_+y_+c_*y_^2, y_,x_,2) := if(4a*c-1==0, 6/c/(C_1+x)^2-1/c/2 and 6/c/(C_1-x)^2-1/c/2, 
	if(isconstant(c), weierstrassP(C_1+x,1/2-2a*c,C_2)/c-1/c/2 ));
dsolve(a_+b_*y_+c_*y_^2, y_,x_,2) := if(b*b-4a*c==0, 6/c/(C_1+x)^2-b/c/2 and 6/c/(C_1-x)^2-b/c/2, 
	if(isconstant(c) and d(b,x,2)==0, weierstrassP(C_1+x,b^2/2-2a*c,C_2)/c-b/c/2 ));

dsolve(a_*log(y_)+b_*log(x_)+c_,y_,x_,1):= if(a+b==0 and isconstant(c), b*W(exp(c/b)/b)*x );
dsolve(log(y_)-log(x_)+c_,y_,x_,1):= if(isconstant(c), -W(-exp(-c))*x );
dsolve(-log(y_)+log(x_)+c_,y_,x_,1):= if(isconstant(c), W(exp(c))*x );
dsolve(b_*log(x_)/x_+b_*log(y_)/x_-1/x_*y_,y_,x_,1):= if(hasnot(b,x),inverseli(C_1+b*x)/x );
dsolve(y_*log(x_)/x_+y_*log(y_)/x_-1/x_*y_,y_,x_,1):= exp(C_1*x)/x;
dsolve(log(x_)/x_+log(y_)/x_-1/x_*y_,y_,x_,1):= inverseli(C_1+x)/x;
dsolve(log(y_)-y_+x_,y_,x_,1):= inverseli(C_1+exp(x))*exp(-x);
dsolve(log(y_)+y_-x_,y_,x_,1):= inverseli(C_1-exp(-x))*exp(x);
dsolve(-log(y_)+y_+x_,y_,x_,1):= inverseli(C_1+exp(-x))*exp(x);

dsolve(a_+b_*exp(y_)*g_+h_,y_,x_,1):= -log(dsolve(-b*g-(a+h)*y,y,x,1));
dsolve(a_+exp(y_)*g_+h_,y_,x_,1):= -log(dsolve(-g-(a+h)*y,y,x,1));
dsolve(a_+b_*exp(y_)+h_,y_,x_,1):= -log(dsolve(-b-(a+h)*y,y,x,1));
dsolve(a_+exp(y_)+h_,y_,x_,1):= -log(dsolve(-1-(a+h)*y,y,x,1));
dsolve(exp(y_)+g_+h_,y_,x_,1):= if(hasnot(g,h,y), -log(dsolve(-1-(g+h)*y,y,x,1)) );
dsolve(a_/x_+exp(x_*y_)*1/x_-1/x_*y_,y_,x_,1):= if(isconstant(a),-log((exp(C_1 - a*x)-1)/a)/x );
dsolve(1/x_+exp(x_*y_)*1/x_-1/x_*y_,y_,x_,1):= -log(exp(C_1 - x)-1)/x;

dsolve(c_+y_^2-x_^2, y_,x_,1) := if(isconstant(c), exp(c*x^2)/(C_1 - 1/2 sqrt(pi)*erfi(sqrt(c)*x)/sqrt(c)) + c*x );
dsolve(c_+b_*x_+a_*y_^2, y_,x_,1) := if(hasnot(a,b,c,x), (cbrt(a*b)/a*BiPrime((-a*c-a*b*x)/(a*b)^(2/3))*C_1+AiPrime((-a*c-a*b*x)/(a*b)^(2/3))*cbrt(a*b)/a)/(Ai((-a*c-a*b*x)/(a*b)^(2/3)) + C_1*Bi((-a*c-a*b*x)/(a*b)^(2/3))) );
dsolve(c_+b_*x_+y_^2, y_,x_,1) := if(isconstant(b,c), cbrt(b)*AiPrime((-b*x - c)/abs(b)^(2/3))/Ai((-b *x - c)/abs(b)^(2/3)) and cbrt(b) *BiPrime((-b *x - c)/abs(b)^(2/3))/Bi((-b *x - c)/abs(b)^(2/3)) );
dsolve(c_+x_+y_^2, y_,x_,1) := if(isconstant(c), (AiPrime(-x-c)+C_1*BiPrime(-x-c))/(Ai(-x-c)+C_1*Bi(-x-c)) );
dsolve(a_*x_+b_*x_^(-0.5)+y_^2,y_,x_,1):=if(a+4b^2==0,sqrt(-a*x));
dsolve(a_*x_+x_^(-0.5)+c_*y_^2,y_,x_,1):=if(a/c+4==0,sqrt(-a/c*x));
dsolve(a_*x_+b_*x_^(-0.5)+c_*y_^2,y_,x_,1):=if(a/c+4b^2==0,sqrt(-a/c*x));
dsolve(a_+b_*y_+c_*y_^2, y_,x_,1) := if(hasnot(a,b,c,x), if(b*b==4a*c,1/(C_1+c*x)-b/2/c, 1/2*(sqrt(4 a*c - b^2)* tan(1/2 *(C_1* sqrt(4 a*c - b^2) + x* sqrt(4 a*c - b^2))) - b)/c ), 
	block(u:=gsolution(b+d(c,x)/c,-a*c,y,x,2), -d(u,x)/u/c) );
dsolve(a_+y_+c_*y_^2, y_,x_,1) := if(has(a,x), block(u:=gsolution(1+d(c,x)/c,-a*c,y,x,2), -d(u,x)/u/c) );
#dsolve(a_+b_*y_+y_^2, y_,x_,1) := if(hasnot(a,b,x), if(b*b==4a, -1/(C_1+x)-b/2, block(u:=gsolution(b,-a,y,x,2), -d(u,x)/u) ));
dsolve(a_+b_*y_+y_^2, y_,x_,1) := if(hasnot(a,b,x), if(b*b==4a, -b/2-1/(C_1+x), 1/2*(sqrt(4 a - b^2)* tan(1/2 *(C_1* sqrt(4 a - b^2) + x* sqrt(4 a - b^2))) - b) ), block(u:=gsolution(b,-a,y,x,2), -d(u,x)/u) );
dsolve(a_+y_+y_^2, y_,x_,1) := if(hasnot(a,x),1/2*(sqrt(4 a - 1)* tan(1/2 *(C_1* sqrt(4 a -1) + x* sqrt(4 a - 1))) - 1),block(u:=gsolution(1,-a,y,x,2), -d(u,x)/u) );
dsolve(b_*x_+y_+y_^2, y_,x_,1) := if(hasnot(b,x), AiPrime((-b*x+1/4)/abs(b)^(2/3))/Ai((-b*x+1/4)/abs(b)^(2/3))*cbrt(b)-1/2 and BiPrime((-b*x+1/4)/abs(b)^(2/3))/Bi((-b*x+1/4)/abs(b)^(2/3))*cbrt(b)-1/2 );
dsolve(x_+y_+y_^2, y_,x_,1) := AiPrime(-x+1/4)/Ai(-x+1/4)-1/2 and (AiPrime(-x+1/4)+C_1*BiPrime(-x+1/4))/(Ai(-x+1/4)+C_1*Bi(-x+1/4))-1/2 ;
dsolve(-x_-y_+y_^2, y_,x_,1) := 1/2-AiPrime(x+1/4)/Ai(x+1/4) and 1/2-(AiPrime(x+1/4)+C_1*BiPrime(x+1/4))/(Ai(x+1/4)+C_1*Bi(x+1/4)) ;
dsolve(x_^2+2x_*y_+y_^2, y_,x_,1) := tan(C_1+x)-x;
dsolve(x_^2+(-2)*x_*y_+y_^2, y_,x_,1) := -tanh(C_1+x)+x;
dsolve(-x_^2+(-2)*x_*y_-y_^2, y_,x_,1) := tanh(C_1+x)-x;
dsolve(-x_^2+2x_*y_-y_^2, y_,x_,1) := -tan(C_1+x)+x;
#dsolve(2y_+(-3)*y_^2+y_^3, y_,x_,1) := 1/sqrt(exp(C_1+2x)+1)+1;

dsolve(y(p_,x_)+y_+d_, y_,x_,q_) := if(isfree(d,y), gsolution(1,p,1,y,x,q)+if(isfree(d,x), -d,psolution(1,p,1,d,y,x,q) ));
dsolve(y(p_,x_)+c_*y_+d_, y_,x_,q_) := if(isfree(c,d,y), gsolution(1,p,c,y,x,q)+if(isfree(c/d,x), -d/c,psolution(1,p,c,d,y,x,q) ));
dsolve(b_*y(p_,x_)+y_+d_, y_,x_,q_) := if(isfree(b,d,y), gsolution(b,p,1,y,x,q)+if(isfree(d,x), -d,psolution(b,p,1,d,y,x,q) ));
dsolve(b_*y(p_,x_)+c_*y_+d_, y_,x_,q_) := if(isfree(b,c,d,y), gsolution(b,p,c,y,x,q)+if(isfree(c/d,x), -d/c,psolution(b,p,c,d,y,x,q) ));

dsolve(a_+y(m_,x_)+y(n_,x_),y_,x_,p_):=if(isconstant(a), -a*x^m/m!,psolution(1,n,1,m,0,a,y,x,p))+gsolution(1,n,1,m,0,y,x,p);
dsolve(a_+y(m_,x_)+c_*y(n_,x_),y_,x_,p_):=if(hasnot(a,c,x), -a*x^m/m!,psolution(1,n,c,m,0,a,y,x,p))+gsolution(1,n,c,m,0,y,x,p);
dsolve(a_+b_*y(m_,x_)+y(n_,x_),y_,x_,p_):=if(hasnot(a,b,x), -a/b*x^m/m!,psolution(b,n,1,m,0,a,y,x,p))+gsolution(b,n,1,m,0,y,x,p);
dsolve(a_+b_*y(m_,x_)+c_*y(n_,x_),y_,x_,p_):=if(hasnot(a,b,c,x), -a/b*x^m/m!,psolution(b,n,c,m,0,a,y,x,p))+gsolution(b,n,c,m,0,y,x,p);

dsolve(y(p_,x_)+y(m_,x_)+c_*y_, y_,x_,q_) := gsolution(1,p,1,m,c,y,x,q);
dsolve(y(p_,x_)+b_*y(m_,x_)+y_, y_,x_,q_) := gsolution(1,p,b,m,1,y,x,q);
dsolve(y(p_,x_)+b_*y(m_,x_)+c_*y_, y_,x_,q_) := gsolution(1,p,b,m,c,y,x,q);
dsolve(a_*y(p_,x_)+y(m_,x_)+c_*y_, y_,x_,q_) := gsolution(a,p,1,m,c,y,x,q);
dsolve(a_*y(p_,x_)+b_*y(m_,x_)+y_, y_,x_,q_) := gsolution(a,p,b,m,1,y,x,q);
dsolve(a_*y(p_,x_)+b_*y(m_,x_)+c_*y_, y_,x_,q_) := gsolution(a,p,b,m,c,y,x,q);


#4+;
dsolve(f_+a_*y_+b_*y(n_,x_)+c_*y(m_,x_),y_,x_,p_):=if(hasnot(b,c,f,y), gsolution(b,n,c,m,a,y,x,p)+psolution(b,n,c,m,a,f,y,x,p) );
dsolve(f_+y_+b_*y(n_,x_)+c_*y(m_,x_),y_,x_,p_):=if(hasnot(b,c,f,y), gsolution(b,n,c,m,1,y,x,p)+psolution(b,n,c,m,1,f,y,x,p) );
dsolve(c_+a_*x_^p_+b_*y_+y_^2,y_,x_,p_):= if(hasnot(a,b,c,x), cbrt(a)*AiPrime(p,b*b/4-c-cbrt(a)*x^p)/Ai(p,b*b/4-c-cbrt(a)*x^p)-b/2 );
dsolve(c_+x_^2+(-2)*x_*y_+y_^2, y_,x_,p_) := dsolve(c+(x-y)^2,y,x,p);
dsolve(c_+x_^2+2x_*y_+y_^2, y_,x_,p_) := dsolve(c+(x+y)^2,y,x,p);

dsolve(c_+x_+y_+y_^2, y_,x_,1) := if(isconstant(c), AiPrime(-x+1/4-c)/Ai(-x+1/4-c)-1/2 and BiPrime(-x+1/4-c)/Bi(-x+1/4-c)-1/2 );
dsolve(c_+b_*x_+y_+y_^2, y_,x_,1) := if(isconstant(b,c), AiPrime((-b*x+1/4-c)/abs(b)^(2/3))/Ai((-b*x+1/4-c)/abs(b)^(2/3))*cbrt(b)-1/2 and BiPrime((-b*x+1/4-c)/abs(b)^(2/3))/Bi((-b*x+1/4-c)/abs(b)^(2/3))*cbrt(b)-1/2 );
#dsolve(x_^a_*y_^3 + (-3)*y_^2 + x_^p_*y_ +x_^m_ +(-1)* a_*x_^n_,y_,x_,1):= exp(-(2 x^(1 - a))/(1 - a))/sqrt(C_1 - (2^((2* (a + 1))/(a - 1) + 1) *(1/(1 - a))^((a + 1)/(a - 1)) *gamma((a + 1)/(1 - a), -(4 x^(1 - a))/(a - 1)))/(a - 1)) + x^(-a);
dsolve(c_+exp(y_)+exp((-y_))-x_,y_,x_,1):=if(isconstant(c), log(x-c) );


#0;
dsolve(a_=b_,u_):=dsolve(replace(toy(a-b),u,y),y);
dsolve(a_=b_,y(x_)):=dsolve(replace(toy(a-b),y(x),y),y);
#dsolve(b_=a_*y(n_,x_),y_):=dsolve(b/a,y,x,n);
dsolve(x(n_,t_)=a_,x_):= dsolve(tox(a),x,t,n);
dsolve(x(n_,t_)+a_,x_):= dsolve(-tox(a),x,t,n);
#dsolve(a_*y(n_,x_)=b_,y_):=dsolve(b/a,y,x,n);
dsolve(y(n_,x_)^m_=b_,y_):= dsolve(b^(1/m),y,x,n);
dsolve(y(n_,x_)=b_,y_):= dsolve(b,y,x,n);


#dsolve(b_+x(n_,t_),d_+y(n_,t_)):= (x=pdsolve(-b,x,t,n),  y=pdsolve(-d,y,t,n));
#dsolve(b_+x(n_,t_),d_+x_+y(n_,t_)):= block(f:=pdsolve(-b,x,t,n), x=f,  y=pdsolve(-d-f,y,t,n));
#dsolve(b_+x(n_,t_),d_+y(m_,t_)):= if(hasnot(b,y(t)) and hasnot(d,x(t)), (x=pdsolve(-b,x(t),t,n), y=pdsolve(-d,y(t),t,m)), 
	if(hasnot(b,y(t)),block(f:=pdsolve(-b,x(t),t,n), (x=f, y=pdsolve(-replace(d,x(t),f),y(t),t,m))),
	if(hasnot(d,x(t)),block(f:=pdsolve(-d,y(t),t,m), (y=f, x=pdsolve(-replace(b,y(t),f),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(dx/dt=f_,dy/dt=g_):= dsolve(x(1,t)=f,y(1,t)=g,x,y);

#dsolve(integrate(f1_,t_,a_,b_)=z_,y_) := dsolve((replace(f1,t,b)-replace(f1,t,a)-d(z,x)));
dsolve(c_+integrate(f1_,t_,a_,b_),y_) := if(hasnot(c,y(x)),solve(replace(f1,t,b)-replace(f1,t,a)+d(c,x),y(x)), dsolve(replace(f1,t,b)-replace(f1,t,a)+d(c,x)));
dsolve(integrate(f1_,t_,a_,b_)+z_,y_) := if(hasnot(z,y(x)),solve(replace(f1,t,b)-replace(f1,t,a)+d(z,x),y(x)), dsolve(replace(f1,t,b)-replace(f1,t,a)+d(z,x)));
dsolve(c_+integrates(f1_,t_,a_,b_),y_) := if(hasnot(c,y(x)),solve(replace(f1,t,b)-replace(f1,t,a)+d(c,x),y), dsolve(replace(f1,t,b)-replace(f1,t,a)+d(c,x)));
dsolve(integrates(f1_,t_,a_,b_)+z_,y_) := if(hasnot(z,y(x)),solve(replace(f1,t,b)-replace(f1,t,a)+d(z,x),y), dsolve(replace(f1,t,b)-replace(f1,t,a)+d(z,x)));
dsolve(c_+integrates(f1_,t_,a_,b_)+z_,y_) := if(hasnot(c,z,y(x)),solve(replace(f1,t,b)-replace(f1,t,a)+d(c+z,x),y), dsolve(replace(f1,t,b)-replace(f1,t,a)+d(c+z,x)));
dsolve(c_+integrate(f1_,t_,a_,b_)+z_,y_) := if(hasnot(c,z,y(x)),solve(replace(f1,t,b)-replace(f1,t,a)+d(c+z,x),y(x)), dsolve(replace(f1,t,b)-replace(f1,t,a)+d(c+z,x)));


dsolve(y(p_,x_)^m_+b_,y_):= if(hasnot(b,y), block(f1:=int((-b)^(1/m),x,p)+gsolution(0,y,x,p), f1 and if(iseven(m), -f1)),
	dsolve((expand(-b))^(1/m),y,x,p) );
#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(p_,x_)^m_+b_,y_):= if(hasnot(a,b,y), block(f1:=int((-b/a)^(1/m),x,p)+gsolution(0,y,x,p), f1 and if(iseven(m), -f1)),
	dsolve(y(p_,x_)^m_+expand(b/a),y) );
dsolve(a_*y(q_,x_)^m_+b_*y(p_,x_),y_):=if(hasnot(b,y),int(dsolve((-b/a*y)^(1/m),y,x,q-p),x,p), 
	dsolve((-b/a)^(1/m)*y(p,x)^(1/m),y,x,q) );
dsolve(a_*y(p_,x_)^m_+b_*y(p_,x_),y_):= if(hasnot(b,y), int((-b/a)^(1/(m-1)),x,p)+gsolution(0,y,x,p), 
	dsolve((-b/a)^(1/(m-1)),y,x,p) );
dsolve(y(q_,x_)^m_+b_*y(p_,x_),y_):= if(hasnot(b,y), int(dsolve((-b*y)^(1/m),y,x,q-p),x,p)+gsolution(0,y,x,p),  
	dsolve((-b)^(1/m)*y(p,x)^(1/m),y,x,q) );
dsolve(y(p_,x_)^m_+b_*y(p_,x_),y_):= if(hasnot(b,y), int((-b)^(1/(m-1)),x,p)+gsolution(0,y,x,p), 
	dsolve((-b)^(1/(m-1)),y,x,p) );

dsolve(a_+y(q_,x_),y_):= dsolve(-a,y,x,q);
dsolve(a_+b_*y(q_,x_),y_):= dsolve(-a/b,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(a_+b_*y(1,x_),y_):= if(has(b,x) and has(a,y), 
	if((d(a,y)-d(b,x))==0, block(f1:=int(a,x),f2:=d(f1,y), f1+int(b-f2,y)=C_1),
	if(a*x-b*y==0, block(f1:=int(a/(a*x+b*y),x),f2:=d(f1,y), expand(f1+int(b/(a*x+b*y)-f2,y))= -C_1), 
	if(a*x+b*y==0, block(f1:=int(a/(a*x-b*y),x),f2:=d(f1,y), expand(f1+int(b/(a*x-b*y)-f2,y))= -C_1), 
	if(d(a*x,y)==d(b*x,x), block(f1:=int(a*x,x),f2:=d(f1,y), expand(f1+int(b*x-f2,y))= -C_1), 
	if(d(a*y,y)==d(b*y,x), block(f1:=int(b*y,y),f2:=d(f1,x), expand(f1+int(a*y-f2,x))= -C_1), 
	if(d(a*exp(x),y)==d(b*exp(x),x), block(f1:=int(a*exp(x),x),f2:=d(f1,y), expand(f1+int(b*exp(x)-f2,y))= -C_1), 
	if(d(a*exp(y),y)==d(b*exp(y),x), block(f1:=int(b*exp(y),y),f2:=d(f1,x), expand(f1+int(a*exp(y)-f2,x))= -C_1),
	dsolve(-a/b,y,x,1) ))))))), 
	dsolve(-a/b,y,x,1) );
#dsolve(a_*y_+b_*y(1,x_),y_):= if(hasnot(a,b,y), exp(C_1+int(-a/b,x)),dsolve(-a*y/b,y,x,1) );
dsolve(b_*f_+c_*y_,y_):=if(isfunction(f) and has(argument(f,1),y(1,x)),dsolve(solve(c*y+b*f,y(1,x)),y,x,1),
	if(isfunction(b) and has(argument(b,1),y(1,x)),dsolve(solve(c*y+b*f,y(1,x)),y,x,1) ));
dsolve(b_*f_+y_,y_):=if(isfunction(f) and has(argument(f,1),y(1,x)),dsolve(solve(y+b*f,y(1,x)),y,x,1),
	if(isfunction(b) and has(argument(b,1),y(1,x)),dsolve(solve(y+b*f,y(1,x)),y,x,1) ));
dsolve(y_+exp(y(1,x_))*x_,y_):= -W(1)*x;
dsolve(y_-exp(-y(1,x_))*x_,y_):=W(1)*x;

#3;
dsolve(a_+y_^(-2)+y(1,x_)^2,y_):= if(isconstant(a), i*sqrt(1/a+a*(C_1+x)^2) );
dsolve(a_+b_*y_^(-2)+y(1,x_)^2,y_):= if(isconstant(a,b), i*sqrt(b/a+a*(C_1+x)^2) );
dsolve(y_^2+c_*y_^4+y(1,x)^2,y_):=if(c<0,sqrt(-1/c)*sec((C_1+x)),
	if(c>0,sqrt(-1/c)*sech((C_1+x)) ));
dsolve(b_*y_^2+y_^4+y(1,x)^2,y_):=if(b>0,sqrt(-b)*sec(sqrt(b)*(C_1+x)),
	if(b<0,sqrt(-b)*sech(sqrt(-b)*(C_1+x)) ));
dsolve(b_*y_^2+c_*y_^4+y(1,x)^2,y_):=if(b>0,sqrt(-b/c)*sec(sqrt(b)*(C_1+x)),
	if(b<0,sqrt(-b/c)*sech(sqrt(-b)*(C_1+x)) ));
dsolve(y_^2+c_*y_^3+y(1,x)^2,y_):=if(c<0,(-1/c)*sec((C_1+x))^2,
	if(c>0,(-1/c)*sech((C_1+x))^2 ));
dsolve(b_*y_^2+y_^3+y(1,x)^2,y_):=if(b>0,(-b)*sec(sqrt(b)/2*(C_1+x))^2,
	if(b<0,(-b)*sech(sqrt(-b)/2*(C_1+x))^2 ));
dsolve(b_*y_^2+c_*y_^3+y(1,x)^2,y_):=if(b>0,(-b/c)*sec(sqrt(b)/2*(C_1+x))^2,
	if(b<0,(-b/c)*sech(sqrt(-b)/2*(C_1+x))^2 ));

dsolve(a_*y(q_,x_)^m_+b_*y(p_,x_)+c_,y_):= dsolve(y(p_,x_)^m_+b/a*y(p,x)+expand(c/a),y) ;
dsolve(a_*y(1,x_)^2+b_*y(2,x_)+c_,y_):= if(d(b,y)==a, if(hasnot(c,y), solve(int(b,y)=C_2*(C_1+x)-int(c,x,2),y),
	if(hasnot(c,x), int(b/sqrt(-2int(c*b,y)),y)=C_1+x)), dsolve(-c/b-a/b*y(1,x)^2,y,x,2) );
#dsolve(y(p_,x_)^m_+y(p_,x_)+c_,y_):= C_1+int(solve(y^m+y+c,y),x,p);
#dsolve(y(p_,x_)^m_+b_*y(p_,x_)+c_,y_):= C_1+dsolve(solve(yy^m+b*yy+c,yy),y,x,p);
dsolve(y(q_,x_)^m_+b_*y(p_,x_)+c_,y_):= if(q-p>1, dsolve(b*y(p,x)+c,y) );
dsolve(y(p_,x_)^2+b_*y(p_,x_)+c_,y_):= if(hasnot(b,c,y) and hasnot(b,c,y(1,x)), C_1+int(-b/2+sqrt(b*b-4c)/2,x,p) and C_1-int(b/2+sqrt(b*b-4c)/2,x,p), 
	dsolve((-b-(b*b-4c)^0.5)/2,y,x,p) and dsolve((-b+(b*b-4c)^0.5)/2,y,x,p));
dsolve(y(1,x_)^2+y_*y(2,x_)+c_, y_):= if(hasnot(c,y), sqrt(-2int(c,x,2)+C_2*(C_1+x)) and -sqrt(-2int(c,x,2)+C_2*(C_1+x)),
	if(hasnot(c,x), int(y/sqrt(-2int(c*y,y)),y)=C_1+x ));
dsolve(-y(1,x_)^2+y_*y(2,x_)+c_, y_):=if(c>0, sqrt(c)*sin(C_2*(C_1+x))/C_2 and sqrt(c)*sinh(C_2*(C_1+x))/C_2,
	if(c<0, sqrt(-c)*cosh(C_2*(C_1+x))/C_2 ));

dsolve(y(p_,x_)^m_+b_*y(p_,x_)+c_*y_,y_):= if(d(b,x,p)+c==0, C_1*x^p-p!^m/c*C_1^m);

dsolve(y(1,x_)^3+y(1,x_)-exp(y_),y_):=int(6cbrt(108exp(y)+12sqrt(12+81exp(2y)))/(cbrt(108exp(y)+12sqrt(12+81exp(2y)))-12),y)=C_1+x;
dsolve(y(1,x_)^2+y(1,x_)+c_*exp(y_),y_):= if(isconstant(c),1/(1 - sqrt(-4c*e^y + 1)) - atanh(sqrt(-4c*e^y + 1))=C_1+x/2 );
dsolve(y(1,x_)^2+b_*y(1,x_)+c_*exp(y_),y_):= if(isconstant(b,c),1/(1 - sqrt(4c/b*e^y + 1)) - atanh(sqrt(4c/b*e^y + 1))=C_1+b*x/2 );
dsolve(y(1,x_)^2+y(1,x_)+y_,y_):= -1/4 W(exp(C_1-x))^2 - 1/2 W(exp(C_1-x));
dsolve(y(1,x_)^2+y(1,x_)+c_*y_,y_):= if(isconstant(c), -1/c/4 W(exp(C_1-c*x))^2 - 1/c/2 W(exp(C_1-c*x)) );
dsolve(y(1,x_)^2+b_*y(1,x_)+y_,y_):= if(hasnot(b,x), -b^2/4 W(exp(C_1-1/b*x))^2 - b^2/2 W(exp(C_1-1/b*x)) );
dsolve(y(1,x_)^2+b_*y(1,x_)+c_*y_,y_):= if(isconstant(b,c), -b^2/c/4 W(exp(C_1-c/b*x))^2 - b^2/c/2 W(exp(C_1-c/b*x)) );

dsolve(a_*y(1,x_)^m_+x_*y(1,x_)-y_,y_):=if(isconstant(a), C_1*x+a*C_1^m );
dsolve(a_*y(1,x_)^m_-x_*y(1,x_)+y_,y_):=if(isconstant(a), C_1*x-a*C_1^m );
dsolve(y(1,x_)^n_+x_*y(1,x_)+c_*y_,y_):= if(isconstant(c), ((n/(1-n)-c)*((n-1)/n)^n)^(1/(n-1))*x^(n/(n-1)) and if(c== -1,C_1^n+C_1*x ));
dsolve(y(1,x_)^n_+b_*x_*y(1,x_)+y_,y_):= if(isconstant(b), ((b*n/(1-n)-1)*((n-1)/n)^n)^(1/(n-1))*x^(n/(n-1)) and if(b== -1,C_1^n/b+C_1*x ));
dsolve(y(1,x_)^n_+b_*x_*y(1,x_)+c_*y_,y_):= if(isconstant(b,c), ((b*n/(1-n)-c)*((n-1)/n)^n)^(1/(n-1))*x^(n/(n-1)) and if(b+c==0,C_1^n/b+C_1*x ));

#dsolve(y(1,x_)^m_-x_*y(1,x_)+y_,y_):= -C_1^m+C_1*x;
#dsolve(y(1,x_)^m_+x_*y(1,x_)-y_,y_):= C_1^m+C_1*x;
#dsolve(y(q_,x_)^2+b_*x_*y(1,x_)+y_,y_):= if(q==1 or q>2 and hasnot(b,x),-(2b+1)/4x^2);
#dsolve(y(1,x_)^3+b_*x_*y(1,x_)+c_*y_,y_):= if(isconstant(b,c),2/3/sqrt(3)*sqrt(-3b-2*c)*x^(3/2) and if(b+c==0, C_1^3/b+C_1*x));
#dsolve(y(1,x_)^2+b_*x_*y(1,x_)+c_*y_,y_):= if(isconstant(b,c),-(2b+c)/4x^2 and if(b+c==0, C_1^2/b+C_1*x));
#dsolve(y(q_,x_)^2-x_*y(1,x_)+y_,y_):= if(q==1,x^2/4 and -C_1^2+C_1*x, if(q>1,C_1*x ));
#dsolve(y(q_,x_)^2+x_*y(1,x_)+c_*y_,y_):= if(q==1 or q>2 and isconstant(c),-(2+c)/4x^2 );
#dsolve(y(q_,x_)^2+x_*y(1,x_)-y_,y_):= if(q==1,C_1^2+C_1*x and -x^2/4, if(q>1,C_1*x ));
#dsolve(y(q_,x_)^2+x_*y(1,x_)+y_,y_):= if(q==1 or q>2,-3/4x^2);

dsolve(-y(1,x_)^2+y_*y(2,x_)+c_*y_, y_):=if(isconstant(c), c/2*sin(C_2*(C_1+x))^2/C_2^2 and c/2*sinh(C_2*(C_1+x))^2/C_2^2,
	if(hasnot(c,x), int(1/sqrt(-2int(c*y^(-2),y))/y,y)=C_1+x ));
dsolve(-y(1,x_)^2+y_*y(2,x_)+c_*y_^n_, y_):= if(hasnot(c,y) and n==2, exp(C_1+C_2*x-int(c,x,2)),
	if(hasnot(c,x), int(1/sqrt(-2int(c*y^(n-3),y))/y,y)=C_1+x ));
dsolve(y(p_,x_)^2+b_*y_*y(p_,x_)+c_*y_^2,y_):= if(b*b==4c, C_1*mittag(p,-p!/2*int(b,x,p)), 
	C_1*mittag(p,p!/2*int((-b+sqrt(b*b-4c)),x,p)) and C_2*mittag(p,-p!/2*int((b+(b*b-4c)^0.5),x,p)) );

#dsolve(y(q_,x_)^2+b_*x_*y(q_,x_)+y(p_,x_),y_):= if(hasnot(b,x) and q-p==1, gsolution(0,y,x,p)-int((2b+1)/4x^2,x,p) and 
	if(b+c==0, C_1^2/b*x^(q-p)/(q-p)!+C_1*x^^(1+q-p)/(q-p)!) );
#dsolve(y(q_,x_)^2+b_*x_*y(q_,x_)+c_*y(p_,x_),y_):= if(isconstant(b,c) and q-p==1, gsolution(0,y,x,p)-int((2b+c)/4x^2,x,p) and 
	if(b+c==0, C_1^2/b*x^(q-p)/(q-p)!+C_1*x^(1+q-p)/(q-p)!) );

dsolve(a_*y(p_,x_)+b_*y_+c_*y_^n_, y_):= dsolve(-b/a*y-c/a*y^n,y,x,p);

dsolve(a_*y(q_,x_)+b_*y(p_,x_)+c_,y_):= dsolve(-b/a*y(p,x)-c/a,y,x,q);
dsolve(a_*y(q_,x_)+b_*y(q_,x_)+c_,y_):= dsolve(-c/(a+b),y,x,q);
dsolve(y(q_,x_)+b_*y(q_,x_)+c_,y_):= dsolve(-c/(1+b),y,x,q);
dsolve(x_*y(2,x_)+y(1,x_)+c_, y_):= if(hasnot(c,y), C_1+C_2*log(x)-int(int(c,x)/x,x), dsolve(-y(1,x)/x-c/x,y,x,2) );

dsolve(a_*x_*y(1,x_)+_f(y(1,x_))+b_*y_,y_):= _f(C_1)/a+C_1*x;

dsolve(a_*y(2,x_)+b_*y(1,x_)+y_,y_):= if(d(a,x,2)-d(b,x)+1==0,solve(dsolve(a*y(1,x)+(b-d(a,x))*y-C_2,y),y),
	dsolve(-b/a*y(1,x)-1/a*y,y,x,2) );
dsolve(a_*y(2,x_)+b_*y(1,x_)+c_*y_,y_):= if(d(a,x,2)-d(b,x)+c==0,solve(dsolve(a*y(1,x)+(b-d(a,x))*y-C_2,y),y),
	dsolve(-b/a*y(1,x)-expand(c/a)*y,y,x,2) );
dsolve((1-x_^2)*y(2,x_)+2*x_*y(1,x_)+c_*y_,y_):=if(hasnot(c,x), C_1*legendreP(sqrt(4c+1)/2-1/2,x)+C_2*legendreQ(sqrt(4c+1)/2-1/2,x) );
dsolve((b_+x_^2)*y(2,x_)+x_*y(1,x_)+y_,y_):= if(hasnot(b,x), C_1*cos(asinh(x/sqrt(b)))+C_2*sin(asinh(x/sqrt(b))) );
dsolve((b_+x_^2)*y(2,x_)+x_*y(1,x_)+c_*y_,y_):= if(hasnot(b,x), if(c<0,C_1*(x+sqrt(x^2+b))^sqrt(-c)+C_2/(x+sqrt(x^2+b))^sqrt(-c),
	C_1*cos(asinh(x/sqrt(b))*sqrt(c))+C_2*sin(asinh(x/sqrt(b))*sqrt(c)) ));


#4;
dsolve(a_+y_^2+c_*y_^4+y(1,x)^2,y_):=if(c<0,sqrt(-1/2/c)*tan((C_1+x)),
	if(c>0,sqrt(-1/2/c)*tanh((C_1+x)) ));
dsolve(a_+b_*y_^2+y_^4+y(1,x)^2,y_):=if(b>0,sqrt(-b/2)*tan(sqrt(b/2)*(C_1+x)),
	if(b<0,sqrt(-b/2)*tanh(sqrt(-b/2)*(C_1+x)) ));
dsolve(a_+b_*y_^2+c_*y_^4+y(1,x)^2,y_):=if(b>0,sqrt(-b/2/c)*tan(sqrt(b/2)*(C_1+x)),
	if(b<0,sqrt(-b/2/c)*tanh(sqrt(-b/2)*(C_1+x)) ));
dsolve(y_^2+b_*y_^3+c_*y_^4+y(1,x)^2,y_):=if(c<0,sech(sqrt(1/2)*(C_1+x))^2/(b+2sqrt(a*c)*tan(sqrt(1/2)*(C_1+x))),
	if(c<0,sech(sqrt(-1/2)*(C_1+x))^2/(b+2sqrt(c)*tanh(sqrt(-1/2)*(C_1+x))) ));
dsolve(a_*y_^2+y_^3+c_*y_^4+y(1,x)^2,y_):=if(a>0,a*sech(sqrt(a/2)*(C_1+x))^2/(1+2sqrt(a*c)*tan(sqrt(a/2)*(C_1+x))),
	if(a<0,a*sech(sqrt(-a/2)*(C_1+x))^2/(1+2sqrt(a*c)*tanh(sqrt(-a/2)*(C_1+x))) ));
dsolve(a_*y_^2+b_*y_^3+c_*y_^4+y(1,x)^2,y_):=if(a>0,a*sech(sqrt(a/2)*(C_1+x))^2/(b+2sqrt(a*c)*tan(sqrt(a/2)*(C_1+x))),
	if(a<0 and b*b-4a*c=0, b/c+b/c*tanh(sqrt(-a/2)*(C_1+x)),
	if(a<0,a*sech(sqrt(-a/2)*(C_1+x))^2/(b+2sqrt(a*c)*tanh(sqrt(-a/2)*(C_1+x))) )));

dsolve(a_*y(p_,x_)^m_+y(p_,x_)+c_*y_+d_,y_):= if(d(d,x,p)==0, dsolve(y(p,x)^m+1/a*y(p,x)+c/a*y,y)-d/c );
dsolve(a_*y(p_,x_)^m_+b_*y(p_,x_)+c_*y_+d_,y_):= if(d(d,x,p)==0, dsolve(y(p,x)^m+b/a*y(p,x)+c/a*y,y)-d/c );
dsolve(y(p_,x_)^m_+y(p_,x_)+c_*y_+d_,y_):= if(d(d,x,p)==0, dsolve(y(p,x)^m+y(p,x)+c*y,y)-d/c );
dsolve(y(p_,x_)^m_+b_*y(p_,x_)+c_*y_+d_,y_):= if(d(d,x,p)==0, dsolve(y(p,x)^m+b*y(p,x)+c*y,y)-d/c );
#dsolve(y(1,x_)^2+b_*x_*y(1,x_)+c_*y_+d_,y_):= if(isconstant(b,c,d),-(2b+c)/4x^2-d/c and if(b+c==0, C_1^2/b+C_1*x-d/c) );
#dsolve(y(1,x_)^n_+b_*x_*y(1,x_)+c_*y_+d_*y(1,x_)^m_,y_):= if(b+c==0,C_1^n/b+d/b*C_1^m+C_1*x );
#dsolve(-y_+a_*y(1,x)^m_+x_*y(1,x)+y(1,x)^n_,y_):= if(hasnot(a,x), C_1^n+a*C_1^m+C_1*x );
#dsolve(b_-y_+a_*y(1,x)^m_+x_*y(1,x)+y(1,x)^n_,y_):= if(hasnot(a,b,x), C_1^n+a*C_1^m+b+C_1*x );

dsolve(x_*y(p_,x_)+a_+b_*y_+c_*y_^n_, y_) := dsolve(-a/x-b/x*y-c/x*y^n,y,x,p);
dsolve(x_*y(1,x_)+a_+c_-y_,y_):= if(isconstant(a),if(isfunction(c) and has(argument(c,1),y(1,x)),a+C_1*x+replace(c,y(1,x),C_1),if(hasnot(c,y), C_1*x-int((a+c)/x^2,x)*x )));
dsolve(x_*y(1,x_)+a_+b_*c_-y_,y_):= if(isconstant(a,b),if(isfunction(c) and has(argument(c,1),y(1,x)),a+C_1*x+b*replace(c,y(1,x),C_1),if(hasnot(c,y), C_1*x-int((a+b*c)/x^2,x)*x )));
dsolve(x_*y(1,x_)+ a_*x_*y_^2 + 2*y_ + c_*x_,y_):= -sqrt(c/a)* tan(a* x* sqrt(c/a) + C_1) - 1/(a* x);
dsolve(x_*y(1,x_)+ x_*y_^2 - y_ + a_*x_^3,y_) := sqrt(a)* x* tan(1/2* (sqrt(a)* C_1 - sqrt(a)* x^2));
dsolve(x_*y(1,x_)+ x_*y_^2 - y_ + (-a_)*x_^3,y_) := sqrt(a)* x* tanh(1/2* (sqrt(a)* C_1 + sqrt(a)* x^2));
dsolve(x_*y(1,x_)+ x_*y_^2+(-1+(-2)*x_^2)*y_ -x_^3,y_):=(1+sqrt(2))*x;
dsolve(x_*y(1,x_)+b_*exp(x_*y_)+y_+a_,y_):= if(isconstant(a),-log((-b-exp(C_1+a*x))/a)/x );

dsolve(y(q_,x_)+b_*y(p_,x_)+y_+d_,y_):= dsolve(-b*y(p,x)-y-d,y,x,q);
dsolve(y(q_,x_)+b_*y(p_,x_)+c_*y_+d_,y_):= dsolve(-b*y(p,x)-c*y-d,y,x,q);
dsolve(a_*y(q_,x_)+b_*y(p_,x_)+c_*y_+d_,y_):= dsolve(-b/a*y(p,x)-c/a*y-d/a,y,x,q);
dsolve(a_*y(2,x_)+b_*y(1,x_)+y_+d_,y_):= if(d(a,x,2)-d(b,x)+1==0,solve(dsolve(a*y(1,x)+(b-d(a,x))*y+int(d,x)-C_2,y),y),
	dsolve(-b/a*y(1,x)-1/a*y-d/a,y,x,2) );
dsolve(a_*y(2,x_)+b_*y(1,x_)+c_*y_+d_,y_):= if(d(a,x,2)-d(b,x)+c==0,solve(dsolve(a*y(1,x)+(b-d(a,x))*y+int(d,x)-C_2,y),y),
	dsolve(-b/a*y(1,x)-c/a*y-d/a,y,x,2) );


dsolve(a_=b_,c_=d_,x_,y_):= dsolve(tox(a=b),toyt(c=d),x,y);
dsolve(x(m_,t_)=a_,y(n_,t_)=c_,x_,y_):= if(hasnot(a,y), block(f:=solve(dsolve(a,x,t,m),x), (x=f,  y=dsolve(replace(c,x,f),y,t,n))), 
	if(hasnot(c,x), block(yy:=solve(dsolve(c,y,t,n),y), (x=dsolve(replace(a,y,yy),x,t,m),y=yy)),
	if(hasnot(a,c,t) and m==n, dsolve(-c+a*y(n,x),y),
	if(hasnot(c,t), y=dsolve(c,y,x,n), 
	if(hasnot(a,t), swap(y=dsolve(swap(a,x,y),y,x,m),x,y) 
	)))));
dsolve(x(m_,t_)=c1_,y(n_,t_)=c2_+x_,x_,y_):= block(yy:=dsolve(d(c2,t,m)+replace(c1,x,y(n,t)-c2),y,t,m+n), (x=d(yy,t,n)-c2, y=yy) );
dsolve(x(m_,t_)=c1_,y(n_,t_)=c2_+x_+y_,x_,y_):= block(yy:=dsolve(y(m,t)+d(c2,t,m)+replace(c1,x,y(n,t)-y-c2),y,t,m+n), (x=d(yy,t,n)-c2-yy, y=yy) );
dsolve(x(m_,t_)=c1_,y(n_,t_)=c2_+x_+b_*y_,x_,y_):= block(yy:=dsolve(b*y(m,t)+d(c2,t,m)+replace(c1,x,y(n,t)-b*y-c2),y,t,m+n), (x=d(yy,t,n)-c2-b*yy, y=yy) );
#dsolve(x(m_,t_)=c1_,y(n_,t_)=x_+b_*y_,x_,y_):= block(yy:=dsolve(b*y(m,t)+replace(c1,x,y(n,t)-b*y),y,t,m+n), (x=d(yy,t,n)-b*yy, y=yy) );
dsolve(x(m_,t_)=c1_+y_,y(n_,t_)=a_+y_,x_,y_):= block(f:=dsolve(y(m,t)+toyt(d(replace(c1,x,y(t)),t,n))+replace(a-c1,x,y),y,t,m+n), 
	(x=f,y=expand(d(f,t,m)-replace(c1,x,f))) );
dsolve(x(m_,t_)=c1_+y_,y(n_,t_)=a_+b_*y_,x_,y_):= block(f:=dsolve(b*y(m,t)+toyt(d(replace(c1,x,y(t)),t,n))+replace(a-b*c1,x,y),y,t,m+n), 
	(x=f,y=expand(d(f,t,m)-replace(c1,x,f))) );
dsolve(x(m_,t_)=c1_+f1_*y_,y(n_,t_)=a_+y_,x_,y_):= block(f:=dsolve(y(m,t)+toyt(d(replace(c1,x,y(t)),t,n))+replace(f1*a-c1,x,y),y,t,m+n), 
	(x=f,y=expand(d(f,t,m)/f1-replace(c1,x,f)/f1)) );
#dsolve(x(m_,t_)=c1_+f1_*y_,y(n_,t_)=a_+b_*y_,x_,y_):= block(f:=dsolve(b*y(m,t)+toyt(d(replace(c1,x,y(t)),t,n))+replace(f1*a-b*c1,x,y),y,t,m+n), 
	(x=f,y=expand(d(f,t,m)/f1-replace(c1,x,f)/f1)) );
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*b*c,(x=C_1*mittag(m,(a+d)/2*t^m), y=C_1*mittag(m,(a+d)/2*t^m)), dsolve((c*x+d*y)/(a*x+b*y),y,x,m) );
dsolve(x(m_,t_)=a_*x_+y_,y(m_,t_)=x_+a_*y_,x_,y_):= if(isconstant(a),(x=C_1*mittag(m,(a+1)*t^m), y=C_1*mittag(m,(a+1)*t^m)) );
dsolve(x(m_,t_)=x_+b_*y_,y(m_,t_)=b_*x_+y_,x_,y_):= if(hasnot(b,x),(x=C_1*mittag(m,(1+b)*t^m), y=C_1*mittag(m,(1+b)*t^m)) );
dsolve(x(m_,t_)=a_*x_+b_*y_,y(m_,t_)=b_*x_+a_*y_,x_,y_):= if(hasnot(a,b,x),(x=C_1*mittag(m,(a+b)*t^m), y=C_1*mittag(m,(a+b)*t^m)) );
dsolve(x(m_,t_)=a_*x_+a_*y_,y(m_,t_)=b_*x_+b_*y_,x_,y_):= if(hasnot(a,b,x),(x=C_1*(a*mittag(m,(a+b)*t^m)+b), y=b*C_1*(mittag(m,(a+b)*t^m)-1)) );

dsolve(x(m_,t_)+b_*y(n_,t_)=c_,x(m_,t_)+b2_*y(n_,t_)=c2_,x_,y_):=
dsolve(x(m,t)=expand((b2*c-b*c2)/(b2-b)),y(n,t)=expand((c-c2)/(b-b2)),x,y);
dsolve(a_*x(m_,t_)+b_*y(n_,t_)=c_,a2_*x(m_,t_)+b2_*y(n_,t_)=c2_,x_,y_):=
dsolve(x(m,t)=expand((b2*c-b*c2)/(a*b2-a2*b)),y(n,t)=expand((a2*c-a*c2)/(a2*b-a*b2)),x,y);


#1;
dsolve(a_):=dsolve(replace(toy(a),y(x),y),y);
dsolve(ds(x_,y_)=c_):= dsolve(c,x,y,1);
dsolve(ds(x,y)=m_/n_):= dsolve(n/m,y,x,1);
dsolve(dx/dy=m_/n_):= dsolve(n/m,y,x,1);
dsolve(dy/dx=c_):=dsolve(c,y,x,1);
dsolve(x(p_,t_)=c_):=dsolve(c,x,t,p);
dsolve(x(p_,t_)+c_):=dsolve(-c,x,t,p);