Cadabra Q&A - Recent questions and answers
http://cadabra.science/qa/qa
Powered by Question2AnswerAnswered: How to collect similar terms?
http://cadabra.science/qa/1476/how-to-collect-similar-terms?show=1477#a1477
<p>Use <code>sort_product</code> to bring the factors in the same order.</p>
<p>Cadabra2 does not support TeXmacs anymore; I don't use it myself and no-one else asked for it, but supporting it would still require a non-trivial time commitment on my end.</p>
<p>There is no auto-completion as of yet, but it is on the todo list.</p>
General questionshttp://cadabra.science/qa/1476/how-to-collect-similar-terms?show=1477#a1477Wed, 11 Dec 2019 09:52:37 +0000Answered: Issues with exponentiation
http://cadabra.science/qa/1472/issues-with-exponentiation?show=1474#a1474
<p>In addition, please note that a lot of the 'standard' simplification stuff in computer algebra (so the things that have nothing to do with tensor algebra) are off-loaded to sympy; you can run its simplifier by simply using <code>simplify</code>:</p>
<pre><code>ex:= A**3 A**2;
simplify(_);
</code></pre>
<p>also gives what you wanted. </p>
General questionshttp://cadabra.science/qa/1472/issues-with-exponentiation?show=1474#a1474Wed, 11 Dec 2019 09:17:30 +0000Answered: fierz identity for chiral spinors
http://cadabra.science/qa/159/fierz-identity-for-chiral-spinors?show=1471#a1471
<p>Do we have any updates on these chiral Fierz identities?</p>
General questionshttp://cadabra.science/qa/159/fierz-identity-for-chiral-spinors?show=1471#a1471Tue, 10 Dec 2019 20:14:21 +0000Answered: Trace of Gamma Matrices?
http://cadabra.science/qa/170/trace-of-gamma-matrices?show=1466#a1466
<p>You can do it with recent versions of Cadabra but it's a little awkward. For example,</p>
<pre><code>{\mu,\nu,\rho,\sigma}::Indices(vector);
{\mu,\nu,\rho,\sigma}::Integer(0..3);
{a,b,c,d}::Indices(spinor);
Tr{#}::Trace(indices=spinor);
\delta_{\mu \nu}::KroneckerDelta;
\Gamma^{#}::GammaMatrix(metric=\delta);
\Gamma^{\mu}::ImplicitIndex(\Gamma^{\mu}_{a b});
\Gamma^{\mu \nu}::ImplicitIndex(\Gamma^{\mu \nu}_{a b});
\Gamma^{\mu \nu \rho \sigma}::ImplicitIndex(\Gamma^{\mu \nu \rho \sigma}_{a b});
ex:=Tr(\Gamma^{\mu} \Gamma^{\nu \rho} \Gamma^{\sigma});
</code></pre>
<p>Then call "join_gamma", "distribute", "untrace" until you only see traces of single gamma matrices. Finally "canonicalise" will kill all of them except Tr(1).</p>
Feature requestshttp://cadabra.science/qa/170/trace-of-gamma-matrices?show=1466#a1466Wed, 04 Dec 2019 01:34:04 +0000Answered: How can I implement cyclicity of trace?
http://cadabra.science/qa/729/how-can-i-implement-cyclicity-of-trace?show=1458#a1458
<p>The current version on github handles this:</p>
<pre><code>{\phi,\psi}::ImplicitIndex;
tr{#}::Trace;
ex:= tr( (\phi\psi - \psi\phi)**2 );
expand_power(_)
distribute(_)
sort_product(_);
</code></pre>
<p>produces your answer. Thanks to Connor Behan for providing the patch that makes this work.</p>
General questionshttp://cadabra.science/qa/729/how-can-i-implement-cyclicity-of-trace?show=1458#a1458Tue, 03 Dec 2019 11:06:10 +0000About data structure in Cadabra
http://cadabra.science/qa/1434/about-data-structure-in-cadabra
<p>I wonder where I could find the complete description of Cadabra's data structure, <a rel="nofollow" href="https://cadabra.science/notebooks/ref_programming.html">this</a> and <a rel="nofollow" href="https://cadabra.science/static/pdf/cadabra.pdf">this</a> are a little simple, I need more details. More examples about how to program in Cadabra is also OK.</p>
General questionshttp://cadabra.science/qa/1434/about-data-structure-in-cadabraMon, 25 Nov 2019 12:26:00 +0000Answered: Simplify LaTeX input
http://cadabra.science/qa/1431/simplify-latex-input?show=1432#a1432
<p>See the answer to this <a rel="nofollow" href="https://cadabra.science/qa/1274/replace-a-list-of-statements-with-a-cycle">post</a></p>
General questionshttp://cadabra.science/qa/1431/simplify-latex-input?show=1432#a1432Mon, 25 Nov 2019 11:46:54 +0000Normal ordering
http://cadabra.science/qa/1395/normal-ordering
<p>I wonder how to normal order a weighted sum of creation and annihilation operators raised to power k?</p>
General questionshttp://cadabra.science/qa/1395/normal-orderingThu, 21 Nov 2019 20:33:07 +0000Answered: Problems with combine(_)
http://cadabra.science/qa/1264/problems-with-combine-_?show=1430#a1430
<p>I'm pleased to report that the AntiCommuting issue has just been fixed in git. In your expression that is unaffected by combine(_), it sounds like that's just because you didn't put an indexbracket around M.</p>
Bug reportshttp://cadabra.science/qa/1264/problems-with-combine-_?show=1430#a1430Sun, 17 Nov 2019 16:22:49 +0000Answered: Unexpected behavior of combine()
http://cadabra.science/qa/1398/unexpected-behavior-of-combine?show=1429#a1429
<p>Thanks for the bug report! The combine() issue has recently been fixed in git. As for the northeast / southwest convention, I would just declare the index positions to be fixed and include explicit metrics. But perhaps Kasper has a better answer.</p>
General questionshttp://cadabra.science/qa/1398/unexpected-behavior-of-combine?show=1429#a1429Sun, 17 Nov 2019 09:13:12 +0000Dealing with multi-index derivatives
http://cadabra.science/qa/1426/dealing-with-multi-index-derivatives
<p>Hi, I've been trying to find a way to work with covariant derivatives on non-abelian gauge theories in cadabra. </p>
<p>The issue is cadabra treats derivatives with multiple indices as being a product of derivatives, as discussed in this question:</p>
<p><a rel="nofollow" href="https://cadabra.science/qa/84/derivatives-with-multiple-indices?show=84#q84">https://cadabra.science/qa/84/derivatives-with-multiple-indices?show=84#q84</a></p>
<p>Is there a simple way to implement this feature other than what is suggested in the link above? Maybe with some lines of python?</p>
<p>Best regards!</p>
General questionshttp://cadabra.science/qa/1426/dealing-with-multi-index-derivativesSat, 16 Nov 2019 21:22:46 +0000Answered: epsilon_to_delta function failed to evaluate
http://cadabra.science/qa/1423/epsilon_to_delta-function-failed-to-evaluate?show=1424#a1424
<p>The problem is that you are using indices on the epsilon symbols which are not part of the index set. In your first example, if you add the <code>e</code> index to the set by writing, instead of the first two lines, </p>
<pre><code>{a,b,c,d,e}::Indices.
{a,b,c,d,e}::Integer(1..3).
</code></pre>
<p>then it works. In the second example, you need to add <code>l, u, v</code> in order to make it work.</p>
Bug reportshttp://cadabra.science/qa/1423/epsilon_to_delta-function-failed-to-evaluate?show=1424#a1424Sat, 16 Nov 2019 10:13:51 +0000Answered: Windows 10 version doesn't work
http://cadabra.science/qa/971/windows-10-version-doesnt-work?show=1416#a1416
<p>Please give the new 2.2.7f installer for Windows a shot, availabe at</p>
<p><a rel="nofollow" href="https://cadabra.science/packages/windows/">https://cadabra.science/packages/windows/</a></p>
<p>and let me know if that works any better.</p>
Installation troublehttp://cadabra.science/qa/971/windows-10-version-doesnt-work?show=1416#a1416Sun, 10 Nov 2019 11:18:22 +0000Answered: Failure of running cadabra on windows.
http://cadabra.science/qa/1259/failure-of-running-cadabra-on-windows?show=1415#a1415
<p>Please try the new 2.2.7f installer for windows, available at</p>
<p><a rel="nofollow" href="https://cadabra.science/packages/windows">https://cadabra.science/packages/windows</a></p>
<p>and let me know if that one is any better.</p>
Bug reportshttp://cadabra.science/qa/1259/failure-of-running-cadabra-on-windows?show=1415#a1415Sun, 10 Nov 2019 11:17:38 +0000Answered: Windows 10 version still doesn't work
http://cadabra.science/qa/1305/windows-10-version-still-doesnt-work?show=1414#a1414
<p>There is a new 2.2.7f installer which fixes a number of issues with previous windows installers. If you are still having problems with the old installer, can you please give this new one a shot? It is at</p>
<p><a rel="nofollow" href="https://cadabra.science/packages/windows/">https://cadabra.science/packages/windows/</a></p>
Installation troublehttp://cadabra.science/qa/1305/windows-10-version-still-doesnt-work?show=1414#a1414Sun, 10 Nov 2019 11:16:30 +0000Answered: Windows 10 64-bit install not working yet
http://cadabra.science/qa/755/windows-10-64-bit-install-not-working-yet?show=1413#a1413
<p>There is a new 2.2.7f installer at </p>
<p><a rel="nofollow" href="https://cadabra.science/packages/windows/">https://cadabra.science/packages/windows/</a></p>
<p>Can anyone who had trouble previously please give that one a shot? It should be able to detect anaconda/miniconda installed in weird places, and should also take care of installing missing DLLs automatically. </p>
<p>All feedback is welcome!</p>
Installation troublehttp://cadabra.science/qa/755/windows-10-64-bit-install-not-working-yet?show=1413#a1413Sun, 10 Nov 2019 11:15:05 +0000Answered: question about 'factor_out'
http://cadabra.science/qa/1392/question-about-factor_out?show=1393#a1393
<p>Remember that you need to write either a space or a <code>*</code> character to indicate products. Also, <code>NonCommuting</code> is spelled with a single <code>t</code>.</p>
<p>What do you want to do with this? You can <code>distribute(_)</code> this, but there isn't much else you can simplify given that the capital symbols do not commute with each other.</p>
General questionshttp://cadabra.science/qa/1392/question-about-factor_out?show=1393#a1393Wed, 30 Oct 2019 15:18:16 +0000Answered: get (anti)commutator
http://cadabra.science/qa/1387/get-anti-commutator?show=1388#a1388
<p>These type of problems are typically handled by writing a product in terms of the commutator and the swapped product. So e.g.</p>
<pre><code>{a,b,c,d,e,f,g,h}::NonCommuting.
ex:=a b c d-c d a b + e f g h+g h e f;
substitute(ex, $a b c d = \commutator{a b}{c d} + c d a b$);
</code></pre>
<p>Something similar is done at the bottom of the example at <a rel="nofollow" href="https://cadabra.science/notebooks/beginners.html">https://cadabra.science/notebooks/beginners.html</a> to rewrite derivatives of the vector potential in terms of the (antisymmetric) field strength.</p>
General questionshttp://cadabra.science/qa/1387/get-anti-commutator?show=1388#a1388Sun, 27 Oct 2019 11:58:47 +0000Answered: How to move scalars to left side?
http://cadabra.science/qa/1383/how-to-move-scalars-to-left-side?show=1384#a1384
<p>Add a <code>SortOrder</code> property to determine how you want symbols to be sorted, and then use the <code>sort_product</code> algorithm:</p>
<pre><code>{\mu,\nu}::Indices(vector).
{a,b,a{#},b{#}}::SortOrder.
{a^{\mu},b^{\mu}}::NonCommuting.
ex:=a b a^{\mu} a b_{\mu} b+a b b^{\mu} b a_{\mu} a;
sort_product(_);
</code></pre>
<p>which produces $$aabb a^{\mu} b_{\mu} + aabb b^{\mu} a_{\mu} .$$ If you want to do it, instead, with <code>factor_out(_, $a,b$)</code>, then you will need a call to <code>distribute(_)</code> afterwards to get rid of the brackets again.</p>
General questionshttp://cadabra.science/qa/1383/how-to-move-scalars-to-left-side?show=1384#a1384Fri, 25 Oct 2019 08:46:40 +0000Answered: Trouble when compiling from the github repository
http://cadabra.science/qa/1378/trouble-when-compiling-from-the-github-repository?show=1379#a1379
<p>Those are unrelated. The Gtk error is something the Gtk team left unresolved, but it is harmless. </p>
<p>For the 2nd issue, read the message: you need to run <code>make deduplicate</code> (possibly with sudo) to remove the manual pages installed in an old deprecated location, and then <code>make install</code> will work again. </p>
Installation troublehttp://cadabra.science/qa/1378/trouble-when-compiling-from-the-github-repository?show=1379#a1379Mon, 21 Oct 2019 08:20:57 +0000Answered: Why the partial derivative example gives wrong answer?
http://cadabra.science/qa/1373/why-the-partial-derivative-example-gives-wrong-answer?show=1374#a1374
<p>The above works fine with the current version on github. If it does not for you,<br>
either upgrade, or say explicitly that the derivative is with respect to $\tau$,</p>
<pre><code> ex:= \partial_{\tau}{ f g};
</code></pre>
<p>or make $f$ depend on <code>\partial</code>:</p>
<pre><code> f::Depends(\partial{#}).
</code></pre>
<p>Otherwise the 'old' version of Cadabra which you use does not know how to figure out that <code>\partial</code> is a $\tau$-derivative. </p>
Bug reportshttp://cadabra.science/qa/1373/why-the-partial-derivative-example-gives-wrong-answer?show=1374#a1374Sun, 13 Oct 2019 13:46:34 +0000Answered: usage of canonicalise
http://cadabra.science/qa/1368/usage-of-canonicalise?show=1371#a1371
<p>The <code>NonCommuting</code> property only relates <em>different</em> objects; your line says that $u^{\mu}$ does not commute with $f^{\mu\nu}$, but it says nothing about how $u^{\mu}$ commutes with $u^{\nu}$. To impose what you want, use <code>SelfNonCommuting</code>, as in:</p>
<pre><code>{\mu,\nu}::Indices(vector).
f^{\mu\nu}::AntiSymmetric.
h^{\mu\nu}::Symmetric.
u^{\mu}::SelfNonCommuting.
ex:=u^{\mu}u^{\nu}f^{\nu\mu}+f^{\mu\nu}h^{\mu\nu};
canonicalise(_);
</code></pre>
<p>which then gives $-u^{\mu} u^{\nu} f^{\mu\nu}$.</p>
<p>(I have taken the liberty of removing the question marks on the indices (you don't need them)).</p>
General questionshttp://cadabra.science/qa/1368/usage-of-canonicalise?show=1371#a1371Sat, 12 Oct 2019 10:15:52 +0000Answered: use of substitute
http://cadabra.science/qa/1354/use-of-substitute?show=1365#a1365
<p>\mu,\nu::Coordinate;<br>
a,b,c::Coordinate;<br>
F:=F(a,b,c);<br>
A:=A(\mu,\nu);<br>
B:=B(\mu,\nu);<br>
C:=C(\mu,\nu);<br>
Seems to work</p>
<p>substitute(F, $a -> A$);<br>
substitute(F, $b -> B$);<br>
substitute(F, $c -> C$);<br>
Also seems to work</p>
<p>I tried this example from the site:<br>
<a rel="nofollow" href="https://cadabra.science/manual/PartialDerivative.html">https://cadabra.science/manual/PartialDerivative.html</a></p>
<p>\tau::Coordinate;<br>
\partial{#}::Derivative(\tau);<br>
f::Depends(\tau);<br>
ex:= \partial{f g};<br>
unwrap(ex);</p>
<p>It returns 0 instead of g∂f</p>
General questionshttp://cadabra.science/qa/1354/use-of-substitute?show=1365#a1365Sun, 06 Oct 2019 10:57:39 +0000Answered: Canonicalise and dummy indices
http://cadabra.science/qa/1360/canonicalise-and-dummy-indices?show=1361#a1361
<p>Use the <code>position=independent</code> attribute to <code>Indices</code>, so </p>
<pre><code>{\mu, \nu}::Indices(vector, position=independent);
ex:= v^{\mu} G_{\mu \nu} v^{\nu};
canonicalise(_);
</code></pre>
General questionshttp://cadabra.science/qa/1360/canonicalise-and-dummy-indices?show=1361#a1361Fri, 04 Oct 2019 10:17:52 +0000is it possible to have two types of epsilon tensors?
http://cadabra.science/qa/1348/is-it-possible-to-have-two-types-of-epsilon-tensors
<p>Hi,</p>
<p>I would like to define two types (if I think properly even more) of epsilon tensors which would not interfere with each other when running "epsilon<em>to</em>delta". I thought that if I define each epsilon tensor with its own "delta" (like \delta and \bar{\delta} respectively) it will work, but that's actually not true. Is there a way to do this?</p>
<p>Thanks,<br>
Andrei</p>
<p>Here is the notebook I used</p>
<pre><code>\dalpha::LaTeXForm("\dot{\alpha}").
\dbeta::LaTeXForm("\dot{\beta}").
\bdelta{#}::LaTeXForm("\bar{\delta}").
{\dot{#}, \bar{#}}::Symbol;
{\alpha, \beta, \gamma}::Indices(chiral, position=fixed);
{\dalpha, \dbeta}::Indices(antichiral, position=fixed);
{\alpha, \beta, \gamma, \delta}::Integer(1..2);
{\dalpha, \dbeta}::Integer(1..2);
\delta{#}::KroneckerDelta(chiral);
\bdelta{#}::KroneckerDelta(antichiral);
\epsilon_{\alpha \beta}::EpsilonTensor(delta=\delta);
\epsilon^{\dalpha \dbeta}::EpsilonTensor(delta=\bdelta);
</code></pre>
<p>And now the epsilons</p>
<pre><code>ex:=\epsilon_{\alpha \beta} \epsilon^{\dalpha \dbeta};
epsilon_to_delta(_);
</code></pre>
<p>which yield a mixed index \delta.</p>
General questionshttp://cadabra.science/qa/1348/is-it-possible-to-have-two-types-of-epsilon-tensorsThu, 26 Sep 2019 13:43:03 +0000"Signature" of the epsilon tensor
http://cadabra.science/qa/1344/signature-of-the-epsilon-tensor
<p>Hi community.</p>
<p>It is (more or less) known that when defining a metric one can provide a parameter <code>signature</code>, e.g +1 for Riemannian metrics or -1 for Lorentzian metrics; and it is also known that one can parametrise the epsilon tensor with a metric.</p>
<p>I'm interested, however, in a generic epsilon tensor defined for a Lorentzian signature... without specifying a metric (because I want to consider spacetimes with diferent dimensionality). I tried the following, and it seems to work:</p>
<pre><code>\delta{#}::KroneckerDelta.
\epsilon{#}::EpsilonTensor(delta=-\delta).
</code></pre>
<h3>Question</h3>
<p>Is the above proposal equivalent to assigning a <code>signature = -1</code> to the epsilon?</p>
General questionshttp://cadabra.science/qa/1344/signature-of-the-epsilon-tensorMon, 23 Sep 2019 16:55:39 +0000Answered: How to obtain the geodesic equation from the action?
http://cadabra.science/qa/1331/how-to-obtain-the-geodesic-equation-from-the-action?show=1343#a1343
<p>So far there is no build-in command that <em>spits</em> the geodesic equations. </p>
<p>However, I'd like to clarify: the geodesic equation can be obtain by extremising (one half of) the <em>Riemannian</em> line element for a given metric, and it is given by the expression stated by @skyfold in the comments of the question.</p>
<p>It is, nonetheless, straightforward to obtain the differential equations for the geodesic---once one knows the metric---. The only <em>nontrivial</em> ingredient is to define the (Levi-Civita) connection in terms of the metric, and calculate the coefficients. This has been shown in the notebook about <a rel="nofollow" href="https://cadabra.science/notebooks/schwarzschild.html">Schwarzschild spacetime</a>.</p>
General questionshttp://cadabra.science/qa/1331/how-to-obtain-the-geodesic-equation-from-the-action?show=1343#a1343Mon, 23 Sep 2019 16:45:17 +0000Answered: Collecting scalar terms in expressions with `DifferentialForms`
http://cadabra.science/qa/1287/collecting-scalar-terms-expressions-with-differentialforms?show=1333#a1333
<p>Current github/master can now do</p>
<pre><code>{f,g}::DifferentialForm(degree=0).
{V, W}::DifferentialForm(degree=1).
foo := f V ^ g W;
unwrap(_);
</code></pre>
<p>producing $f g V \wedge W$. Enjoy (and let me know if things don't work properly).</p>
Feature requestshttp://cadabra.science/qa/1287/collecting-scalar-terms-expressions-with-differentialforms?show=1333#a1333Sun, 22 Sep 2019 13:18:21 +0000Answered: Dotted indices are not substituted correctly
http://cadabra.science/qa/1327/dotted-indices-are-not-substituted-correctly?show=1332#a1332
<p>A fix for this bug is now on the master branch on github. If you encounter related bugs with 'accented' indices (as you hinted at near the end of your post), please post more details. </p>
Bug reportshttp://cadabra.science/qa/1327/dotted-indices-are-not-substituted-correctly?show=1332#a1332Sat, 21 Sep 2019 19:51:39 +0000Answered: simplify expressions in Cadabra
http://cadabra.science/qa/1317/simplify-expressions-in-cadabra?show=1318#a1318
<p>Use <code>sort_product</code> to put all factors in all products in the same order, before you <code>canonicalise</code>. The latter only changes index labels, not factor positions.</p>
General questionshttp://cadabra.science/qa/1317/simplify-expressions-in-cadabra?show=1318#a1318Sat, 14 Sep 2019 18:03:00 +0000Answered: CLI convertion from cadabra2 to LaTeX
http://cadabra.science/qa/1309/cli-convertion-from-cadabra2-to-latex?show=1311#a1311
<p>There wasn't, but there is now ;-) Check out the latest commit on github/master, build/install, and you will have a <code>cadabra2latex</code> command, which does</p>
<pre><code>cadabra2latex in.cnb out.tex
</code></pre>
<p>This will create <code>out.tex</code> from your notebook <code>in.cnb</code>, plus any <code>outnnn.png</code> files if your notebook contains plots. You should then be able to do e.g.</p>
<pre><code>pdflatex out.tex
</code></pre>
<p>to build a PDF.</p>
General questionshttp://cadabra.science/qa/1309/cli-convertion-from-cadabra2-to-latex?show=1311#a1311Thu, 12 Sep 2019 09:05:27 +0000Is it possible to define assumptions?
http://cadabra.science/qa/1310/is-it-possible-to-define-assumptions
<p>It would be useful to be able of provide extra properties to the expressions, that allow <code>Cadabra</code>, <code>SymPy</code> or <code>Mathematica</code> to improve their simplification algorithms.</p>
<p>An existing example is the property <code>Integer</code>. It could be useful to include others like <code>Real</code>, <code>Positive</code>, <code>Negative</code>, or even a sort of <code>In([<list of values>])</code></p>
<h3>Question</h3>
<p>Is any of these properties currently defined?</p>
General questionshttp://cadabra.science/qa/1310/is-it-possible-to-define-assumptionsThu, 12 Sep 2019 07:33:25 +0000Answered: Copy/Paste output from notebook
http://cadabra.science/qa/257/copy-paste-output-from-notebook?show=1308#a1308
<p>The feature is available in v.2.x since January 2018.</p>
General questionshttp://cadabra.science/qa/257/copy-paste-output-from-notebook?show=1308#a1308Wed, 11 Sep 2019 18:14:08 +0000Answered: meaning symbol action[1][0][0][2]
http://cadabra.science/qa/1293/meaning-symbol-action-1-0-0-2?show=1304#a1304
<p>Hi skyfold,</p>
<p>as explained by doxdrum, the </p>
<pre><code>action[1][0][0][2]
</code></pre>
<p>command selects the part of expression we are interested to. <br>
In particular, the command extracts the terms not represented by total derivatives.</p>
<p>I note that in general this approach is not very stable because it depends on the position [1][0][0][2] of the terms in the expression. If they had had a change of position or the expression had a different manipulation, the command would fail.</p>
<p>Mattia</p>
General questionshttp://cadabra.science/qa/1293/meaning-symbol-action-1-0-0-2?show=1304#a1304Sat, 07 Sep 2019 14:11:07 +0000Answered: Providing a `Weight` to a `Derivative`
http://cadabra.science/qa/1297/providing-a-weight-to-a-derivative?show=1302#a1302
<p>If you want a derivative to inherit a weight <em>and</em> have a weight of that same type itself, you need to use the <code>self</code> parameter to <code>WeightInherit</code>. So</p>
<pre><code>\nabla{#}::WeightInherit(label=order, self=1, type=multiplicative);
</code></pre>
<p>(and drop the <code>Weight</code> property). The type should be <code>multiplicative</code>, which is a confusing way to say that the weights of the child node of the derivative should be combined as if they had been sitting in a product, that is, they should be added up.</p>
<p>(<code>type=additive</code> means that the weights of the children are handled as if the children are sitting in a sum, that is, they should all be equal).</p>
Feature requestshttp://cadabra.science/qa/1297/providing-a-weight-to-a-derivative?show=1302#a1302Thu, 05 Sep 2019 20:59:33 +0000Fierz (Request)
http://cadabra.science/qa/1301/fierz-request
<p>Hi everyone,</p>
<p>Is there a way to perform a Fierz transformation on a product of <strong>two</strong> spinors?</p>
<p>Thanks.</p>
<p>Edit: </p>
<p>For example, if we have the majonara spinors $\chi^{\sigma} = \bar{\chi} = \bar{\lambda} P_{L}$ and $\varphi_{\alpha} = \varphi = P_{L} \chi$, where $P_{L} = \frac{1}{2} (1 + \gamma_{*}) $, the fierz identity for $\varphi \bar{\chi}$ is $ \varphi \bar{\chi} = -\frac{1}{2} P_{L} (\bar{\lambda} P_{L} \chi) + \frac{1}{8} P_{L} (\gamma_{\mu \nu} \bar{\lambda} \gamma^{\mu \nu} P_{L} \chi)$.</p>
Feature requestshttp://cadabra.science/qa/1301/fierz-requestWed, 04 Sep 2019 13:14:46 +0000Answered: Extending zoom() function
http://cadabra.science/qa/1284/extending-zoom-function?show=1300#a1300
<p>The fact that <code>zoom(smth,$ a Q?? $)</code> does not match a single term <code>a</code> is intended behaviour, but of course that does not help you. This should have been possible by using multiple patterns in the same zoom, but that does not work at the moment. I have opened an issue at <a rel="nofollow" href="https://github.com/kpeeters/cadabra2/issues/161.">https://github.com/kpeeters/cadabra2/issues/161.</a></p>
Feature requestshttp://cadabra.science/qa/1284/extending-zoom-function?show=1300#a1300Tue, 03 Sep 2019 13:36:13 +0000Answered: Cadabra on Raspberry Pi 3
http://cadabra.science/qa/1298/cadabra-on-raspberry-pi-3?show=1299#a1299
<p>The Raspberry Pi 3 has CPU architecture 'armv7l', while all the packages I distribute are built for 'amd64'. While it is possible to do a cross-compile, I have never attempted that with Cadabra's build system. I may give it a quick shot by playing with CPACK's parameters, but I don't have time to do much more.</p>
<p>If you have experience cross-compiling, you may want to give that a shot yourself. Or perhaps someone else here has attempted this?</p>
Installation troublehttp://cadabra.science/qa/1298/cadabra-on-raspberry-pi-3?show=1299#a1299Mon, 02 Sep 2019 17:39:49 +0000Answered: Replace a list of statements with a cycle
http://cadabra.science/qa/1274/replace-a-list-of-statements-with-a-cycle?show=1278#a1278
<p>You can't do this with a straightforward <code>eval</code>, because that function does not pre-parse the Cadabra input into Python input. But if you realise that the <code>::</code> notation gets translated into a simple function call, then it's a relatively simple thing to do yourself:</p>
<pre><code>for i in range(20):
LaTeXForm(Ex(r'\a'+str(i)+r'{#}'), Ex(r'"\alpha_{'+str(i)+r'}"') )
</code></pre>
<p>The only tricky thing here is the quotes in the 2nd <code>Ex</code>: oyu need the single quote to generate a string, and then the double quote inside that so that Cadabra's <code>LaTeXForm</code> property gets fed a string too, not a maths expression.</p>
<p>Granted, this would be nice to have in a cleaner notation, but it gets the job done.</p>
General questionshttp://cadabra.science/qa/1274/replace-a-list-of-statements-with-a-cycle?show=1278#a1278Wed, 28 Aug 2019 20:50:14 +0000Manipulating matrix valued differential forms
http://cadabra.science/qa/1276/manipulating-matrix-valued-differential-forms
<p>Dear community, I'm trying to manipulate matrix valued differential forms. By academic deformation, I'm used to work in models with extra dimensions (say five to analyse the simplest case).</p>
<p>The problem I'm having is with the order of indices and elements of the expressions.</p>
<p>Below the calculations:</p>
<h2>Example of notebook</h2>
<h3>Some initial definitions</h3>
<pre><code>{A,B,C,L,M,N,P,Q}::Indices(full,position=independent);
{\alpha,\beta,\mu,\nu,\lambda,\rho,\sigma}::Indices(position=independent, parent=full);
d{#}::ExteriorDerivative.
d{#}::LaTeXForm("\mathrm{d}").
\delta{#}::KroneckerDelta.
G_{M N}::Metric(signature=-1).
G^{M N}::InverseMetric.
\epsilon{#}::EpsilonTensor(metric=G);
</code></pre>
<h3>Notation and properties</h3>
<pre><code>eh{#}::LaTeXForm("\hat{e}").
oh{#}::LaTeXForm("\hat{\omega}").
Rh{#}::LaTeXForm("\hat{R}").
Th{#}::LaTeXForm("\hat{T}").
{eh^{A?}, oh^{A? B?}}::DifferentialForm(degree=1);
{Th^{A?}, Rh^{A? B?}}::DifferentialForm(degree=2);
{oh^{A? B?}, Rh^{A? B?}}::AntiSymmetric.
Rh^{A? B?}::SelfCommuting.
eh^{A?}::SelfAntiCommuting.
{\epsilon{#}, Rh^{4 B}, Rh^{A B}, eh^{m}, eh^{4}}::SortOrder;
</code></pre>
<h3>Working a term</h3>
<pre><code>Lambda := \epsilon_{A B C L M} eh^{A} ^ eh^{B} ^ eh^{C} ^ eh^{L} ^ eh^{M};
split_index(Lambda, $M, m, 4$, repeat = True)
sort_product(_)
canonicalise(_);
</code></pre>
<p>The result is shown in the <br>
<img src="https://imge.to/i/vv77H4" alt="image"></p>
<h2>Discussion</h2>
<p>As you can see, the wedge product is not sorted properly, nor the indices!<br>
the right result should be</p>
<p>$$\epsilon_{a b c l m} \hat{e}^{m}\wedge \hat{e}^{a}\wedge \hat{e}^{b}\wedge \hat{e}^{c}\wedge \hat{e}^{l} - 5\epsilon_{4 a b c l} \hat{e}^{l}\wedge \hat{e}^{a}\wedge \hat{e}^{b}\wedge \hat{e}^{c}\wedge \hat{e}^{4}.$$</p>
<p>Any suggestion on how to manipulate correctly these expressions?</p>
<hr>
<p><strong>Update:</strong> Looking at the source code I found that the algorithm <code>indexsort</code>is implemented, but the problem persists. It seems to be a "bug" with the <code>sort_product</code> and <code>canonicalise</code> algorithms on differential forms.</p>
General questionshttp://cadabra.science/qa/1276/manipulating-matrix-valued-differential-formsWed, 28 Aug 2019 20:09:48 +0000Answered: Improper handling of fractions
http://cadabra.science/qa/1273/improper-handling-of-fractions?show=1275#a1275
<p>Thanks for reporting this, and for doing the digging! Yes, this is caused by a bug in the ping-pong procedure between Cadabra's internal representation and Sympy. But in fact it goes deeper: it has to do with the fact that Cadabra would not always simplify rational expressions to canonical form.</p>
<p>I have pushed a partial fix for this to the <code>fix/collectcomponents</code> branch on github. Feel free to test (it does do the right thing for your example above, but I have had no time to do more testing and checking). </p>
Bug reportshttp://cadabra.science/qa/1273/improper-handling-of-fractions?show=1275#a1275Tue, 27 Aug 2019 21:58:14 +0000Differential forms --- on a subspace???
http://cadabra.science/qa/1271/differential-forms-on-a-subspace
<p>Dear developers and community in general.</p>
<p>So far, there is a tutorial about the use of differential forms within <code>cadabra</code>, but there is no manual for their related properties.</p>
<p>I've like to know whether it is possible to define forms on a space (or subspace).</p>
<h3>Example <em>of desired behaviour</em></h3>
<pre><code>{a,b,c}::Indices(space);
{e^{a}, \omega^{a}_{b}}::DifferentialForm(degree=1, space);
</code></pre>
<p>or possibly something like</p>
<pre><code>{a,b,c}::Indices.
{x,y}::Coordinate(space);
{e^{a}, \omega^{a}_{b}}::DifferentialForm(degree=1, space);
</code></pre>
<p>to denote that $$e^a = e^a<em>x dx + e^a</em>y dy,$$ despite the possible values of the indices.</p>
<h3>Question</h3>
<p>Is something like this implemented? </p>
General questionshttp://cadabra.science/qa/1271/differential-forms-on-a-subspaceThu, 22 Aug 2019 08:39:12 +0000Answered: Build fails on Ubuntu 19.04, unspecified reference to boost::system::generic_category().
http://cadabra.science/qa/1268/fails-ubuntu-unspecified-reference-system-generic_category?show=1269#a1269
<p>I have just pushed a change to github related to boost. Can you give that another shot and let me know?</p>
Installation troublehttp://cadabra.science/qa/1268/fails-ubuntu-unspecified-reference-system-generic_category?show=1269#a1269Tue, 20 Aug 2019 15:55:25 +0000Answered: canonicalise with calagraphic font
http://cadabra.science/qa/1254/canonicalise-with-calagraphic-font?show=1255#a1255
<p>Cadabra has considerable flexibility in defining symbols, but <code>{\cal F}</code> goes a bit too far. What happens here is that this expression gets interpreted as the product of <code>\cal</code> and <code>F</code>, and then this gets indices added to it. Then all hell breaks loose... Granted, some kind of error message would probably have helped you here.</p>
<p>The easiest way around this is to do</p>
<pre><code>calF_{a b}::AntiSymmetric;
calF_{a b}::LaTeXForm("{\cal F}").
</code></pre>
<p>and then</p>
<pre><code>example2:= calF_{a b} calF_{c d} - calF_{a c} calF_{b d} ;
</code></pre>
<p>This will display the way you want because of the <code>LaTeXForm</code> property, and saves some typing as well.</p>
Bug reportshttp://cadabra.science/qa/1254/canonicalise-with-calagraphic-font?show=1255#a1255Fri, 16 Aug 2019 17:08:28 +0000Answered: Substitution of tensors - Einstein equations
http://cadabra.science/qa/1251/substitution-of-tensors-einstein-equations?show=1252#a1252
<p>That 'weird' equation does look ok, but it's perhaps a bit of an unusual notation. Can you run <code>collect_components</code> after that, and let me know if that makes more sense? </p>
<p>The logic behind all this is that Cadabra has the concept of an 'anonymous component tensor', which is what you get when you substitute values for components. Such a tensor is displayed as a 'box' with the indices of the original tensor, and then a list of all components following the large bracket. In this way you can have expressions which are 'half evaluated' (as you noticed in your first picture, where the metric has not yet been substituted).</p>
<p>We are working on making this somewhat less scary to look at, but until that work is done, it usually helps to 'collect all anonymous tensors in a sum', which is what <code>collect_components</code> does.</p>
General questionshttp://cadabra.science/qa/1251/substitution-of-tensors-einstein-equations?show=1252#a1252Fri, 16 Aug 2019 15:30:25 +0000Derivatives depend on index position
http://cadabra.science/qa/1250/derivatives-depend-on-index-position
<p>Hi,</p>
<p>I noticed recently that <br>
- the dependence of an object only includes the given position of the index<br>
and also that<br>
- objects with derivatives cannot change their index-position<br>
if the index position is given as fixed.</p>
<p>For example, the Exp in the following gives zero, because only A with an upper index depends on the derivative:</p>
<pre><code>{\mu,\nu}::Indices(position=fixed);
{\mu,\nu}::Integer(0..3);
\partial{#}::PartialDerivative;
A^\mu::Depends(\partial{#});
Exp:= \partial^{\mu}{A_\nu};
unwrap(_);
</code></pre>
<p>Of course I could just make A dependent on \partial for lowercase indices as well or just for every index position via </p>
<pre><code>A{#}::Depends(...);
</code></pre>
<p>but it still strikes me as odd.</p>
<p>Secondly, once I have defined objects with derivatives, the index position does not change through the use of canonicalise. So for example</p>
<pre><code>Exp:= \partial_{\mu}{A^\mu} - \partial^{\mu}{A_\mu};
canonicalise(_);
</code></pre>
<p>gives not zero as expected. And even if I derive a scalar, its index is fixed, so</p>
<pre><code>Exp:= A^\mu \partial_{\mu}{B} - A_\mu \partial^{\mu}{B};
canonicalise(_);
</code></pre>
<p>does not give zero.</p>
<p>I usually don't want to think about the position of dummy indices. So if it would be possible to give the index positions of derivatives a bit more freedom I would be very grateful!</p>
<p>Cheers,<br>
Karim</p>
Bug reportshttp://cadabra.science/qa/1250/derivatives-depend-on-index-positionFri, 16 Aug 2019 08:29:19 +0000Answered: How will I get the number of terms in an object in Cadabra 2?
http://cadabra.science/qa/1248/how-will-i-get-the-number-of-terms-in-an-object-in-cadabra-2?show=1249#a1249
<p>First of all, you cannot use <code>Ex</code> (with a capital <code>E</code>) as a name for an expression, because <code>Ex</code> is the name of the Cadabra expression object. Secondly, you cannot add pre-fix superscripts like this; the best you can do there is to use the <code>LaTeXForm</code> property. So you can do</p>
<pre><code>R1{#}::LaTeXForm("{}^{1}R").
ex:= R1_{\mu\nu};
</code></pre>
<p>Now what do you wan to do next? This expression clearly only contains one term. Did you want to compute it for a particular metric and then determine the number of non-zero components?</p>
General questionshttp://cadabra.science/qa/1248/how-will-i-get-the-number-of-terms-in-an-object-in-cadabra-2?show=1249#a1249Wed, 14 Aug 2019 10:50:46 +0000Answered: Assigning the result of `get_component`
http://cadabra.science/qa/1243/assigning-the-result-of-get_component?show=1244#a1244
<p>The <code>get_component</code> function returns a Python object, which you can directly assign to another symbol, e.g. <code>A00</code>. So a complete example would be</p>
<pre><code>from cdb.core.component import *
{t,x}::Coordinate;
{i,j}::Indices(values={t,x});
ex:= a_{i};
evaluate(ex, $a_{t}=1, a_{x}=2$);
A00=get_component(ex, $x$)
</code></pre>
<p>and then <code>A00</code> is a cadabra <code>Ex</code> object as usual.</p>
General questionshttp://cadabra.science/qa/1243/assigning-the-result-of-get_component?show=1244#a1244Tue, 13 Aug 2019 13:05:03 +0000A documentation bug
http://cadabra.science/qa/1242/a-documentation-bug
<p>In the documentation page <a rel="nofollow" href="https://cadabra.science/manual/cdb/core/component.html">component</a>, there is no mention to the fact that one have to import the function</p>
<pre><code>from cdb.core.component import get_component
</code></pre>
<p>At least I have to do it.</p>
Bug reportshttp://cadabra.science/qa/1242/a-documentation-bugTue, 13 Aug 2019 11:02:22 +0000Kronecker $\delta$ for Indices of different dimensions
http://cadabra.science/qa/1240/kronecker-%24-delta%24-for-indices-of-different-dimensions
<p>Hi,<br>
I have $\delta$-symbols involving a color index $a$ that runs from 1 to 3 and a Euclidian index $\mu$ from 1 to 4.</p>
<pre><code>{\mu,\nu}::Indices(Euklid, position=free).
{\mu,\nu}::Integer(1..4).
{a,b}::Indices(Color, position=independent).
{a,b}::Integer(1..3).
\delta_{#}::KroneckerDelta.
</code></pre>
<p>But when I try to contract them like in</p>
<pre><code>ex := \delta_{a \mu} \delta_{a \mu} ;
eliminate_kronecker(ex);
</code></pre>
<p>I get 4 but it should be 3. When I reverse the order of the indices I get the correct number:</p>
<pre><code>ex2 := \delta_{\mu a} \delta_{\mu a} ;
eliminate_kronecker(ex2);
</code></pre>
<p>This gives 3.</p>
<p>I suppose cadabra contracts the first two indices first so in the first case we get</p>
<p>$\delta<em>{a \mu} \delta^{a \mu} = \delta</em>{\mu}^{\mu} = 4$</p>
<p>and in the second it becomes </p>
<p>$\delta<em>{\mu a} \delta^{\mu a} = \delta</em>{a}^{a} = 3$.</p>
<p>Maybe this behavior could be avoided by always first contracting the indices of higher dimension? In the meantime, can somebody think of a workaround? </p>
<p>In the interest of completeness:</p>
<pre><code>ex3 := \delta_{\mu a} \delta_{a \mu} ;
eliminate_kronecker(ex3);
</code></pre>
<p>gives 4 and </p>
<pre><code>ex4 := \delta_{a \mu} \delta_{\mu a} ;
eliminate_kronecker(ex4);
</code></pre>
<p>returns 3.</p>
<p>Thank you</p>
<p>EDIT: Directly after asking I think I found a workaround by adding a substitution to the post_process function that sorts the indices such that the Euclidian one gets contracted first. </p>
<pre><code>def post_process(ex):
substitute( ex, $\delta_{a \mu} = \delta_{\mu a}$ )
</code></pre>
Bug reportshttp://cadabra.science/qa/1240/kronecker-%24-delta%24-for-indices-of-different-dimensionsMon, 12 Aug 2019 08:07:36 +0000