# I'm trying to solve the indefinite integral of a real function (with a bunch of real parameters inside) but the result is a complex function

The integral I'm trying to solve is $$\int{\frac{12\left(c_3-R\ c_2\cos{(\frac{s}{R}})+R\ c_1\sin{(\frac{s}{R})}\right)}{l\ Y\left(\frac{H}{2}+4k\frac{s(s-\pi R)}{(\pi R)^2}\right)^3}ds}$$ but, when given to Wolfram Mathematica, the result is a complex function and I cannot accept this solution.
The code I used is this:

\[Theta][s_] =Integrate[(12 (c3 - R c2 Cos[s/R] + R c1 Sin[s/R]))/(l y (H/2 + (
4 k s (-\[Pi] R + s))/(\[Pi]^2 R^2))^3),s]


What could be the problem? Is there a problem in the first place or am I getting something wrong? Is there a way to force Mathematica into giving me a real function as a result?

• Hi. I think the parameters are a distraction in this question. Also say Integrate[Sin[s]/(1+s^2)^3,s] contains the imaginary unit. Commented Sep 21, 2022 at 11:16
• An indefinite integral is an anti-derivative. Any function that differs by at most a constant (including complex constants) from the anti-derivative is also a valid anti-derivative. The algorithms that Mathematica uses generally operate in the complex domain and may return results that are or appear complex. Also "many algebraic numbers are real-valued but cannot be expressed in radicals without introducing complex numbers" (casus irreducibilis) Commented Sep 21, 2022 at 14:33

the result is a complex function and I cannot accept this solution.

Maple 2022.1 gives anti-derivative with no explicit I in it. Here it is. It is in terms of cos/sin integral special functions. The code is below. I did not verify if it correct or not. You can try to differentiate it and see if you get the integrand back.

Gives

-((18432*c3*k^2*Pi^7*
R)/(L*(32*H*k*Pi^2 - 64*k^2*Pi^2)^2*(H*Pi^2 - (8*k*Pi*s)/
R + (8*k*s^2)/R^2)*y)) + (36864*c3*k^2*Pi^6*
s)/(L*(32*H*k*Pi^2 - 64*k^2*Pi^2)^2*(H*Pi^2 - (8*k*Pi*s)/
R + (8*k*s^2)/R^2)*y) +
(18432*c3*k^2*Pi^6*R*
ArcTan[(-8*k*Pi + (16*k*s)/R)/(4*
Sqrt[2*H*k*Pi^2 - 4*k^2*Pi^2])])/(L*(32*H*k*Pi^2 -
64*k^2*Pi^2)^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