1.40 problem 41

1.40.1 Solving as homogeneousTypeD2 ode
1.40.2 Solving as exact ode
1.40.3 Solving as riccati ode
1.40.4 Maple step by step solution

Internal problem ID [3185]
Internal file name [OUTPUT/2677_Sunday_June_05_2022_08_38_40_AM_78153908/index.tex]

Book: Differential equations for engineers by Wei-Chau XIE, Cambridge Press 2010
Section: Chapter 2. First-Order and Simple Higher-Order Differential Equations. Page 78
Problem number: 41.
ODE order: 1.
ODE degree: 1.

The type(s) of ODE detected by this program : "riccati", "exactByInspection", "homogeneousTypeD2"

Maple gives the following as the ode type

[[_homogeneous, `class D`], _rational, _Riccati]

\[ \boxed {y+y^{2}-y^{\prime } x=-x^{2}} \]

1.40.1 Solving as homogeneousTypeD2 ode

Using the change of variables \(y = u \left (x \right ) x\) on the above ode results in new ode in \(u \left (x \right )\) \begin {align*} u \left (x \right ) x +u \left (x \right )^{2} x^{2}-\left (u^{\prime }\left (x \right ) x +u \left (x \right )\right ) x = -x^{2} \end {align*}

Integrating both sides gives \begin {align*} \int \frac {1}{u^{2}+1}d u &= x +c_{2}\\ \arctan \left (u \right )&=x +c_{2} \end {align*}

Solving for \(u\) gives these solutions \begin {align*} u_1&=\tan \left (x +c_{2} \right ) \end {align*}

Therefore the solution \(y\) is \begin {align*} y&=x u\\ &=x \tan \left (x +c_{2} \right ) \end {align*}

Summary

The solution(s) found are the following \begin{align*} \tag{1} y &= x \tan \left (x +c_{2} \right ) \\ \end{align*}

Figure 63: Slope field plot

Verification of solutions

\[ y = x \tan \left (x +c_{2} \right ) \] Verified OK.

1.40.2 Solving as exact ode

Entering Exact first order ODE solver. (Form one type)

To solve an ode of the form\begin {equation} M\left ( x,y\right ) +N\left ( x,y\right ) \frac {dy}{dx}=0\tag {A} \end {equation} We assume there exists a function \(\phi \left ( x,y\right ) =c\) where \(c\) is constant, that satisfies the ode. Taking derivative of \(\phi \) w.r.t. \(x\) gives\[ \frac {d}{dx}\phi \left ( x,y\right ) =0 \] Hence\begin {equation} \frac {\partial \phi }{\partial x}+\frac {\partial \phi }{\partial y}\frac {dy}{dx}=0\tag {B} \end {equation} Comparing (A,B) shows that\begin {align*} \frac {\partial \phi }{\partial x} & =M\\ \frac {\partial \phi }{\partial y} & =N \end {align*}

But since \(\frac {\partial ^{2}\phi }{\partial x\partial y}=\frac {\partial ^{2}\phi }{\partial y\partial x}\) then for the above to be valid, we require that\[ \frac {\partial M}{\partial y}=\frac {\partial N}{\partial x}\] If the above condition is satisfied, then the original ode is called exact. We still need to determine \(\phi \left ( x,y\right ) \) but at least we know now that we can do that since the condition \(\frac {\partial ^{2}\phi }{\partial x\partial y}=\frac {\partial ^{2}\phi }{\partial y\partial x}\) 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 \[ M(x,y) \mathop {\mathrm {d}x}+ N(x,y) \mathop {\mathrm {d}y}=0 \tag {1A} \] Therefore \begin {align*} \left (-x\right )\mathop {\mathrm {d}y} &= \left (-x^{2}-y^{2}-y\right )\mathop {\mathrm {d}x}\\ \left (x^{2}+y^{2}+y\right )\mathop {\mathrm {d}x} + \left (-x\right )\mathop {\mathrm {d}y} &= 0 \tag {2A} \end {align*}

Comparing (1A) and (2A) shows that \begin {align*} M(x,y) &= x^{2}+y^{2}+y\\ N(x,y) &= -x \end {align*}

The next step is to determine if the ODE is is exact or not. The ODE is exact when the following condition is satisfied \[ \frac {\partial M}{\partial y} = \frac {\partial N}{\partial x} \] Using result found above gives \begin {align*} \frac {\partial M}{\partial y} &= \frac {\partial }{\partial y} \left (x^{2}+y^{2}+y\right )\\ &= 2 y +1 \end {align*}

And \begin {align*} \frac {\partial N}{\partial x} &= \frac {\partial }{\partial x} \left (-x\right )\\ &= -1 \end {align*}

Since \(\frac {\partial M}{\partial y} \neq \frac {\partial N}{\partial x}\), then the ODE is not exact. By inspection \(\frac {1}{y^{2}+x^{2}}\) is an integrating factor. Therefore by multiplying \(M=x^{2}+y+y^{2}\) and \(N=-x\) by this integrating factor the ode becomes exact. The new \(M,N\) are \begin{align*} M&=\frac {x^{2}+y+y^{2}}{y^{2}+x^{2}} \\ N&=-\frac {x}{y^{2}+x^{2}} \\ \end{align*}

