# What should I learn from DSolve working better with a named constant than a number in this case?

I have an equation $$\bigl(r''(\phi)r(\phi) - r'(\phi)^2\bigr)\bigl(b + r(\phi)\bigr) = r(\phi)\bigl(r'(\phi)^2 + r(\phi)^2\bigr)$$ Here $b$ and $r$ are lengths, and $\phi$ is an angle (in radians, so dimensionless). As recommended in another answer, I rewrite the equation in terms of the dimensionless variable $\tilde{r} = r/b$ by dividing both sides by $b^3$, obtaining $$\bigl(\tilde r''(\phi)\tilde r(\phi) - \tilde r'(\phi)^2\bigr)\bigl(1 + \tilde r(\phi)\bigr) = \tilde r(\phi)\bigl(\tilde r'(\phi)^2 + \tilde r(\phi)^2\bigr)$$ But putting this into Mathematica,

DSolve[(r''[ϕ] r[ϕ] - r'[ϕ]^2) (1 + r[ϕ]) ==
r[ϕ] (r'[ϕ]^2 + r[ϕ]^2), r, ϕ]


yields nothing - it works for a while and then returns the expression unevaluated.

On the other hand, if I put in the original equation, I get a solution reasonably quickly.

DSolve[(r''[ϕ] r[ϕ] - r'[ϕ]^2) (b + r[ϕ]) ==
r[ϕ] (r'[ϕ]^2 + r[ϕ]^2), r, ϕ]


Note that in Mathematica code, this is identical to the previous expression except that 1 has been replaced by b.

The solution (actually two solutions) can be represented as $$r(\phi) = \frac{4 \left(b^2 c_1-1\right)^2}{i \left(1-b^2 c_1\right)^{3/2} e^{\pm i \sqrt{1-b^2 c_1} \left(c_2+\phi \right)}-4 i c_1 \sqrt{1-b^2 c_1} e^{\mp i \sqrt{1-b^2 c_1} \left(c_2+\phi \right)}-4 b c_1 \left(b^2 c_1-1\right)}$$ I find it strange that Mathematica is able to solve the equation with a named constant (b) but not with a number in its place, considering that the switch is unrelated to the dependent and independent variables in the problem, and I see no reason that $b = 1$ prevents the solution from being valid. Am I missing some problem that arises with the solution when $b = 1$?

More importantly, is there a general lesson I can take from this about how to enter equations into Mathematica to give it the best chance of finding a solution?

I'm using version 10.3.0 on Mac OS X El Capitan.

I do note that the solution Mathematica produces is not dimensionally consistent, if one takes $b$ to have dimensions of length, but that's a separate issue.

• I like the way you phrased this question. I remember seeing an instance of this before (where generalizing a diffeq by replacing a number with a symbol worked), but I couldn't find it. Sometimes the generalization works because, as you mentioned, the solution wouldn't be valid at b=1. Substituting the solutions back, it seems to be find though. The lesson I'd learn is that the pattern matcher can only try so many things and sometimes strange things like making the problem harder help it to find a solution. Jan 4 '16 at 15:49
• If you look at the solution, the case where b=1 looks very special and this probably has a lot to do with the behavior. Jan 4 '16 at 15:49
• I would try to investigate the correctness of the generic solution by considering a numerical example. NDSolve readily solves some initial value problems for b=1. Attempts to find corresponding C,C for the generic solution did not prove fruitful, but I didn't work at it too hard. Jan 4 '16 at 15:59
• @Searke well, $b$ always occurs in combination with the arbitrary constant $c_1$. Certainly the case where $b^2 c_1 = 1$ is special, but I don't think that implies anything about merely having $b = 1$. Jan 4 '16 at 16:00
• Here's another example (perhaps the one @Searke was thinking of) where NDSolve returns a useful result for a general case and a less useful result for a specific case: About a simple differential equation. Note, though, that this one had to do with boundary conditions rather than parameters in the ODE itself. Jan 5 '16 at 17:01

In fact, b = 1 is special, at least to DSolve. DSolve returns an answer for any other value of b that I have tried. Further, replacing b by a numerical value very close to 1 yields a surprising (to me) result.

DSolve[{(r''[ϕ] r[ϕ] - r'[ϕ]^2) (1 + 10^-10 + r[ϕ]) == r[ϕ] (r'[ϕ]^2 + r[ϕ]^2)},
r[ϕ], ϕ] // FullSimplify
(* {{r[ϕ] -> (4 E^(I Sqrt[1 - 100000000020000000001 C] (ϕ + C))
(1 - 100000000020000000001 C)^(3/2))/
(I + (-100000000020000000001 I + 40000000000
E^(I Sqrt[1 - 100000000020000000001 C] (ϕ + C))
(-10000000000 I E^(I Sqrt[1 - 100000000020000000001 C] (ϕ + C)) +
10000000001 Sqrt[1 - 100000000020000000001 C])) C)},
{r[ϕ] -> (4 (1 - 100000000020000000001 C)^2)/
(I E^(I Sqrt[1 - 100000000020000000001 C] (ϕ + C))
(1 - 100000000020000000001 C)^(3/2) -
400000000000000000000 I E^(-I Sqrt[1 - 100000000020000000001 C] (ϕ + C))
Sqrt[1 - 100000000020000000001 C] C -
400000000040000000000 C (-1 + 100000000020000000001 C))}} *)


The correspnding answer for 1 + 10^-100 is far longer still, as is the answer for 1 - 10^-100. Whatever DSolve is doing internally, it certainly has singled out b = 1 as something special.

Incidentally,

SetOptions[Solve, Method -> Reduce]


causes DSolve to return unevaluated in the few instances I have tried.

• Weird, but interesting. It kind of looks like the symbolic solution I included in the post, but with $b^2$ replaced by $\frac{1}{(b - 1)^2}$. I guess in that case $b = 1$ clearly would be special. Perhaps this is a separate solution? Jan 5 '16 at 9:50
• Actually, I figured it out: this is the same solution identified in my question, just with a different definition of $c_1$. It differs by a factor of $10^{20}$, as you can show with something like FullSimplify[r[phi]/.mysoln/.b->1+10^-10/.C->10^20C == r[phi]/.yoursoln]. Apparently, when we give b a symbolic value of a certain form, Mathematica absorbs a constant factor into $c_1$ to simplify the result a bit. This particular simplification procedure fails at $b=1$, but the solution itself should be fine. Jan 7 '16 at 15:33
• Interesting. Add it as an answer. Well done. Jan 7 '16 at 17:19
• Oh, sorry if I was misleading: what I figured out is the apparent discrepancy between the partially-numeric solution you put in your answer and the symbolic one in my question. But that leaves me no closer to finding an answer to the original posted question. Jan 7 '16 at 18:14