Упрощение с letimp в Maxima, что происходит? - PullRequest
2 голосов
/ 14 апреля 2020

Вот простой сеанс с максимумами, в котором я пытаюсь сделать упрощение (r-r0) = h

(%i1) ax: G*M*m*(r-r0)/r0^2 - G*M*m/r0 ;
                            G M m (r - r0)   G M m
(%o1)                       -------------- - -----
                                   2          r0
                                 r0
(%i2) let(r-r0,h);
(%o2)                            r - r0 --> h
(%i3) expand(scanmap(letsimp,ax));
                               G M m r   2 G M m
(%o3)                          ------- - -------
                                   2       r0
                                 r0

Я ожидал этого в последней части:

                               G M m h   2 G M m
                              ------- - -------
                                   2       r0
                                 r0

Почему максимумы заменили (r-r0) на r , а не h ? Iv попытался letimp и letrat, как указано в этом другом вопросе: общие подвыражения

1 Ответ

2 голосов
/ 16 апреля 2020

r - r0 не поддерживается формой let. Из документации:

- Функция: let let (,,,, ...,) let ([,,,, ...,],)

 Defines a substitution rule for 'letsimp' such that <prod> is
 replaced by <repl>.  <prod> is a product of positive or negative
 powers of the following terms:

    * Atoms which 'letsimp' will search for literally unless
      previous to calling 'letsimp' the 'matchdeclare' function is
      used to associate a predicate with the atom.  In this case
      'letsimp' will match the atom to any term of a product
      satisfying the predicate.
    * Kernels such as 'sin(x)', 'n!', 'f(x,y)', etc.  As with atoms
      above 'letsimp' will look for a literal match unless
      'matchdeclare' is used to associate a predicate with the
      argument of the kernel.

В этом случае можно начать с подстановки syntacti c:

    (%i1) ax: G*M*m*(r-r0)/r0^2 - G*M*m/r0 $

    (%i2) subst(h, r - r0, ax);
                                    G M h m   G M m
    (%o2)                           ------- - -----
                                        2      r0
                                      r0
...