# Help with Plot excluding parts of a curve even with “Exclusions” option set to “None” and speed up of code

I modeled a system mathematically. When the model is ideal, I can plot the results and export the plotted points. Everything works fine. Now, I started to model some imperfections of the system, but due to the increase in complexity, the code is taking a long time to complete and some plots are showing just some slices of the output curves, even when the "Exclusions" option is set to "None". This results in exported ".dat" files containing just the shown points, not the entire set of points corresponding to the whole response.

Since I'm not proficient in Mathematica, I would like to know if someone can help me obtain a complete plot that can be exported and if someone could give me some tips to speed up the code.

So as to create a minimum workable example, I edited part of my code and pasted it below.

The code slows down when it arrives in the Convolve functions.

One example showing a plot excluding several parts of the response curve is given below. The attended response curve oscillates wildly, presenting peaks around 3.64e-8, 5.82e-8 and 8.31e-8.

In the orignial code I generate random values for several variables with the aim of realizing a Monte Carlo analysis. In the snippet below, I changed the random number generation functions by constant values so as to obtain the plot shown.

I am running Mathematica 11.3 under CentOS 6 Linux.

Thanks for any help!

mcRuns = 1;
f0 = 500*10^6; f1 = 35*10^8; T = 10^-7; k = (f1 - f0)/T;
fChirp0 = 500450500; fChirp1 = 3502866500; kChirp = 30024160000000000;
f0FilterR1 = 504951500; f1FilterR1 = 3485653500; kFilterR1 = 29807020000000000;
f0FilterR2 = 500928500; f1FilterR2 = 3480158500; kFilterR2 = 29792300000000000;
f0FilterQ1 = 498051000; f1FilterQ1 = 3491950000; kFilterQ1 = 29938990000000000;
f0FilterQ2 = 502194000; f1FilterQ2 = 3465150500; kFilterQ2 = 29629565000000000;

fsig1 = 16*10^8; fsig2 = 225*10^7; fsig3 = 3*10^9;
x[t_] := Cos[2*Pi*fsig1*t] + Cos[2*Pi*fsig2*t] + Cos[2*Pi*fsig3*t]

fSin = 499965500;
off1 = 0.07379240420574634; off2 = -0.06867065530350358;
epsilonSin1 = 0.07653722613968617; epsilonSin2 = 0.06544308702156804;
phiSin1 = 0.016583716312827568; phiSin2 = -0.019716403101947583;
snr[t_] := off1 + (1 + epsilonSin1)*Cos[2*\[Pi]*(fSin*t + phiSin1)]
snq[t_] := off2 + (1 + epsilonSin2)*Sin[-2*\[Pi]*(fSin*t + phiSin2)]

aMult11 = -0.036011825399982655; aMult12 = -0.07131350475532566;
s1r[t_] := (1 + aMult11)*x[t]*snr[t]
s1q[t_] := (1 + aMult22)*x[t]*snq[t]

off3 = -0.0952868081375434; off4 = -0.03259688015912082;
epsilonChirp11 = 0.0691805003127352; epsilonChirp12 = -0.0015776850659453001;
phiChirp11 = 0.00931194743841307; phiChirp12 = -0.047750333974009615;
chplusr[t_] := off3 + (1 + epsilonChirp11)*Cos[2*\[Pi]*((kChirp*t^2)/2 + fChirp0*t + phiChirp11)]
chplusq[t_] := off4 + (1 + epsilonChirp12)*Sin[2*\[Pi]*((kChirp*t^2)/2 + fChirp0*t + phiChirp12)]

aMult21 = 0.08088512603398779; bMult21 = -0.07254083805555872;
aMult22 = -0.0919771424991831; bMult22 = 0.0741476090364463;
s2r[t_] := (1 + aMult21)*s1r[t]*chplusr[t] - (1 + bMult22)*s1q[t]*chplusq[t]
s2q[t_] := (1 + aMult22)*s1q[t]*chplusr[t] + (1 + bMult21)*s1r[t]*chplusq[t]

epsilonFilterr1 = 0.026462490504123526; epsilonFilterr2 = 0.06662722622028866;
epsilonFilterq1 = -0.0733713585780158; epsilonFilterq2 = 0.02180448442599564;
phiFilterr1 = 0.025987325229855418; phiFilterr2 = 0.031660146121940624;
phiFilterq1 = -0.007133114618442266; phiFilterq2 = 0.050710634280748984;
chmoinsr1[t_] := (1 + epsilonFilterr1)*Cos[2*\[Pi]*((kFilterR1*t^2)/2 + f0FilterR1*t + phiFilterr1)]
chmoinsr2[t_] := (1 + epsilonFilterr2)*Cos[2*\[Pi]*((kFilterR2*t^2)/2 + f0FilterR2*t + phiFilterr2)]
chmoinsq1[t_] := (1 + epsilonFilterq1)*Sin[-2*\[Pi]*((kFilterQ1*t^2)/2 + f0FilterQ1*t + phiFilterq1)]
chmoinsq2[t_] := (1 + epsilonFilterq2)*Sin[-2*\[Pi]*((kFilterQ2*t^2)/2 + f0FilterQ2*t + phiFilterq2)]

s3r[t_] := Convolve[s2r[to]*UnitStep[to], chmoinsr1[to]*UnitStep[to], to, t, Assumptions -> t >= 0] - Convolve[s2q[to]*UnitStep[to], chmoinsq2[to]*UnitStep[to], to, t, Assumptions -> t >= 0]
s3q[t_] := Convolve[s2q[to]*UnitStep[to], chmoinsr2[to]*UnitStep[to], to, t, Assumptions -> t >= 0] + Convolve[s2r[to]*UnitStep[to], chmoinsq1[to]*UnitStep[to], to, t, Assumptions -> t >= 0]
Grid[{{Plot[Evaluate[s3r[t]], {t, 0, T}, PlotRange -> 6*10^-8, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}, {Plot[Evaluate[s3q[t]], {t, 0, T}, PlotRange -> 6*10^-8, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}}]

• The problems lies within the Convolves. They do not evaluate. – Henrik Schumacher Aug 27 '18 at 13:16
• This is strange because no warning is issued, and the output seems correct, despite missing some parts. Any hints on how to get around the problem? – Joao Alberto Aug 27 '18 at 13:45
• And this problem does not happen always. Depending on the random values generated, the plot shows the entire curve. – Joao Alberto Aug 27 '18 at 14:01