| 1 | initial version |
The thing to understand is that the subs method work at the level of the expression tree : when the pattern is found in the tree, it is replaced.
For example, 2*(a + b) is represented as the following tree:
*
├── 2
└── +
├── a
└── b
However, the addition is not considered as a binary operation, but as an operation of arbitrary arity, hence 2*(a + b + c) is not represented as
*
├── 2
└── +
├── a
└── +
├── b
└── c
but as
*
├── 2
└── +
├── a
├── b
└── c
This implies that a+b is not a subtree of a+b+c.
In particular, you have to define two different rules to replace alpha_1^2 + beta_1^2 with 1 - gamma_1^2 and alpha_1^2 + beta_1^2 + gamma_1^2 with 1.
In terms of code, the previous explanations translate to:
sage: dkkr1.subs(alpha_1^2 + beta_1^2 == 1-gamma_1^2, alpha_1^2 + beta_1^2 + gamma_1^2 == 1)
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.