To solve an ode of the form\begin {equation} M\left ( x,y\right ) +N\left ( x,y\right ) \frac {dy}{dx}=0\tag {A} \end {equation} We assume there exists a function \(\phi \left ( x,y\right ) =c\) where \(c\) is constant, that satisfies the ode. Taking derivative of \(\phi \) w.r.t. \(x\) gives\[ \frac {d}{dx}\phi \left ( x,y\right ) =0 \] Hence\begin {equation} \frac {\partial \phi }{\partial x}+\frac {\partial \phi }{\partial y}\frac {dy}{dx}=0\tag {B} \end {equation} Comparing (A,B) shows that\begin {align*} \frac {\partial \phi }{\partial x} & =M\\ \frac {\partial \phi }{\partial y} & =N \end {align*}

But since \(\frac {\partial ^{2}\phi }{\partial x\partial y}=\frac {\partial ^{2}\phi }{\partial y\partial x}\) then for the above to be valid, we require that\[ \frac {\partial M}{\partial y}=\frac {\partial N}{\partial x}\] If the above condition is satisfied, then the original ode is called exact. We still need to determine \(\phi \left ( x,y\right ) \) but at least we know now that we can do that since the condition \(\frac {\partial ^{2}\phi }{\partial x\partial y}=\frac {\partial ^{2}\phi }{\partial y\partial x}\) 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 \[ M(x,y) \mathop {\mathrm {d}x}+ N(x,y) \mathop {\mathrm {d}y}=0 \tag {1A} \] Therefore \begin {align*} \left (-\frac {x}{x^{2}+y^{2}}\right )\mathop {\mathrm {d}y} &= \left (-\frac {x^{2}+y^{2}+y}{x^{2}+y^{2}}\right )\mathop {\mathrm {d}x}\\ \left (\frac {x^{2}+y^{2}+y}{x^{2}+y^{2}}\right )\mathop {\mathrm {d}x} + \left (-\frac {x}{x^{2}+y^{2}}\right )\mathop {\mathrm {d}y} &= 0 \tag {2A} \end {align*}

Comparing (1A) and (2A) shows that \begin {align*} M(x,y) &= \frac {x^{2}+y^{2}+y}{x^{2}+y^{2}}\\ N(x,y) &= -\frac {x}{x^{2}+y^{2}} \end {align*}

The next step is to determine if the ODE is is exact or not. The ODE is exact when the following condition is satisfied \[ \frac {\partial M}{\partial y} = \frac {\partial N}{\partial x} \] Using result found above gives \begin {align*} \frac {\partial M}{\partial y} &= \frac {\partial }{\partial y} \left (\frac {x^{2}+y^{2}+y}{x^{2}+y^{2}}\right )\\ &= \frac {x^{2}-y^{2}}{\left (x^{2}+y^{2}\right )^{2}} \end {align*}

And \begin {align*} \frac {\partial N}{\partial x} &= \frac {\partial }{\partial x} \left (-\frac {x}{x^{2}+y^{2}}\right )\\ &= \frac {x^{2}-y^{2}}{\left (x^{2}+y^{2}\right )^{2}} \end {align*}

Since \(\frac {\partial M}{\partial y}= \frac {\partial N}{\partial x}\), then the ODE is exact The following equations are now set up to solve for the function \(\phi \left (x,y\right )\) \begin {align*} \frac {\partial \phi }{\partial x } &= M\tag {1} \\ \frac {\partial \phi }{\partial y } &= N\tag {2} \end {align*}

