在 Maxima 中使用 letsimp 进行简化,这是怎么回事?
Simplification with letsimp in Maxima, what is going on?
这是一个简单的 maxima 会话,我在其中尝试进行简化 (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
为什么 maxima 将 (r-r0) 替换为 r 而不是 h ?
我按照另一个问题中的指示尝试了 letsimp 和 letrat:common subexpressions
r - r0
不是 let
支持的形式。来自文档:
-- Function: 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.
在这种情况下,可以从句法替换开始:
(%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
这是一个简单的 maxima 会话,我在其中尝试进行简化 (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
为什么 maxima 将 (r-r0) 替换为 r 而不是 h ? 我按照另一个问题中的指示尝试了 letsimp 和 letrat:common subexpressions
r - r0
不是 let
支持的形式。来自文档:
-- Function: 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.
在这种情况下,可以从句法替换开始:
(%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