I have defined this function:
f[x_]:=1/(1+Sin[FractionalPart[x]])
Then I tried to plot it using this code
Plot[Integrate[f[t],{t,0,x}],{x,0,2}]
It finally plot it, but it takes about 4-5 minutes to do it. There is a way to speed up similar plots, that involve commands as FractionalPart
?
EDIT: I observed that changing Integrate
by NIntegrate
the plot speed up a lot, but Im not sure how accurate is the numerical integration to trust in the result of the plot.
Anyway I will like to know if there are other approaches to this problem using the symbolic integration. Thank you.
Assuming[0 < x < 2, Integrate[PiecewiseExpand[1/(1 + Sin[FractionalPart[t]]), 0 < t < 2] // Evaluate, {t, 0, x}]]
$\endgroup$f[x_?NumberQ] := 1/(1 + Sin[FractionalPart[x]]) Plot[NIntegrate[f[t], {t, 0, x}], {x, 0, 2}]
One could further improve by keeping track of prior quadrature results and only adding increments. $\endgroup$Plot[1/(1 + Sin[FractionalPart[x]]), {x, 0, 10.7}]
The integration will beAssuming[x > 0, IntegerPart[x]*Integrate[1/(1 + Sin[x]), {t, 0, 1}] + Integrate[f[t], {t, 0, FractionalPart[x]}]]
which is somthig like manual using PiecewiseExpand $\endgroup$