HP Forums
recall a function - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: recall a function (/thread-3146.html)



recall a function - salvomic - 02-19-2015 03:07 PM

hi,
please, I need hints to recall a function in the same program passing parameters.

The second function of this code won't work:
Code:

EXPORT gammad(k,t,n)
BEGIN
local f;
f:= (n^(k-1)*e^(-n/t))/(t^k*Gamma(k));
return f;
END;

EXPORT gamma_cdf(k,t,n)
BEGIN
local f,u;
f:= int(gammad(k,t,u), u, 0, n);
return f;
END ;

How to pass "u" as variable for the integral?

Also ProgName.gammad() doesn't works...


RE: recall a function - bobkrohn - 02-19-2015 03:32 PM

use a List?

L1(1):=f;
L1(2):=u;

RETURN L1;

or just...


RETURN {f,u}


RE: recall a function - salvomic - 02-19-2015 03:39 PM

or just...
RETURN {f,u}
[/quote]

no, I'm not using list:

my program has two functions:
gammad(k,t,n) and gammad_cdf(k,t,n)
from the second I want recall the first to make an integral, using u as "du".
With my code I get "bad argument: ex. using gammad_cdf(7.5,1,8) the program gives "int(gammad(7.5,1,0),0,0,8) error..." (it sees u=0 but (int(gammad(7.5,1,8),u,0,8) is ok)...


RE: recall a function - Han - 02-19-2015 05:02 PM

Any symbolic manipulation is going to require the CAS, with exception for a few commands. To get around this, you could try:

Code:
EXPORT gamma_cdf(k,t,n)
BEGIN
local f:= int((X^(k-1)*e^(-X/t))/(t^k*Gamma(k)), X, 0, n);
return f;
END ;

Sometimes it is possible to also quote an expression (e.g. 'X' vs X) although in HPPPL, quoted objects are still (generally) evaluated.


RE: recall a function - salvomic - 02-19-2015 05:12 PM

(02-19-2015 05:02 PM)Han Wrote:  Any symbolic manipulation is going to require the CAS, with exception for a few commands. To get around this, you could try:
...

thank you!
I didn't remember that...

with X it works!