Menu

#828 sqrt of negative numbers

v1.0 (example)
open
nobody
None
5
2026-02-12
2026-02-12
No

In the section for Behavioral sources, the manual says "If the argument of log, ln, or sqrt becomes less than zero, the absolute value of the argument is used". However, I tested sqrt with negative arguments in B sources, and a transient simulation aborts at the moment when the argument becomes negative.

The attached test circuit demonstrates the simulator aborting when the argument to sqrt is negative. I tested no compatibility mode, pspice compatibility mode an ltspice compatibility mode, and they all abort the same way.

I tested sqrt in B sources in three other simulators. PSPICE for TI and spice3f5 evaluate sqrt(abs(x)) when x in sqrt(x) is negative, while ltspice returns 0 for sqrt when the argument is negative.

I am using ngspice 45.2 running in Ubuntu on a 64-bit Intel processor.

Victor

1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB