On Sun, Feb 09, 2025 at 01:59:29PM +0100, 'Ralf Hemmecke' via FriCAS - computer 
algebra system wrote:
> Dear Waldek,
> 
> thanks a lot for you description for decomposing the result of 'guess'.
> 
> I now wanted to rename the running variable by simply modifying the third
> entry in the argument list of the %defprod kernel and reconstruct.
> 
> %%% (2) -> p := product(x^2+x+1, x=1..n)
> 
>           n
>         ++-++   2
>    (2)   | |   x  + x + 1
>          | |
>         x = 1
> %%% (3) -> k := kernels(p).1; o := operator k; a := argument k
> 
>            2
>    (3)  [%B  + %B + 1, %B, x, 1, n]
>                                 Type: List(Expression(Integer))
> 
> %%% (4) -> py := o [a.1,a.2,y,a.4,a.5]
> 
>           n
>         ++-++   2
>    (4)   | |   x  + x + 1
>          | |
>         x = 1
>                                       Type: Expression(Integer)
> 
> Unfortunately, that does not replace x by y. :-(

This is design choice in current Expression.  Consider:

(1) -> product(i, i=1..n)

          n
        ++-++
   (1)   | |   i
         | |
        i = 1
                                                    Type: Expression(Integer)
(2) -> product(i, i=1..n) - product(j, j=1..n)

   (2)  0
                                                    Type: Expression(Integer)
(3) -> product(j, j=1..n)                     

          n
        ++-++
   (3)   | |   i
         | |
        i = 1
                                                    Type: Expression(Integer)

(2) is obtained thanks to (3).  More precisely, when creating new
kernel FriCAS tests if it is equal to one of the already existing
kernels and in such case returns the old one.  In case of sums and
products FriCAS knows that indices are "dummies" and their names
do not take part in comparison.

If you want different behaviour, there is now KernelCategory,
you should be able to define new kind of kernels which behaves
differently.  But a lot of things in algebra depend on current
behaviour of Kernel, so that is not an easy change.

Alternatively, there were few attempts to create "symbolic"
domains, you could use any of them to represent more general
expressions, possibly converting to/from Expression to
perform actual computations.

> The following works, but is certainly not what I want because of a
> destructive operation that also modifies the original p.
> 
> Ralf
> 
> %%% (5) -> a.3 := y
> 
>    (5)  y
> 
> %%% (6) -> a
> 
>            2
>    (6)  [%B  + %B + 1, %B, y, 1, n]
>                                 Type: List(Expression(Integer))
> %%% (7) -> p
> 
>           n
>         ++-++   2
>    (7)   | |   y  + y + 1
>          | |
>         y = 1
>                                      Type: Expression(Integer)
> %%% (8) -> o a
> 
>           n
>         ++-++   2
>    (8)   | |   y  + y + 1
>          | |
>         y = 1
>                                      Type: Expression(Integer)

That is problematic, kernel cache should be sorted, but modification
changes ordering relation.  You may get "lucky" because some cases
revert to linear search.

-- 
                              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 view this discussion visit 
https://groups.google.com/d/msgid/fricas-devel/Z6ivKVYhidFJyzwZ%40fricas.org.

Reply via email to