Second order non linear ODE - hard to solve integral makes me think I need a different substitution

I have this here ODE:

$$xy'' = y' + x((y')^2 + x^2)$$

Naturally, I'd try this substitution first: $$y' = p, p=p(x)$$

The equation then transforms into $$xp' = p+x(p^2+x^2)$$ Dividing it by $$x$$, I get

$$p' = \frac{p}{x} + p^2 + x^2$$

Which is a Riccati equation with the solution: $$p = x \cdot \tan{(\frac{x^2}{2}+C_1)}$$

The thing is, if I substitute back $$y'=p$$, the integral on the right side is not an easy one to solve, and even if I do solve it with WolframAlpha the solutions are not the same as if I plug in the second-order equation directly. It makes me wonder if I should have tried another substitution/method.

Any help will be appreciated!

• @LutzLehmann thanks fixed May 17, 2021 at 14:43
• The equation is of the first order in $y'$.
– user65203
May 17, 2021 at 14:45

$$y' = x \cdot \tan{\left(\frac{x^2}{2}+C\right)}$$ $$\dfrac {dy}{du}\dfrac {du}{dx} = x \cdot \tan(u)$$ $$\dfrac {dy}{du} = \tan(u)$$ Where $$u=\dfrac {x^2}{2}+C$$ then integrate. $$y=-\ln |\cos u |+K$$
You have now a formula of the form $$y'(x)=f(u(x))u'(x)$$ with $$f(u)=\tan(u)$$ and $$u(x)=\frac{x^2}2+c$$. This the gives that $$y(x)=F(u(x))+d,$$ where $$F'=f$$, here $$F(u)=-\ln|\cos(u)|$$
Let $$y'=xz$$. The equation becomes
$$xz+x^2z'=xz+x(x^2z^2+x^2),$$ which is separable:
$$\frac{z'}{z^2+1}=x$$ or $$\arctan z=\frac{x^2}2+c$$ and $$y'=x\tan\left(\frac{x^2}2+c\right)$$ as you found.
Now the integral is not difficult: $$\int x\tan\left(\frac{x^2}2+c\right)dx=\int \tan\left(u+c\right)du=-\log(\cos(u+c))+c'\\ =-\log\left(\cos\left(\frac{x^2}2+c\right)\right)+c'.$$