Post Reply 
Problem with MVAR on HP42S
06-07-2020, 08:09 PM
Post: #1
Problem with MVAR on HP42S
Hello,

It seems I forgot how to use MVAR on HP42S:

I entered this stupid program:
LBL "COS"
MVAR "X"
RCL "X"
COS
RTN

Then when I do XEQ "COS", the answer is "Nonexistent", instead of letting me enter a value and press "X" to calculate cosinus. Why ?

I feel as stupid as my program ...

Thank you
Find all posts by this user
Quote this message in a reply
06-07-2020, 08:41 PM (This post was last modified: 06-07-2020 08:43 PM by grsbanks.)
Post: #2
RE: Problem with MVAR on HP42S
Do you actually have a variable called "X"?

If not, the error message you're getting is a result of the calculator attempting to recall (RCL) a variable that does not exist.

If you haven't already done so, I would suggest reading chapter 9 of the HP-42S user manual, which is the chapter that deals with program input and output. MVAR doesn't display any menus, all it does is tell the calculator that the variable is to be part of the menu if the menu is displayed with VARMENU.

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
06-09-2020, 01:24 AM
Post: #3
RE: Problem with MVAR on HP42S
As mentioned, the error is because you’ve never created X in memory.

As written, your program requires that you store the value of interest into X and then execute COS. That’s not what you describe you wanted to do. Maybe you’re confused because MVAR is typically used with a solver programs or much larger, non-trivial programs with LOTS of variables.

I find it easiest to always create the variables used first before entering the program with:

STO
Shift
Alpha (enter key)
Then type out the name
EXIT when done

Then when you use MVAR or RCL (or anything that references a variable), you can just press the upper row key for that variable. If you have lots of them, you’ll have to use the up/down arrow keys to find the one of interest.

Take away: trivial programs don’t use/need MVAR. What are you actually trying to accomplish? I doubt it is to create a program to calculate a cosine...
Find all posts by this user
Quote this message in a reply
06-09-2020, 04:27 AM
Post: #4
RE: Problem with MVAR on HP42S
(06-07-2020 08:09 PM)Pekis Wrote:  Hello,

It seems I forgot how to use MVAR on HP42S:

I entered this stupid program:
LBL "COS"
MVAR "X"
RCL "X"
COS
RTN

Then when I do XEQ "COS", the answer is "Nonexistent", instead of letting me enter a value and press "X" to calculate cosinus. Why ?

Change your MVAR "X" to INPUT "X" and see if it does what you want. No need to previously create the variable "X".

V.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-10-2020, 08:58 AM
Post: #5
RE: Problem with MVAR on HP42S
Hello,

Thanks for your answers.

All I wanted to do was a solver program to solve internal rate of return (IRR) of a cash flow set (including frequency for each cash flow).

I was rusty and this is how it ended up:

CF = Preexisting Cash flow matrix (amount in column 1, frequency in column 2, CF(1,1) < 0)
Use Solver with NPV to find IRR (Enter guess for interest rate "IR" (e.g. use 0.1 for 10%))
XEQ NPV alone calculates Net Present Value for the CF cash flow set (with "IR" value)

R03: Intermediary future value
R04: Intermediary total number of cash flows
R05: Current cash flow amount
R06: Current cash flow frequency

Code:

00 { 70-Byte Prgm }
01 LBL "NPV"
02 MVAR "IR"
03 INDEX "CF"
04 0
05 STO 03
06 STO 04
07 LBL 00
08 RCLEL
09 STO 05
10 J+
11 RCLEL
12 STO 06
13 STO+ 04
14 LBL 01
15 1
16 RCL+ "IR"
17 RCL× 03
18 RCL+ 05
19 STO 03
20 DSE 06
21 GTO 01
22 J+
23 FC? 77
24 GTO 00
25 1
26 RCL+ "IR"
27 1
28 RCL- 04
29 Y↑X
30 RCL× 03
31 RTN
32 END

Thanks !
Find all posts by this user
Quote this message in a reply
06-12-2020, 08:59 AM (This post was last modified: 06-12-2020 11:26 AM by Werner.)
Post: #6
RE: Problem with MVAR on HP42S
I had to try that out, too: NPV and IRR

I you want it to work like yours, you can leave out the lines referring to NPV:
(line 05 MVAR "NPV" and line 57 RCL- "NPV")
Then, to get the IRR, SOLVE the program "NPV".
To get the NPV, provide the values for CF0, CFj and IRR% (you can do that interactively with VARMENU "NPV", that is shift-PGM FCN, up, VARM) , and XEQ "NPV".

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 




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