4
$\begingroup$

I'm trying to solve

    DSolve[f[x]*(x^2*g''[x] - 2*g[x] + 2) + x*(x*g'[x] - 2*g[x])*f'[x] == 0, g[x], x]  

for $g(x)$, however Mathematica cannot find a solution. It can find a solution for $f(x)$ but it is rather complicated. I tried a little bit to solve it by hand and after some manipulations i found that

$$g(x) = x^2 \left(a+\int \frac{b-\int 2 f(x) \, dx}{x^4 f(x)} \, dx\right)$$

where $a,b$ are constants, which satisfies the differential equation. I would like to ask why Mathematica cannot integrate this? Is there somehting wrong that i'm doing? Can i force somehow Mathematica to solve this?

$\endgroup$
2
  • $\begingroup$ Maybe you need 2 equations in order to find 2 functions? $\endgroup$
    – yarchik
    Commented Oct 16, 2021 at 7:16
  • $\begingroup$ I know that, but i want to solve it in a generally first. $\endgroup$
    – bloom
    Commented Oct 16, 2021 at 7:18

1 Answer 1

4
$\begingroup$

Mathematica can do it, if you move the term $2 f(x)$ to the RHS !

Clear["Global`*"]
ode = f[x]*(x^2*g''[x] - 2*g[x] + 2) + x*(x*g'[x] - 2*g[x])*f'[x] == 0
lhs = ode[[1]] - 2*f[x]
rhs = ode[[2]] + 2*f[x]

(*make it first order ODE*)
newOde = ApplySides[Integrate[#, x] &, lhs == rhs];

Mathematica graphics

(*Now it can solve it*)
DSolve[newOde, g[x], x]

Mathematica graphics

Mathematica should have been able to do it. btw, I do not see an a and b in your ode.

$\endgroup$
3
  • $\begingroup$ Thank you!!! This is actually the way i integrated by hand. $a,b$ are constants of integration. Is there any general method to solve equations like this? In this case, it seems that we need to create a total differential and then Mathematica can solve it. If we cannot create a total differential how can we solve something like this? $\endgroup$
    – bloom
    Commented Oct 16, 2021 at 8:53
  • 1
    $\begingroup$ @ApolloRa DSolve should have been able to do this. May be in V13 which will be released soon). I do not have a general method to workaround this for all cases other than moving the unknown function to the RHS manually if it an isolated term like in your example and then integrate both sides. This trick happened to work for your example since the LHS was integrable after moving $2 f(x)$ to the RHS. THis might not be the case for other examples. May be you can report this to WRI. $\endgroup$
    – Nasser
    Commented Oct 16, 2021 at 9:18
  • $\begingroup$ Ok! Thank you again for your help!!! $\endgroup$
    – bloom
    Commented Oct 16, 2021 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.