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 including those 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:= b_{i} = a_{i}; evaluate(ex, $a_{t}=1, a_{x}=2$, rhsonly=True); get_component(ex, $x$);
\(\displaystyle{}\text{Property Coordinate attached to }\left[t, x\right].\)
\(\displaystyle{}\text{Property Indices(position=free) attached to }\left[i, j\right].\)
\(\displaystyle{}b_{i} = a_{i}\)
b_{i} = a_{i}
\(\displaystyle{}b_{i} = \square{}_{i}\left\{\begin{aligned}\square{}_{t}& = 1\\[-.5ex] \square{}_{x}& = 2\\[-.5ex] \end{aligned}\right. \)
b_{i} = \components_{i}({{t} = 1, {x} = 2})
\(\displaystyle{}b_{x} = 2\)
b_{x} = 2
ex := 0 = 6(\Phi)**1 a2 k_{\nu} k_{\mu}- (\Phi)**1 b2 \eta^{\sigma \rho} \partial_{\rho}(z) \omega (c)**(-1) B_{\nu \sigma} k_{\mu}- 2(\Phi)**1 a2 k_{\mu} k_{\nu} + (\Phi)**1 b2 \partial_{\sigma}(z) \omega (c)**(-1) B_{\nu \mu} k_{\rho} \eta^{\sigma \rho} + (\Phi)**1 b2 \eta^{\sigma \rho} \partial_{\rho}(z) \omega (c)**(-1) B_{\nu \mu} k_{\sigma}- (\Phi)**1 b2 \partial_{\alpha}(z) \omega (c)**(-1) B_{\rho \mu} k_{\nu} \eta^{\alpha \rho} - 1/2 A_{\rho \sigma} k_{\nu} A_{\beta \alpha} k_{\mu} \eta^{\beta \rho} \eta^{\sigma \alpha} - 1/2 A_{\rho \sigma} A_{\beta \alpha} k_{\nu} k_{\mu} \eta^{\beta \rho} \eta^{\sigma \alpha} + 1/4 A_{\alpha \beta} k_{\nu} A_{\sigma \rho} k_{\mu} \eta^{\beta \sigma} \eta^{\rho \alpha}; get_component(ex, $t, t$);
\(\displaystyle{}0 = 6{\Phi}^{1} {a_{2}} k_{\nu} k_{\mu}-{\Phi}^{1} {b_{2}} \eta^{\sigma \rho} \partial_{\rho}\left(z\right) \omega {c}^{-1} B_{\nu \sigma} k_{\mu}-2{\Phi}^{1} {a_{2}} k_{\mu} k_{\nu}+{\Phi}^{1} {b_{2}} \partial_{\sigma}\left(z\right) \omega {c}^{-1} B_{\nu \mu} k_{\rho} \eta^{\sigma \rho}+{\Phi}^{1} {b_{2}} \eta^{\sigma \rho} \partial_{\rho}\left(z\right) \omega {c}^{-1} B_{\nu \mu} k_{\sigma}-{\Phi}^{1} {b_{2}} \partial_{\alpha}\left(z\right) \omega {c}^{-1} B_{\rho \mu} k_{\nu} \eta^{\alpha \rho} - \frac{1}{2}A_{\rho \sigma} k_{\nu} A_{\beta \alpha} k_{\mu} \eta^{\beta \rho} \eta^{\sigma \alpha} - \frac{1}{2}A_{\rho \sigma} A_{\beta \alpha} k_{\nu} k_{\mu} \eta^{\beta \rho} \eta^{\sigma \alpha}+\frac{1}{4}A_{\alpha \beta} k_{\nu} A_{\sigma \rho} k_{\mu} \eta^{\beta \sigma} \eta^{\rho \alpha}\)
0 = 6(\Phi)**1 a2 k_{\nu} k_{\mu}-(\Phi)**1 b2 \eta^{\sigma \rho} \partial_{\rho}(z) \omega (c)**(-1) B_{\nu \sigma} k_{\mu}-2(\Phi)**1 a2 k_{\mu} k_{\nu} + (\Phi)**1 b2 \partial_{\sigma}(z) \omega (c)**(-1) B_{\nu \mu} k_{\rho} \eta^{\sigma \rho} + (\Phi)**1 b2 \eta^{\sigma \rho} \partial_{\rho}(z) \omega (c)**(-1) B_{\nu \mu} k_{\sigma}-(\Phi)**1 b2 \partial_{\alpha}(z) \omega (c)**(-1) B_{\rho \mu} k_{\nu} \eta^{\alpha \rho} - 1/2 A_{\rho \sigma} k_{\nu} A_{\beta \alpha} k_{\mu} \eta^{\beta \rho} \eta^{\sigma \alpha} - 1/2 A_{\rho \sigma} A_{\beta \alpha} k_{\nu} k_{\mu} \eta^{\beta \rho} \eta^{\sigma \alpha} + 1/4 A_{\alpha \beta} k_{\nu} A_{\sigma \rho} k_{\mu} \eta^{\beta \sigma} \eta^{\rho \alpha}
\(\displaystyle{}0 = 6{\Phi}^{1} {a_{2}} k_{t} k_{t}-{\Phi}^{1} {b_{2}} \eta^{\sigma \rho} \partial_{\rho}\left(z\right) \omega {c}^{-1} B_{t \sigma} k_{t}-2{\Phi}^{1} {a_{2}} k_{t} k_{t}+{\Phi}^{1} {b_{2}} \partial_{\sigma}\left(z\right) \omega {c}^{-1} B_{t t} k_{\rho} \eta^{\sigma \rho}+{\Phi}^{1} {b_{2}} \eta^{\sigma \rho} \partial_{\rho}\left(z\right) \omega {c}^{-1} B_{t t} k_{\sigma}-{\Phi}^{1} {b_{2}} \partial_{\alpha}\left(z\right) \omega {c}^{-1} B_{\rho t} k_{t} \eta^{\alpha \rho} - \frac{1}{2}A_{\rho \sigma} k_{t} A_{\beta \alpha} k_{t} \eta^{\beta \rho} \eta^{\sigma \alpha} - \frac{1}{2}A_{\rho \sigma} A_{\beta \alpha} k_{t} k_{t} \eta^{\beta \rho} \eta^{\sigma \alpha}+\frac{1}{4}A_{\alpha \beta} k_{t} A_{\sigma \rho} k_{t} \eta^{\beta \sigma} \eta^{\rho \alpha}\)
0 = 6(\Phi)**1 a2 k_{t} k_{t}-(\Phi)**1 b2 \eta^{\sigma \rho} \partial_{\rho}(z) \omega (c)**(-1) B_{t \sigma} k_{t}-2(\Phi)**1 a2 k_{t} k_{t} + (\Phi)**1 b2 \partial_{\sigma}(z) \omega (c)**(-1) B_{t t} k_{\rho} \eta^{\sigma \rho} + (\Phi)**1 b2 \eta^{\sigma \rho} \partial_{\rho}(z) \omega (c)**(-1) B_{t t} k_{\sigma}-(\Phi)**1 b2 \partial_{\alpha}(z) \omega (c)**(-1) B_{\rho t} k_{t} \eta^{\alpha \rho} - 1/2 A_{\rho \sigma} k_{t} A_{\beta \alpha} k_{t} \eta^{\beta \rho} \eta^{\sigma \alpha} - 1/2 A_{\rho \sigma} A_{\beta \alpha} k_{t} k_{t} \eta^{\beta \rho} \eta^{\sigma \alpha} + 1/4 A_{\alpha \beta} k_{t} A_{\sigma \rho} k_{t} \eta^{\beta \sigma} \eta^{\rho \alpha}

remove_zero_components(ex: Ex) -> Ex

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}& = 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})

