2.1.9 Problem 2(c)

Solved using first_order_ode_linear
Solved using first_order_ode_exact
Solved using first_order_ode_LIE
Maple
Mathematica
Sympy

Internal problem ID [4198]
Book : Elementary Differential equations, Chaundy, 1969
Section : Exercises 3, page 60
Problem number : 2(c)
Date solved : Friday, April 25, 2025 at 09:13:43 AM
CAS classification : [_linear]

Solved using first_order_ode_linear

Time used: 0.085 (sec)

Solve

xy+ny=xn

In canonical form a linear first order is

y+q(x)y=p(x)

Comparing the above to the given ode shows that

q(x)=nxp(x)=xn1

The integrating factor μ is

μ=eqdx=enxdx=xn

The ode becomes

ddx(μy)=μpddx(μy)=(μ)(xn1)ddx(yxn)=(xn)(xn1)d(yxn)=(xn1xn)dx

Integrating gives

yxn=xn1xndx=x2n2n+c1

Dividing throughout by the integrating factor xn gives the final solution

y=xn2n+xnc1

Summary of solutions found

y=xn2n+xnc1
Solved using first_order_ode_exact

Time used: 0.101 (sec)

Solve

xy+ny=xn

To solve an ode of the form

(A)M(x,y)+N(x,y)dydx=0

We assume there exists a function ϕ(x,y)=c where c is constant, that satisfies the ode. Taking derivative of ϕ w.r.t. x gives

ddxϕ(x,y)=0

Hence

(B)ϕx+ϕydydx=0

Comparing (A,B) shows that

ϕx=Mϕy=N

But since 2ϕxy=2ϕyx then for the above to be valid, we require that

My=Nx

If the above condition is satisfied, then the original ode is called exact. We still need to determine ϕ(x,y) but at least we know now that we can do that since the condition 2ϕxy=2ϕyx is satisfied. If this condition is not satisfied then this method will not work and we have to now look for an integrating factor to force this condition, which might or might not exist. The first step is to write the ODE in standard form to check for exactness, which is

(1A)M(x,y)dx+N(x,y)dy=0

Therefore

(x)dy=(ny+xn)dx(2A)(nyxn)dx+(x)dy=0

Comparing (1A) and (2A) shows that

M(x,y)=nyxnN(x,y)=x

The next step is to determine if the ODE is is exact or not. The ODE is exact when the following condition is satisfied

My=Nx

Using result found above gives

My=y(nyxn)=n

And

Nx=x(x)=1

Since MyNx, then the ODE is not exact. Since the ODE is not exact, we will try to find an integrating factor to make it exact. Let

A=1N(MyNx)=1x((n)(1))=n1x

Since A does not depend on y, then it can be used to find an integrating factor. The integrating factor μ is

μ=eAdx=en1xdx

The result of integrating gives

μ=e(n1)ln(x)=xn1

M and N are multiplied by this integrating factor, giving new M and new N which are called M and N for now so not to confuse them with the original M and N.

M=μM=xn1(nyxn)=(nyxn)xn1

And

N=μN=xn1(x)=xn

Now a modified ODE is ontained from the original ODE, which is exact and can be solved. The modified ODE is

M+Ndydx=0((nyxn)xn1)+(xn)dydx=0

The following equations are now set up to solve for the function ϕ(x,y)

(1)ϕx=M(2)ϕy=N

Integrating (2) w.r.t. y gives

ϕydy=Ndyϕydy=xndy(3)ϕ=yxn+f(x)

Where f(x) is used for the constant of integration since ϕ is a function of both x and y. Taking derivative of equation (3) w.r.t x gives

(4)ϕx=xnnyx+f(x)=nyxn1+f(x)

But equation (1) says that ϕx=(nyxn)xn1. Therefore equation (4) becomes

(5)(nyxn)xn1=nyxn1+f(x)

Solving equation (5) for f(x) gives

f(x)=xn1xn=x2n1

Integrating the above w.r.t x results in

f(x)dx=(x2n1)dxf(x)=x2n2n+c2

Where c2 is constant of integration. Substituting result found above for f(x) into equation (3) gives ϕ

ϕ=yxnx2n2n+c2

But since ϕ itself is a constant function, then let ϕ=c3 where c3 is new constant and combining c2 and c3 constants into the constant c2 gives the solution as

c2=yxnx2n2n

Solving for y gives

y=(2c2n+x2n)xn2n

Which simplifies to

y=xnc2n+xn2n

Summary of solutions found

y=xnc2n+xn2n
Solved using first_order_ode_LIE

Time used: 0.437 (sec)

Solve

xy+ny=xn

Writing the ode as

y=ny+xnxy=ω(x,y)

The condition of Lie symmetry is the linearized PDE given by

(A)ηx+ω(ηyξx)ω2ξyωxξωyη=0

To determine ξ,η then (A) is solved using ansatz. Making bivariate polynomials of degree 1 to use as anstaz gives

(1E)ξ=xa2+ya3+a1(2E)η=xb2+yb3+b1

Where the unknown coefficients are

{a1,a2,a3,b1,b2,b3}

Substituting equations (1E,2E) and ω into (A) gives

(5E)b2+(ny+xn)(b3a2)x(ny+xn)2a3x2(xnnx2ny+xnx2)(xa2+ya3+a1)+n(xb2+yb3+b1)x=0

Putting the above in normal form gives

n2y2a3+xnnxa2xnnya3nx2b2+ny2a3+x2na3+xnna1xnxb3xnya3nxb1+nya1b2x2xna1x2=0

Setting the numerator to zero gives

