HP Forums
CAS Vars and integrals - 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: CAS Vars and integrals (/thread-17388.html)



CAS Vars and integrals - robmio - 08-24-2021 05:37 AM

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]



RE: CAS Vars and integrals - C.Ret - 08-24-2021 06:09 PM

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



RE: CAS Vars and integrals - Albert Chan - 08-24-2021 08:56 PM

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-16635-post-148129.html#pid148129


RE: CAS Vars and integrals - rprosperi - 08-24-2021 11:56 PM

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.