Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is my code:

ode = x'[t] == (x[t] (x[t] + 1))/(t (t + 1));
sol = DSolve[ode, x[t], t] // Simplify

Then I get this output for sol:

$$\left\{\left\{x(t)\to \frac{e^{c_1} t}{-e^{c_1} t+t+1}\right\}\right\}$$

This result is not correct. I should have something like:

$$\frac{1}{C_1 \left( \frac{1}{t}+1 \right)-1}$$

And when I check my code in mathematica to see if it is correct, then I don't get "True" as I should:


Can someone tell me what I've done wrong, and how to get the correct result?

share|improve this question

closed as too localized by whuber, m_goldberg, Oleksandr R., István Zachar, Artes Apr 23 '13 at 17:00

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Let E^(-C[1]) be C[2], and see if it simplifies... –  J. M. Apr 22 '13 at 17:05
That looks better, but doesn't solve it. –  Jens Jensen Apr 22 '13 at 17:12
You couldn't see that the exponential of an arbitrary constant is also an arbitrary constant? –  J. M. Apr 22 '13 at 23:05

2 Answers 2

Solve for x instead of x[t].

sol = DSolve[ode, x, t][[1]];
Simplify[ode /. sol]
(* True *)

So it's a correct solution.

x[t] /. sol
(* (E^C[1] t)/(-1 - t + E^C[1] t) *)

Transforming it to the desired form:

y = x[t] /. sol /. E^C[1] -> 1/C[2];
Denominator[y]/Numerator[y] // Simplify
-1 + (1 + 1/t) C[2]
share|improve this answer
Okay, but how can let Mathematica to calculate the function so I can see my desired solution? –  Jens Jensen Apr 22 '13 at 17:36
@JensJensen It's the same solution. You can reshape it though. See edit. –  BoLe Apr 22 '13 at 18:03
if that is true, then why do I find different values for C[2] based on the condition: $x(1)=1/3$.. Then I get C[2]-> 2/3 with your solution and C[2]->2 with my desired solution.. I thought we should end up with same value for the constants.. –  Jens Jensen Apr 22 '13 at 18:14
@JensJensen there is no C[2] in your solution... And why would you assume that your constant should be the same as BoLe's? –  Sjoerd C. de Vries Apr 22 '13 at 18:37

The reason why

(D[x[t], t] == (x[t] (x[t] + 1))/(t (t + 1)) /. sol) // FullSimplify

doesn't return True can be found by examining x'[t] using FullForm:



So, when your going to replace x[t] in the ode, the left hand side has nothing to replace. There is no x[t] there.

Try instead

(D[(E^C[1] t)/(1 + t - E^C[1] t), t] == 
(x[t] (x[t] + 1))/(t (t + 1)) /. 
x[t] -> (E^C[1] t)/(1 + t - E^C[1] t)) // FullSimplify


A little bit of basic algebra shows that Mathematica's solution and your desired solution are the same.

share|improve this answer
And is it possible to let Mathematica do the basic algebra so I can see my desired solution? –  Jens Jensen Apr 22 '13 at 17:34
@JensJensen Sometimes you can, sometimes you can't. Mathematica has a slew of algebraic manipulation functions that you could use to transform your expression. But quite often Mathematica has other ideas about the result's optimal form than you. In this case the following comes close: ((E^C[1] t)/(1 + t - E^C[1] t) /. t -> 1/(c E^C[1] )) /. 1/(c E^C[1] ) -> t –  Sjoerd C. de Vries Apr 22 '13 at 18:23

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