HP Forums

Full Version: recall a function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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...
use a List?

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

RETURN L1;

or just...


RETURN {f,u}
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)...
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.
(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!
Reference URL's