HP Forums

Full Version: CAS Vars and integrals
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone. I have a problem to raise. I wrote a small #cas-program (see below) which performs a definite integral. Each time I launch the program, the integration variable (for example “t”) is stored in “CAS Vars”. Is there any way to avoid storing the variable in “CAS Vars”?
Also, sometimes not only the integration variable is stored in “CAS Vars”, but other things like question marks or whatever. How do I avoid this.
Best regards, Roberto.

Code:
#cas
Beta_r(z,a,b):=
BEGIN
LOCAL funz;
funz:=(t)→(t^(a-1)*(1-t)^(b-1));
RETURN int(funz(t),t,0,z);
END;
#end
[code]
Hello,

If you want the 't' variable to be local to your program, you have to declare it in the LOCAL statement. Otherwise, your code is using a global CAS variable named 't', that make it appears in the VAR CAS sub menu.

Try this :
#cas
Beta_r(z,a,b):=
BEGIN
LOCAL funz,t;
funz:=(t)→(t^(a-1)*(1-t)^(b-1));
RETURN int(funz(t),t,0,z);
END;
#end
Hi, robmio

I did try OP code. Global t is not affected.

CAS> purge(t)               → "No such variable t"
CAS> Beta_r(1,2,3)       → 1/12
CAS> t       → t

CAS> t := 99
CAS> Beta_r(1,2,3)       → 1/12
CAS> ∫(t^3, t = 0 .. 1)  → 1/4
CAS> t       → 99

Definite integral variable (and function arguments) are supposed to be local.
Requiring LOCAL for these is a bug, and should be fixed.

In the meantime, a hard reset should do the trick.
see https://www.hpmuseum.org/forum/thread-16...#pid148129
If you (either, both) believe it's a bug (and it seems so) you should report it to Tim and Cyrille; you can contact them via PM here. It's a sure bet to get attention sooner if they're notified than hoping they notice and read each and every thread, looking for possible conclusions that it is indeed a bug. Many threads with innocuous titles like this one may simply be a user asking a question, confused, etc. and not likely to grab their attention.
Reference URL's