Ralf Hemmecke wrote:
> 
> (1) -> s := operator 'sin
> 
>     (1)  sin
>                               Type: BasicOperator
> (2) -> c := operator 'cos
> 
>     (2)  cos
>                               Type: BasicOperator
> (3) -> simplify((s x)^2 + (c x)^2 -1)
> 
>                  2         2
>     (3)  - cos(x)  + cos(x)
>                               Type: Expression(Integer)
> 
> That is probably the standard case that I see something that looks 
> equal, but isn't.
> 
> But isn't it strange that the simplify function recognized sin and 
> replaced it with the corresponding cos expresssion, but for + they are 
> two different cos's now.
> 
> I would call this a bug. Opinions?
> 
> Well, I could understand this one
> 
> (6) -> cos x - c x
> 
>     (6)  cos(x) - cos(x)
>                                Type: Expression(Integer)
> 
> But it is also not very nice that this is possible.
> 
> I know that making something canonical isn't trivial, but there's only a 
> finite number of functions like cos in the exports of Expression(X) that 
> must be considered.
> 

Look at:

(1) -> c := operator 'cos                       

   (1)  cos
                                                          Type: BasicOperator
(2) -> c2 := operator(kernels(cos(x)).1)

   (2)  cos
                                                          Type: BasicOperator
(3) -> (c = c2)@Boolean                 

   (3)  false
                                                                Type: Boolean
(4) -> (c2 = operator(c2)$Expression(Integer))@Boolean

   (4)  true
                                                                Type: Boolean

You get two different operators.  To get 'true cos' you need to
use the 'operator' function twice, first getting general operator,
than the canonical version in Expression(Integer).

I am not sure if I should call this a bug: this is limitation
of current design of our symbolic machinery.  Namely, we
store data in operators, so 'cos' in Expression(Integer)
must be different than 'cos' in Expression(Fraction(Integer)).

This implies that coercions must actually produce _new_
operator, like in fourth line above.

AFAICS the assumption in most of algebra code is that there
is only one valid operator with given name, so operators
can be compared by name.  So using operator with the some
name as library function should be considerd as user error.
If you do this, in some constexts, based on name such operator
is treated as it would be a library operator (so the chanege
of your 'sin(x)^2' to '1 - cos(x)^2') but in other contexts
it is treated as unequal...

-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to