2.4.1 Problem 1

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

Internal problem ID [18481]
Book : Elementary Differential Equations. By Thornton C. Fry. D Van Nostrand. NY. First Edition (1929)
Section : Chapter IV. Methods of solution: First order equations. section 31. Problems at page 85
Problem number : 1
Date solved : Monday, March 31, 2025 at 05:36:25 PM
CAS classification : [_separable]

Solved using first_order_ode_separable

Time used: 0.072 (sec)

Solve

y+xy=x

The ode

(1)y=xy+x

is separable as it can be written as

y=xy+x=f(x)g(y)

Where

f(x)=xg(y)=y+1

Integrating gives

1g(y)dy=f(x)dx1y+1dy=xdx
ln(y1)=x22+c1

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

y+1=0

for y gives

y=1

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

ln(y1)=x22+c1y=1

Solving for y gives

y=1y=ex22c1+1
Figure 2.38: Slope field y+xy=x

Summary of solutions found

y=1y=ex22c1+1
Solved using first_order_ode_linear

Time used: 0.047 (sec)

Solve

y+xy=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)=xp(x)=x

The integrating factor μ is

μ=eqdx=exdx=ex22

The ode becomes

ddx(μy)=μpddx(μy)=(μ)(x)ddx(yex22)=(ex22)(x)d(yex22)=(xex22)dx

Integrating gives

yex22=xex22dx=ex22+c2

Dividing throughout by the integrating factor ex22 gives the final solution

y=ex22c2+1
Figure 2.39: Slope field y+xy=x

Summary of solutions found

y=ex22c2+1
Solved using first_order_ode_exact

Time used: 0.086 (sec)

Solve

y+xy=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

dy=(xy+x)dx(2A)(xyx)dx+dy=0

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

M(x,y)=xyxN(x,y)=1

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

And

Nx=x(1)=0

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

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

μ=eAdx=exdx

The result of integrating gives

μ=ex22=ex22

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=ex22(xyx)=x(y1)ex22

And

N=μN=ex22(1)=ex22

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

M+Ndydx=0(x(y1)ex22)+(ex22)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=ex22dy(3)ϕ=yex22+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=yxex22+f(x)

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

(5)x(y1)ex22=yxex22+f(x)

Solving equation (5) for f(x) gives

f(x)=xex22

Integrating the above w.r.t x gives

f(x)dx=(xex22)dxf(x)=ex22+c3

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

ϕ=yex22ex22+c3

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

c3=yex22ex22

Solving for y gives

y=(ex22+c3)ex22

Which simplifies to

y=ex22c3+1
Figure 2.40: Slope field y+xy=x

Summary of solutions found

y=ex22c3+1
Solved using first_order_ode_LIE

Time used: 0.177 (sec)

Solve

y+xy=x

Writing the ode as

y=xy+xy=ω(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+(xy+x)(b3a2)(xy+x)2a3(y+1)(xa2+ya3+a1)+x(xb2+yb3+b1)=0

Putting the above in normal form gives

x2y2a3+2x2ya3x2a3+x2b2+2xya2+y2a32xa2+xb1+xb3+ya1ya3a1+b2=0

Setting the numerator to zero gives

(6E)x2y2a3+2x2ya3x2a3+x2b2+2xya2+y2a32xa2+xb1+xb3+ya1ya3a1+b2=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)a3v12v22+2a3v12v2+2a2v1v2a3v12+a3v22+b2v12+a1v22a2v1a3v2+b1v1+b3v1a1+b2=0

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

{v1,v2}

Equation (7E) now becomes

(8E)a3v12v22+2a3v12v2+(a3+b2)v12+2a2v1v2+(2a2+b1+b3)v1+a3v22+(a1a3)v2a1+b2=0

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

a3=02a2=0a3=02a3=0a1+b2=0a1a3=0a3+b2=02a2+b1+b3=0

Solving the above equations for the unknowns gives

a1=0a2=0a3=0b1=b3b2=0b3=b3

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

ξ=0η=y1

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=1y1dy

Which results in

S=ln(y1)

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)=xy+x

Evaluating all the partial derivatives gives

Rx=1Ry=0Sx=0Sy=1y1

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

(2A)dSdR=x

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=R

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=RdRS(R)=R22+c6

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

ln(y1)=x22+c6

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=xy+x

dSdR=R

R=xS=ln(y1)

Solving for y gives

y=ex22+c6+1
Figure 2.41: Slope field y+xy=x

Summary of solutions found

y=ex22+c6+1
Maple. Time used: 0.001 (sec). Leaf size: 14
ode:=diff(y(x),x)+x*y(x) = x; 
dsolve(ode,y(x), singsol=all);
 
y=1+ex22c1

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 solveddxy(x)+xy(x)=xHighest derivative means the order of the ODE is1ddxy(x)Solve for the highest derivativeddxy(x)=xy(x)+xSeparate variablesddxy(x)y(x)1=xIntegrate both sides with respect toxddxy(x)y(x)1dx=xdx+C1Evaluate integralln(y(x)1)=x22+C1Solve fory(x)y(x)=ex22+C1+1Redefine the integration constant(s)y(x)=C1ex22+1
Mathematica. Time used: 0.062 (sec). Leaf size: 24
ode=D[y[x],x]+x*y[x]==x; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
y(x)1+c1ex22y(x)1
Sympy. Time used: 0.263 (sec). Leaf size: 12
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(x*y(x) - x + Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
y(x)=C1ex22+1