02-24-2019, 06:29 PM
If I wanted to, say, find what "x" would satisfy the integral of x^2 from 0 to x such that the area under the curve equaled 10, can this be accomplished in solve on an HP 42S?
00 { 12-Byte Prgm }
01▸LBL "f"
02 MVAR "t"
03 RCL "t"
04 X↑2
05 END
00 { 28-Byte Prgm }
01▸LBL "∫f"
02 MVAR "x"
03 RCL "x"
04 STO "ULIM"
05 PGMINT "f"
06 INTEG "t"
07 10
08 -
09 END
(02-24-2019 08:13 PM)Thomas Klemm Wrote: [ -> ]Code:
00 { 12-Byte Prgm }
01▸LBL "f"
02 MVAR "t"
03 RCL "t"
04 X↑2
05 END
Code:
00 { 28-Byte Prgm }
01▸LBL "∫f"
02 MVAR "x"
03 RCL "x"
04 STO "ULIM"
05 PGMINT "f"
06 INTEG "t"
07 10
08 -
09 END
You can set LLIM and ACC:
0
STO "LLIM"
1e-10
STO "ACC"
And then just use the SOLVER with the program ∫f and the variable x to get
3.10723250595
Cheers
Thomas
(02-25-2019 05:17 AM)Gerald H Wrote: [ -> ]Line 002 of programme f is not essential.
02 MVAR "x"
03 RCL "x"
04 STO "ULIM"
02 MVAR "ULIM"
(02-25-2019 05:17 AM)Gerald H Wrote: [ -> ]Line 002 of programme f is not essential.
05 PGMINT "f"
00 { 9-Byte Prgm }
01▸LBL "f"
02 RCL "x"
03 X↑2
04 END
00 { 19-Byte Prgm }
01▸LBL "∫f"
02 MVAR "ULIM"
03 INTEG "x"
04 10
05 -
06 END
(02-26-2019 03:15 AM)lrdheat Wrote: [ -> ]I will begin to try-relearn indirect addressing (last did this on an HP 67 in the 1970's
(02-26-2019 03:30 AM)Thomas Okken Wrote: [ -> ]Both have only one "indirect" register, which makes a lot of algorithms awkward to implement, always having to shuffle things around to get the right pointer into register 0 (which is the I equivalent on the 19C and 29C).
Compared to that, programming the 41C, where every register, even the stack registers, can be used for indirect addressing, is so much more pleasant, and the 42S inherited that programming model.
LBL A CLEAR REG
8 STO A
LBL 0 RCL 0 RCL A
x=y? GTO 4
1 STO+ 0
RCL 0 STO I
RCL A STO(i)
LBL 1 RCL B 1 + STO B
RCL 0 STO 9
LBL 2 1 STO- 9
RCL 9 x=0? GTO 0
RCL 0 STO I RCL(i)
RCL 9 STO I
Rv RCL(i) -
x=0? GTO 3
ABS RCL 0 RCL 9 -
x<>y? GTO 2
LBL 3 RCL 0 STO I
1 STO-(i)
RCL(i) x<>0? GTO 1
1 STO- 0
RCL 0 x<>0? GTO 3
LBL 4 RCL B
RTN
LBL A CLRG
8 STO 11
LBL 00 RCL 00 RCL 11
X=Y? GTO 04
ISG 00 DEG
STO IND 00
LBL 01 ISG 10 DEG
RCL 00 STO 09
LBL 02 DSE 09 DEG
RCL 09 X=0? GTO 00
RCL IND 00 RCL IND 09 -
X=0? GTO 03
ABS RCL 00 RCL 09 -
X<>Y? GTO 02
LBL 03 DSE IND 00 GTO 01
DSE 00 GTO 03
LBL 04 RCL 10
RTN
RCL 0 STO I RCL(i)
RCL 9 STO I
Rv RCL(i) -
RCL IND 00 RCL IND 09 -
(02-25-2019 08:09 AM)Thomas Klemm Wrote: [ -> ]So we end up with:
Code:
00 { 9-Byte Prgm }
01▸LBL "f"
02 RCL "x"
03 X↑2
04 END
Code:
00 { 19-Byte Prgm }
01▸LBL "∫f"
02 MVAR "ULIM"
03 INTEG "x"
04 10
05 -
06 END
Example:
0
STO "LLIM"
1e-10
STO "ACC"
PGMINT "f"
Then use the SOLVER with the program ∫f and the variable ULIM to get
3.10723250595
Cheers
Thomas
00 { 30-Byte Prgm }
01▸LBL "∫f"
02 MVAR "ACC"
03 MVAR "LLIM"
04 MVAR "ULIM"
05 INTEG "x"
06 10
07 -
08 END
(02-26-2019 07:41 AM)Werner Wrote: [ -> ]It would make sense to then add ACC and LLIM as MVARS to "∫f":
Code:
00 { 30-Byte Prgm }
01▸LBL "∫f"
02 MVAR "ACC"
03 MVAR "LLIM"
04 MVAR "ULIM"
05 INTEG "x"
06 10
07 -
08 END
.. makes it a lot easier to enter the numbers, and to play with different ACC's.
Cheers, Werner
0. { 21-Byte Prgm }
1. ►LBL "FXACC"
2. FIX IND ST X
3. +/-
4. 10^X
5. STO "ACC"
6. CLX
7. LASTX
8. +/-
9. END
0. { 26-Byte Prgm }
1. ►LBL "ΣDPREP"
2. STO "ULIM"
3. CLX
4. STO "LLIM"
5. INTEG "x"
6. END
0. { 96-Byte Prgm }
1. ►LBL "NPDF"
2. RCL "x"
3. X^2
4. -2
5. ÷
6. E^X
7. RTN
8. ►LBL "Z→P"
9. PGMINT "NPDF"
10. ►LBL 00
11. XEQ "ΣDPREP"
12. PI
13. RCL+ ST X
14. SQRT
15. ÷
16. 0.5
17. X<>Y
18. -
19. RTN
20. ►LBL "?Z"
21. RCL "z"
22. XEQ 00
23. RCL- 00
24. RTN
25. ►LBL "P→Z"
26. PGMINT "NPDF"
27. STO 00
28. PGMSLV "?Z"
29. 4
30. STO "z"
31. SIGN
32. SOLVE "z"
33. END