I have a not-so-complicated piecewise cubic function, shown below as the yellow curve on the right. It's derivative is on the left; the blue lines are references. Please see the code below where I call it myF (and its derivative myf).
To my surprise, the integration with a parameter $u$ and sine in the argument gives an ugly result involving the complex $i$.
Is the result of $\int$myF$(u\sin x)$d$x$ (as shown in the screenshot below) correct? Or is it some kind of failure due to my erroneous way of using
Integrate
coupled withPiecewise
?
As just the area under the curve modulated by sine, I for now don't see how this can be mathematically true to have involved $\sqrt{-1}$.
Screen shot below:
The code to define the curves, generate the plots, and do the integration is below. When the parameter $u < \frac12$ of course there's no problem since the integration doesn't go over the `splitting point' (where is differentiable).
I tried various ways to code the integration with assumptions, but the outcomes are basically the same. Some hint or confirmation would be greatly appreciated. Thank you.
ClearAll[myF, myf, u, v, ImgSz];
myF[v_] := Piecewise[{
{0, v < 0},
{4/3 v^3, 0 <= v < 1/2},
{1/3 (1 - 6 v + 12 v^2 - 4 v^3), 1/2 <= v < 1},
{1, v >= 1}
}];
myf = D[myF[u], u] /. {u -> v};
ImgSz = 250;
Row[{ Plot[{ 1, (* symmetry reference *)
myf
}, {v, -.3, 1.3}, PlotRange -> {-0.1, 2}, ImageSize -> ImgSz],
Plot[{ v, (* linear reference *)
myF[v]
}, {v, -.3, 1.3}, PlotRange -> {-0.1, 1}, ImageSize -> ImgSz]
}]
Assuming[ 1/2 < u < 1 ,
Integrate[ myF[ u Sin[x]], {x, 0, Pi}] ]
Summarizing Edit
Okay, so I couldn't recognize the expression as real-disguised-in-complex-conjugate, neither did I know reliable ways to test that. I'm glad to have learned from both answer posts.
In my case, defining the function with UnitStep
doesn't allow Mathematica to evaluate differently like in another post (which I cannot find right now). Nor does PrincipalValue -> True
or change of variables apply here as it does sometimes. I have accepted that in my case I need to post-process the expression the way I see fit. Nonetheless, for the record, there are some known bugs, old and new, solved and unsolved.