We wish to know what the general solution is for
import sympy
from sympy.abc import x, b, t
sympy.integrate((x + b)**t, x)
which returns the following piecewise solution:
However, this is not correct for t = 0 and t = 1.
Shouldn't the piecewise solution look something like this(?):
$$\begin{cases} \log{\left(b + x \right)} & \text{for} \: t = -1 \\x & \text{for} \: t = 0 \\ \frac{x^2}{2} + bx & \text{for} \: t = 1 \\ \frac{\left(b + x\right)^{t + 1}}{t + 1} & \text{otherwise} \\ \end{cases}$$
I assume Sympy is correct and that there is something I don't understand about the situation, and I would like to know what that is. I can only assume there is an underlying or implicit assumption that t is not 0 or 1.
We try setting t = 0:
import sympy
from sympy.abc import x, b, t
general_solution = sympy.integrate((x + b)**t, x)
specific_solution = general_solution.subs(t, 0)
Here the specific_solution returns: x + b (incorrect)
We can now try calculating the same thing directly:
import sympy
from sympy.abc import x, b, t
direct_solution = sympy.integrate((x + b)**0, x)
Here the direct_solution returns: x (correct)
The same holds for t = 1
The result from SymPy is correct. Indefinite integrals are only defined up to an arbitrary additive constant and so are not unique. The
integratefunction does not add+ Cbut you need to understand that it is there implicitly. The antiderivative is correct if its derivative returns the original function:The differences that you see here are just constants wrt the integration variable
xand it is valid to add any constant when computing an antiderivative (because the derivative of the constant is zero):More generally symbolic expressions for antiderivatives are potentially defined only up to addition of a piecewise constant function but that subtlety is not relevant in this example.