2.1.7 Problem 2(a)

Solved using first_order_ode_linear
Solved using first_order_ode_homog_A
Solved using first_order_ode_homog_type_D2
Solved using first_order_ode_homog_type_maple_C
Solved using first_order_ode_exact
Solved using first_order_ode_isobaric
Solved using first_order_ode_LIE
Maple
Mathematica
Sympy

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

Solved using first_order_ode_linear

Time used: 0.034 (sec)

Solve

xy+y=x

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)=1xp(x)=1

The integrating factor μ is

μ=eqdx=e1xdx=x

The ode becomes

ddx(μy)=μddx(yx)=xd(yx)=xdx

Integrating gives

yx=xdx=x22+c1

Dividing throughout by the integrating factor x gives the final solution

y=x2+2c12x
Figure 2.18: Slope field xy+y=x

Summary of solutions found

y=x2+2c12x
Solved using first_order_ode_homog_A

Time used: 0.173 (sec)

Solve

xy+y=x

In canonical form, the ODE is

y=F(x,y)(1)=yxx

An ode of the form y=M(x,y)N(x,y) is called homogeneous if the functions M(x,y) and N(x,y) are both homogeneous functions and of the same order. Recall that a function f(x,y) is homogeneous of order n if

f(tnx,tny)=tnf(x,y)

In this case, it can be seen that both M=y+x and N=x are both homogeneous and of the same order n=1. Therefore this is a homogeneous ode. Since this ode is homogeneous, it is converted to separable ODE using the substitution u=yx, or y=ux. Hence

dydx=dudxx+u

Applying the transformation y=ux to the above ODE in (1) gives

dudxx+u=1ududx=12u(x)x

Or

u(x)12u(x)x=0

Or

u(x)x+2u(x)1=0

Which is now solved as separable in u(x).

The ode

(1)u(x)=2u(x)1x

is separable as it can be written as

u(x)=2u(x)1x=f(x)g(u)

Where

f(x)=1xg(u)=2u+1

Integrating gives

1g(u)du=f(x)dx12u+1du=1xdx
ln(2u(x)1)2=ln(x)+c2

Taking the exponential of both sides the solution becomes

12u(x)1=c2x

We now need to find the singular solutions, these are found by finding for what values g(u) is zero, since we had to divide by this above. Solving g(u)=0 or

2u+1=0

for u(x) gives

u(x)=12

Now we go over each such singular solution and check if it verifies the ode itself and any initial conditions given. If it does not then the singular solution will not be used.

Therefore the solutions found are

12u(x)1=c2xu(x)=12

Converting 12u(x)1=c2x back to y gives

12y+xx=c2x

Converting u(x)=12 back to y gives

y=x2

Which simplifies to

12yxx=c2xy=x2
Figure 2.19: Slope field xy+y=x

Summary of solutions found

12yxx=c2xy=x2
Solved using first_order_ode_homog_type_D2

Time used: 0.055 (sec)

Solve

xy+y=x

Applying change of variables y=u(x)x, then the ode becomes

x(u(x)x+u(x))+u(x)x=x

Which is now solved The ode

(2)u(x)=2u(x)1x

is separable as it can be written as

u(x)=2u(x)1x=f(x)g(u)

Where

f(x)=1xg(u)=2u+1

Integrating gives

1g(u)du=f(x)dx12u+1du=1xdx
ln(2u(x)1)2=ln(x)+c3

Taking the exponential of both sides the solution becomes

12u(x)1=c3x

We now need to find the singular solutions, these are found by finding for what values g(u) is zero, since we had to divide by this above. Solving g(u)=0 or

2u+1=0

for u(x) gives

u(x)=12

Now we go over each such singular solution and check if it verifies the ode itself and any initial conditions given. If it does not then the singular solution will not be used.

Therefore the solutions found are

12u(x)1=c3xu(x)=12

Converting 12u(x)1=c3x back to y gives

12yx1=c3x

Converting u(x)=12 back to y gives

y=x2

Which simplifies to

12yxx=c3xy=x2
Figure 2.20: Slope field xy+y=x

Summary of solutions found

12yxx=c3xy=x2
Solved using first_order_ode_homog_type_maple_C

Time used: 0.245 (sec)

Solve

xy+y=x

Let Y=yy0 and X=xx0 then the above is transformed to new ode in Y(X)

