(08-27-2017 03:15 PM)Dieter Wrote: (08-27-2017 06:18 AM)Skirmitch Wrote: LBL "PAR2"
INPUT "R1"
1/X
INPUT "R2"
1/X
+
1/X
END
This program will not work correctly if you enter a value at the R1 resp. R2 prompt. If you do so, the previous content of that variable (the value displayed after "R1?" resp. "R2?") will be pushed to Y and the new value is in X. So this mixes up the stack contents and the calculation will go wrong. Some later calculators, e.g. the 35s, behave differently in this regard.
Anyway, you can do it this way:
Code:
01 LBL "PAR2"
02 INPUT "R1"
03 INPUT "R2"
04 RCL"R1"
05 1/X
06 RCL"R2"
07 1/X
08 +
09 1/X
10 "Rtotal="
11 AVIEW
12 END
You can insert a STO "R1" between line 09 and 10 so that the result is stored as input for the next calculation. This way you can add further resistors in parallel without having to re-enter the last result.
But you can also do it without this fancy prompting and named variables:
Code:
01 LBL "PAR"
02 1/X
03 x<>y
04 1/X
05 +
06 1/X
07 END
Or even better since it also allows zero resistances:
Code:
01 LBL "PAR"
02 RCLx ST Y
03 x<>y
04 RCL+ ST L
05 /
06 END
If you replace line 03 with RCL ST Y you can even see both the current result in X and the previous one in Y. ;-)
Both versions work for as many resistors in parallel as you like:
100 [ENTER] 150 [XEQ]"PAR" => 60
200 [R/S] => 46,15
50 [R/S] => 24
Dieter
Your third code not only allows zero resistances but is also more accurate, especially if there are both large and small resistances involved. Joe Horn explains the concept
here.
For the 48gx and later, this can be simply expressed as:
\<< DUP \GPLIST DUP ROT / \GSLIST / \>>
for a list of two or more resistances.
John