login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBoxOperatorsAndSqrt revision 2 of 2

1 2
Editor: test1
Time: 2015/06/01 19:17:14 GMT+0
Note:

added:
'f(x)' is computed by 'elt' in ExpressionSpace.  'elt' uses 'belong?' to
check for correct operator and complains otherwise.

AlgebraicNumber defines:

    belong? op           == belong?(op)$ExpressionSpace_&(%) or has?(op, ALGOP)


changed:
-whereas Expression overrides this with::
so 'f' is not among allowed operators, whereas Expression defines::

This fails unexpectedly:

fricas
(1) -> f:=operator 'f

\label{eq1}f(1)
Type: BasicOperator?
fricas
f(sin(-1))

\label{eq2}f \left({-{\sin \left({1}\right)}}\right)(2)
Type: Expression(Integer)
fricas
f(sqrt(-1))
>> Error detected within library code: Unknown operator 3: f

But this works

fricas
f(sqrt(-1)::Expression(Integer))

\label{eq3}f \left({\sqrt{- 1}}\right)(3)
Type: Expression(Integer)

This happens because sqrt(-1) is interpreted as an AlgebraicNumber? and

fricas
AlgebraicNumber has ExpressionSpace

\label{eq4} \mbox{\rm true} (4)
Type: Boolean

f(x) is computed by elt in ExpressionSpace?. elt uses belong? to check for correct operator and complains otherwise.

AlgebraicNumber? defines:

belong? op == belong?(op)$ExpressionSpace?_&(%) or has?(op, ALGOP)

while ExpressionSpace? exports:

    belong? op   ==
        has?(op, 'any) and (is?(op, PAREN) or is?(op, BOX))

so f is not among allowed operators, whereas Expression defines:

    belong? op == true