Cadabra Q&A  Recent questions and answers
http://cadabra.science/qa/qa
Powered by Question2Answer

Answered: Integrate by parts multiple tensors at once
http://cadabra.science/qa/1755/integratebypartsmultipletensorsatonce?show=1756#a1756
<p>Ah, you found an interesting bug in <code>integrate_by_parts</code> in the code which compares indices with object patterns (e.g. <code>a??</code>) or name patterns (e.g. <code>a?</code>). It's fixed now on github (version 2.3.1.6). </p>
<p>Here's a slight fix of your code, which does the right thing:</p>
<pre><code>{A,B,C,D,E,F,F#}::Indices(full);
{a,b,c,d,e,f,f#}::Indices(space1);
{m,n,o,p,q,r,r#}::Indices(space2);
\partial{#}::PartialDerivative.
\delta{#}::Accent.
F_{A B C}::AntiSymmetric.
F_{a b c}::AntiSymmetric.
F_{m n p}::AntiSymmetric.
F_{#}::Depends(\partial{#}).
ex:=\int{ c_{0} \partial_{a d}{ \delta{F_{a b c}}} F_{d b c}
+ 2 c_{1} \partial_{a c}{ \delta{F_{m a b}}} F_{m c b} }{x};
integrate_by_parts(ex, $\partial_{n?}{\delta{F_{m? a b}}}$)
</code></pre>
<p>So to elaborate on those index patterns: There are two ways in which you can write patterns with indices. If you use, in <code>integrate_by_parts</code>, a pattern</p>
<pre><code>\partial_{a}{\delta{F_{m b c}}}
</code></pre>
<p>then this will only match a term in which the index on the derivative comes from the <code>space1</code> set, and the three indices on the <code>F</code> tensor come from <code>space2</code>, <code>space1</code> and <code>space1</code> respectively. So in other words, if you write a pattern with indices, then they will match indices from the same set <em>only</em>. As it stands, this pattern would only match your 2nd term (the one multiplying <code>c_{1}</code>).</p>
<p>If you use name patterns, or object patterns, then these will match name or any object. So if you write</p>
<pre><code>\partial_{a}{\delta{F_{m? b c}}}
</code></pre>
<p>then this matches both of your terms, because <code>m?</code> can match any name (the fact that it is called <code>m</code> followed by a question mark makes no difference, it does not mean that this object needs to come from the <code>space2</code> set).</p>
<p>The <code>#</code> pattern means 'any number of child nodes' and is a very generic pattern. Rarely useful inside a <code>substitute</code> or <code>integrate_by_parts</code> because you cannot use it on the righthand side.</p>
<p>Hope this helps; if not, please ask again.</p>
General questions
http://cadabra.science/qa/1755/integratebypartsmultipletensorsatonce?show=1756#a1756
Sat, 26 Sep 2020 15:13:50 +0000

Answered: sign changed index splitting
http://cadabra.science/qa/1746/signchangedindexsplitting?show=1753#a1753
<p>With the version of Cadabra currently on github (2.3.1.5) you can write a small function which examines every term in the expression, counts the number of '5' indices, and flips the sign if there is an odd number of pairs. Starting from</p>
<pre><code>{m,n,p}::Indices(space);
{\mu,\nu}::Indices(subspace, parent=space);
ex:=A^{m n} B_{m n};
split_index(ex, $m, \mu, 5$, repeat=True);
</code></pre>
<p>which produces $$A^{\mu \nu} B_{\mu \nu}+A^{\mu 5} B_{\mu 5}+A^{5 \mu} B_{5 \mu}+A^{5 5} B_{5 5},$$ you can define</p>
<pre><code>def flip5(ex):
for node in ex:
for term in node.terms():
cnt=0
for index in term.indices():
if index.name=="1" and index.multiplier==5:
cnt+=1
term.multiplier *= (1)**(cnt//2)
return ex
</code></pre>
<p>and then do</p>
<pre><code>flip5(ex);
</code></pre>
<p>to get $$A^{\mu \nu} B_{\mu \nu}A^{\mu 5} B_{\mu 5}A^{5 \mu} B_{5 \mu}+A^{5 5} B_{5 5}$$</p>
General questions
http://cadabra.science/qa/1746/signchangedindexsplitting?show=1753#a1753
Tue, 22 Sep 2020 16:28:17 +0000

Answered: ModuleNotFoundError: no module named 'sympy'
http://cadabra.science/qa/1751/modulenotfounderrornomodulenamedsympy?show=1752#a1752
<p>Install the <code>sympy</code> module with anaconda (<code>conda install sympy</code> from the terminal).</p>
Installation trouble
http://cadabra.science/qa/1751/modulenotfounderrornomodulenamedsympy?show=1752#a1752
Mon, 21 Sep 2020 19:16:10 +0000

Answered: After alt+Up or altDown, cursor fails to autojump into newly created cell.
http://cadabra.science/qa/1727/afteraltdowncursorfailsautojumpintonewlycreatedcell?show=1749#a1749
<p>Dom has added this as an option; go to <code>Tools</code> then <code>Options</code> and select the relevant option. That's with current master on github.</p>
Bug reports
http://cadabra.science/qa/1727/afteraltdowncursorfailsautojumpintonewlycreatedcell?show=1749#a1749
Sun, 20 Sep 2020 11:57:40 +0000

Answered: Bug Generic TeX error
http://cadabra.science/qa/1743/buggenerictexerror?show=1745#a1745
<p>The <code>pdflatex</code> of texlive2020 does not seem to understand the <code>quiet</code> option. If you installed texlive just for cadabra, you may want to remove that and install miktex instead. If you use texlive for other things, this will need to wait until we have time to make a new installer.</p>
General questions
http://cadabra.science/qa/1743/buggenerictexerror?show=1745#a1745
Fri, 18 Sep 2020 13:42:24 +0000

Answered: Integration using tutorials raises a dummy symbol error.
http://cadabra.science/qa/1742/integrationusingtutorialsraisesadummysymbolerror?show=1744#a1744
<p>There are two things you should avoid here. One is to use SymPy's algorithms directly on Cadabra's <code>Ex</code> objects. That does work for some situations, but in case you need to pass more parameters (like here, where you want to pass the function which you want to solve for), it is better and more convenient to use the wrappers in <code>cdb.sympy.solvers</code>.</p>
<p>The second thing is that you use <code>integrate</code>. That does not work well with differential equations (not even in SymPy). Use <code>dsolve</code> instead.</p>
<p>With that, the following will produce your answer $a=C_1  b$:</p>
<pre><code>import cdb.sympy.solvers as solvers
solvers.dsolve(rtt, $a$);
</code></pre>
General questions
http://cadabra.science/qa/1742/integrationusingtutorialsraisesadummysymbolerror?show=1744#a1744
Thu, 17 Sep 2020 08:26:41 +0000

Answered: riemann_to_ricci doesn't work
http://cadabra.science/qa/1739/riemann_to_riccidoesntwork?show=1740#a1740
<p>That's a bug, thanks for reporting. I'll push a fix shortly.</p>
General questions
http://cadabra.science/qa/1739/riemann_to_riccidoesntwork?show=1740#a1740
Mon, 14 Sep 2020 17:33:22 +0000

Split free indices, and not just dummy indices.
http://cadabra.science/qa/1736/splitfreeindicesandnotjustdummyindices
<p>It is possible to split sums based on dummy indices:</p>
<pre><code>{M,N,P,Q,R}::Indices(full).
{m,n,p,q,r}::Indices(space1, parent=full).
{a,b,c,d,e}::Indices(space2, parent=full).
ex:=A_{M d Q R} B_{M p Q R};
split_index(_, $M,m,a$);
</code></pre>
<p>Can something like this be used for free indices too?</p>
<p>For example, I want:</p>
<pre><code>ex := A_{m p} + A_{a p};
</code></pre>
<p>This should split the tensor into two tensors. Graphically, this would split the matrix into two smaller matrices based on their columns, and missing values will be set to zero.</p>
<p>This can be extended for more complicated splits. In this case, one would have to somehow specify splits based on subgroups of indices.</p>
<p>For example, one might want to split a tensor based on an arbitrary set of indices. I.e. given tensor A_{x1 x2 ... xN}, get some specific indices {x1 x2 ... xN} into one tensor, and the rest in another tensor.</p>
Feature requests
http://cadabra.science/qa/1736/splitfreeindicesandnotjustdummyindices
Wed, 09 Sep 2020 20:31:14 +0000

Answered: IPython notebooks example not working
http://cadabra.science/qa/963/ipythonnotebooksexamplenotworking?show=1731#a1731
<p>My old answer is no longer relevant; the current version (2.3.0 onwards) handles your example just fine.</p>
Bug reports
http://cadabra.science/qa/963/ipythonnotebooksexamplenotworking?show=1731#a1731
Sun, 30 Aug 2020 16:04:01 +0000

Answered: Highlighted text almost invisible.
http://cadabra.science/qa/1552/highlightedtextalmostinvisible?show=1722#a1722
<p>Took a while, but this is now resolved in 2.3.1 on github.</p>
Bug reports
http://cadabra.science/qa/1552/highlightedtextalmostinvisible?show=1722#a1722
Sat, 29 Aug 2020 20:44:27 +0000

Answered: Cadabra 2.3 for OpenSUSE Leap 15.1 ?
http://cadabra.science/qa/1713/cadabra23foropensuseleap151?show=1721#a1721
<p>I have built a package of 2.3.1 for Leap 15.0, now available from the download page; can you give that a shot and let me know?</p>
Bug reports
http://cadabra.science/qa/1713/cadabra23foropensuseleap151?show=1721#a1721
Sat, 29 Aug 2020 18:18:17 +0000

Answered: gmpy2 module error
http://cadabra.science/qa/1707/gmpy2moduleerror?show=1720#a1720
<p>This often happens when you are using a different Python to do that <code>pip</code> command from the one you use to run Cadabra.</p>
<p>Try instead</p>
<pre><code>/usr/local/bin/python3 m pip install sympy gmpy2
</code></pre>
<p>and let me know if that's any better. </p>
Installation trouble
http://cadabra.science/qa/1707/gmpy2moduleerror?show=1720#a1720
Sat, 29 Aug 2020 17:31:18 +0000

Answered: Autocompletion of commands?
http://cadabra.science/qa/1711/autocompletionofcommands?show=1719#a1719
<p>Thanks for the push. This is now working on the master branch on github.</p>
General questions
http://cadabra.science/qa/1711/autocompletionofcommands?show=1719#a1719
Sat, 29 Aug 2020 17:28:52 +0000

Answered: TableauSymmetry/young_project_tensor command on spin connection causes kernel to crash
http://cadabra.science/qa/1714/tableausymmetryyoung_project_tensorcommandconnection?show=1715#a1715
<p>In your first problem, you are missing an equals sign between the <code>indices</code> and <code>{1,2}</code>. Make it read </p>
<pre><code>\omega_{\mu}^{a b}::TableauSymmetry( shape={1,1}, indices={1,2} ).
^here!
</code></pre>
<p>and things work as expected. </p>
<p>You don't have to 'define' anything special for objects with different types of indices, just write them and specify their index symmetries. If that doesn't solve your problem, maybe you can be a bit more explicit in explaining where you get stuck?</p>
General questions
http://cadabra.science/qa/1714/tableausymmetryyoung_project_tensorcommandconnection?show=1715#a1715
Sat, 29 Aug 2020 10:33:18 +0000

Answered: LaTeXForm does not work properly(?)
http://cadabra.science/qa/1710/latexformdoesnotworkproperly?show=1712#a1712
<p>These more fancy constructions were introduced in 2.3.0; you need to upgrade if you are running an earlier version.</p>
<p>The second example works (but again, only in 2.3.0 and later) if you do</p>
<pre><code>\GG{n??}::LaTeXForm("\stackrel{",n??,"}{G}").
GGtst := \GG{1};
</code></pre>
Bug reports
http://cadabra.science/qa/1710/latexformdoesnotworkproperly?show=1712#a1712
Fri, 28 Aug 2020 08:23:01 +0000

Answered: \delta^\mu_\mu fails to contract to 4.
http://cadabra.science/qa/1708/deltamu_mufailstocontractto4?show=1709#a1709
<p>Cadabra does not automatically assume that the dimension of spacetime is 4. So you have to declare the range of the indices. If you do</p>
<pre><code>{\mu,\nu}::Indices.
{\mu,\nu}::Integer(0..3).
\delta^{\mu}_{\nu}::KroneckerDelta.
Z := Z = \delta^\mu_\mu;
eliminate_kronecker(Z);
</code></pre>
<p>you get <code>Z=4</code> as expected.</p>
Bug reports
http://cadabra.science/qa/1708/deltamu_mufailstocontractto4?show=1709#a1709
Thu, 27 Aug 2020 10:23:18 +0000

Solution of Einstein's equations in a vacuum
http://cadabra.science/qa/1702/solutionofeinsteinsequationsinavacuum
<p>Hello people.<br>
I'm trying to solve Einstein's equations in vacuo for a generic line element, I can get to the equations G _ {\ alpha \ beta}, but I can't get the values for exp (\ mu) and \ exp (nu). If anyone knows thank you.</p>
<pre><code>enter code here
</code></pre>
<p>{r,t,\phi,\theta}::Coordinate;<br>
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma}::Indices(values=t,r,\phi,\theta},position=fixed);</p>
<p>\partial{#}::PartialDerivative;<br>
g_{\mu\nu}::Metric;<br>
g^{\mu\nu}::InverseMetric;</p>
<p>v::Depends(r);<br>
u::Depends(r);</p>
<p>ss:={g<em>{t t} = \exp(v),<br>
g</em>{r r} =\exp(u),<br>
g_{\theta\theta} = r<strong>2,<br>
g_{\phi\phi} = r</strong>2 \sin(\theta)**2}.<br>
complete(ss,$g^{\mu\nu}$);</p>
<p>ch := \Gamma^{\mu}<em>{\nu\rho} = 1/2 g^{\mu\sigma} (<br>
\partial</em>{\rho}{g<em>{\nu\sigma}}<br>
+\partial</em>{\nu}{g<em>{\rho\sigma}}<br>
\partial</em>{\sigma}{g_{\nu\rho}});<br>
evaluate(ch,ss,rhsonly=True);</p>
<p>rm:= R^{\rho}<em>{\sigma\mu\nu} = \partial</em>{\mu}{\Gamma^{\rho}<em>{\nu\sigma}}<br>
\partial</em>{\nu}{\Gamma^{\rho}<em>{\mu\sigma}}<br>
+\Gamma^{\rho}</em>{\mu\lambda}\Gamma^{\lambda}<em>{\nu\sigma}<br>
\Gamma^{\rho}</em>{\nu\lambda}\Gamma^{\lambda}_{\mu\sigma};<br>
substitute(rm,ch);<br>
evaluate(rm,ss,rhsonly=True);</p>
<p>rc:= R<em>{\sigma\nu} = R^{\rho}</em>{\sigma\rho\nu};<br>
substitute(rc, rm)<br>
evaluate(rc, ss, rhsonly=True);</p>
<p>src:= R = g^{\sigma\nu}R_{\sigma\nu};<br>
substitute(src,rc);<br>
evaluate(src,ss,rhsonly=True);</p>
<p>Eins := G<em>{\sigma\nu} = R</em>{\sigma\nu}1/2g_{\sigma\nu}R;<br>
substitute(Eins,rc);<br>
substitute(Eins,src);<br>
evaluate(Eins,ss,rhsonly=True);</p>
<p>from cdb.core.component import *<br>
from cdb.core.manip import *</p>
<p>gtt = get<em>component(Eins,$t,t$)[1];<br>
grr = get</em>component(Eins,$r,r$)[1];<br>
gth = get<em>component(Eins,$\theta,\theta$)[1];<br>
gph = get</em>component(Eins,$\phi,\phi$)[1];</p>
<p>from cdb.sympy.solvers import *</p>
<p>eq1:= @(gtt)@(grr);</p>
<p>from sympy import *</p>
General questions
http://cadabra.science/qa/1702/solutionofeinsteinsequationsinavacuum
Sun, 09 Aug 2020 23:17:10 +0000

Problems with import cdb.core.manip as manip
http://cadabra.science/qa/1700/problemswithimportcdbcoremanipasmanip
<p>I am running win 10, and I have installed anaconda, and the package gmpy2.<br>
The problemi is that when I try to do import cdb.core.manip as manip<br>
I get the error "dll load failed".<br>
What can I try to fix it?</p>
Installation trouble
http://cadabra.science/qa/1700/problemswithimportcdbcoremanipasmanip
Thu, 06 Aug 2020 22:09:51 +0000

Answered: "undo" the young_project_tensor...
http://cadabra.science/qa/1697/undotheyoung_project_tensor?show=1698#a1698
<p>Yes, you can do this with the new <code>meld</code> which Dom Price implemented. This combines terms into a minimal number. Full example:</p>
<pre><code>{a,b,c,d,e,f,g,h}::Indices;
R_{a b c d}::RiemannTensor;
\gamma{#}::AntiSymmetric;
ex:= R_{a b c d} R_{a c e f} \gamma_{b d e f} + \frac{1}{2} R_{a b c d} R_{a b e f} \gamma_{c d e f};
young_project_tensor(_, modulo_monoterm=True)
distribute(_)
canonicalise(_)
rename_dummies(_);
meld(_);
</code></pre>
<p>This gives</p>
<pre><code>2 R_{a b c d} R_{a c e f} \gamma_{b d e f}
</code></pre>
<p>which is not identical to the expression you gave, but equivalent. To see that, just meld the difference:</p>
<pre><code>tst:= R_{a b c d} R_{a b e f} \gamma_{c d e f}  @(ex);
meld(_);
</code></pre>
<p>which gives <code>0</code> as expected.</p>
<p>You can of course do that <code>meld</code> also on the original expression before the <code>young_project_tensor</code>; the result is the same.</p>
<p>There's proper documentation and a paper coming up on this algorithm shortly.</p>
General questions
http://cadabra.science/qa/1697/undotheyoung_project_tensor?show=1698#a1698
Wed, 05 Aug 2020 10:45:40 +0000

Windows 10 installation not working / stuck on source installation
http://cadabra.science/qa/1695/windowsinstallationnotworkingstucksourceinstallation
<p>Hi there, I am attempting to install Cadabra with the source code, because neither of the Windows 10 installations are currently working (both lead to Cadabra crashing immediately upon opening).</p>
<p>I am following the instructions, and I am stuck on the following step:</p>
<p><code>cmake G "Visual Studio 16 2019" A x64 ..</code></p>
<p>I cannot figure out what those dots <code>..</code> are supposed to be. If I skip this part, and just run:</p>
<p><code>cmake build . config RelWithDebInfo target install</code></p>
<p>then run</p>
<p><code>ctest</code></p>
<p>all 46 of the tests fail. Any help with this part would be greatly appreciated!</p>
Installation trouble
http://cadabra.science/qa/1695/windowsinstallationnotworkingstucksourceinstallation
Sun, 02 Aug 2020 06:49:16 +0000

First derivative with multiple indices
http://cadabra.science/qa/1690/firstderivativewithmultipleindices
<p>Is there any simple way to have multiple indices on a single derivative? If I define a derivative in the usual way</p>
<p>\delta{#}::Derivative;</p>
<p>then \delta<em>{\mu\nu} is interpreted as a second derivative. I would like \delta</em>{\mu\nu} to represent a single derivative (thus satisfying the product rule) but with multiple indices. This is important for the implementation of derivatives with respect to tensors for example.</p>
General questions
http://cadabra.science/qa/1690/firstderivativewithmultipleindices
Fri, 17 Jul 2020 13:57:48 +0000

Meld on undistributed input
http://cadabra.science/qa/1689/meldonundistributedinput
<p>Hello,</p>
<p>I've found situations where <code>meld</code> returns an incorrect 0, when applied on some undistributed sums, namely</p>
<pre><code>(w_{a} x_{b} y_{c}w_{c} x_{b} y_{a}) f^{a c}
(w_{a} x_{b} y_{c} z_{d}w_{c} x_{b} y_{a} z_{d}) f^{a b c}
(w_{a} x_{b} y_{c} z_{d}w_{c} x_{b} y_{a} z_{d}) f^{a b c d}
</code></pre>
<p>More precisely, the above 3 lines are the output corresponding to the following input:</p>
<pre><code>{a,b,c,d,e#}::Indices(Lorentz,parent=ambient).
f^{a b}::TableauSymmetry(shape=(1,1),indices=(0,1)).
f^{a b c}::TableauSymmetry(shape=(2,1),indices=(0,1,2)).
f^{a b c d}::TableauSymmetry(shape=(2,2),indices=(0,1,2,3)).
fac:=f^{a c}.
fabc:=f^{a b c}.
fabcd:=f^{a b c d};
Dwy:=(w_{a} y_{c}  w_{c} y_{a}).
Dwxy:=(w_{a} x_{b} y_{c}  w_{c} x_{b} y_{a}).
Dwyz:=(w_{a} y_{c} z_{d}  w_{c} y_{a} z_{d}).
Dwxyz:=(w_{a} x_{b} y_{c} z_{d}  w_{c} x_{b} y_{a} z_{d}).
for f in [fac,fabc,fabcd]:
for D in [Dwy,Dwxy,Dwyz,Dwxyz]:
fD=f*D
meld(fD)
if fD==0:
print(f*D)
Df=D*f
meld(Df)
if Df==0:
print(D*f)
</code></pre>
Bug reports
http://cadabra.science/qa/1689/meldonundistributedinput
Wed, 15 Jul 2020 15:31:01 +0000

Answered: convert the commutator of covariant derivatives acting on spinor into curvature
http://cadabra.science/qa/1675/convertcommutatorcovariantderivativesspinorcurvature?show=1687#a1687
<p>I think that what you are after (but correct me if I'm wrong) is some way to detect the presence of <code>\nabla_{c}{\nabla_{d}{...}</code> where the remainder of that term enforces that <code>c</code> and <code>d</code> are antisymmetrised?</p>
<p>There isn't currently a pattern that allows you to do that (though I agree it would be nice to have, not just for this purpose). So you'll have to work around it using some additional information. Do you have many different contractions that could lead to this implicit antisymmetrisation? Or is it always a handful of tensors (Riemann like above plus a few other possibilities)?</p>
General questions
http://cadabra.science/qa/1675/convertcommutatorcovariantderivativesspinorcurvature?show=1687#a1687
Fri, 10 Jul 2020 12:22:20 +0000

Answered: Problem extracting free indices
http://cadabra.science/qa/1676/problemextractingfreeindices?show=1680#a1680
<p>Well spotted, that's a bug indeed. It's fixed on github now.</p>
Bug reports
http://cadabra.science/qa/1676/problemextractingfreeindices?show=1680#a1680
Wed, 08 Jul 2020 21:49:24 +0000

Answered: Using function within expression
http://cadabra.science/qa/1644/usingfunctionwithinexpression?show=1674#a1674
<p>With the version currently on github, you can enable experimental function evaluation using</p>
<pre><code>kernel(call_embedded_python_functions=True)
</code></pre>
<p>You can then do</p>
<pre><code>Rule:= { x > asym( A B, {A,B} ) };
</code></pre>
<p>to get</p>
<pre><code>Rule:= x > 1/2 A B  1/2 B A;
</code></pre>
<p>Please be aware that this is experimental. You can use <em>any</em> Python function here, including the ones that you define yourself. The arguments you will receive are always <code>Ex</code> objects (so the <code>A B</code> and <code>{A, B}</code> above are passed to <code>asym</code> as two <code>Ex</code> objects, as required).</p>
<p>Note that the interface may change in the future because there may be unwanted side effects which I haven't yet grasped. (For instance, <em>any</em> function that is known on the python side will now get called, whether you want it or not. So if you were in the habit of writing <code>sin(x)</code> in Cadabra expressions, instead of <code>\sin(x)</code>, then turning this option on will produce an error, because Python's <code>sin</code> function does not accept <code>Ex</code> objects).</p>
<p>Feedback (more than) welcome.</p>
General questions
http://cadabra.science/qa/1644/usingfunctionwithinexpression?show=1674#a1674
Sat, 04 Jul 2020 20:33:41 +0000

Answered: Can not define Kronecker delta using Jupyter notebook
http://cadabra.science/qa/1667/cannotdefinekroneckerdeltausingjupyternotebook?show=1668#a1668
<p>Are you sure you are using a Cadabra kernel, not a standard Python kernel? What does</p>
<pre><code>print(__cdbkernel__.version)
</code></pre>
<p>show when you evaluate it in a cell?</p>
Bug reports
http://cadabra.science/qa/1667/cannotdefinekroneckerdeltausingjupyternotebook?show=1668#a1668
Wed, 17 Jun 2020 17:06:42 +0000

Answered: EpsilonTensor product not showing negative sign?
http://cadabra.science/qa/1665/epsilontensorproductnotshowingnegativesign?show=1666#a1666
<p>Cadabra's epsilon product will always produce a plus sign, irrespective of the signature of the metric. So you'll need to stick in that '1' by hand if your convention is different.</p>
General questions
http://cadabra.science/qa/1665/epsilontensorproductnotshowingnegativesign?show=1666#a1666
Tue, 16 Jun 2020 07:46:39 +0000

Defining a vector field.
http://cadabra.science/qa/1664/definingavectorfield
<p>Hello,</p>
<p>I am trying to define a vector fields $X=X^{\mu} \partial{x^{\mu}}$, $Y=Y^{\nu}\partial{x^{\nu}}$ and a one form $\omega=\omega_{\mu}dx^{\mu}$. I want to evaluate expressions such as $X[\omega(Y)]$. Need help/direction on how to do this.</p>
General questions
http://cadabra.science/qa/1664/definingavectorfield
Mon, 15 Jun 2020 18:01:09 +0000

Answered: Issue with brew link
http://cadabra.science/qa/1658/issuewithbrewlink?show=1659#a1659
<p>You can try that suggestion, but if that also fails, try <code>brew doctor</code> before you do anything else. That usually comes up with useful suggestions on broken installations.</p>
Installation trouble
http://cadabra.science/qa/1658/issuewithbrewlink?show=1659#a1659
Fri, 12 Jun 2020 15:33:11 +0000

Answered: bugs with sort_product&meld
http://cadabra.science/qa/1647/bugswithsort_product%26meld?show=1656#a1656
<p>The <code>meld</code> algorithm does not work with noncommuting/anticommuting objects yet, please wait a little longer.</p>
Bug reports
http://cadabra.science/qa/1647/bugswithsort_product%26meld?show=1656#a1656
Thu, 11 Jun 2020 08:13:12 +0000

Problem with rename_dummies and sort_product
http://cadabra.science/qa/1649/problemwithrename_dummiesandsort_product
<p>Hello,</p>
<p>With the input</p>
<pre><code>{a,b,c#}::Indices("a");
ex:=1/2 X_{a} B^{a b} X_{b} + K^{a} X_{a};
vary(ex,$X_{a}>A_{a}$);
sort_product(ex);
rename_dummies(ex);
{\delta{#},Z{#},X{#},B{#},K{#}}::SortOrder;
ex:=1/2 X_{a} B^{a b} X_{b} + K^{a} X_{a};
vary(ex,$X_{a}>Z_{a}$);
sort_product(ex);
rename_dummies(ex);
\delta{#}::Accent;
ex:=1/2 X_{a} B^{a b} X_{b} + K^{a} X_{a};
vary(ex,$X_{a}>\delta{X_{a}}$);
sort_product(ex);
rename_dummies(ex);
</code></pre>
<p>The output I get is</p>
<pre><code>Attached property Indices(position=free) to {a, b, c#}.
1/2 X_{a} B^{a b} X_{b} + K^{a} X_{a}
1/2 A_{a} B^{a b} X_{b} + 1/2 X_{a} B^{a b} A_{b} + K^{a} A_{a}
1/2 A_{a} B^{a b} X_{b} + 1/2 A_{b} B^{a b} X_{a} + A_{a} K^{a}
1/2 A_{a} B^{a b} X_{b} + 1/2 A_{a} B^{b a} X_{b} + A_{a} K^{a}
Attached property SortOrder to {\delta(#), Z(#), X(#), B(#), K(#)}.
1/2 X_{a} B^{a b} X_{b} + K^{a} X_{a}
1/2 Z_{a} B^{a b} X_{b} + 1/2 X_{a} B^{a b} Z_{b} + K^{a} Z_{a}
1/2 Z_{a} X_{b} B^{a b} + 1/2 Z_{b} X_{a} B^{a b} + Z_{a} K^{a}
1/2 Z_{a} X_{b} B^{a b} + 1/2 Z_{b} X_{a} B^{a b} + Z_{a} K^{a}
Attached property Accent to \delta{#}.
1/2 X_{a} B^{a b} X_{b} + K^{a} X_{a}
1/2 \delta{X_{a}} B^{a b} X_{b} + 1/2 X_{a} B^{a b} \delta{X_{b}} + K^{a} \delta{X_{a}}
1/2 \delta{X_{a}} X_{b} B^{a b} + 1/2 \delta{X_{b}} X_{a} B^{a b} + \delta{X_{a}} K^{a}
1/2 \delta{X_{a}} X_{b} B^{a b} + 1/2 \delta{X_{b}} X_{a} B^{a b} + \delta{X_{a}} K^{a}
</code></pre>
<p>Is this behaviour expected? If yes, is there a way to obtain</p>
<pre><code> 1/2 Z_{a} X_{b} B^{a b} + 1/2 Z_{a} X_{b} B^{b a} + Z_{a} K^{a}
</code></pre>
<p>and</p>
<pre><code> 1/2 \delta{X_{a}} X_{b} B^{a b} + 1/2 \delta{X_{a}} X_{b} B^{b a} + \delta{X_{a}} K^{a}
</code></pre>
<p>instead?</p>
<p>In case it is really a bug, I run Cadabra 2.2.9 (built on April 7) on macOS High Sierra.</p>
Bug reports
http://cadabra.science/qa/1649/problemwithrename_dummiesandsort_product
Mon, 25 May 2020 11:02:13 +0000

Answered: Problem with installation from github repository (Debian bullseye)
http://cadabra.science/qa/1638/probleminstallationfromgithubrepositorydebianbullseye?show=1642#a1642
<p>Can you please pull from github once more and try on Debian again? I have updated pybind11, which seems to have fixed the issue with attempting to link to the wrong python library. It builds here fine on a clean Debian bullseye installation.</p>
Installation trouble
http://cadabra.science/qa/1638/probleminstallationfromgithubrepositorydebianbullseye?show=1642#a1642
Tue, 19 May 2020 11:03:08 +0000

Answered: About data structure in Cadabra
http://cadabra.science/qa/1434/aboutdatastructureincadabra?show=1640#a1640
<p>This is now handled cleanly by Dom's new <code>meld</code> algorithm, which is now on github. Instead of <code>sort_product</code>, just use <code>meld(_)</code>. Documentation on this will be in a forthcoming paper.</p>
General questions
http://cadabra.science/qa/1434/aboutdatastructureincadabra?show=1640#a1640
Mon, 18 May 2020 20:35:57 +0000

Answered: Q: extending coordinate computation from configuration space to phase space
http://cadabra.science/qa/1632/extendingcoordinatecomputationconfigurationspacespace?show=1635#a1635
<p>Because the <code>a</code> index is not in the index set of which <code>h</code> forms part, the pattern in <code>h_flow</code> will not match when you try to substitute <code>h_flow</code> into <code>D1</code>. You can do</p>
<pre><code>D1 := \nabla{q_{h}};
</code></pre>
<p>and then the substitutes work. To make <code>evaluate</code> work, you need to declare that <code>q_{h}</code> depends on <code>x</code> and <code>y</code>,</p>
<pre><code>q_{h}::Depends(x,y);
</code></pre>
<p>After that things seem to work as intended (have not verified the result).</p>
General questions
http://cadabra.science/qa/1632/extendingcoordinatecomputationconfigurationspacespace?show=1635#a1635
Sat, 09 May 2020 16:57:19 +0000

Answered: all_contractions( ) is not defined?
http://cadabra.science/qa/1629/all_contractionsisnotdefined?show=1630#a1630
<p>This doesn't exist at the moment, as people had the wrong ideas about what this would do, and solving the problem properly is more complicated than you might think. In particular, it is quite nontrivial to take into account dimensiondependent identities between tensor monomials. There is ongoing work to get more general purpose algorithms in cadabra which handle this, but <code>all_contractions</code> does not have the highest priority at the moment.</p>
General questions
http://cadabra.science/qa/1629/all_contractionsisnotdefined?show=1630#a1630
Tue, 05 May 2020 20:18:15 +0000

Answered: Weird output when running through terminal.
http://cadabra.science/qa/1623/weirdoutputwhenrunningthroughterminal?show=1624#a1624
<p>What does the first line of output read when you start <code>cadabra2</code>, e.g.</p>
<pre><code> Cadabra 2.2.9 (build 2387.f0a2a51a62 dated 20200502)
</code></pre>
<p>?</p>
General questions
http://cadabra.science/qa/1623/weirdoutputwhenrunningthroughterminal?show=1624#a1624
Sun, 03 May 2020 09:54:40 +0000

Answered: Q: simple Cadabra coordinate computation
http://cadabra.science/qa/1618/qsimplecadabracoordinatecomputation?show=1621#a1621
<p>So as you already discovered, the following gives the form with $V$ unevaluated:</p>
<pre><code>{x, y}::Coordinate;
{i, j, k, l, m, n, h#}::Indices(values={x, y}, position=fixed);
\partial{#}::PartialDerivative;
g_{i j}::Metric.
g^{i j}::InverseMetric.
# HÃ©nonHeiles potential
V::Depends(x,y);
V := (x**2 + y**2)/2 + (x**2)*y  (y**3)/3;
# Ho is a constant: conservation of energy
metric := { g_{x x} = 2*(Ho  V), g_{y y} = 2*(Ho  V) };
complete(metric, $g^{i j}$);
Christoffel := \Gamma^{i}_{j k} = (1/2)*g^{i l}*( \partial_{k}{g_{l j}}
+ \partial_{j}{g_{l k}}
 \partial_{l}{g_{j k}} );
</code></pre>
<p>followed by</p>
<pre><code>evaluate(Christoffel, metric, rhsonly=True);
</code></pre>
<p>This produces e.g. $\Gamma^{x}{}_{x x}=2\partial_{y}V (2Ho  2V)^{1}$.</p>
<p>If you want that written out in terms of $x$ and $y$, you <em>probably</em> want that only for the derivative part. I would then do something like</p>
<pre><code>substitute(Christoffel, $\partial_{a?}{V} = \partial_{a?}{@(V)}$ )
map_sympy(Christoffel, 'simplify');
</code></pre>
<p>which produces precisely the result you quoted, $\Gamma^{x}{}_{x x} = x(2y+1) (2Ho2V)^{1}$. In the first line above, note how we 'pull in' the value of the expression <code>V</code> using <code>@(V)</code>. In Cadabra, there is a difference between 'python objects' and 'maths objects'. The things on the lefthand side of a <code>:=</code> symbol are python objects, and everything appearing on the righthand side is built from maths objects. You have to tell Cadabra when to make such substitutions, it won't automatically do that for you (with the advantage that you can keep $V$ in the overall factor $(2Ho2V)^{1}$ while writing out the derivative).</p>
<p>The last line above just uses 'sympy' to simplify the expression (cadabra does not have a lot of scalar computer algebra logic built in, but instead passes that on to 'sympy' or 'mathematica'). </p>
<p>Last comment: if you wanted to eliminate $V$ immediately, you can of course substitute</p>
<pre><code>substitute(metric, $V = @(V)$);
</code></pre>
<p>just before you <code>evaluate</code>.</p>
<p>Hope this helps; if not, please ask again.</p>
General questions
http://cadabra.science/qa/1618/qsimplecadabracoordinatecomputation?show=1621#a1621
Wed, 29 Apr 2020 21:16:56 +0000

Answered: Why am I getting "Free indices in different terms in a sum do not match" when I integrate by parts?
http://cadabra.science/qa/1613/gettingindicesdifferenttermsmatchwhenintegrateparts?show=1614#a1614
<p>The reason for that error message is that, as it stands in your code, the object <br>
$\delta(A_{\mu})$ does not have any free indices. That is because Cadabra by default 'absorbs' indices when you apply a function to a tensor. So $\delta(...)$ is seen as a function applied to $A_{\mu}$ and that has no indices.</p>
<p>To make $\delta(...)$ show these indices, you need to give it a property <code>IndexInherit</code> (or if you want to inherit other properties, like dependence on coordinates, you may want to use the catchall <code>Accent</code> property instead).</p>
<p>With that, your example becomes</p>
<pre><code>{\mu,\nu,\rho,\sigma}::Indices(position=free).
\partial{#}::Derivative.
\delta{#}::Accent.
FieldStrength := F_{\mu\nu} > \partial_{\mu}{A_\nu}  \partial_{\nu}{A_\mu};
Lagrangian := L > (1/4)F_{\mu\nu}F^{\mu\nu};
S := \int{L}{x}:
substitute(S,Lagrangian);
substitute(S,FieldStrength);
distribute(S);
vary(S, $A_{\mu} > \delta{A_{\mu}}$);
integrate_by_parts(S, $\delta{A_{\mu}}$);
sort_product(_);
canonicalise(_);
factor_out(S, $\delta{A^{\mu}}$);
</code></pre>
<p>to produce</p>
<p>$$ \frac{1}{4}\int \delta\left(A^{\mu}\right) \left(4\partial^{\nu}\left(\partial_{\nu}{A_{\mu}}\right)+4\partial^{\nu}\left(\partial_{\mu}{A_{\nu}}\right)\right) {\rm d}x$$</p>
General questions
http://cadabra.science/qa/1613/gettingindicesdifferenttermsmatchwhenintegrateparts?show=1614#a1614
Tue, 21 Apr 2020 18:10:50 +0000

Answered: No output  Running Cadabra 2 on WSL 2 [Ubuntu 18.04] using VS Code
http://cadabra.science/qa/1608/nooutputrunningcadabra2onwsl2ubuntu1804usingvscode?show=1610#a1610
<p>"Have you tried whether running it using Jupyter's own notebook server works?"</p>
<p>No, I had not done so.</p>
<p>While WSL 2 is a fully functional Linux OS, not an emulator, it is commandline only  there is no GUI desktop and no browser. With a addition of an Xserver on the Windows 10 side, such as VcXsrv, one can display matplotlib output, in a separate window, generated in VS Code running on WSL side.Which is more than sufficient for scientific computing using numpy/sympy/numba/etc.</p>
<p>[update in following comment]</p>
Installation trouble
http://cadabra.science/qa/1608/nooutputrunningcadabra2onwsl2ubuntu1804usingvscode?show=1610#a1610
Sun, 19 Apr 2020 23:24:49 +0000

Answered: Can indices be moved?
http://cadabra.science/qa/1605/canindicesbemoved?show=1606#a1606
<p>Declare your index positions <code>free</code> and use <code>lower_free_indices</code>:</p>
<pre><code>{m,n,p}::Indices(position=free);
ex:=A_{m p} B^{p n};
lower_free_indices(ex);
</code></pre>
<p>The word 'free' here refers to the index type <code>position=free</code>, not to the fact that they are uncontracted.</p>
General questions
http://cadabra.science/qa/1605/canindicesbemoved?show=1606#a1606
Thu, 09 Apr 2020 08:25:15 +0000

Answered: Bug in @unwrap for Cadabra 1.42
http://cadabra.science/qa/761/bugin%40unwrapforcadabra142?show=1601#a1601
<p>Fixed on github master now (finally...).</p>
Bug reports
http://cadabra.science/qa/761/bugin%40unwrapforcadabra142?show=1601#a1601
Tue, 07 Apr 2020 19:34:02 +0000

Answered: "unwrap" returns 0 if pushing anticommuting constant past a mixed object
http://cadabra.science/qa/1598/unwrapreturnspushingcommutingconstantpastmixedobject?show=1599#a1599
<p>Good one. Internally, when Cadabra cannot figure out how to commute two objects, an internal function somewhere returns '0', instead of '+1' or '1'. That zero should have made <code>unwrap</code> stop, but instead it just went ahead and then multiplied the resulting unwrapped expression with '0'. </p>
<p>Now fixed in github, can you give it a shot? It will leave that first expression untouched, because it cannot move <code>C</code> through <code>A F + G</code> without flipping that 2nd factor to <code>A F  G</code>, and it will not do that kind of thing. Hope that's ok for now.</p>
Bug reports
http://cadabra.science/qa/1598/unwrapreturnspushingcommutingconstantpastmixedobject?show=1599#a1599
Tue, 07 Apr 2020 19:16:24 +0000

Answered: Export file to pdf
http://cadabra.science/qa/1595/exportfiletopdf?show=1596#a1596
<p>From the notebook you can pick 'Export to standalone LaTeX', after which you can latex the resulting file just like any other. Images will be exported as <code>.png</code> files and included at the appropriate places (if you use any).</p>
General questions
http://cadabra.science/qa/1595/exportfiletopdf?show=1596#a1596
Sun, 05 Apr 2020 21:48:02 +0000

Answered: Installing CADABRA2
http://cadabra.science/qa/1588/installingcadabra2?show=1590#a1590
<p>You are building against python3.7 which you installed yourself, right? (since it fetches <code>libpython3.7m.a</code> from <code>/usr/local/lib</code>). </p>
<p>Moreover, you are lacking the shared libraries, since it tries to link to the <code>.a</code>, not the <code>.so</code>. That by itself won't work; you need to link against shared libraries in order to produce the Python <code>cadabra2.so</code> module.</p>
<p>Any chance you can just build against stock python3.6 which comes with Ubuntu 18.04? I just tried that on a clean 18.04 install and it works fine. If that's not an option for you, you'll need to figure out why your python 3.7 installation does not have the shared libraries.</p>
Installation trouble
http://cadabra.science/qa/1588/installingcadabra2?show=1590#a1590
Mon, 30 Mar 2020 10:59:00 +0000

Bugs with 'sort_product'
http://cadabra.science/qa/1587/bugswithsort_product
<p>When I use 'sort_product' in the following code</p>
<pre><code>{\mu,\nu,\rho,sigma}::Indices(vector).
a^{\mu}::SelfNonCommuting.
{a^{\mu},b^{\mu}}::NonCommuting.
\nabla{#}::Derivative.
tr{#}::Trace.
ex:=tr{a^{\mu}\nabla^{\nu}{a^{\mu}}b^{\nu}\nabla^{\rho}{a^{\rho}}};
sort_product(_);
sort_product(_);
</code></pre>
<p>I find that cadabra don't know where to stop. This bug is similar to <a rel="nofollow" href="https://cadabra.science/qa/1434/aboutdatastructureincadabra">this</a> and <a rel="nofollow" href="https://cadabra.science/qa/729/howcaniimplementcyclicityoftrace">this</a>.</p>
Bug reports
http://cadabra.science/qa/1587/bugswithsort_product
Fri, 27 Mar 2020 15:49:16 +0000

Answered: Issues with 'canonicalise'
http://cadabra.science/qa/1576/issueswithcanonicalise?show=1577#a1577
<p>Well spotted, thanks for reporting this. I have just pushed a fix to github that handles part of the problem (when the content of the trace is a simple tensor, not a sum or product). The problem was (and to some extent still is) that the symmetries did not make it 'out of' the trace. Will post here when a full solution is available.</p>
Bug reports
http://cadabra.science/qa/1576/issueswithcanonicalise?show=1577#a1577
Sat, 21 Mar 2020 21:08:23 +0000

Issues with 'integrate_by_parts'
http://cadabra.science/qa/1573/issueswithintegrate_by_parts
<p>I want to implement the following integration by parts</p>
<pre><code>\nabla{#}::Derivative.
{A,B,C}::Depends(\nabla{#}).
tr{#}::Trace.
ex:=\int{\tr{A}\tr{B\nabla{C}}};
integrate_by_parts(_,$C$);
</code></pre>
<p>I have a try</p>
<pre><code>substitute(_,$\tr{A??}\tr{B?? \nabla{C??}}>\tr{\nabla{A??}}\tr{B?? C??}\tr{A??}\tr{\nabla{B??} C??}$);
</code></pre>
<p>Is there is any simpler way to implement it?</p>
General questions
http://cadabra.science/qa/1573/issueswithintegrate_by_parts
Thu, 12 Mar 2020 15:35:28 +0000

Answered: How to know the properties of an object?
http://cadabra.science/qa/1564/howtoknowthepropertiesofanobject?show=1569#a1569
<p>You can query a property to see whether a pattern has been registered with it; in your example</p>
<pre><code>p = RiemannTensor.get($R_{a1 a2 a3 a4}$)
</code></pre>
<p>will set <code>p</code> to the corresponding <code>RiemannTensor</code> object (which, since it derives from <code>TableauSymmetry</code>, has methods such as <code>get_tab</code>, <code>is_simple_symmetry</code> etc...). If there is no associated property then <code>None</code> is returned.</p>
General questions
http://cadabra.science/qa/1564/howtoknowthepropertiesofanobject?show=1569#a1569
Mon, 24 Feb 2020 17:49:29 +0000

Answered: Installation problem on macOSMojave
http://cadabra.science/qa/1565/installationproblemonmacosmojave?show=1566#a1566
<p>What happens if you try to run <code>cadabraserver</code> ? It should produce some output and then sit there until you kill it, but it probably produces an error instead.</p>
Installation trouble
http://cadabra.science/qa/1565/installationproblemonmacosmojave?show=1566#a1566
Mon, 24 Feb 2020 06:55:42 +0000

Answered: How to sort by upper and lower indices?
http://cadabra.science/qa/1558/howtosortbyupperandlowerindices?show=1561#a1561
<p>Never mind, I solved it with</p>
<pre><code>{\gamma_{p? q?},\gamma^{p? q?}}::SortOrder()
</code></pre>
<p>But anyway, thanks for the quick response!</p>
General questions
http://cadabra.science/qa/1558/howtosortbyupperandlowerindices?show=1561#a1561
Fri, 21 Feb 2020 12:44:28 +0000