Post Reply 
Define an immediate function in RPN mode
12-30-2023, 03:51 PM (This post was last modified: 12-30-2023 08:52 PM by deSitter.)
Post: #1
Define an immediate function in RPN mode
Hello, I'd like to have e.g. the gamma function be immediate like SIN and COS and not require parenthesis. Is that doable, to define an immediate function that pops the stack into the argument slot? Has to work with complex values. This calculator is certainly a strange beast. Thanks in advance. PS obviously, in RPN mode..

-drl
Find all posts by this user
Quote this message in a reply
01-01-2024, 07:08 PM
Post: #2
RE: Define an immediate function in RPN mode
(12-30-2023 03:51 PM)deSitter Wrote:  Hello, I'd like to have e.g. the gamma function be immediate like SIN and COS and not require parenthesis. Is that doable, to define an immediate function that pops the stack into the argument slot? Has to work with complex values. This calculator is certainly a strange beast. Thanks in advance. PS obviously, in RPN mode..

Turns out that the CAS Gamma function has some undocumented optional parameters. (See below for documentation from Xcas.) Since the function can take up to 3 parameters, in RPN you have to specify Gamma(1), Gamma(2), or Gamma(3) depending on how many parameters you want to use.

One way around this would be to write your own gamma function, say something like
Code:
EXPORT gamma(x)
BEGIN
 CAS.Gamma(EVAL(x));
END;

Then in RPN, you could just enter gamma without parentheses. (Notice the use of lowercase gamma to distinguish it from the built-in Gamma.)


Just for the record, according to the Xcas documentation,
Gamma(a)=∫(t^(a-1)*e^(-t),t,0,∞)
Gamma(a,b)=ugamma(a,b) where ugamma(a,b)=∫(t^(a-1)*e^(-t),t,b,∞)
Gamma(a,b,1)=ugamma(a,b) / Gamma(a); (the 1 can be any non-zero value)
Find all posts by this user
Quote this message in a reply
Post Reply 




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