I read through some of the previous posts on imaginary answers popping up due to integrals, but I was unable to find a solution to my similar problem. I have the following integral (reduced to its simplest form) and I'm only getting an imaginary solution. I've tried plotting it and even assigned values to my variables to produce an overall function that looks continuous so it should be able to integrate.

Either way here is the function and any help would be greatly appreciated.

    Integrate[(b (m y + d))/((b^2 + (y - y0)^2) Sqrt[b^2 + (-y + y0)^2 + (-m y - d)^2]),y]

All the variables are real and I've even tried using Assumptions but without success.

  • $\begingroup$ Your antiderivative is correct. In[2]:= Simplify[D[%,y] - (b (m y + d))/((b^2 + (y - y0)^2) Sqrt[b^2 + (-y + y0) ^2 + (-m y - d)^2])] Out[2]= 0 As for imaginary units appearing, that's hard to avoid. $\endgroup$ – Daniel Lichtblau Feb 2 '17 at 22:45
  • $\begingroup$ I do not think the result is correct. If you integrate a function in real space, you will get a real answer. If you add up everything under any real curve the answer must be real. The only time I've ever seen when you can get an imaginary solution is when you have problem areas and you need to do a contour integration due to a bad spot and you pick up the residue portion that is imaginary. It does not appear that the function being evaluated has a problem that would require that (and even if it did I don't think Mathematica could do it). $\endgroup$ – Josh Feb 2 '17 at 23:23
  • $\begingroup$ If I can take the derivative and recover the original function, then, barring bugs in differentiation or simplification (both very unlikely, in this case) the putative antiderivative is correct. Whether there might be a different form that one might prefer is another matter entirely. $\endgroup$ – Daniel Lichtblau Feb 2 '17 at 23:31
  • 4
    $\begingroup$ "If you integrate a function in real space, you will get a real answer." But you are not integrating; you are finding an antiderivative. I actually don't like the term "indefinite integral" exactly because of this problem. In general, if you are trying to use the antiderivative to find the definite integral, you need to be extra-special careful. I took your antiderivative, evaluated it at {b -> 1, m -> 1, d -> 1, b -> 1, y0 -> 1}, and plotted it, and it was discontinuous, which is not what you want $\endgroup$ – march Feb 2 '17 at 23:56
  • 1
    $\begingroup$ I'd like to add to the above comment that there is a very easy way to see why a primitive of a real function does not need to be real. Remember the old rule that if F[x] is a primitive of f[x], then F[x] + constant is also a primitive? Well, who's to say that constant cannot be imaginary? It's very easy to get a complex primitive, and that's by just adding an imaginary number to a real-valued primitive. $\endgroup$ – Sjoerd Smit Feb 3 '17 at 12:00

Integrate it with the Rule-Based-Integrator (Rubi) of Albert Rich at http://www.apmaths.uwo.ca/~arich/ and you will get an anitderivative without imaginary part.

     rint = 
 Int[(b (m y + d))/((b^2 + (y - y0)^2) Sqrt[
  b^2 + (-y + y0)^2 + (-m y - d)^2]), y]

(*   -ArcTan[(b^2 m - y (d + m y0) + y0 (d + m y0))/(
b Sqrt[b^2 + d^2 + (1 + m^2) y^2 + 2 y (d m - y0) + y0^2])]  *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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