function f= Bernoulli(p,q,n) % - Bernoulli first order nonlinear ode y' +p(x) y= q(x) y^n % - is linearized by W =y^(1-n). to become W'+(1-n)*P(x)*W=(1-n)*q(x) % - usage f=Bernoulli(p,q,n) % syms x y c wh wp u disp(' Bernoulli type first order ode '); disp(q) % disp(' for example you need: syms x y p q w;p=x;q=1;n=-1; f=bernoulli(p,q,n ]']; disp(' You are solving yprime+py=q y ^ n'); disp(' where p = '); disp(p) disp(' and, q = '); disp(q) disp(' and, where n = '); disp(n) disp('Let W = y^(1-n)') disp('then the ode becomes linear nonhomogeneous ode as :') disp(' Wprime +(1-n)pw =(1-n)q') disp('Integrating Factor u= exp(int((1-n)*p))') u=simplify(exp(int((1-n)*p,'x'))) disp(' Homogeneous solution is wh=c/u') wh=c/u disp(' The Particular solution is wp=1/u * Int( (1-n)*u*q)') wp=simplify(int((1-n)*u*q)/u) disp(' The general solution is w = wh+wp') w=simplify(wh+wp) y=w^(1/(1-n)) disp(' y=w^(1/(1-n))=');disp(y) return