Cadabra
a field-theory motivated approach to computer algebra

cdb.core.component

Simple access to component expressions
This package contains helper functions to access components of tensors, as they are computed by e.g. evaluate.

get_component(ex: Ex, component: Ex) -> Ex

Extract a single component from an expression.
Gets a component of an expression resulting from an evaluate command. The component argument for vector-like objects should be e.g. $t$, and for higher-rank tensors like e.g. $x, t$.
{t,x}::Coordinate; {i,j}::Indices(values={t,x}); ex:= a_{i}; evaluate(ex, $a_{t}=1, a_{x}=2$);
\(\displaystyle{}\text{Attached property Coordinate to }\left[t, x\right].\)
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left[i, j\right].\)
\(\displaystyle{}a_{i}\)
a_{i}
\(\displaystyle{}\square{}_{i}\left\{\begin{aligned}\square{}_{t}= & 1\\[-.5ex] \square{}_{x}= & 2\\[-.5ex] \end{aligned}\right. \)
\components_{i}({{t} = 1, {x} = 2})
get_component(ex, $x$);
\(\displaystyle{}2\)
2

remove_zero_components

Remove all components of an expression that are equal to zero.
{x, y, z}::Coordinate. {i, j}::Indices(values={x, y, z}, position=fixed). ex := a_{i}a_{j}; evaluate(ex, $a_{x} = k, a_{y} = l, a_{z} = m$); substitute(ex, $k m -> 0$); remove_zero_components(ex);
\(\displaystyle{}a_{i} a_{j}\)
a_{i} a_{j}
\(\displaystyle{}\square{}_{i}{}_{j}\left\{\begin{aligned}\square{}_{x}{}_{x}= & {k}^{2}\\[-.5ex] \square{}_{x}{}_{y}= & k l\\[-.5ex] \square{}_{x}{}_{z}= & k m\\[-.5ex] \square{}_{y}{}_{x}= & k l\\[-.5ex] \square{}_{y}{}_{y}= & {l}^{2}\\[-.5ex] \square{}_{y}{}_{z}= & l m\\[-.5ex] \square{}_{z}{}_{x}= & k m\\[-.5ex] \square{}_{z}{}_{y}= & l m\\[-.5ex] \square{}_{z}{}_{z}= & {m}^{2}\\[-.5ex] \end{aligned}\right. \)
\components_{i j}({{x, x} = (k)**2, {x, y} = k l, {x, z} = k m, {y, x} = k l, {y, y} = (l)**2, {y, z} = l m, {z, x} = k m, {z, y} = l m, {z, z} = (m)**2})
\(\displaystyle{}\square{}_{i}{}_{j}\left\{\begin{aligned}\square{}_{x}{}_{x}= & {k}^{2}\\[-.5ex] \square{}_{x}{}_{y}= & k l\\[-.5ex] \square{}_{x}{}_{z}= & 0\\[-.5ex] \square{}_{y}{}_{x}= & k l\\[-.5ex] \square{}_{y}{}_{y}= & {l}^{2}\\[-.5ex] \square{}_{y}{}_{z}= & l m\\[-.5ex] \square{}_{z}{}_{x}= & 0\\[-.5ex] \square{}_{z}{}_{y}= & l m\\[-.5ex] \square{}_{z}{}_{z}= & {m}^{2}\\[-.5ex] \end{aligned}\right. \)
\components_{i j}({{x, x} = (k)**2, {x, y} = k l, {x, z} = 0, {y, x} = k l, {y, y} = (l)**2, {y, z} = l m, {z, x} = 0, {z, y} = l m, {z, z} = (m)**2})
\(\displaystyle{}\square{}_{i}{}_{j}\left\{\begin{aligned}\square{}_{x}{}_{x}= & {k}^{2}\\[-.5ex] \square{}_{x}{}_{y}= & k l\\[-.5ex] \square{}_{y}{}_{x}= & k l\\[-.5ex] \square{}_{y}{}_{y}= & {l}^{2}\\[-.5ex] \square{}_{y}{}_{z}= & l m\\[-.5ex] \square{}_{z}{}_{y}= & l m\\[-.5ex] \square{}_{z}{}_{z}= & {m}^{2}\\[-.5ex] \end{aligned}\right. \)
\components_{i j}({{x, x} = (k)**2, {x, y} = k l, {y, x} = k l, {y, y} = (l)**2, {y, z} = l m, {z, y} = l m, {z, z} = (m)**2})
Copyright © 2001-2019 Kasper Peeters
Questions? info@cadabra.science