# How to plot dy/dx versus x of a given y=f(x) plot in LTspice?

Below is a plot of a sweep which shows how Vo changes versus Vi in LTspice:

How can I plot the "derivative of Vo" i.e dVo/dVi versus Vi? How can I plot the "integral of Vo" versus Vi?

Edit: I was trying to see how the voltage gain for a transistor changes with input. I tried to plot -dVout/dVin versus Vin below which is the plot of voltage gain:

For 10mV change in Vin causes very different gain in the middle of active region. "Change in Vin" must be around 1mV or less for a stable gain.

• Try D(V(Vo)) for derivative of Vo. And LTspice does not "support" the integral as the old PSpice do, s(x) integral. At least I did not hear about it. – G36 Feb 6 '18 at 19:08
• Yes this works for derivative. – floppy380 Feb 6 '18 at 19:15
• See my edit do you think it is correct? – floppy380 Feb 6 '18 at 19:39
• This is not a surprise since the BJT's gain is gmRc ≈ 40*IcRc. As you can see the voltage gain changes with Ic. This is why we add RE resistor and if RE > 1/gm the gain becomes Rc/RE. – G36 Feb 6 '18 at 19:44
• Since the gain of grounded-emitter CE arranged BJT is $R_C\cdot g_m$ and since $g_m$ depends upon $I_C$ and since $I_C$ depends on the instantaneous signal voltage value being applied, the output applies a variable gain to the signal. No shock. This is called "distortion." (Temperature also matters.) The solution is to use the excess gain and provide lots of NFB. That can be done with an emitter resistor, or with a resistor from collector back to base (or using an emitter follower's output back to base), or by wrapping a whole circuit with global NFB. – jonk Feb 6 '18 at 20:02

Oh, cripes. It's not so hard:

Then just plot the formulas you already seem to have known about:

From the above pair of curves, you can see that when the collector voltage is near halfway between the rails, that the voltage gain is about 200. Given that $I_C=\frac{6\:\text{V}}{1\:\text{k}\Omega}\approx 6\:\text{mA}$ and that $A_V=R_C\cdot g_m=1\:\text{k}\Omega\cdot\frac{6\:\text{mA}}{26\:\text{mV}}\approx 230$, there's no real shock here.

Also notice the sudden demise of the voltage gain when the collector voltage plummets and the BJT enters into saturation.

No matter where you position your operating point on this gain curve, with a large enough input signal you will experience an output signal that is a distorted result of that input signal because of the significant gain variations. (Temperature and part variations will also dramatically shift that operating point around, by the way.)

This grounded emitter amplifier is a case where either local or global NFB is pretty much required.

• Great answer thanks! People like you should write the books. – floppy380 Feb 7 '18 at 0:33
• @user1234 Hehe. Thanks. Now my wife is going to go beat on me to write something. Sheesh. ;) – jonk Feb 7 '18 at 1:00

Bad news, you can't plot a derivative of a variable with respect to another derivative in LT spice. You can however plot the derivative with respect to time like this $\frac{dx}{dt}$ or $\int{x}dt$.

You can plot integrals with respect to time like listed here There is also a way to integrate a signal by holding down control in the time domain.

I was able to get a graph by inserting d(V(vo)) on the horizontal axis and d(V(vi)) (my signals are not the same as yours) however, I'm not sure that ${\frac{dx}{dt}}/{\frac{dy}{dt}}$ is going to get you the same as $\frac{dx}{dy}$

If not you can always export into python, excel or matlab and use the math functions there.

• Please see my edit. Is the plot in my edit correct? Or atleast close to correct? – floppy380 Feb 6 '18 at 19:38