# Mathematica gives an unexpected answer for Integrate [closed]

I need to integrate the following: $$$$\tag{1} \frac{\sqrt{C + (1 - C) x^3}}{x},$$$$ where $$0 < C < 1$$ and $$x$$ is a positive variable (then $$x^3 \ge 0$$). When I integrate:

Integrate[Sqrt[C + (1 - C) x^3]/x, x, Assumptions -> 0 < C < 1]


I get this answer: $$$$\tag{2} \frac{2}{3} \sqrt{C + (1 - C)\, x^3} - \frac{2}{3} \sqrt{C} \, \mathrm{argtanh} \Big( \frac{\sqrt{C + (1 - C) \, x^3}}{\sqrt{C}} \Big).$$$$ This answer is wrong because the term inside parenthesis (inside the argtanh) is larger than 1, which invalidates the answer.

So how can I get the proper integration of (1), using Mathematica?

EDIT: Actually, what I need is to find the general solution of the following differential equation ($$\lambda$$ is a positive constant): $$$$\tag{3} \frac{d a}{d t} = \pm \, \frac{\lambda \, a}{\sqrt{C + (1 - C) \, a^3}},$$$$ i.e. the function $$a(t)$$ or the time $$t(a)$$.

## closed as off-topic by Szabolcs, Daniel Lichtblau, m_goldberg, Bob Hanlon, Bill WattsJan 14 at 2:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Szabolcs, Daniel Lichtblau, m_goldberg, Bob Hanlon, Bill Watts
If this question can be reworded to fit the rules in the help center, please edit the question.

