Giles Atkinson - 2025-10-09

An interesting test case!

The expression parser generates expressions for the differentials of the primary expression with respect to the circuit variables. For pow(a, b), calculating pow(a, b -1) is a shortcut used only when b is a constant. When b is an expression a different formula is used (D(pow(a,b)) = pow(a,b) * (D(b)log(abs(a)) + bD(a)/a)).

So if there is a bug here, it is failing to check the constant value. With that added, no failure. Your test case also shows that constant-valued expressions are not evaluated at parse time, perhaps a useful optimisation.