Cadabra
a field-theory motivated approach to computer algebra

zoom

Only show selected terms in a sum, and restrict subsequent algorithms to these terms.
Often you want manipulations to only apply to a selected subset of terms in a large sum. The zoom algorithm makes only certain terms visible, representing the remaining terms with dots. Here is an expression with a 5 terms,
ex:=\int{ A_{m n} + B_{m n} C + D_{m} F_{n} C + T_{m n} + B_{m n} R}{x};
\(\displaystyle{}\int \left(A_{m n}+B_{m n} C+D_{m} F_{n} C+T_{m n}+B_{m n} R\right)\,\,{\rm d}x\)
\int{A_{m n} + B_{m n} C + D_{m} F_{n} C + T_{m n} + B_{m n} R}{x}
In order to restrict attention only to the terms containing a $B_{m n}$ factor, we use
zoom(_, $B_{m n} Q??$);
\(\displaystyle{}\int \left( ... +B_{m n} C+ ... +B_{m n} R\right)\,\,{\rm d}x\)
\int{ ... + B_{m n} C + ... + B_{m n} R}{x}
Subsequent algorithms only work on the visible terms above, not on the terms hidden inside the dots,
substitute(_, $C->Q$);
\(\displaystyle{}\int \left( ... +B_{m n} Q+ ... +B_{m n} R\right)\,\,{\rm d}x\)
\int{ ... + B_{m n} Q + ... + B_{m n} R}{x}
To make the hidden terms visible again, use unzoom, and note that the third term below has remained unaffected by the substitution above,
unzoom(_);
\(\displaystyle{}\int \left(A_{m n}+B_{m n} Q+D_{m} F_{n} C+T_{m n}+B_{m n} R\right)\,\,{\rm d}x\)
\int{A_{m n} + B_{m n} Q + D_{m} F_{n} C + T_{m n} + B_{m n} R}{x}
The zoom/unzoom combination is somewhat similar to the old deprecated take_match/replace_match algorithms, but makes it more clear that terms have been suppressed.
Copyright © 2001-2018 Kasper Peeters
Questions? info@cadabra.science