Riccardo Guida wrote:
>
> The first thing I like to understand about a CAS is how evaluation works ..=
> .so, unable to find this topic on the documentation, I did some trials... A=
> nd here's my question:
>
> a:=b;
> b:=1;
> [a,eval(a),simplify(a)]
>
> returns [b, b,b].
>
> How can I force the interpreter in using the information that VALUE(b) =
> 1 in expressions containing a?
>
> This one-level evaluation behavior is similar to the one found in masyma, b
> ut there there is ev(a, infeval) which does the job and one gets 1.
> On the other hand Mathematica uses fixed-point infinite evaluation by defau
> lt so it returns 1 for a.
>
> The answer:
> eval(a, 'b = b)
> returns 1 but it is not satisfactory to me because it requires the apriori
> knowledge of all the variables involved in Value (a).
>
> Is there a better way to get 1 from a, or maybe not having it is a feature=
> of the language?
In a sense this is part of philosophy behing FriCAS. Namely, there
is programming language level, which is at core a very simple
imperative language. Things that you type at command line are
normally treated as expressions in FriCAS language and evaluated
as such. FriCAS supports multiple domains of computation and
each domain has much freedom in implementing wanted behaviour.
In particlar
[a,eval(a),simplify(a)]
at programming language level sees a list constructor containing
3 expressions and evaluates those expressions. 'a' simply gives
you current value of variable, 'eval(a)' and 'simplfy(a)' are
function calls to functions in 'Expression(Integer)'. Note
that at programming language level FriCAS knows nothing about
what 'eval' (or 'simplify') will do. FriCAS language is modular,
so 'eval' knows nothing about your variables, it sees only its
argument. In other words FriCAS works in mostly "context free" way.
As an illustration, AFAIK in Maxima to say that 'f' is a
function of 'x' and 'y' you would you 'depends' which would
put this information in environment. In FriCAS you need to
write 'f(x, y)' to explictly denote dependence:
(1) -> opf := operator 'f
(1) f
Type: BasicOperator
(2) -> opf(x, y)
(2) f(x,y)
Type: Expression(Integer)
Admitedly, this goes against usual mathematical practise where
a lot of information is contained in context. But it also
avoids bugs due to "environment pollution" when values from
environment cause unintended effects.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.