For information about the theory behind this, see Electronic Circuit & System Simulation Methods by Pillage