Post Reply 
50g multiple output
12-11-2021, 02:18 AM (This post was last modified: 12-11-2021 04:23 AM by nlj.)
Post: #11
RE: 50g multiple output
Hi oierpa,

(12-10-2021 06:53 PM)oierpa Wrote:  I think that my biggest problem is entering understanding logic of User RPL.

I feel that you are maybe making it more complicated for yourself than it need be. With the exception of a few control flow constructs almost everything in UserRPL is exactly the same as the RPN you use when using the calculator interactively*.

The only thing you really need to wrap your mind around is the simple idea that commands take zero or more arguments off the bottom of the stack and return zero or more results there.

[* If you normally use the calculator in algebraic mode, I suggest you switch it RPN mode at least to get yourself in the right mindset for programming the calculator.]

(12-10-2021 06:53 PM)oierpa Wrote:  Anyway I make few test and of course it works.
Now last running version is:
Code:
<<"Ins C t A n" {
    ":C:
     :t:
     :A:
     :n:" {1 0} V} INPUT OBJ-> -> C t A n
     << t 100 / n / DUP 1+ n  
     A * NEG ^ NEG 1 + / C * 
     'R' STO>>
      n A *
      R * "M" -> TAG 
      ->STR "
      " ->STR + 'R' RCL "R" -> TAG 
      ->STR +
      MSGBOX 'R' PURGE
       >>
This work fine, so I tried some new versions using your suggestions.

I don't think that is actually working the way you intend because the `n A *' expression is not using your local variables n and A but whatever values you happen to have stored in them globally.

(12-10-2021 06:53 PM)oierpa Wrote:  Version with algebraic formula:
Code:

<<"Ins C t A n" {
    ":C:
     :t:
     :A:
     :n:" {1 0} V} INPUT OBJ-> -> C t A n
     << C t A n 'C* (t/100/n)/(1-(1+t/100/n)^(-n*a))' EVAL
     'R' STO 'R*n*A' EVAL >> 'M' RCL "M" -> TAG 
     -> STR "
" -> STR + 'R' RCL "R" ->TAG
-> STR +
      MSGBOX 'R' PURGE 'M' PURGE
       >>
Calculation time over a minute and an error occurred (insufficient memory)

Ah, now you have gotten in quite a tangle!

One thing that jumps out at me is that you haven't defined the lower case `a' in your long algebraic so that will be accessing an arbitrary global variable if you have one defined -- and if you haven't you're asking the CAS to evaluate an expression with an unknown.

To get back on track I suggest you re-read Chapter 1 on the Advanced User's Reference Manual slowly, and try little bits of your program interactively.

Also consider this simpler code which expects to get values for C, t, A and n off the stack and returns R and M to the stack (appropriately tagged). [To avoid for now your long algebraic expression, in this example R is the sum of C, t, A, and n.]

Code:

<< 0 0 -> C t A n R M
    << 'C + t + A + n' ->NUM 'R' STO
        'R * n * A' ->NUM 'M' STO 
        R "R" ->TAG
        M "M" ->TAG
    >>
>>

I hope this helps a bit!

[Edit: Replacing EVAL with ->NUM, otherwise the calculator needs to be in Numeric Results Mode (unless an exact rational result is desired, but calculating that here is very slow).]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
50g multiple output - oierpa - 12-03-2021, 03:43 PM
RE: 50g multiple output - DA74254 - 12-03-2021, 09:44 PM
RE: 50g multiple output - Joe Horn - 12-03-2021, 10:42 PM
RE: 50g multiple output - oierpa - 12-04-2021, 08:13 AM
RE: 50g multiple output - nlj - 12-05-2021, 02:35 PM
RE: 50g multiple output - oierpa - 12-05-2021, 06:23 PM
RE: 50g multiple output - John Keith - 12-06-2021, 12:39 PM
RE: 50g multiple output - oierpa - 12-06-2021, 02:36 PM
RE: 50g multiple output - nlj - 12-06-2021, 05:59 PM
RE: 50g multiple output - oierpa - 12-10-2021, 06:53 PM
RE: 50g multiple output - nlj - 12-11-2021 02:18 AM
RE: 50g multiple output - DavidM - 12-11-2021, 02:45 PM
RE: 50g multiple output - oierpa - 01-10-2022, 11:45 AM
RE: 50g multiple output - DavidM - 01-10-2022, 12:16 PM



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