# How to find real subspace of solutions to differential equation?

I have the following differential equation

$$\sqrt{f(x)}-a \frac{f'(x)}{f(x)}+b \frac{1}{x}=c$$

where $$a,b,c>0$$ and I am interested in the solutions for $$x<0$$. DSolve gives me an analytic result, but for generic values of the integration constant it is complex. I wonder how I can find out for which values the solutions are real?

assumptions = {a > 0, b > 0, c > 0, x < 0};
numbers = {a -> 1, b -> 3, c -> 2, C[1] -> -2};
f[x] /. DSolve[Sqrt[f[x]] - a f'[x]/f[x] + b/x == c, f[x], x,
Assumptions -> assumptions] // First // FullSimplify
Plot[{Re[%], Im[%]} /. numbers // Evaluate, {x, -10, 0}]


The output is

• $b=2ka, k\in\mathbb N$ Jul 31, 2023 at 20:08

\$Version

(* "13.3.0 for Mac OS X ARM (64-bit) (June 3, 2023)" *)

Clear["Global*"]

assumptions = {a > 0, b > 0, c > 0, x < 0};
numbers = {a -> 1, b -> 3, c -> 2, C[1] -> -2};

expr1 = f[x] /.
DSolve[Sqrt[f[x]] - a f'[x]/f[x] + b/x == c, f[x], x,
Assumptions -> assumptions] // First // FullSimplify


The assumptions also can be used by FullSimplify. Use an Assuming construct to make the assumptions available to all enclosed functions.

expr2 = Assuming[assumptions,
f[x] /. DSolve[Sqrt[f[x]] - a f'[x]/f[x] + b/x == c, f[x], x] // First //
FullSimplify]


Use FunctionDomain to determine the conditions for the expression to be real.

Assuming[assumptions,
FunctionDomain[expr2, x] // FullSimplify]
`