Integrating (1) w.r.t. \(x\) gives \begin{align*} \int \frac {\partial \phi }{\partial x} \mathop {\mathrm {d}x} &= \int M\mathop {\mathrm {d}x} \\ \int \frac {\partial \phi }{\partial x} \mathop {\mathrm {d}x} &= \int \frac {x^{2}+y^{2}+y}{x^{2}+y^{2}}\mathop {\mathrm {d}x} \\ \tag{3} \phi &= x +\arctan \left (\frac {x}{y}\right )+ f(y) \\ \end{align*} Where \(f(y)\) is used for the constant of integration since \(\phi \) is a function of both \(x\) and \(y\). Taking derivative of equation (3) w.r.t \(y\) gives \begin{align*} \tag{4} \frac {\partial \phi }{\partial y} &= -\frac {x}{y^{2} \left (\frac {x^{2}}{y^{2}}+1\right )}+f'(y) \\ &=-\frac {x}{x^{2}+y^{2}}+f'(y) \\ \end{align*} But equation (2) says that \(\frac {\partial \phi }{\partial y} = -\frac {x}{x^{2}+y^{2}}\). Therefore equation (4) becomes \begin{equation} \tag{5} -\frac {x}{x^{2}+y^{2}} = -\frac {x}{x^{2}+y^{2}}+f'(y) \end{equation} Solving equation (5) for \( f'(y)\) gives \[ f'(y) = 0 \] Therefore \[ f(y) = c_{1} \] Where \(c_{1}\) is constant of integration. Substituting this result for \(f(y)\) into equation (3) gives \(\phi \) \[ \phi = x +\arctan \left (\frac {x}{y}\right )+ c_{1} \] But since \(\phi \) itself is a constant function, then let \(\phi =c_{2}\) where \(c_{2}\) is new constant and combining \(c_{1}\) and \(c_{2}\) constants into new constant \(c_{1}\) gives the solution as \[ c_{1} = x +\arctan \left (\frac {x}{y}\right ) \] The solution becomes\[ y = \frac {x}{\tan \left (-x +c_{1} \right )} \]

Summary

The solution(s) found are the following \begin{align*} \tag{1} y &= \frac {x}{\tan \left (-x +c_{1} \right )} \\ \end{align*}

Figure 64: Slope field plot

Verification of solutions

\[ y = \frac {x}{\tan \left (-x +c_{1} \right )} \] Verified OK.

1.40.3 Solving as riccati ode

In canonical form the ODE is \begin {align*} y' &= F(x,y)\\ &= \frac {x^{2}+y^{2}+y}{x} \end {align*}

This is a Riccati ODE. Comparing the ODE to solve \[ y' = x +\frac {y^{2}}{x}+\frac {y}{x} \] With Riccati ODE standard form \[ y' = f_0(x)+ f_1(x)y+f_2(x)y^{2} \] Shows that \(f_0(x)=x\), \(f_1(x)=\frac {1}{x}\) and \(f_2(x)=\frac {1}{x}\). Let \begin {align*} y &= \frac {-u'}{f_2 u} \\ &= \frac {-u'}{\frac {u}{x}} \tag {1} \end {align*}

Using the above substitution in the given ODE results (after some simplification)in a second order ODE to solve for \(u(x)\) which is \begin {align*} f_2 u''(x) -\left ( f_2' + f_1 f_2 \right ) u'(x) + f_2^2 f_0 u(x) &= 0 \tag {2} \end {align*}

But \begin {align*} f_2' &=-\frac {1}{x^{2}}\\ f_1 f_2 &=\frac {1}{x^{2}}\\ f_2^2 f_0 &=\frac {1}{x} \end {align*}

Substituting the above terms back in equation (2) gives \begin {align*} \frac {u^{\prime \prime }\left (x \right )}{x}+\frac {u \left (x \right )}{x} &=0 \end {align*}

Solving the above ODE (this ode solved using Maple, not this program), gives

\[ u \left (x \right ) = c_{1} \sin \left (x \right )+c_{2} \cos \left (x \right ) \] The above shows that \[ u^{\prime }\left (x \right ) = c_{1} \cos \left (x \right )-c_{2} \sin \left (x \right ) \] Using the above in (1) gives the solution \[ y = -\frac {\left (c_{1} \cos \left (x \right )-c_{2} \sin \left (x \right )\right ) x}{c_{1} \sin \left (x \right )+c_{2} \cos \left (x \right )} \] Dividing both numerator and denominator by \(c_{1}\) gives, after renaming the constant \(\frac {c_{2}}{c_{1}}=c_{3}\) the following solution

\[ y = \frac {x \left (-c_{3} \cos \left (x \right )+\sin \left (x \right )\right )}{c_{3} \sin \left (x \right )+\cos \left (x \right )} \]

Summary

The solution(s) found are the following \begin{align*} \tag{1} y &= \frac {x \left (-c_{3} \cos \left (x \right )+\sin \left (x \right )\right )}{c_{3} \sin \left (x \right )+\cos \left (x \right )} \\ \end{align*}

Figure 65: Slope field plot

Verification of solutions

\[ y = \frac {x \left (-c_{3} \cos \left (x \right )+\sin \left (x \right )\right )}{c_{3} \sin \left (x \right )+\cos \left (x \right )} \] Verified OK.

1.40.4 Maple step by step solution

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & y+y^{2}-y^{\prime } x =-x^{2} \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 1 \\ {} & {} & y^{\prime } \\ \bullet & {} & \textrm {Solve for the highest derivative}\hspace {3pt} \\ {} & {} & y^{\prime }=\frac {x^{2}+y+y^{2}}{x} \end {array} \]

Maple trace

`Methods for first order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying 1st order linear 
trying Bernoulli 
trying separable 
trying inverse linear 
trying homogeneous types: 
trying homogeneous D 
<- homogeneous successful`
 

Solution by Maple

Time used: 0.0 (sec). Leaf size: 10

dsolve((x^2+y(x)+y(x)^2)-x*diff(y(x),x)=0,y(x), singsol=all)
 

\[ y \left (x \right ) = \tan \left (c_{1} +x \right ) x \]

Solution by Mathematica

Time used: 0.207 (sec). Leaf size: 12

DSolve[(x^2+y[x]+y[x]^2)-x*y'[x]==0,y[x],x,IncludeSingularSolutions -> True]
 

\[ y(x)\to x \tan (x+c_1) \]