Cadabra Q&A - Recent questions and answers
http://cadabra.science/qa/qa
Powered by Question2AnswerAnswered: Expansion of covariant derivative
http://cadabra.science/qa/2041/expansion-of-covariant-derivative?show=2053#a2053
<p>I faced the same problem in my time, so I ended up writing a function like this. </p>
<pre><code>def select_index(used_indices):
indeces = r'w v u s r q o n m l k j i h g f e d c b a'.split()
for uind in indeces:
found = False
for qind in used_indices:
if qind == uind:
found = True
break
if not found:
used_indices.add(uind)
index = uind
break
return Ex(index), used_indices
def one_nabla(ex, used_indices):
t3, used_indices = select_index(used_indices)
free = dict()
free['sub'] = set()
free['up'] = set()
for nabla in ex[r'\nabla']:
nabla.name=r'\partial'
dindex = nabla.indices().__next__()
for arg in nabla.args():
ret:=0;
for index in arg.free_indices():
if index.parent_rel==sub:
free['sub'].add(str(index.ex()))
else:
free['up'].add(str(index.ex()))
for key in free.keys():
for index in free[key]:
ind = Ex(index)
if key == 'sub':
t1:= -\Gamma^{@[t3]}_{@(dindex) @[ind]};
else:
t1:= \Gamma^{@[ind]}_{@(dindex) @[t3]};
t2:= @[arg];
for term_index in arg.free_indices():
if str(term_index.ex()) == index:
if term_index.parent_rel==sub:
t2[term_index]:= _{@[t3]};
else:
t2[term_index]:= ^{@[t3]};
ret += Ex(str(nabla.multiplier)) * t1 * t2
nabla += ret #
break
break
return ex, used_indices
def nabla_calculation(ex, used_indices, count):
ex = ex.ex()
for element in ex.top().terms():
new:=1;
local_count = 0
for nabla in element[r'\nabla']:
local_count += 1
if local_count == 0:
continue
elif local_count == 1:
new, used_indices = (one_nabla(element, used_indices))
element.replace(new.ex())
count -= 1
else:
if element.ex().top().name == r'\prod':
i = 0
while i < 2:
for mult in element.ex().top().children():
local_count2 = 0
for nabla in mult[r'\nabla']:
local_count2 += 1
if local_count2 == 0:
new *= mult.ex()
elif local_count2 == 1:
for nabla in mult[r'\nabla']:
nabla1, used_indices = one_nabla(nabla, used_indices)
nabla.replace(nabla1.ex())
new *= nabla.ex()
else:
mult1, used_indices = nabla_calculation(mult, used_indices, local_count)
new *= mult1
i+=1
new *= Ex(str(element.multiplier))
element.replace(new)
else:
for nabla in element[r'\nabla']:
for arg1 in nabla.args():
arg2, used_indices = nabla_calculation(arg1, used_indices, count - 1)
index = nabla.indices().__next__()
t := \nabla_{@(index)}{@[arg2]};
new = t
nabla1, used_indices = one_nabla(new, used_indices)
new = Ex(str(nabla.multiplier)) * nabla1
nabla.replace(new)
return ex, used_indices
def expand_nabla(ex):
if ex.top().name == '\equals':
for child in ex.top().children():
ret:=0;
for element in child.ex().top().terms():
count = 0
used_indices = set()
for nabla in element.ex()[r'\nabla']:
count += 1
if count == 0:
ret += element.ex()
#new_ex += element.ex()
else:
for n in element.ex():
for index in n.indices():
used_indices.add(str(index))
#for nabla in element[r'\nabla']:
element1, used_indices = nabla_calculation(element, used_indices, count)
ret +=element1
child.replace(ret)
else:
for element in ex.top().terms():
count = 0
used_indices = set()
for nabla in element.ex()[r'\nabla']:
count += 1
if count == 0:
pass
else:
for n in element.ex():
for index in n.indices():
used_indices.add(str(index))
element1, used_indices = nabla_calculation(element, used_indices, count)
element.replace(element1)
return ex
</code></pre>
<p>To use it, you need to call the main function expand_nabla(ex). It is suitable for large expressions, does not duplicate already occupied indexes, and also knows how to work with equalities.</p>
General questionshttp://cadabra.science/qa/2041/expansion-of-covariant-derivative?show=2053#a2053Thu, 21 Oct 2021 18:24:52 +0000Answered: Run cadabra kernel in colab
http://cadabra.science/qa/2048/run-cadabra-kernel-in-colab?show=2050#a2050
<p>To add to my earlier answer: you can install Conda and then the Cadabra kernel with</p>
<pre><code>!pip install -q condacolab
import condacolab
condacolab.install()
conda install cadabra2-jupyter-kernel
</code></pre>
<p>In principle it should then be possible to use that kernel from another notebook, as all your notebooks should be running inside the same VM. It didn't work for me, but maybe you have more luck.</p>
General questionshttp://cadabra.science/qa/2048/run-cadabra-kernel-in-colab?show=2050#a2050Sun, 17 Oct 2021 14:23:56 +0000Answered: Calling a cadabra note book in another one.
http://cadabra.science/qa/2046/calling-a-cadabra-note-book-in-another-one?show=2047#a2047
<p>Cadabra notebooks are treated as normal python modules when importing them into other notebooks. So you can have one notebook <code>one.cnb</code> and then from another one do</p>
<pre><code>import one
</code></pre>
<p>just like you would in Python. The standard rules for importing modules hold, in particular that you need to have the <code>one.cnb</code> somewhere in the <code>PYTHONPATH</code> (or <code>sys.path</code>).</p>
<p>For some more details see <a rel="nofollow" href="https://cadabra.science/notebooks/ref_import.html">https://cadabra.science/notebooks/ref_import.html</a></p>
Feature requestshttp://cadabra.science/qa/2046/calling-a-cadabra-note-book-in-another-one?show=2047#a2047Fri, 08 Oct 2021 07:25:46 +0000Answered: Strange substitution behavior in Cadabra v1
http://cadabra.science/qa/2044/strange-substitution-behavior-in-cadabra-v1?show=2045#a2045
<p>A lot of fixes where made in <code>substitute</code> for v2, and I remember at least one issue in which the presence of <code>LaTeXForm</code> messed with the substitution. So I am not entirely surprised that it works in v2 now. I'll consider it closed for now, but if you find anything remotely similar in v2, please let me know.</p>
Bug reportshttp://cadabra.science/qa/2044/strange-substitution-behavior-in-cadabra-v1?show=2045#a2045Fri, 01 Oct 2021 17:35:34 +0000Metric after coordinate transformation
http://cadabra.science/qa/2043/metric-after-coordinate-transformation
<p>Hi,<br>
I'm trying to figure out how to use Cadabra for the following:<br>
I defined a set of coordinate variables (e.g. {t,r,\theta,\phi}) and an explicit metric replacement statement, e.g. Schwarzschild metric:</p>
<blockquote>
<p>g<em>schw :={g</em>{t t}=-(1-R/r). g_{r r}=(1-R/r)**(-1), g_{\theta \theta}=...}<br>
complete(g_schw, $g^{\mu \nu}$);</p>
</blockquote>
<p>I have a formula for transformation from said coordinates into <a rel="nofollow" href="https://en.wikipedia.org/wiki/Schwarzschild_metric#Alternative_coordinates">harmonic coordinates</a> (Y0,Y1,Y2,Y3) <br>
(or Kruskal coordinates (T,X,\theta,\phi), or whatever...)<br>
I want to calculate the metric in the new coordinates, say h_{m n} (0<=m,n<=3).</p>
<p>The best I have so far (code below) is <br>
1) make substitution rules for Y0(t,r,\theta,\phi)...Y3(t,r,\theta,\phi)<br>
2) use the substitute and evaluate method to evaluate the inverse metric<br>
h^{m n} = g^{\mu \nu} * partial<em>{mu}{Y^{m}} * partial</em>{nu}{Y^{n}}</p>
<p>However<br>
* Cadabra constructs the new expression for the tensor with the indices values of [t,r,\theta,\phi] instead of [0,1,2,3]<br>
* I can't use complete to calculate h_{m n} from h^{m n}. The complete method doesn't work.</p>
<pre><code>{t,r,\theta,\phi}::Coordinate
{\mu,\nu,\rho,\sigma,\kappa,\xi,\zeta}::Indices(position=fixed,values=[t,r,\theta,\phi]);
{g_{\mu \nu},h_{\mu \nu}}::Metric;
{g^{\mu \nu},h^{\mu \nu}::InverseMetric;
{g_{\mu}^{\nu},h_{\mu}^{\nu}}::KroneckerDelta;
\partial{#}::PartialDerivative.
x_Y_schw := {X^{t}=t, X^{r}=r, X^{\theta}=\theta, X^{\phi}=\phi, Y^{t}=c t, Y^{r}=(r-R0/2) sin(\theta) cos(\phi), Y^{\theta}=(r-R0/2) sin(\theta) sin(\phi), Y^{\phi}=(r-R0/2) cos(\theta)};
{Y^{#}}::Depends(r,t,\theta,\phi);
evaluate($\partial_{\mu}{Y^{\nu}}$, x_Y_schw);
g_schw := {g_{t t}=-c**2 * (1-R0/r), g_{r r}=(1-R0/r)**(-1), g_{\theta \theta}=r**2, g_{\phi \phi}=r**2 * (sin(\theta))**2};
complete(g_schw, $g^{\mu \nu}$);
h_harm := h^{\rho \sigma} -> \partial_{\mu}{Y^{\rho}} \partial_{\nu}{Y^{\sigma}} g^{\mu \nu};
evaluate(h_harm, g_schw + x_Y_schw,rhsonly=True);
complete(h_harm, $h_{\rho \sigma}$);
</code></pre>
General questionshttp://cadabra.science/qa/2043/metric-after-coordinate-transformationSun, 26 Sep 2021 13:02:58 +0000Answered: Substitute Affected by Unrelated Expression Definition
http://cadabra.science/qa/2027/substitute-affected-by-unrelated-expression-definition?show=2042#a2042
<p>Hi Simon,</p>
<p>I'm not getting the behaviour you describe. Am I doing something wrong?</p>
<p><img src="https://ibb.co/sPTzKtT" alt="enter image description here"></p>
Bug reportshttp://cadabra.science/qa/2027/substitute-affected-by-unrelated-expression-definition?show=2042#a2042Fri, 24 Sep 2021 10:11:51 +0000Matching expressions with variable index ranges
http://cadabra.science/qa/2038/matching-expressions-with-variable-index-ranges
<p>I am trying to write a substitution that does essentially the following:</p>
<pre><code>\gamma_{a}_{\alpha \beta} \gamma_{b}^{\beta \gamma} -> X_{a b}_{\alpha}^{\gamma}
</code></pre>
<p>but with $a$ and $b$ allowed to be a range of vector indices, e.g. I want to also encompass</p>
<pre><code>\gamma_{a1 a2 a3}_{\alpha \beta} \gamma_{b}^{\beta \gamma} -> X_{a1 a2 a3 b}_{\alpha}^{\gamma}
</code></pre>
<p>and so on. I can of course define this for all possible collective indices a<em>i and b</em>i, or introduce some intermediate kluge, but I suspect there ought to be a compact, elegant way of doing this. My initial instinct was to try</p>
<pre><code>\gamma_{A??}_{\alpha \beta} \gamma_{B??}^{\beta \gamma} -> X_{A?? B??}_{\alpha}^{\gamma}
</code></pre>
<p>but this doesn't seem to work. Any ideas of a simple solution?</p>
General questionshttp://cadabra.science/qa/2038/matching-expressions-with-variable-index-rangesMon, 20 Sep 2021 14:31:47 +0000Problems with substitute and kronecker
http://cadabra.science/qa/2034/problems-with-substitute-and-kronecker
<p>Hi,<br>
i'm having some problems with the program. Currently, i'm using it to calculate one-loop diagrams in quantum gravity. The problems are that the kronecker delta does not completely disappear and that sometimes the algorithm "substitute" does not work. I have installed the software following the steps in the link "kpeeters/cadabra2" in the section "download" of the site. To be more precise, let $\Gamma_{\alpha\beta}$ be the 2-scalar-1 graviton vertex and $\Gamma_{\alpha\beta\mu\nu}$ be the 2 scalar- 2 graviton vertex. In the contraction $\Gamma_{\alpha\beta}\Gamma^{\alpha\beta\mu\nu}$, the substitution of $\Gamma_{\alpha\beta\mu\nu}$ occurs (sometimes) only after the distribute algorithm. I was thinking about the length of the components but I'm not sure. I have tried the combinations indices=free or fixed but it does not change. Kronecker delta still remains in every test.<br>
I hope in your response and I thank you in advance</p>
General questionshttp://cadabra.science/qa/2034/problems-with-substitute-and-kroneckerWed, 15 Sep 2021 08:16:11 +0000Answered: manipulating expressions: get_rhs and joining to an equation
http://cadabra.science/qa/2028/manipulating-expressions-get_rhs-and-joining-to-equation?show=2030#a2030
<p>You can multiply expressions like this:</p>
<pre><code> ex:= A+B+C;
ex:= (D+E) @(ex);
</code></pre>
<p>I am not entirely sure what you mean with (2). Do you mean that you have two expressions and you want to turn them into an equation by setting one equal to the other? Something like</p>
<pre><code>lhs:= A+B;
rhs:= C+D;
ex:= @(lhs) = @(rhs);
</code></pre>
<p>?</p>
<p>Finally, if you think <code>simplify</code> has a bug when acting on equations, please try to provide a minimal example and send that to me, so it can be fixed.</p>
General questionshttp://cadabra.science/qa/2028/manipulating-expressions-get_rhs-and-joining-to-equation?show=2030#a2030Tue, 07 Sep 2021 08:23:53 +0000Getting list of arguments of functions
http://cadabra.science/qa/2029/getting-list-of-arguments-of-functions
<p>Hi,</p>
<p>The "evaluate" function has several arguments, like the parameter rhsonly that appears in different manuals I read. In the official documentation <br>
<a rel="nofollow" href="https://cadabra.science/manual/evaluate.html"></a><a rel="nofollow" href="https://cadabra.science/manual/evaluate.html">https://cadabra.science/manual/evaluate.html</a><br>
it isn't listed.<br>
I also went over the different pdf documents and didn't find a complete list of the arguments and their meaning.</p>
<p>Is there a document with a more thorough description of all the usable functions for Cadabra?</p>
<p>Alternatively, is there a way to get a list of arguments of an arbitrary function (like python's inspect)?</p>
<p>Thanks in advance,<br>
Amnon</p>
Feature requestshttp://cadabra.science/qa/2029/getting-list-of-arguments-of-functionsMon, 06 Sep 2021 10:39:31 +0000Trouble with Dummy-Index Manipulation within Index Brackets and Partial Derivatives
http://cadabra.science/qa/2026/trouble-manipulation-within-brackets-partial-derivatives
<p>Hi,</p>
<p>I am having difficulties with canonicalizing dummy indices on expressions involving index brackets. In particular, I want to canonicalize indices in a term involving a factor with no symmetries but with dummy indices shared with a gamma matrix, particularly for the purpose of combining with other terms with indices already arranged in canonical order. This works perfectly when no index brackets are present, as in the code sample below,</p>
<pre><code>ex := \Gamma^{a b} \Psi_{b a} + \Gamma^{a b} \Psi_{a b};
canonicalise(ex);
</code></pre>
<p>which gives</p>
<pre><code>Γ^{a b} Ψ_{b a} + Γ^{a b} Ψ_{a b}
0
</code></pre>
<p>However, when index brackets are added, the expression is no longer canonicalized, and hence the terms are no longer combined, as in the code sample below,</p>
<pre><code>ex := (\Gamma^{a b})_{\alpha \beta} (\Psi_{b a})_{\gamma \eta} + (\Gamma^{a b})_{\alpha \beta} (\Psi_{a b})_{\gamma \eta};
canonicalise(ex);
</code></pre>
<p>which gives</p>
<pre><code>\indexbracket(Γ^{a b})_{α β} \indexbracket(Ψ_{b a})_{γ η} + \indexbracket(Γ^{a b})_{α β} \indexbracket(Ψ_{a b})_{γ η}
\indexbracket(Γ^{a b})_{α β} \indexbracket(Ψ_{b a})_{γ η} + \indexbracket(Γ^{a b})_{α β} \indexbracket(Ψ_{a b})_{γ η}
</code></pre>
<p>Is there any way to fix this? I have tried to tease out a solution using an index substitution, which I know is <a rel="nofollow" href="https://cadabra.science/qa/609/should-substitute-act-on-indices">generally counter-recommended</a> (rename_dummies() unfortunately does not help here), as in the code below,</p>
<pre><code>ex := (\Gamma^{a b})_{\alpha \beta} (\Psi_{b a})_{\gamma \eta};
substitute(ex, $_{a} -> _{b}, ^{a} -> ^{b}, _{b} -> _{a}, ^{b} -> ^{a}$);
canonicalise(ex);
</code></pre>
<p>which successfully gives</p>
<pre><code>\indexbracket(Γ^{a b})_{α β} \indexbracket(Ψ_{b a})_{γ η}
\indexbracket(Γ^{b a})_{α β} \indexbracket(Ψ_{a b})_{γ η}
\indexbracket(-Γ^{a b})_{α β} \indexbracket(Ψ_{a b})_{γ η}
</code></pre>
<p>However, applying this index substitution in the context of arithmetic is still a hurdle, and such an index substitution sometimes raises errors when partial derivatives are involved, as in the code below (I have removed the index brackets in order to isolate the feature that is triggering the error),</p>
<pre><code>ex := \Gamma_{b c} \Gamma^{b c d} \delta_{a}^{e} \partial_{e}(\Psi_{d});
substitute(ex, $_{e} -> _{b}, ^{e} -> ^{b}, _{b} -> _{c}, ^{b} -> ^{c}, _{c} -> _{d}, ^{c} -> ^{d}, _{d} -> _{e}, ^{d} -> ^{e}$);
</code></pre>
<p>which raises a triple index error. Note that the same code works with the partial derivative factor replaced, as in the code below.</p>
<pre><code>ex := \Gamma_{b c} \Gamma^{b c d} \delta_{a}^{e} \Psi_{e d};
substitute(ex, $_{e} -> _{b}, ^{e} -> ^{b}, _{b} -> _{c}, ^{b} -> ^{c}, _{c} -> _{d}, ^{c} -> ^{d}, _{d} -> _{e}, ^{d} -> ^{e}$);
</code></pre>
<p>Both the index-canonicalization issue with index brackets and the index-substitution issue with partial derivatives seem to have to do with recognizing vector indices and their symmetries within different branches of the ExNode tree structure of the expression. Am I making a mistake in my index handling? Is there any way to get around these issues?</p>
<p>The full code for the above tests is shown below.</p>
<pre><code>{a,b,c,d,e}::Indices(vector)
{a,b,c,d,e}::Integer(0..10)
{\alpha,\beta,\gamma,\eta}::Indices(spinor)
\partial{#}::PartialDerivative
\Psi{#}::Depends(\partial{#})
\Gamma_{#}::GammaMatrix(metric=\delta)
\delta{#}::KroneckerDelta
print('\ntest 1')
ex := \Gamma^{a b} \Psi_{b a} + \Gamma^{a b} \Psi_{a b};
canonicalise(ex);
print('\ntest 2')
ex := (\Gamma^{a b})_{\alpha \beta} (\Psi_{b a})_{\gamma \eta} + (\Gamma^{a b})_{\alpha \beta} (\Psi_{a b})_{\gamma \eta};
canonicalise(ex);
print('\ntest 3')
ex := (\Gamma^{a b})_{\alpha \beta} (\Psi_{b a})_{\gamma \eta};
substitute(ex, $_{a} -> _{b}, ^{a} -> ^{b}, _{b} -> _{a}, ^{b} -> ^{a}$);
canonicalise(ex);
print('\ntest 4')
ex := \Gamma_{b c} \Gamma^{b c d} \delta_{a}^{e} \Psi_{e d};
substitute(ex, $_{e} -> _{b}, ^{e} -> ^{b}, _{b} -> _{c}, ^{b} -> ^{c}, _{c} -> _{d}, ^{c} -> ^{d}, _{d} -> _{e}, ^{d} -> ^{e}$);
print('\ntest 5')
ex := \Gamma_{b c} \Gamma^{b c d} \delta_{a}^{e} \partial_{e}(\Psi_{d});
substitute(ex, $_{e} -> _{b}, ^{e} -> ^{b}, _{b} -> _{c}, ^{b} -> ^{c}, _{c} -> _{d}, ^{c} -> ^{d}, _{d} -> _{e}, ^{d} -> ^{e}$);
</code></pre>
<p>Thanks in advance.</p>
<p>-Simon</p>
General questionshttp://cadabra.science/qa/2026/trouble-manipulation-within-brackets-partial-derivativesTue, 24 Aug 2021 03:05:58 +0000Answered: Configuring jupyterhub with cadabra2
http://cadabra.science/qa/2023/configuring-jupyterhub-with-cadabra2?show=2024#a2024
<p>OK... I think I solved the issue by updating the jupyterhub.service configuration.<br>
I had to locate the jupyterhub.service file. In my system it was in the folder<br>
/etc/systemd/system/</p>
<p>i.e.</p>
<pre><code>sudo gedit /etc/systemd/system/jupyterhub.service
</code></pre>
<p>Underneath the existing "Environment=" line, I added another line</p>
<blockquote>
<p>Environment=export PYTHONPATH=${PYTHONPATH}:/usr/local/lib/python3.9/site-packages</p>
</blockquote>
<p>After saving the file, I had to re-load the configuration into the system with</p>
<pre><code>sudo systemctl daemon-reload
</code></pre>
<p>finally - restart the service:</p>
<pre><code>sudo systemctl restart jupyterhub.service
</code></pre>
<p>Now I can run cadabra2 commands in jupyterhub from any computer in my LAN<br>
(I configured a firewall rule to allow http traffic only from LAN IPs).</p>
Installation troublehttp://cadabra.science/qa/2023/configuring-jupyterhub-with-cadabra2?show=2024#a2024Tue, 10 Aug 2021 20:49:22 +0000Answered: Coefficients Inconsistency with expand=False in join_gamma()
http://cadabra.science/qa/2020/coefficients-inconsistency-with-expand-false-join_gamma?show=2021#a2021
<blockquote>
<p>It seems as though the implicit (anti)symmetrization given with expand=False is not being recognized by the next loop of join_gamma().</p>
</blockquote>
<p>That's correct. There is no such thing as 'an expression with implicit anti-symmetrisation' in the sense that Cadabra still knows about it. I have had this on the todo list for a long time, and there has been some basic infrastructure for that internally, but it never really materialised. So in effect, you can only use <code>expand=False</code> at the very last step of a gamma join.</p>
General questionshttp://cadabra.science/qa/2020/coefficients-inconsistency-with-expand-false-join_gamma?show=2021#a2021Sun, 08 Aug 2021 09:15:26 +0000How to Create an Antisymmetric Metric
http://cadabra.science/qa/2019/how-to-create-an-antisymmetric-metric
<p>Hi.</p>
<p>Is there any way to create an antisymmetric metric in Cadabra, like the spinor metric (charge conjugation matrix with spinor indices) in 11d? That is, I am looking for a way to create an antisymmetric object that can be contracted to raise and lower indices (as with eliminate_metric()), but it seems that objects with the Metric property in Cadabra must be symmetric.</p>
<p>Thanks in advance.</p>
<p>-Simon</p>
General questionshttp://cadabra.science/qa/2019/how-to-create-an-antisymmetric-metricSun, 08 Aug 2021 07:14:34 +0000Answered: Support for plugin `Remote - WSL` in vscode
http://cadabra.science/qa/2015/support-for-plugin-remote-wsl-in-vscode?show=2016#a2016
<p>It's not something I will be implementing myself anytime soon (there simply isn't enough time in the day), but I'm happy to take patches if anyone figures out how to do this.</p>
Feature requestshttp://cadabra.science/qa/2015/support-for-plugin-remote-wsl-in-vscode?show=2016#a2016Thu, 08 Jul 2021 09:00:54 +0000Answered: how to cite cadabra2 in 2021
http://cadabra.science/qa/2013/how-to-cite-cadabra2-in-2021?show=2014#a2014
<p>The most recent paper (and the only one from my hand about Cadabra 2.x) is</p>
<pre><code>@article{Peeters2018,
doi = {10.21105/joss.01118},
url = {https://doi.org/10.21105/joss.01118},
year = {2018},
publisher = {The Open Journal},
volume = {3},
number = {32},
pages = {1118},
author = {Kasper Peeters},
title = {Cadabra2: computer algebra for field theory revisited},
journal = {Journal of Open Source Software}
}
</code></pre>
<p>So that's probably the best one. Wouldn't hurt me if you would cite the two others as well though.</p>
General questionshttp://cadabra.science/qa/2013/how-to-cite-cadabra2-in-2021?show=2014#a2014Tue, 06 Jul 2021 15:02:30 +0000Answered: component_to_subrule function
http://cadabra.science/qa/2008/component_to_subrule-function?show=2009#a2009
<p>This is a recent addition; make sure you are running a current version of Cadabra.</p>
Bug reportshttp://cadabra.science/qa/2008/component_to_subrule-function?show=2009#a2009Wed, 30 Jun 2021 20:57:39 +0000Bug with isolate function
http://cadabra.science/qa/2007/bug-with-isolate-function
<p>Hello!<br>
Then I try to solve linear equation like</p>
<pre><code>import cdb.core.manip as man
expr:= G - 2*F * X =0;
man.isolate(expr, $F$);
</code></pre>
<p>I get something like that<br>
<img src="https://sun9-1.userapi.com/impg/N5JkB_247NPa-RQCJFUDIjZ5Dm-ZtX93oyzBjA/tEej2DE_67o.jpg?size=436x235&quality=96&sign=6f3b1c2cead815519843d9fb7cf73483&type=album" alt="enter image description here"></p>
<p>I think it's not ok. It's a bug, or I'm doing something wrong?</p>
Bug reportshttp://cadabra.science/qa/2007/bug-with-isolate-functionTue, 01 Jun 2021 16:08:34 +0000Answered: Error when applying the complete algorithm in the inverse Schwarzschild metric.
http://cadabra.science/qa/2004/applying-complete-algorithm-inverse-schwarzschild-metric?show=2005#a2005
<p>Be careful with your brackets and backslashes. The following segment works:</p>
<pre><code>{r,t,\phi,\theta}::Coordinate;
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma,\alpha,\beta#}::Indices(values= {t,r,\phi,\theta}, position=independent);
\partial{#}::PartialDerivative;
g_{\mu\nu}::Metric;
g^{\mu\nu}::InverseMetric;
# Schwarzschild metric:
scw:= { g_{t t} = -(1-2 M/r), g_{r r} = 1/(1-2 M/r), g_{\theta\theta} = r**2, g_{\phi\phi}=r**2 \sin(\theta)**2 };
# inverse metric:
complete(scw, $g^{\mu\nu}$);
</code></pre>
<p>I had to fix the declaration of the indices (a missing curly opening bracket) and the use of <code>sin</code> (which you need to write as <code>\sin</code>, with a backslash).</p>
<p>If you copy-paste the above, do you still get the error?</p>
General questionshttp://cadabra.science/qa/2004/applying-complete-algorithm-inverse-schwarzschild-metric?show=2005#a2005Tue, 11 May 2021 08:59:13 +0000Answered: Failure of running cadabra on windows.
http://cadabra.science/qa/1259/failure-of-running-cadabra-on-windows?show=1998#a1998
<p>Windows is no longer supported, I do not have the time for it anymore. Volunteers welcome to bring this back to life.</p>
Bug reportshttp://cadabra.science/qa/1259/failure-of-running-cadabra-on-windows?show=1998#a1998Tue, 13 Apr 2021 16:31:26 +0000Answered: Sum of tensors in coordinate form
http://cadabra.science/qa/1993/sum-of-tensors-in-coordinate-form?show=1994#a1994
<p>Use <code>collect_components(ex)</code>.</p>
General questionshttp://cadabra.science/qa/1993/sum-of-tensors-in-coordinate-form?show=1994#a1994Fri, 09 Apr 2021 18:07:58 +0000Answered: Problem with combine
http://cadabra.science/qa/1834/problem-with-combine?show=1992#a1992
<p>I can confirm the behaviour of your code. </p>
<p><strong>Just a comment:</strong> It seems that <code>combine</code> privilege the position of the indices (lower like a covariant and upper like contravariant) over the <code>property</code> of the objects. </p>
<p><img src="https://ibb.co/BVCM67P" alt="cadabra_combine"></p>
Bug reportshttp://cadabra.science/qa/1834/problem-with-combine?show=1992#a1992Wed, 07 Apr 2021 10:35:56 +0000Answered: Canonicalizing with independent indices mixes up raised/lowered
http://cadabra.science/qa/1968/canonicalizing-independent-indices-mixes-raised-lowered?show=1991#a1991
<p>The algorithm does funny things if you declare indices <code>independent</code> but then not stick to Einstein conventions of having only one upper and one lower index. In your example, the <code>b</code> index appears as subscript twice. It tried to keep those two <code>b</code>s as lower indices, but as a result, it had to raise the index on <code>X</code>.</p>
<p>I would classifyl this as undefined behaviour, though perhaps a warning would have been appropriate. I don't think I will spend time on 'fixing' this, especially because it isn't even clear what the right fix should do.</p>
Bug reportshttp://cadabra.science/qa/1968/canonicalizing-independent-indices-mixes-raised-lowered?show=1991#a1991Sun, 04 Apr 2021 20:41:36 +0000Answered: About the `\commutator` operation
http://cadabra.science/qa/1986/about-the-commutator-operation?show=1990#a1990
<p>Answers to your re-stated questions: no, yes, yes. </p>
General questionshttp://cadabra.science/qa/1986/about-the-commutator-operation?show=1990#a1990Sun, 04 Apr 2021 14:41:55 +0000Answered: Installing Cadabra
http://cadabra.science/qa/1978/installing-cadabra?show=1988#a1988
<p>There are instructions on the download page; it's a few lines of <code>brew install</code> and related in a terminal.</p>
<p>If that does not work, please get back here with some details on where it fails.</p>
General questionshttp://cadabra.science/qa/1978/installing-cadabra?show=1988#a1988Sun, 04 Apr 2021 12:52:36 +0000Answered: Support for Apple Silicon(M1)
http://cadabra.science/qa/1981/support-for-apple-silicon-m1?show=1982#a1982
<p>Lucky you. Donations for the purchase of M1 hardware can be made by paypal ;-)</p>
<p>What is the dependency you are struggling with?</p>
Installation troublehttp://cadabra.science/qa/1981/support-for-apple-silicon-m1?show=1982#a1982Tue, 23 Mar 2021 17:21:43 +0000Answered: Problem with definition of the generalized delta
http://cadabra.science/qa/1974/problem-with-definition-of-the-generalized-delta?show=1976#a1976
<p>The help for <code>KroneckerDelta</code> states that indices are 'paired' in the way it comes out here. It is perhaps more transparent if you write upper and lower indices, so</p>
<p>$$2 \delta_{a}{}^{b}{}_{c}{}^{d} = \delta_{a}{}^{b} \delta_{c}{}^{d} - \delta_{c}{}^{b} \delta_{a}{}^{d}.$$</p>
<p>Your version just has all indices moved to subscript position.</p>
<p>It's all a matter of convention of course (there's nothing wrong with defining things 'your' way), but this is the convention Cadabra uses.</p>
General questionshttp://cadabra.science/qa/1974/problem-with-definition-of-the-generalized-delta?show=1976#a1976Tue, 16 Mar 2021 17:53:57 +0000Answered: Copy output to mathematica
http://cadabra.science/qa/1967/copy-output-to-mathematica?show=1973#a1973
<p>If you click the expression, there is no feedback, but you can then paste into another application.</p>
<p>Alternatively, write your expressions into a file. Or use the <code>map_mma</code> functionality (only available if you build Cadabra from source yourself and pass <code>-DENABLE_MATHEMATICA=ON</code> to <code>cmake</code>).</p>
General questionshttp://cadabra.science/qa/1967/copy-output-to-mathematica?show=1973#a1973Sat, 13 Mar 2021 14:39:14 +0000Answered: Same problem with jupyter kernel in Ubuntu 20.04.2 LTS
http://cadabra.science/qa/1971/same-problem-with-jupyter-kernel-in-ubuntu-20-04-2-lts?show=1972#a1972
<p>For any problem that involves a Cadabra kernel which does not want to start, please send the relevant error lines which are printed to the terminal. So start the sage notebook using</p>
<pre><code>./sage -notebook
</code></pre>
<p>from a terminal, and copy-paste the output into an email to <code>info@cadabra.science</code>.</p>
<p>I have just tried the above with the current Cadabra on an Ubuntu 18.04 system with Sage 9.2, and it works, so it is definitely possible.</p>
General questionshttp://cadabra.science/qa/1971/same-problem-with-jupyter-kernel-in-ubuntu-20-04-2-lts?show=1972#a1972Fri, 12 Mar 2021 21:24:28 +0000Answered: Maximum column width for input
http://cadabra.science/qa/1958/maximum-column-width-for-input?show=1964#a1964
<p>Can you run <code>cadabra2-gtk</code> from inside <code>gdb</code> and get me a backtrace when this happens? I suspect it crashes in gtk itself.</p>
Bug reportshttp://cadabra.science/qa/1958/maximum-column-width-for-input?show=1964#a1964Sat, 06 Mar 2021 21:31:06 +0000Answered: I have a Python3 installation, and I want to run Cadabra2 on top of it
http://cadabra.science/qa/1961/have-python3-installation-and-want-run-cadabra2-on-top-of-it?show=1963#a1963
<p>Cadabra does not need Conda (I am not using Conda myself either). A standard build from source will produce a Jupyter kernel which runs with the Python installation which is picked up at build time.</p>
<p>Your main problem will be that you are trying to do this on Windows 10. Building Cadabra from source on that platform is far from trivial, and I have no idea how to do that such that it builds against the version of Python shipped with SageMath. In addition, SageMath is a bit of a weird beast to start with, as it tends to ship with <em>everything</em> it needs, including compilers. That is only changing slowly recently, but I am not following this very closely.</p>
<p>Your best bet, if you insist on staying with Windows, may be to ask people on the SageMath mailing list how to build a mixed C++/Python program like Cadabra from source. A better choice may be to switch to Linux, as that platform really is much more friendly for software like this.</p>
<p>Feel free to get in touch wagain ith more technical questions if you decide to give this a shot.</p>
General questionshttp://cadabra.science/qa/1961/have-python3-installation-and-want-run-cadabra2-on-top-of-it?show=1963#a1963Sat, 06 Mar 2021 20:57:28 +0000Accessing the Weight of an object
http://cadabra.science/qa/1956/accessing-the-weight-of-an-object
<p>Is there a way to access the weight of an object?</p>
<p>I've figured out that I can do</p>
<pre><code>X::Weight(label=dimension,value=2);
Weight.get($X$,label=dimension);
</code></pre>
<p>to determine that the Weight attribute has been set. But is there a way to find out that X has weight 2?</p>
General questionshttp://cadabra.science/qa/1956/accessing-the-weight-of-an-objectWed, 03 Mar 2021 21:39:32 +0000Answered: Bug in expand_delta
http://cadabra.science/qa/1952/bug-in-expand_delta?show=1955#a1955
<p>This only seems to happen when the delta appears at the very top of the expression (so not in a product or sum). Now fixed on github, thanks for reporting.</p>
Bug reportshttp://cadabra.science/qa/1952/bug-in-expand_delta?show=1955#a1955Wed, 03 Mar 2021 21:28:26 +0000Taking out a common numerical factor
http://cadabra.science/qa/1951/taking-out-a-common-numerical-factor
<p>Is there a way to somehow conveniently take out the total numerical factor, because factor_out does not work for me. For example:</p>
<pre><code>{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,u,v,w#}::Indices(full, values={t,x,y,z}, position=independent).
{t, x, y, z}::Coordinate.
ex:= -\frac{1}{4} A_{x} + -\frac{1}{4}A_{y};
factor_out(ex, $-\frac{1}{4}$);
</code></pre>
<p>does nothing</p>
General questionshttp://cadabra.science/qa/1951/taking-out-a-common-numerical-factorThu, 25 Feb 2021 16:34:53 +0000Non-Leibniz differential operators
http://cadabra.science/qa/1950/non-leibniz-differential-operators
<p>Hi Everyone.</p>
<p>I am trying to use Cadabra2 with weighted tensor densities. Specifically I'd need to introduce a "non-standard" differential operator, i.e. an operator that does not satisfy the usual Leibniz product rule, but picks up a correction term in addition to the usual product rule.</p>
<p>Is there a way to introduce such a "differentiation" operator in Cadabra?</p>
<p>I tried to just declare dependency with</p>
<blockquote>
<p>::Depends(D{#});</p>
</blockquote>
<p>for the tensors, and then define the differentiation rules case-by-case, but cadabra seems to misunderstand index positions. For example</p>
<blockquote>
<p>_ := D^{A}{Y<em>{A} V} = D^{A}{Y</em>{A}} V + Y<em>{A} D^{A}{V} + N X^{A} D^{B}{Y</em>{A}} D_{B}{V} ;</p>
</blockquote>
<p>produces a "free indices do not match" error message, but if I truncate off the last two terms,</p>
<blockquote>
<p>_ := D^{A}{Y<em>{A} V} = D^{A}{Y</em>{A}} V ;</p>
</blockquote>
<p>the error message disappears. Also, the error message disappears if I run D_#::Derivative; first.</p>
<p>Many Thanks!</p>
General questionshttp://cadabra.science/qa/1950/non-leibniz-differential-operatorsThu, 18 Feb 2021 11:38:03 +0000Answered: Displaying the result in jupyter notebook
http://cadabra.science/qa/1943/displaying-the-result-in-jupyter-notebook?show=1949#a1949
<p>I increased the buffer size of mathjax as described in this question and it worked.</p>
<p><a rel="nofollow" href="https://stackoverflow.com/questions/22751772/mathjax-in-ipython-notebook-fails-for-fairly-large-equations">https://stackoverflow.com/questions/22751772/mathjax-in-ipython-notebook-fails-for-fairly-large-equations</a></p>
General questionshttp://cadabra.science/qa/1943/displaying-the-result-in-jupyter-notebook?show=1949#a1949Wed, 17 Feb 2021 10:36:14 +0000Answered: Repeated derivatives
http://cadabra.science/qa/1938/repeated-derivatives?show=1940#a1940
<p>That simplification should have happened automatically. Can you email me (<code>info@cadabra.science</code>) the code that leads to that non-zero result?</p>
General questionshttp://cadabra.science/qa/1938/repeated-derivatives?show=1940#a1940Sat, 13 Feb 2021 11:02:41 +0000Problems in compiling Cadabra from source
http://cadabra.science/qa/1937/problems-in-compiling-cadabra-from-source
<p>Hi</p>
<p>When I was trying to build the Cadabra from the source, I did find certain errors during the build, and that I cannot open the application at all. </p>
<p>The building process I was following is exactly from <a rel="nofollow" href="https://github.com/kpeeters/cadabra2#windows">here</a>, and after I input the code<br>
<code>cmake --build . --config RelWithDebInfo --target install</code> , I found these errors:</p>
<blockquote>
<p><code>C:\Dev\cadabra2\core\DisplayTerminal.cc(18,14): error C2001: newline in constant [C:\Dev\cadabra2\build\core\cadabra2.v
cxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(19,14): error C2001: newline in constant [C:\Dev\cadabra2\build\core\cadabra2.v
cxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(18,14): error C2064: term does not evaluate to a function taking 1 arguments [C
:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(20,4): error C2059: syntax error: ';' [C:\Dev\cadabra2\build\core\cadabra2.vcxp
roj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(662,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(663,20): error C2065: 'it': undeclared identifier [C:\Dev\cadabra2\build\core\c
adabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(664,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(664,53): error C2143: syntax error: missing ';' before '{' [C:\Dev\cadabra2\bui
ld\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(664,53): error C2447: '{': missing function header (old-style formal list?) [C:
\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(672,6): error C2143: syntax error: missing ';' before '<<' [C:\Dev\cadabra2\bui
ld\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(672,6): error C4430: missing type specifier - int assumed. Note: C++ does not s
upport default-int [C:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(674,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,22): error C2065: 'it': undeclared identifier [C:\Dev\cadabra2\build\core\c
adabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,24): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int [C:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,25): error C2440: 'initializing': cannot convert from 'initializer list' to
'int' [C:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,16): message : The initializer contains too many elements [C:\Dev\cadabra2\
build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(679,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(681,2): error C2059: syntax error: '}' [C:\Dev\cadabra2\build\core\cadabra2.vcx
proj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(681,2): error C2143: syntax error: missing ';' before '}' [C:\Dev\cadabra2\buil
d\core\cadabra2.vcxproj]</code></p>
</blockquote>
<p>And after the installation is complete, I tried to run <code>ctest</code>, which gives that all 47 tests were failed. Therefore, I would like to know what was going on during the compilation.</p>
<p>The OS I am using is Windows 10, with Anaconda 2020.07(Conda 4.9.2), Texlive 6.3.2, and Visual Studio 16.8.5 installed. The exact process conducted was:</p>
<ol>
<li>Doing <code>git clone</code> from the provided link</li>
<li>Executing <code>C:\Dev\cadabra2\build>cmake -DCMAKE_TOOLCHAIN_FILE=C:/Dev/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_INSTALL_PREFIX=C:\Cadabra -G "Visual Studio 16 2019" -A x64 ..</code></li>
<li>Executing cmake command shown in the link from very above, giving error on DisplayTerminal.cc mentioned before.</li>
</ol>
Installation troublehttp://cadabra.science/qa/1937/problems-in-compiling-cadabra-from-sourceFri, 12 Feb 2021 21:27:10 +0000Answered: Evaluate function kernel crash
http://cadabra.science/qa/1926/evaluate-function-kernel-crash?show=1936#a1936
<p>You have defined both <code>x</code> and <code>y</code> as <code>Indices</code>, but also as <code>Coordinate</code>. This makes the definition of that <code>box</code> ambiguous,</p>
<pre><code>box := h^{a b} (\partial_{a b}{p} - \Gamma^{y}_{a b}\partial_{y}{p});
</code></pre>
<p>as it contains a <code>y</code> which could either be an index or a fixed index value. The checks in Cadabra to catch this kind of problem are not strong enough to prevent the crash.</p>
<p>If you drop <code>x</code> and <code>y</code> from your index set and write e.g. <code>c</code> in the definition of <code>box</code> all seems well.</p>
<p>Also note that you really need a space (or star) between <code>h^{a b}</code> and the bracket that follows, otherwise it gets interpreted as <code>h^{a b}</code> with an argument, not as two factors.</p>
Bug reportshttp://cadabra.science/qa/1926/evaluate-function-kernel-crash?show=1936#a1936Fri, 12 Feb 2021 21:08:56 +0000Answered: Cadabra2 kernel for jupyter
http://cadabra.science/qa/1930/cadabra2-kernel-for-jupyter?show=1931#a1931
<p>It can't find the cadabra kernel module, set your <code>PYTHON_PATH</code> so it picks it up.</p>
Installation troublehttp://cadabra.science/qa/1930/cadabra2-kernel-for-jupyter?show=1931#a1931Tue, 09 Feb 2021 18:34:06 +0000Answered: Access to parts of equality
http://cadabra.science/qa/1918/access-to-parts-of-equality?show=1920#a1920
<p>You could wrap this in an outer loop which iterates over the two sides of the equality, e.g.</p>
<pre><code>ex:= A+B = C
for sides in ex.top().children():
for element in sides.terms():
element.multiplier *= 2
</code></pre>
<p>which turns <code>ex</code> into</p>
<pre><code>2A + 2B = 2C
</code></pre>
<p>If you only wanted to e.g. touch the right-hand side, do something like</p>
<pre><code>ch = ex.top().children()
next(ch)
next(ch)
for element in ch.terms():
element.multiplier *= 2
</code></pre>
General questionshttp://cadabra.science/qa/1918/access-to-parts-of-equality?show=1920#a1920Wed, 27 Jan 2021 17:39:22 +0000Answered: Installation error v2.3.6.5 on Ubuntu 18.04
http://cadabra.science/qa/1915/installation-error-v2-3-6-5-on-ubuntu-18-04?show=1917#a1917
<p>Configure with</p>
<pre><code> cmake -DENABLE_MATHEMATICA=OFF ..
</code></pre>
<p>For some reason the script which tries to locate Mathematica messes up other parts of the CMake procedure.</p>
Installation troublehttp://cadabra.science/qa/1915/installation-error-v2-3-6-5-on-ubuntu-18-04?show=1917#a1917Sun, 24 Jan 2021 15:45:20 +0000Answered: Meld function
http://cadabra.science/qa/1888/meld-function?show=1914#a1914
<p>This has been fixed in 2.3.6.4.</p>
Bug reportshttp://cadabra.science/qa/1888/meld-function?show=1914#a1914Sat, 23 Jan 2021 21:49:05 +0000Answered: Labelling Objects
http://cadabra.science/qa/1908/labelling-objects?show=1913#a1913
<p>From 2.3.6.5 (which I have just pushed to github) you can use the auto-declare syntax for this, using the <code>#</code> character after the name. So e.g.</p>
<pre><code>T#^{a b c}_{e f}::TableauSymmetry(shape={1,1}, indices={3,4});
ex:=T1^{a b c}_{e f} T2^{e f g}_{h i} + T1^{a b c}_{e f} T2^{f e g}_{h i};
canonicalise(ex);
</code></pre>
<p>to produce zero.</p>
General questionshttp://cadabra.science/qa/1908/labelling-objects?show=1913#a1913Sat, 23 Jan 2021 21:47:18 +0000Answered: Coordinate indices mess up diagonal tensor?
http://cadabra.science/qa/1911/coordinate-indices-mess-up-diagonal-tensor?show=1912#a1912
<p>Cadabra used to only handle <code>Diagonal</code> with numerical indices. I have just pushed a fix (2.3.6.5) which also handles symbolic indices like in your first example.</p>
Bug reportshttp://cadabra.science/qa/1911/coordinate-indices-mess-up-diagonal-tensor?show=1912#a1912Sat, 23 Jan 2021 21:45:19 +0000Answered: Tab for autocomplete crashes Cadabra
http://cadabra.science/qa/1909/tab-for-autocomplete-crashes-cadabra?show=1910#a1910
<p>This was fixed in 2.3.6 but I forgot to generate new packages; now available.</p>
Bug reportshttp://cadabra.science/qa/1909/tab-for-autocomplete-crashes-cadabra?show=1910#a1910Sun, 17 Jan 2021 12:46:50 +0000Changing the settings
http://cadabra.science/qa/1897/changing-the-settings
<p>Hello, I would like to know if you can change the color of the cursor, as it is almost transparent I cannot see.</p>
General questionshttp://cadabra.science/qa/1897/changing-the-settingsThu, 07 Jan 2021 22:33:47 +0000Answered: explicit_indices used in two trace
http://cadabra.science/qa/1887/explicit_indices-used-in-two-trace?show=1893#a1893
<p>The first problem arises because you did not tell <code>tr</code> over which indices it traces. If you have <code>ImplicitIndex</code> objects inside the trace which have an explicit form listed, then you also need to specify the indices on which <code>tr</code> acts, otherwise it takes those objects out. Perhaps the default is not entirely logical, apologies. So this is easily fixed by using</p>
<pre><code>tr{#}::Trace(indices=vector).
</code></pre>
<p>instead.</p>
<p>The second problem was a bug, thanks for reporting it. It is now fixed on github with version 2.3.5.4.</p>
General questionshttp://cadabra.science/qa/1887/explicit_indices-used-in-two-trace?show=1893#a1893Mon, 28 Dec 2020 22:39:30 +0000Answered: Question about Kronecker delta
http://cadabra.science/qa/1889/question-about-kronecker-delta?show=1890#a1890
<p>You cannot use <code>\delta{#}</code> for the Kronecker delta <em>and</em> the variational delta at the same time. By making <code>\delta{#}</code> a <code>Derivative</code>, the <code>\delta_{m1}^{m3}</code> gets interpreted as 'a second-order derivative in the <code>m1</code> and <code>m3</code> directions, acting on nothing', which is zero.</p>
<p>The least confusing is if you rename your variational delta (you can still use a <code>LaTeXForm</code> property to make it print as a $\delta$ symbol). Alternatively, be a bit less generic with your patterns, as in the working example below.</p>
<pre><code>{a,b,c,d,e,f,g,h,i,j,k,l,m,n,q,r,s,u,v,w,z#}::Indices(position=independent).
h_{m n}::Metric.
h^{m n}::InverseMetric.
\delta^{m?}_{n?}::KroneckerDelta.
\delta_{m?}^{n?}::KroneckerDelta.
\partial{#}}::PartialDerivative.
{\nabla{#}, \delta{A??}}::Derivative.
delh_{m n}::Depends(\nabla{#}, \partial{#}).
delh^{m n}::Depends(\nabla{#}, \partial{#}).
h_{m n}::Depends(\partial{#}, \delta{#}).
h^{m n}::Depends(\partial{#}, \delta{#}).
\Dh::LaTeXForm("\sqrt{-h}").
delh{#}::LaTeXForm("\delta h").
ex:= \nabla_{a}{\nabla_{b}{delh^{c a}}} h_{c d} h^{d b};
substitute(ex, $h_{m1 m2} h^{m2 m3} -> \delta_{m1}^{m3}$);
</code></pre>
<p>To understand why this works, remember that the pattern <code>#</code> stands for 'any number of arguments', while <code>A??</code> stands for 'any object'. </p>
General questionshttp://cadabra.science/qa/1889/question-about-kronecker-delta?show=1890#a1890Mon, 21 Dec 2020 20:38:24 +0000Only write out one index summation
http://cadabra.science/qa/1878/only-write-out-one-index-summation
<p>I have a basic question based on <a rel="nofollow" href="https://cadabra.science/qa/1851/manipulate-matrix.">https://cadabra.science/qa/1851/manipulate-matrix.</a> I have seen that you have updated some codes related to the above question a few days ago, but I still have the following question: How to just expand the dummy indices <code>a,b</code> and don't touch the indices $\mu,\nu$ in the following expression?</p>
<p>$$<br>
L:=D_{\mu} B^a D_{\nu}B^b D_{\mu} B^a D_{\nu}B^b,<br>
$$ </p>
<p>where <code>a,b</code> and $\mu,\nu$ are the different index types, and $B^a$ is <code>SelfNonCommuting</code>.</p>
General questionshttp://cadabra.science/qa/1878/only-write-out-one-index-summationFri, 18 Dec 2020 02:04:16 +0000