(6E)n2y2a3xnnxa2+xnnya3+nx2b2ny2a3x2na3xnna1+xnxb3+xnya3+nxb1nya1+b2x2+xna1=0

Looking at the above PDE shows the following are all the terms with {x,y} in them.

{x,y,xn}

The following substitution is now made to be able to collect on all terms with {x,y} in them

{x=v1,y=v2,xn=v3}

The above PDE (6E) now becomes

(7E)n2v22a3v3nv1a2nv22a3+v3nv2a3+nv12b2nv2a1v3na1+nv1b1+v3v2a3v32a3+b2v12+v3v1b3+v3a1=0

Collecting the above on the terms vi introduced, and these are

{v1,v2,v3}

Equation (7E) now becomes

(8E)(nb2+b2)v12+(na2+b3)v1v3+nv1b1+(n2a3na3)v22+(na3+a3)v2v3nv2a1v32a3+(na1+a1)v3=0

Setting each coefficients in (8E) to zero gives the following equations to solve

nb1=0a3=0na1=0na1+a1=0na3+a3=0n2a3na3=0nb2+b2=0na2+b3=0

Solving the above equations for the unknowns gives

a1=0a2=a2a3=0b1=0b2=0b3=na2

Substituting the above solution in the anstaz (1E,2E) (using 1 as arbitrary value for any unknown in the RHS) gives

ξ=xη=ny

Shifting is now applied to make ξ=0 in order to simplify the rest of the computation

η=ηω(x,y)ξ=ny(ny+xnx)(x)=2nyxnξ=0

The next step is to determine the canonical coordinates R,S. The canonical coordinates map (x,y)(R,S) where (R,S) are the canonical coordinates which make the original ode become a quadrature and hence solved by integration.

The characteristic pde which is used to find the canonical coordinates is

(1)dxξ=dyη=dS

The above comes from the requirements that (ξx+ηy)S(x,y)=1. Starting with the first pair of ode’s in (1) gives an ode to solve for the independent variable R in the canonical coordinates, where S(R). Since ξ=0 then in this special case

R=x

S is found from

S=1ηdy=12nyxndy

Which results in

S=ln(2nyxn)2n

Now that R,S are found, we need to setup the ode in these coordinates. This is done by evaluating

(2)dSdR=Sx+ω(x,y)SyRx+ω(x,y)Ry

Where in the above Rx,Ry,Sx,Sy are all partial derivatives and ω(x,y) is the right hand side of the original ode given by

ω(x,y)=ny+xnx

Evaluating all the partial derivatives gives

Rx=1Ry=0Sx=xn14ny+2xnSy=12nyxn

Substituting all the above in (2) and simplifying gives the ode in canonical coordinates.

(2A)dSdR=12x

We now need to express the RHS as function of R only. This is done by solving for x,y in terms of R,S from the result obtained earlier and simplifying. This gives

dSdR=12R

The above is a quadrature ode. This is the whole point of Lie symmetry method. It converts an ode, no matter how complicated it is, to one that can be solved by integration when the ode is in the canonical coordiates R,S.

Since the ode has the form ddRS(R)=f(R), then we only need to integrate f(R).

dS=12RdRS(R)=ln(R)2+c5

To complete the solution, we just need to transform the above back to x,y coordinates. This results in

ln(2nyxn)2n=ln(x)2+c5

Solving for y gives

y=en(ln(x)+2c5)+xn2n

Summary of solutions found

y=en(ln(x)+2c5)+xn2n
Maple. Time used: 0.002 (sec). Leaf size: 20
ode:=x*diff(y(x),x)+n*y(x) = x^n; 
dsolve(ode,y(x), singsol=all);
 
y=xn2n+xnc1

Maple trace

Methods for first order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying 1st order linear 
<- 1st order linear successful
 

Maple step by step

Let’s solvex(ddxy(x))+ny(x)=xnHighest derivative means the order of the ODE is1ddxy(x)Solve for the highest derivativeddxy(x)=ny(x)+xnxCollect w.r.t.y(x)and simplifyddxy(x)=ny(x)x+xnxGroup terms withy(x)on the lhs of the ODE and the rest on the rhs of the ODEddxy(x)+ny(x)x=xnxThe ODE is linear; multiply by an integrating factorμ(x)μ(x)(ddxy(x)+ny(x)x)=μ(x)xnxAssume the lhs of the ODE is the total derivativeddx(y(x)μ(x))μ(x)(ddxy(x)+ny(x)x)=(ddxy(x))μ(x)+y(x)(ddxμ(x))Isolateddxμ(x)ddxμ(x)=μ(x)nxSolve to find the integrating factorμ(x)=xnIntegrate both sides with respect tox(ddx(y(x)μ(x)))dx=μ(x)xnxdx+C1Evaluate the integral on the lhsy(x)μ(x)=μ(x)xnxdx+C1Solve fory(x)y(x)=μ(x)xnxdx+C1μ(x)Substituteμ(x)=xny(x)=(xn)2xdx+C1xnEvaluate the integrals on the rhsy(x)=(xn)22n+C1xnSimplifyy(x)=xn2n+xnC1
Mathematica. Time used: 0.049 (sec). Leaf size: 24
ode=x*D[y[x],x]+n*y[x]==x^n; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
y(x)xn2n+c1xn
Sympy. Time used: 0.230 (sec). Leaf size: 20
from sympy import * 
x = symbols("x") 
n = symbols("n") 
y = Function("y") 
ode = Eq(n*y(x) + x*Derivative(y(x), x) - x**n,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
y(x)=C1enlog(x)+enlog(x)2n