# Precision improvement for solution of the simplest low-pass filter

I solved the most basic low-pass filter using NDSolve in Mathematica and LTSpice. The solution provided by Mathematica seems to lack precision. I tried to deal with WorkingPrecision but I didn't manage to get it to improve the solution. Could you please help me with precision improvement?

Here is the electrical circuit in LTSpice: The solution for potential difference across the capacitor C1 solved by LTSpice is below: Here is my code in Mathematica:

freq = 10000;
vs[t_] = 20 + 30*Sin[2*Pi*freq*t];
r1 = 5;
c1 = 0.0001;
plotx = 1/freq*50;

sol = NDSolve[{vs[t] == r1*c1*vc1'[t] + vc1[t], vc1 == 0},
vc1[t], {t, 0, 0.060}];
Plot[vc1[t] /. sol, {t, 0, plotx}]


which gives this Plot: As you can see from the plots above, the solution by LTSpice provides better precision by default.

• Try increasing the setting of PlotPoints in Plot[], e.g. Plot[vc1[t] /. sol, {t, 0, plotx}, PlotPoints -> 45]. – J. M. will be back soon Nov 16 '17 at 2:37
• @J.M., that worked! And PlotPoints -> 15 worked as well. I added Mesh -> All to see each point on the plot. Could you explain the mechanism that Mathematica uses to choose a number of PlotPoints by default? I tried to find the value for PlotPoints that would correspond to the result without specifying PlotPoints, and I couldn't find it. – space bobcat Nov 16 '17 at 2:44
• Unfortunately, the mechanism for automatically choosing PlotPoints does not seem to be publicly known. – J. M. will be back soon Nov 16 '17 at 2:46

Plot[vc1[t]/.sol,{t,0,plotx}, 