Post Reply 
Example of MISO solver for WP 34s
05-24-2018, 06:17 PM (This post was last modified: 05-24-2018 06:59 PM by Dieter.)
Post: #7
RE: Example of MISO solver for WP 34s
(05-23-2018 07:36 PM)Dieter Wrote:  So there should be a better solution for flagging the variable to solve for. I have been thinking about several methods, but none is really convincing. Maybe someone has a better idea?

If the input can be essentially ...anything, there are two basic methods:

- At the input prompt, press a key like B or C to continue at a different position in the program. This sounds nice ("simply press B at the input prompt when this is the variable you want to solve for"), but it will not work here as it pops the return stack. So the next RTN will not return from the pending subroutine call (LBL 99 or "VAR") to continue with the next variable input, instead the program will simply stop. However, this can be fixed by changing the XEQ calls into GTOs and then jump back to the next variable input with a GTO→J. Of course this requires ten additional labels 01...10. If you want to give it a try, here is the code. Press B when the variable to solve for shows up.

Code:
001 LBL A
002 CLx
003 STO J
004 STO K
005 CLα
006 α'S'
007 GTO 99
008 LBL 01
009 α'Pe'
010 GTO 99
011 LBL 02
012 α'Pwf'
013 GTO 99
014 LBL 03
015 α'q'
016 GTO 99
017 LBL 04
018 α'Bo'
019 GTO 99
020 LBL 05
021 α'μ'
022 GTO 99
023 LBL 06
024 α'k'
025 GTO 99
026 LBL 07
027 α'h'
028 GTO 99
029 LBL 08
030 α'Re'
031 GTO 99
032 LBL 09
033 α'Rw'
034 GTO 99
035 LBL 10
036 RCL K
037 x≥1?
038 GTO 00
039 CLα
040 α'Sel'
041 α'ect'
042 α' Va'
043 α'r !'
044 VIEWα
045 PSE 20
046 GTO A
047 LBL 00
048 STO J
049 # 1/2
050 RCL×→J
051 # 002
052 RCL×→J
053 SLV'SSR'
054 SKIP 001
055 ERR 20
056 RTN
057 LBL 99
058 INC J
059 α'=?'
060 RCL→J
061 PROMPT
062 SKIP 004
063 LBL B
064 RCL J
065 STO K
066 R↓
067 STO→J
068 CLα
069 GTO→J
070 LBL'SSR'
071 STO→J
072 RCL 07
073 RCL× 08
074 RCL 02
075 RCL- 03
076 ×
077 # 002
078 SDR 001
079 # 141
080 +
081 RCL× 06
082 RCL× 05
083 RCL 09
084 RCL/ 10
085 LN
086 RCL+ 01
087 ×
088 /
089 RCL- 04
090 RTN

- Use a flag. That's what the next version does. Here the program expects the user to set flag A when the prompt for the variable to solve for appears (press SF A). This turns on the big "=" sign in the display, so there is a visual feedback.

Here is the code:

Code:
001 LBL A
002 CLx
003 STO J
004 STO K
005 CLα
006 α'S'
007 XEQ 99
008 α'Pe'
009 XEQ 99
010 α'Pwf'
011 XEQ 99
012 α'q'
013 XEQ 99
014 α'Bo'
015 XEQ 99
016 α'μ'
017 XEQ 99
018 α'k'
019 XEQ 99
020 α'h'
021 XEQ 99
022 α'Re'
023 XEQ 99
024 α'Rw'
025 XEQ 99
026 RCL K
027 x≥1?
028 GTO 00
029 CLα
030 α'Sel'
031 α'ect'
032 α' Va'
033 α'r !'
034 VIEWα
035 PSE 20
036 GTO A
037 LBL 00
038 STO J
039 # 1/2
040 RCL×→J
041 # 002
042 RCL×→J
043 SLV'SSR'
044 SKIP 001
045 ERR 20
046 RTN
047 LBL 99
048 INC J
049 CF A
050 α'=?'
051 RCL→J
052 PROMPT
053 STO→J
054 RCL J
055 FS?C A
056 STO K
057 CLα
058 RTN
059 LBL'SSR'
060 STO→J
061 RCL 07
062 RCL× 08
063 RCL 02
064 RCL- 03
065 ×
066 # 002
067 SDR 001
068 # 141
069 +
070 RCL× 06
071 RCL× 05
072 RCL 09
073 RCL/ 10
074 LN
075 RCL+ 01
076 ×
077 /
078 RCL- 04
079 RTN

In both cases the program also takes the input at this prompt as an estimate for the solution. It feeds 1/2x and 2x this value as the two initial guesses into the solver. So if you enter 100 the first two guesses are 50 and 200. Adjust this as you like with the two factors in line 049/051 or 039/041, respectively.

Now try it and see if this works for you. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Example of MISO solver for WP 34s - Dieter - 05-24-2018 06:17 PM



User(s) browsing this thread: 1 Guest(s)