ddXY(X)=Y(X)+y0Xx0X+x0

Solving for possible values of x0 and y0 which makes the above ode a homogeneous ode results in

x0=0y0=0

Using these values now it is possible to easily solve for Y(X). The above ode now becomes

ddXY(X)=Y(X)XX

In canonical form, the ODE is

Y=F(X,Y)(1)=YXX

An ode of the form Y=M(X,Y)N(X,Y) is called homogeneous if the functions M(X,Y) and N(X,Y) are both homogeneous functions and of the same order. Recall that a function f(X,Y) is homogeneous of order n if

f(tnX,tnY)=tnf(X,Y)

In this case, it can be seen that both M=XY and N=X are both homogeneous and of the same order n=1. Therefore this is a homogeneous ode. Since this ode is homogeneous, it is converted to separable ODE using the substitution u=YX, or Y=uX. Hence

dYdX=dudXX+u

Applying the transformation Y=uX to the above ODE in (1) gives

dudXX+u=u+1dudX=2u(X)+1X

Or

ddXu(X)2u(X)+1X=0

Or

(ddXu(X))X+2u(X)1=0

Which is now solved as separable in u(X).

The ode

(3)ddXu(X)=2u(X)1X

is separable as it can be written as

ddXu(X)=2u(X)1X=f(X)g(u)

Where

f(X)=1Xg(u)=2u+1

Integrating gives

1g(u)du=f(X)dX12u+1du=1XdX
ln(2u(X)1)2=ln(X)+c4

Taking the exponential of both sides the solution becomes

12u(X)1=c4X

We now need to find the singular solutions, these are found by finding for what values g(u) is zero, since we had to divide by this above. Solving g(u)=0 or

2u+1=0

for u(X) gives

u(X)=12

Now we go over each such singular solution and check if it verifies the ode itself and any initial conditions given. If it does not then the singular solution will not be used.

Therefore the solutions found are

12u(X)1=c4Xu(X)=12

Converting 12u(X)1=c4X back to Y(X) gives

12Y(X)+XX=c4X

Converting u(X)=12 back to Y(X) gives

Y(X)=X2

Using the solution for Y(X)

(A)12Y(X)+XX=c4X

And replacing back terms in the above solution using

Y=y+y0X=x0+x

Or

Y=yX=x

Then the solution in y becomes using EQ (A)

12y+xx=c4x

Using the solution for Y(X)

(A)Y(X)=X2

And replacing back terms in the above solution using

Y=y+y0X=x0+x

Or

Y=yX=x

Then the solution in y becomes using EQ (A)

y=x2

Which simplifies to

12yxx=c4xy=x2
Figure 2.21: Slope field xy+y=x

Summary of solutions found

12yxx=c4xy=x2
Solved using first_order_ode_exact

Time used: 0.057 (sec)

Solve

xy+y=x

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=(y+x)dx(2A)(yx)dx+(x)dy=0

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

