# KHN biquad: why does LTSPICE plot a wrong phase plot for bandpass filter?

I'm studying the KHN biquadratic section and its outputs to obtain a lowpass filter, a highpass filter and a bandpass filter. I simulated the filter using Mathematica and obtained the following plots, which match the theoretical. Now, then I decided to simulate the circuit using LTSPICE. Obtaining the following plots: Now, comparing both plots everything looks fine with the Low pass output and with the High pass output, both in terms of magnitude and phase. My question is with the band pass output. While the magnitude plot looks fine, the phase plot has nothing to do with the one I plotted with Mathematica. Why does this happen? What is the difference between the simulation and the theoretical plot? I didn't expect such an abrupt phase change as the one obtained with Mathematica, but the phase plot obtained has nothing to do with it: the limits are different, the variation is the exact opposite... What am I missing here?

• Mathematica phase plots are limited to lie between -180 deg and +180 deg. such a restriction is not seen in the SPICE result. By the way, the SPICE plot is very difficult to see. Try to increase the line thickness or change the colours. – AJN Aug 18 '20 at 13:53
• The mathematica phase plot (green color) goes from -100 to -180 then +180 to +90 (which is same as -180 to -270). The spice Green plot goes from -100 to -180, then from -180 to -270. So the result is not surprising ? – AJN Aug 18 '20 at 13:55
• Oh I get it now! The jump in the Mathematica plot is due to reaching -180. It adds 360 and then goes from 180 to 90. In SPICE such restriction does not exist and, therefore, after -180 it continues down to -270. I didn't know about the Mathematica restriction (but it makes sense to keep the phase in the [-180, 180] interval to make it more evident when signals are leading or lagging). Thank you very much! – Granger Obliviate Aug 18 '20 at 14:08
• Phase plots will be relatively the same, they will not start from the same absolute postion. – Voltage Spike Aug 25 '20 at 21:54

What you see is called phase wrapping, and it's the result of calculating the phase with the four-quadrant version of atan(), atan2(). Its domain is from $$\-\pi\$$ to $$\\pi\$$, or, in degrees, from $$\-180^\text{o}\$$ to $$\180^\text{o}\$$. The Unravel Branch Wrap is checked, by default. Unchecking it will result in the phase being displayed as you see in Mathematica. If you want for Mathematica to also display it unwrapped, then you'll have to do a bit of calculation involving the derivative of the phase, searching for the jumps, and adding or subtracting $$\2\pi\$$, as needed. Or maybe there's a builtin function.