# The assumption in integration does not work?

I am new to mathematica. Here is the question. I try to do the following integration with the assumption that k1<0, k2<0 and k1,k2 are real number. However, the result includes \sqrt{k1}?

Furthermore, in the result, the term e^{2h(s-T)}k1 - k2 could also be negative ? How I can do to prevent mathematica use log function?

• reals must be capitalized. – Szabolcs Jan 21 '16 at 17:05
• Change to capital letter, does not work either – J.J.Gao Jan 21 '16 at 17:12
• Please post, properly formatted, copy-and-pastable code in code blocks rather than screenshots of code. Edit your post by clicking the grey edit button at the bottom of the post and click on the grey question mark on the right side of the editing toolbar for help with formatting. – march Jan 21 '16 at 17:20
• Indefinite integration in Integrate makes no use of Assumptions. One might do Refine[Integrate[...], Assumptions->...]. Or use (Full)Simplify if Refine is not strong enough. – Daniel Lichtblau Jan 21 '16 at 23:14

## 1 Answer

The copyable code you omitted:

res = Integrate[(1 - Exp[h *(s - T)])^4/(k2 - k1* Exp[(s - T)*(2 h)])^2, s,
Assumptions -> Element[k1 | k2, Reals] && k1 < 0 && k2 < 0]


You are surprised to see a term $\sqrt{k1}$ pop up in the answer, with k1 defined as being negative. You don't specify why you see that as a problem, so I have to guess. I presume that you feel it is a problem that you will end up with complex numbers in the integral of a function that itself is real, and indeed you get those if you fill in a few numbers:

res /. {k1 -> -1., k2 -> -2., t -> 0, s -> 1, h -> 1}
(* 2.01401 + 0.0673765 I *)


What you forget is that you have an indefinite integral whose result is determined up to a constant of integration. Indeed, if you check a different value of s you get:

res /. {k1 -> -1., k2 -> -2., t -> 0, s -> 3, h -> 1}
(* 3.18752 + 0.0673765 I *)


Subtract both values to get the definite integral and you see the imaginary terms will cancel.

About negative logs: No problem, Mathematica can deal easily with those, just as it handles square roots of negative values:

Log[-2]
(* I π + Log[2] *)

• Thanks for the answer. Actually, I need the analytical expression of this integration in matlab. Mathematica is more robust to the thing like log(-1). – J.J.Gao Jan 22 '16 at 7:10