M(x,y)=yxN(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(yx)=1

And

Nx=x(x)=1

Since My=Nx, then the ODE is exact 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=xdy(3)ϕ=yx+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=y+f(x)

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

(5)yx=y+f(x)

Solving equation (5) for f(x) gives

f(x)=x

Integrating the above w.r.t x gives

f(x)dx=(x)dxf(x)=x22+c5

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

ϕ=yx12x2+c5

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

c5=yx12x2

Solving for y gives

y=x2+2c52x
Figure 2.22: Slope field xy+y=x

Summary of solutions found

y=x2+2c52x
Solved using first_order_ode_isobaric

Time used: 0.102 (sec)

Solve

xy+y=x

Solving for y gives

(1)y=yxx

Each of the above ode’s is now solved An ode y=f(x,y) is isobaric if

(1)f(tx,tmy)=tm1f(x,y)

Where here

(2)f(x,y)=yxx

m is the order of isobaric. Substituting (2) into (1) and solving for m gives

m=1

Since the ode is isobaric of order m=1, then the substitution

y=uxm=ux

Converts the ODE to a separable in u(x). Performing this substitution gives

u(x)+xu(x)=xu(x)xx

The ode

(4)u(x)=2u(x)1x

is separable as it can be written as

u(x)=2u(x)1x=f(x)g(u)

Where

f(x)=1xg(u)=2u+1

Integrating gives

1g(u)du=f(x)dx12u+1du=1xdx
ln(2u(x)1)2=ln(x)+c7

Taking the exponential of both sides the solution becomes

12u(x)1=c7x

We now need to find the singular solutions, these are found by finding for what values g(u) is zero, since we had to divide by this above. Solving g(u)=0 or

2u+1=0

for u(x) gives

u(x)=12

Now we go over each such singular solution and check if it verifies the ode itself and any initial conditions given. If it does not then the singular solution will not be used.

Therefore the solutions found are

12u(x)1=c7xu(x)=12

Converting 12u(x)1=c7x back to y gives

12yx1=c7x

Converting u(x)=12 back to y gives

yx=12

Solving for y gives

12yx1=c7xy=x2

Which simplifies to

12yxx=c7xy=x2
Figure 2.23: Slope field xy+y=x

Summary of solutions found

12yxx=c7xy=x2
Solved using first_order_ode_LIE

Time used: 0.238 (sec)

Solve

xy+y=x

Writing the ode as

y=yxxy=ω(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(yx)(b3a2)x(yx)2a3x2(1x+yxx2)(xa2+ya3+a1)+xb2+yb3+b1x=0

Putting the above in normal form gives

x2a2+x2a32b2x2x2b32xya3+2y2a3xb1+ya1x2=0

Setting the numerator to zero gives

(6E)x2a2x2a3+2b2x2+x2b3+2xya32y2a3+xb1ya1=0

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

{x,y}

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

{x=v1,y=v2}

The above PDE (6E) now becomes

(7E)a2v12a3v12+2a3v1v22a3v22+2b2v12+b3v12a1v2+b1v1=0

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

{v1,v2}

Equation (7E) now becomes

(8E)(a2a3+2b2+b3)v12+2a3v1v2+b1v12a3v22a1v2=0

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

b1=0a1=02a3=02a3=0a2a3+2b2+b3=0

Solving the above equations for the unknowns gives

a1=0a2=2b2+b3a3=0b1=0b2=b2b3=b3

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

ξ=xη=y

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

η=ηω(x,y)ξ=y(yxx)(x)=2yxξ=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=12yxdy

Which results in

S=ln(2yx)2

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)=yxx

Evaluating all the partial derivatives gives

Rx=1Ry=0Sx=12x4ySy=12yx

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+c9

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

ln(2yx)2=ln(x)2+c9

The following diagram shows solution curves of the original ode and how they transform in the canonical coordinates space using the mapping shown.

Original ode in x,y coordinates

Canonical coordinates transformation

ODE in canonical coordinates (R,S)

dydx=yxx

dSdR=12R

R=xS=ln(2yx)2

Solving for y gives

y=x2+e2c92x
Figure 2.24: Slope field xy+y=x

Summary of solutions found

y=x2+e2c92x
Maple. Time used: 0.001 (sec). Leaf size: 13
ode:=x*diff(y(x),x)+y(x) = x; 
dsolve(ode,y(x), singsol=all);
 
y=x2+c1x

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))+y(x)=xHighest derivative means the order of the ODE is1ddxy(x)Isolate the derivativeddxy(x)=1y(x)xGroup terms withy(x)on the lhs of the ODE and the rest on the rhs of the ODEddxy(x)+y(x)x=1The ODE is linear; multiply by an integrating factorμ(x)μ(x)(ddxy(x)+y(x)x)=μ(x)Assume the lhs of the ODE is the total derivativeddx(y(x)μ(x))μ(x)(ddxy(x)+y(x)x)=(ddxy(x))μ(x)+y(x)(ddxμ(x))Isolateddxμ(x)ddxμ(x)=μ(x)xSolve to find the integrating factorμ(x)=xIntegrate both sides with respect tox(ddx(y(x)μ(x)))dx=μ(x)dx+C1Evaluate the integral on the lhsy(x)μ(x)=μ(x)dx+C1Solve fory(x)y(x)=μ(x)dx+C1μ(x)Substituteμ(x)=xy(x)=xdx+C1xEvaluate the integrals on the rhsy(x)=x22+C1xSimplifyy(x)=x2+2C12x
Mathematica. Time used: 0.026 (sec). Leaf size: 17
ode=x*D[y[x],x]+y[x]==x; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
y(x)x2+c1x
Sympy. Time used: 0.152 (sec). Leaf size: 8
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(x*Derivative(y(x), x) - x + y(x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
y(x)=C1x+x2