On Sun, Apr 20, 2025 at 03:19 AM, Udo Huhn-Rohrbacher wrote:
Spice error log shows:
z_value: z=3.14159265359
?
To our surprise, we observed different results between users, although the same setup was implemented.
Mike Engelhardt¡¯s LTspice XV!! Help-file Copyright ? 1998-2018 Analog Devices Corporation Shows on page 105:
The following constants are internally defined:
Name Value
E 2.7182818284590452354
pi 3.14159265358979323846
Looks OK so far.? The value listed in the Help just has more digits (greater precision) than the values printed in the Error Log file.? It should be obvious why that happened.
?
Do you have the different values for pi that you found from different users?? Can we see them?
?
If the value differed in different LTspice versions, perhaps its value was updated internally.? Anything identified as LTspice 24 was done by Analog Devices, not by Mike Engelhardt as either an LTC employee or an ADI employee.? Mike's value for pi might have been unchanged since before 2000 when he started working on SwitcherCAD III which became LTspice III.? New pairs of eyes (after Mike left) may have noticed that
pi's value needed to be corrected.
?
The solver was set to ?Alternate¡°. We assume, "Alternate" is 1000 times more accurate compared to ¡°Normal¡±
Let's be really careful about that statement.? The Alternate solver is not necessarily 1000 times more
accurate, even if the wording in the Help suggests that.? The Alternate solver has about 3 digits more numerical resolution because of the way its numbers are stored internally, and that extra resolution
could be capable of yielding better accuracy, but it does not guarantee it.? Accuracy is not the same as resolution.
?
Because SPICE/LTspice is a nonlinear circuit solver, what Tony said is true, that every result of a circuit calculation is an approximation and not exact.? This is not about numerical resolution or math calculation accuracy; it is because you can't get exact results from circuits that are nonlinear and whose parameters shift with the slightest change in the inputs, making it impossible to solve a voltage or current's value exactly.? This is where the SPICE *TOL settings affect the outcome.? SPICE/LTspice calculates differently when a circuit is 100% linear, and those calculations (and results) theoretically could be as accurate as the math allows them to be - those solutions are theoretically "exact", to the degree that the number resolution and the math allows them to be.
?
The values you printed from parameters has nothing to do with that.? Parameter values are set, or calculated from math formulas and then set, but they are never subject to Newton iterations which are at the core of SPICE's/LTspice's need to approximate nonlinear circuits.? Well, you did calculate a square-root and then a square, so yes, those calculations might be subject to whatever math (in)accuracy there is in your operating system's math routines.
?
Note that when LTspice needs to do a math calculation, it calls the appropriate O.S. math routine to actually do that calculation.? This is why we sometimes get strange error codes, coming from your O.S.'s math routines, which end up in the waveforms - values such as -1.#QNAN.? That is the math routine's error code.? Wine users and Windows users and MAC users might see different error codes in a few cases, because they are OS-specific.
?
Andy
?