Integrate is giving imaginary solution

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.

• 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. – Daniel Lichtblau Feb 2 '17 at 22:45
• 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). – Josh Feb 2 '17 at 23:23
• 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. – Daniel Lichtblau Feb 2 '17 at 23:31
• "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 – march Feb 2 '17 at 23:56
• 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. – Sjoerd Smit Feb 3 '17 at 12:00

     rint =