# Is it possible to impose “Assumptions” in DSolve or equivalent? (differential equation solving)

When DSolve tries to solve differential equations, it is sometimes not smart enough to generate conditions according to different possible value of parameters. Consider the following minimal example, $x'=x^2-a$:

DSolve[x'[t] == x[t]^2 - a, x[t], t]


The result is

{{x[t] -> -Sqrt[a] Tanh[Sqrt[a] t - Sqrt[a] C[1]]}}


This would be wrong if $a \leq 0$. (When $a<0$ one may argue that the above result is correct in the sense of complex $\tanh$ function; I did not bother to think about this, but this is definitely not we normally want.)

If the problem at hand is Integrate, we can use Assumptions to explicitly state the range of parameter; but DSolve does not provide such an option. So, is there any way to achieve a similar effect? I tried to use Boole etc. but failed.

-
Can you use the equivalent of DSolve[x'[t] == x[t]^2 - b^2, x[t], t] or DSolve[x'[t] == x[t]^2 + b^2, x[t], t] ? – b.gatessucks Apr 4 '13 at 7:59
@b.gatessucks Yeah, I use that kind of workaround since I've no choice. But not every constraint can be avoided this easily. – 4ae1e1 Apr 4 '13 at 15:19
Try FullSimplify your resulting solution, you can put in Assumptions there. – user7705 May 30 '13 at 9:53

Actually the only offending value here is $a=0$

(this can be seen easily if you calculate the integral

 Integrate[1/(x^2 - a), x]


).

For all the other values of $a$ the solution given is valid. The problem is that for $a=0$ we have what is called a singular solution for the ODE. This is something difficult to cope with in general and assuming won't help you with. I am still actively looking at this issue, in sometimes i was successful to implement a "patch" to DSolve to overcome this but not always, like this situation.

If your DE includes many parameters and/or arbitrary functions it might be useful to find the equivalence transformations for this class of DE and through them to study instead the better representative of this class including the least number of parameters.

-
Thanks for answering, but "assuming" will obviously help us since we can Assumptions -> a>0,Assumptions -> a<0, or Assumptions -> a==0 (Yeah I mentioned that for a<0 the solution is correct in the complex sense but we seldom want a complex solution for a real ODE). The underlying problem is integration in this simple example, but the distinction is Integrate allows Assumptions while DSolve does not. I don't need Mathematica to be smart enough to recognize the singular solution; I just want it to be flexible enough so that human can intervene. That's exactly the problem. – 4ae1e1 Apr 4 '13 at 19:29
I mentioned Integrate for a reason, if you include the option Assumptions you will see that for the two cases $a<0,\ a>0$ it gives the same answer. When the problem is more complex you cant see from the beginning the domain of the parametric space that will give you real solutions. So making an assumption a priori might not be the correct way to handle the problem in general. – Spawn1701D Apr 4 '13 at 19:36
Oh sorry, you are right. I had some wrong memories in my mind when I wrote the previous lines. – 4ae1e1 Apr 5 '13 at 3:10