Stability of derivative function

Congratulations for this fantastic simulation tool. Being able to merge analog with programming is really something I’ve been waiting for for a long time (and not only for electronic simulation)

I did the following simulations :


With the following results:

The B1 source should compute the derivative of V(IN_OUT) signal but that is not really the case.

Do you have an explanation for that (my simulation file here included)?

Thank you QSpice community

question.qsch (3.8 KB)

Try to change the integration method to gear, because that is trapezoidal ringing.
.options method=gear
And check page 20 of this manual.
Achieving Accurate Results With a Circuit Simulator.pdf (176.0 KB)

Best regards

1 Like

If you search trap ringing in this forum, you can find multiple posts discussed about this and with answer from Mike Engelhardt (author of Qspice).
Your example demonstrated how trap ringing can be observed. Spice uses numerical method and trapezoidal/gear integration method and they exhibit unique characteristics. In default, Qspice uses trapezoidal integration and trapezoidal ringing is one of its characteristics.

As your simulation is basically function and formula, not a circuit with realistic components, where function being integrated has sudden changes, and this is why trap ringing is observed. These slides explains why trap ringing in your setup (I simplified your circuit with a source disabled its timectrl). Change to Gear can eliminate this ringing, but remember this is not a recommended method as it changed your circuit by introduces artificial damping.


This is a method to get rid of trap ringing for derivative. Setup a DLL block (C++) and calculate derivative from two consecutive points can give you result of derivative which not relates to trap integration.

question-dll.qsch (4.4 KB)
derivativedll.qsym (334 Bytes)
derivativedll.cpp (1.7 KB)

C++ code


Hello Ivan ,

Thank you for your reply. In fact yes there is no more ringing but I got something like one “parasit” spike but this is the effect that the Gear methode can provides , see the post

Than you for your documentation !

Regards, Davide

Hello KSKelvin,
Thank you for your replies. Very complete an interesting.
I will use your dll . I use QSpice to simulate electromecanical actuators (valves) where I compute current , voltage , reluctance, magnetic flux, force, velocity and stroke with some limit conditions which make equations strongly non-linear. Thank you for your Help.


Nice clarification of ddt and trap ringing KSKelvin.

I noticed, if you take derivative of simulated data with waveform viewer function D(x), result will not suffer from trap ringing effect. Naturally you cannot use this during simulation, but if you are only intrested to see derivative of simulated signal this may be an option.

waveform-derivative.qsch (3.7 KB)


Didn’t think about this post-processing method, thanks for sharing.
Slope of V(IN_OUT) is correct and post-processing with DLL block or Waveform Viewer GUI can yield correct result. Trap ringing is also correct if you consider integration is area under curve which is what integration do.

Your test setup has actually helped me understand why trapezoidal ringing can occur! I have contemplated this topic many times, but this is the first instance where I have been able to comprehend and demonstrate its nature.