• When evaluating a definite integral don't the imaginary parts cancel out? – JimB Jan 13 at 16:31
• @JimB, I need the general solution on the indefinite integration, since I don't know the limits of the variable $x$ (except that $x > 0$). It's the solution of some differential equation. – Cham Jan 13 at 16:34
• You should change the subject line of the question from "wrong" to perhaps "unexpected" since Assuming[{0<C<1, x>=0}, Sqrt[C+(1-C) x^3]/x == D[Integrate[Sqrt[C+(1-C) x^3]/x, x], x] // Simplify] evaluates to True – Bob Hanlon Jan 13 at 20:25
• Tha antiderivative shown is fine. Can check by differentiation: In[646]:= i0 = Sqrt[C + (1 - C) x^3]/x; i1 = Integrate[i0, x]; Simplify[D[i1, x] - i0] Out[648]= 0 – Daniel Lichtblau Jan 13 at 21:59

$$\int\frac{\sqrt{C + (1 - C) x^3}}{x}dx=\int\frac{\left(\sqrt{C + (1 - C) x^3}\right)x^2}{x^3}dx$$

Let $$C + (1 - C) x^3=u^2$$

$$3(1 - C) x^2dx=2udu$$

$$\frac{2}{3}\int\frac{u^2du}{u^2-C}du$$

$$\frac{2}{3}\int\left(1+\frac{c}{u^2-C}\right)du$$

$$\frac{2}{3}\left(u+C\int\frac{du}{u^2-\sqrt{C}^2}\right)$$

$$\frac{2}{3}\left(u-C\frac{Arctanh(\frac{u}{\sqrt{C}})}{\sqrt{C}}\right)$$

Substituting back gives

$$$$\tag{2} \frac{2}{3} \sqrt{C + (1 - C)\, x^3} - \frac{2}{3} \sqrt{C} \, \mathrm{argtanh} \Big( \frac{\sqrt{C + (1 - C) \, x^3}}{\sqrt{C}} \Big).$$$$

FunctionDomain[ArcTanh[Sqrt[C + (1 - C) x^3]/Sqrt[C]], x]


-1 < Sqrt[C + x^3 - C x^3]/Sqrt[C] < 1 && -C - x^3 + C x^3 <= 0

Or

 ArcTanh[Sqrt[C + (1 - C) x^3]/Sqrt[C]] // TrigToExp


-(1/2) Log[1 - Sqrt[C + (1 - C) x^3]/Sqrt[C]] + 1/2 Log[1 + Sqrt[C + (1 - C) x^3]/Sqrt[C]]

• There's still a problem with the argument of arctanh. – Cham Jan 13 at 17:06
• I think it's better to split the integral of $\frac{1}{u^2 - C}$ in two parts : $\frac{1}{u - \sqrt{C}} - \frac{1}{u + \sqrt{C}}$, then integration gives a $\ln{\dots}$. – Cham Jan 13 at 17:09
• They are equivalent.. – OkkesDulgerci Jan 13 at 17:12
• My solution appears to be this: $$\frac{2 u}{3 \sqrt{C}} + \frac{1}{3} \, \ln{\Big(\frac{u - \sqrt{C}}{u + \sqrt{C}}\Big)},$$ which is good since $u \ge \sqrt{C}$. – Cham Jan 13 at 17:12

Here are four five six forms for an antiderivative, the first ad1 being the same as the OP's and complex-valued over the intended domain. The other three four five are real-valued.

ad1 = Integrate[Sqrt[c + (1 - c) x^3]/x, x, Assumptions -> 0 < c < 1]
(*  2/3 Sqrt[c + x^3 - c x^3] - 2/3 Sqrt[c] ArcTanh[Sqrt[c + (1 - c) x^3]/Sqrt[c]]  *)


The imaginary part of ad is constant so we can subtract it off (which is the point of @JimB's comment under the OP):

ad2 = ad1 /. {{x -> 1}, {x -> x}} // Differences // First;

Assuming[0 < c < 1 && x > 0,
TrigToExp@ad2 /. {Log[z_] /; Simplify[z < 0] :> Log[-1] + Log[-z]} //
Expand // FullSimplify
]
(*
2/3 (-1 + Sqrt[c + x^3 - c x^3] +
Sqrt[c] ArcTanh[(Sqrt[c] (x^3 - Sqrt[c + x^3 - c x^3]))/(c + x^3)])
*)


Applying the identity, $$\tanh ^{-1}\left(\frac{1}{z}\right) - \tanh ^{-1}(z)=\frac{i \pi}{2} \,,$$ changes ad1 by a constant, which results in another antiderivative:

ad3 = ad1 /. ArcTanh[z_] :> ArcTanh[1/z]
(*  2/3 Sqrt[c + x^3 - c x^3] - 2/3 Sqrt[c] ArcTanh[Sqrt[c]/Sqrt[c + (1 - c) x^3]] *)


Rewrite ad3 in terms of logarithms:

ad4 = TrigToExp@ad3 /.
a__ Log[u_] + b__ Log[v_] + w__ /; Times@a == -Times@b :> a Log@Simplify[u/v] + w
(*
2/3 Sqrt[c + x^3 - c x^3] +
1/3 Sqrt[c] Log[(-Sqrt[c] + Sqrt[c + x^3 - c x^3]) /
(Sqrt[c] + Sqrt[c + x^3 - c x^3])]
*)


Check:

D[{ad1, ad2, ad3, ad4}, x] // Simplify
(*
{Sqrt[c + x^3 - c x^3]/x, Sqrt[c + x^3 - c x^3]/x,
Sqrt[c + x^3 - c x^3]/x, Sqrt[c + x^3 - c x^3]/x}
*)


Addendum: Here is a fifth, the real part of ad1:

ad5 = ComplexExpand[Re[ad1], TargetFunctions -> {Re, Im}] //
Simplify[#, 0 < c < 1 && x > (c/(1 - c))^(1/3)] &
(*
1/6 (4 Sqrt[c + x^3 - c x^3] +
Sqrt[c] Log[(x^3 - c (-2 + x^3) - 2 Sqrt[c (c + x^3 - c x^3)])/c] -
Sqrt[c] Log[(x^3 - c (-2 + x^3) + 2 Sqrt[c (c + x^3 - c x^3)])/c])
*)


Addendum 2: Doing a line integral within the domain of interest will often give the desired result; however, this time it ran forever, until I turned off GenerateConditions. The antiderivative comes back in terms of HypergeometricPFQ which can be simplified with the aid of FunctionExpand.

Assuming[0 < c < 1 && x > 0 && t > 0,