# DSolve doesn't produce the expected result

I have the following function:

$$B(t) = \frac{a^n}{a^n + t^n}.$$

By taking derivative from both sides with respect to $$t$$ and after some manipulation, one obtains:

$$B' = - \frac{n}{a} B^2 \left(\frac{1 - B}{B}\right)^{\frac{n-1}{n}}.$$

Now, I want to solve the above differential equation with DSolve, and reproduce my starting function, thus:

DSolve[B'[t] == -n ( B[t]^2/a) ((1 - B[t])/B[t])^((n - 1)/n), B[t], t]


Mathematica returns another solution. How can I force it to reproduce the above function?

• By taking derivative from both sides with respect to t and after some manipulation, one obtains: I can't verify this using Mathematica. Nov 21, 2023 at 14:16
• Using Mathematica, it says the ode is $$B'(t)=\frac{n a^n t^{n-1}}{\left(a^n+t^n\right)^2}$$ or B'[t] == (a^n n t^(-1 + n))/(a^n + t^n)^2; Nov 21, 2023 at 14:19
• sometimes simplification with side relation works, but not on this one. Nov 21, 2023 at 14:31
• There is no error. It just gives warning Inverse functions are being used by Solve, so some solutions may not be found that is all. !Mathematica graphics Nov 21, 2023 at 14:39
• AGain, your ode is wrong. It is not based on $B'(t)$ as given initially. Here is screen shot !Mathematica graphics You can use Mathematica to do the derivative. Nov 21, 2023 at 14:53

The problem is that you started with $$B(t)$$ and trying to compare the solution of the ode to this $$B(t)$$. But the $$B(t)$$ you started with is one solution curve while the solution that DSolve returns has an arbitrary constant of integration. So you can not just compare the two like this.

You need to find specific value of $$c$$ to make it match. i.e. the solution returned is whole family of solutions, while your original $$B$$ is just one member.

The problem is that the $$c$$ returned is hard to isolate. But forcing $$c$$ to be a value to the make the ode solution gives the original $$B$$ works.

ClearAll[B, t, n, a];
rhs = a^n/(a^n + t^n);


ode = B'[t] == -n (B[t]^2/a) ((1 - B[t])/B[t])^((n - 1)/n)
sol = DSolveValue[ode, B[t], t]


Now find the $$c$$ to make them match

cValue=First@Solve[sol==rhs,C[1]];
sol=FullSimplify[sol/.cValue]


The above $$c$$ picks the correct member of the family of solutions. But Reduce and FullSimplify could not show this. May be there is a workaround. I did not try too hard.

But there is a plot showing they match.

Row[{Plot[Evaluate[sol /. {n -> 2, a -> 2}], {t, -1, 3},
PlotRange -> All, PlotLabel -> "solution of ode", ImageSize -> 300],
Plot[Evaluate[rhs /. {n -> 2, a -> 2}], {t, -1, 3},
PlotRange -> All, PlotLabel -> "original B", ImageSize -> 300]}]


Row[{Plot[Evaluate[sol /. {n -> 7, a -> 8}], {t, -1, 3},
PlotRange -> All, PlotLabel -> "solution of ode", ImageSize -> 300],
Plot[Evaluate[rhs /. {n -> 8, a -> 8}], {t, -1, 3},
PlotRange -> All, PlotLabel -> "original B", ImageSize -> 300]}]


• @Tim because your $a=23,n=26$ are not compatible with the initial condition $B(15)=1$ you gave to NDSovle. If you try to plug these values, you see they do not satisfy the B(t). So you are comparing two different things. To get close to what NDSolve gave, try $a=23,n=-200$ Nov 22, 2023 at 14:49
• According to Mathematica, it is not. Here is screen shot !Mathematica graphics You see, these values do not satisfy the equation of $B$ at time $t=15$ It says False. Which means the equality is not satisfied. Nov 22, 2023 at 15:04

The complex power function can be finicky. If we may assume positive values, then we can get the following:

DSolve[{
B'[t] == -n (B[t]^2/a) ((1 - B[t])/B[t])^((n - 1)/n),
B[0] == 1}, (* condition for given B[t] *)
B[t], t] //
Simplify[#, a > 0 && t > 0 && n > 1] & //
PowerExpand // Simplify // Quiet

 (* {{B[t] -> a^n/(a^n + t^n)}} *)