CAS Vars and integrals
08-24-2021, 05:37 AM
Post: #1
 robmio Member Posts: 164 Joined: Jan 2020
CAS Vars and integrals
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]
08-24-2021, 06:09 PM (This post was last modified: 08-24-2021 06:28 PM by C.Ret.)
Post: #2
 C.Ret Member Posts: 218 Joined: Dec 2013
RE: CAS Vars and integrals
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
08-24-2021, 08:56 PM
Post: #3
 Albert Chan Senior Member Posts: 2,103 Joined: Jul 2018
RE: CAS Vars and integrals
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.
08-24-2021, 11:56 PM
Post: #4
 rprosperi Super Moderator Posts: 5,536 Joined: Dec 2013
RE: CAS Vars and integrals
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.

--Bob Prosperi
 « Next Oldest | Next Newest »

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