# LTspice: How can I plot the derivative of a function?

In the given circuit I plotted I(R1) with respect to time and tried to plot it's derivative using d(I(R1)).

However d(I(R1)) doesn't look like the derivative of I(R1), so I'm wondering what went wrong.

Sorry, if this is a basic question, but I just started out with LTspice and I couldn't find a straight forward answer. Thanks!

• Try plotting them separately. Apr 17 at 21:51
• Make a behavioral source (e.g. bv) and use V= ddt(stuff) Apr 17 at 21:58

## 1 Answer

Setting the initial voltage across the inductor creates an initial current through R1 which messes up the scaling of the derivative plot. You want start the voltage source at zero. Your derivative plot shows the correct results, but you need to zoom in to see what's happening.

There are a few ways to set the initial conditions. One way is to add startup to the .tran card to start voltage sources at zero. You can also set .ic I(L1)=0.

The following shows that the derivative function works as advertised in the following simulation. The cursors show a slope of 12.1958 and the derivative graph shows something similar.