Post Reply 
recall a function
02-19-2015, 03:07 PM
Post: #1
recall a function
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...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
02-19-2015, 03:32 PM
Post: #2
RE: recall a function
use a List?

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

RETURN L1;

or just...


RETURN {f,u}
Find all posts by this user
Quote this message in a reply
02-19-2015, 03:39 PM
Post: #3
RE: recall a function
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)...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
02-19-2015, 05:02 PM
Post: #4
RE: recall a function
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.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
02-19-2015, 05:12 PM
Post: #5
RE: recall a function
(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!

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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