components_to_subrule(ex: Ex) -> Ex

Turn a component expression (the result of a \texttt{evaluate
command) into a set of substitution rules}
{x, y, z}::Coordinate. {i, j}::Indices(values={x, y, z}, position=fixed). ex := b_{i j} = a_{i}a_{j}; evaluate(ex, $a_{x} = k, a_{y} = l, a_{z} = m$, rhsonly=True); # substitute(ex, $k m -> 0$); components_to_subrule(ex);
\(\displaystyle{}b_{i j} = a_{i} a_{j}\)
b_{i j} = a_{i} a_{j}
\(\displaystyle{}b_{i j} = \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. \)
b_{i j} = \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{}\left[b_{x x} \rightarrow {k}^{2}, b_{x y} \rightarrow k l, b_{x z} \rightarrow k m, b_{y x} \rightarrow k l, b_{y y} \rightarrow {l}^{2}, b_{y z} \rightarrow l m, b_{z x} \rightarrow k m, b_{z y} \rightarrow l m, b_{z z} \rightarrow {m}^{2}\right]\)
{b_{x x} -> (k)**2, b_{x y} -> k l, b_{x z} -> k m, b_{y x} -> k l, b_{y y} -> (l)**2, b_{y z} -> l m, b_{z x} -> k m, b_{z y} -> l m, b_{z z} -> (m)**2}
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science