7
$\begingroup$

I'm trying to solve this differential equation with respect to $x$

$$ \frac{d^2y}{dx^2}-\bigg(\frac{dy}{dx}\bigg)^2-\frac{1}{x}\frac{dy}{dx}=\frac{1}{x^2} $$

With boundary condition $y(1)=2, y'(1)=-2$. Mathematica v10.0.0 was able to produce the correct solution, but with a warning that doesn't make much sense to me

Solve::incnst: "Inconsistent or redundant transcendental equation. After reduction, the bad equation is 1-C[1] == 0"

This is my code

 DSolve[{y''[x] - y'[x]^2 - y'[x]/x == 1/x^2, y[1] == 2, y'[1] == -2},y[x], x]
(*{{y[x] -> 2 - Log[x] - Log[1 + Log[x]]}}*)

Plus, if I substitute $1/x^2$ on the RHS with $a/x^2$, the solution by DSolve won't include the case where $a=1$.

 DSolve[{y''[x] - y'[x]^2 - y'[x]/x == a/x^2}, y[x], x]
 % /. a -> 1
(*{{y[x] -> C[2] + 1/2 (2 (-1 + Sqrt[1 - a]) Log[x] - 2 Log[x^(2 Sqrt[1 - a]) + C[1]])}}*)
(*{{y[x] -> C[2] + 1/2 (-2 Log[x] - 2 Log[1 + C[1]])}}*)

Is this a bug or should it be expected for DSolve?

$\endgroup$
8
$\begingroup$

I get the same message, and have gotten it before, on V10.2. I think it has to do with working out the boundary conditions when the solution & ODE has branch cuts. In this case there appears to be a singularity at a == 1, which needs to be approached via limits. Or so it seems to me.

One workaround is to use Reduce instead of Solve, as I did in Accessing Reduce from DSolve. We get no warning and a slightly different form of the solution.

With[{opts = Options[Solve]},
 Internal`WithLocalSettings[
  SetOptions[Solve, Method -> Reduce],
  {sola} = 
   DSolve[{y''[x] - y'[x]^2 - y'[x]/x == a/x^2, y[1] == 2, y'[1] == -2}, y, x],
  SetOptions[Solve, opts]
  ]
 ]
(*
  {{y -> Function[{x}, 
      2 + Log[1 + (-2 + 2 Sqrt[1 - a] + a)/a] - Log[x] + 
       Sqrt[1 - a] Log[x] - Log[(-2 + 2 Sqrt[1 - a] + a)/a + x^(2 Sqrt[1 - a])]]}}
*)

Check at a -> 1:

Limit[y[x] /. sola, a -> 1]
% // PowerExpand
(*
  2 + (I π)/2 - Log[x] - Log[I (1 + Log[x])]
  2 - Log[x] - Log[1 + Log[x]]
*)

This agrees with solution with a == 1:

With[{opts = Options[Solve]},
 Internal`WithLocalSettings[
  SetOptions[Solve, Method -> Reduce],
  DSolve[{y''[x] - y'[x]^2 - y'[x]/x == 1/x^2, y[1] == 2, y'[1] == -2}, y[x], x],
  SetOptions[Solve, opts]
  ]
 ]
(*
  {{y[x] -> 2 - Log[x] - Log[1 + Log[x]]}}
*)

Note: My experience shows that this approach does not always work when one gets a Solve::incnst message.

$\endgroup$
3
$\begingroup$
eqns1 = {y''[x] - y'[x]^2 - y'[x]/x == 1/x^2, y[1] == 2, y'[1] == -2};

soln1 = DSolve[eqns1, y, x][[1]] // Quiet

(*  {y -> Function[{x}, 2 - Log[x] - Log[1 + Log[x]]]}  *)

Verifing that soln1 satisfies eqns1

And @@ (eqns1 /. soln1 // Simplify)

(*  True  *)

Using your generalization of eqns1

eqns2 = {y''[x] - y'[x]^2 - y'[x]/x == a/x^2, y[1] == 2, y'[1] == -2};

soln2 = DSolve[eqns2, y, x][[1]] // Quiet

(*  {y -> Function[{x}, 
       2 + Log[2 - 2/a + 
             (2*Sqrt[1 - a])/a] - 
         Log[x] + Sqrt[1 - a]*Log[x] - 
         Log[(-2 + 2*Sqrt[1 - a] + a)/
               a + x^(2*Sqrt[1 - a])]]}  *)

Verifing that soln2 satisfies eqns2

And @@ (eqns2 /. soln2 // Simplify)

(*  True  *)

In the limit as a -> 1

soln21 = ReplacePart[soln2, {1, -1, -1} -> Limit[soln2[[1, -1, -1]], a -> 1]]

(*  {y -> Function[{x}, 2 + (I*Pi)/2 - 
         Log[x] - Log[I*(1 + Log[x])]]}  *)

Verifing that soln21 satisfies the original eqns1

And @@ (eqns1 /. soln21 // Simplify)

(*  True  *)

In the domain of x for which soln21 is real, soln21 equals soln1

(y[x] /. soln1) == ((y[x] /. soln21) // PowerExpand)

(*  True  *)

For the results to be real

Reduce[{x > 0, 1 + Log[x] > 0}, x]

(*  x > 1/E  *)

Plot[Evaluate[y[x] /. {soln1, soln21}],
 {x, 0, 2},
 PlotStyle -> {
   Directive[Thick, AbsoluteDashing[{7, 5}]],
   AbsoluteDashing[{10, 10}]},
 Epilog -> {Gray, Dashed,
   Tooltip[Line[{{1/E, 0}, {1/E, 6}}], x == 1/E]},
 PlotLegends -> Placed["Expressions", Bottom]]

enter image description here

$\endgroup$
  • $\begingroup$ I forgot that C[1] and C[2] are dependent on a! So the latter issue is not a bug after all. $\endgroup$ – arax Oct 10 '15 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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