Cadabra Q&A - Recent questions and answers
https://cadabra.science/qa/qa
Powered by Question2AnswerCadabra 2 notebooks and REPL more responsive than script interpreter
https://cadabra.science/qa/2288/cadabra-notebooks-repl-more-responsive-script-interpreter
<p>I am having some trouble using the <code>diff</code> command. If run Cadabra2 REPL with <code>cadabra2</code> it works just fine:</p>
<pre><code>> ex:= A*A + B + C;
A A + B + C
> diff(ex, $A$);
2*A</code></pre>
<p>Same with the GTK GUI. I would expect it to do the same if I put my commands into a <code>.cdb</code> file and ran <code>cadabra2 file.cdb</code>. File contents are</p>
<pre><code>ex:= A*A + B + C;
diff(ex, $A$);</code></pre>
<p>so exactly the same thing, but <code>diff</code> just spits the original expression back at me instead:</p>
<pre><code>$ cadabra2 file.cdb
A A + B + C
A A + B + C</code></pre>
<p>It seems to just echo the last expression before the diff command; if I put some other expression in between the two,</p>
<pre><code>ex:= A*A + B + C;
foo:= B;
diff(ex, $A$);</code></pre>
<p>the output is</p>
<pre><code>$ cadabra2 file.cdb
A A + B + C
B
B</code></pre>
<p>Surely this is not intentional?</p>Bug reportshttps://cadabra.science/qa/2288/cadabra-notebooks-repl-more-responsive-script-interpreterSun, 22 May 2022 21:11:05 +0000Answered: doubt about how to make assumptions in multiple files
https://cadabra.science/qa/2286/doubt-about-how-to-make-assumptions-in-multiple-files?show=2287#a2287
<p>Put these lines in a separate notebook, let's say <code>defs.cnb</code>. Then import that notebook into another one by doing <code>import defs</code>. </p>General questionshttps://cadabra.science/qa/2286/doubt-about-how-to-make-assumptions-in-multiple-files?show=2287#a2287Sat, 21 May 2022 10:29:43 +0000Answered: Generic TeX error bug
https://cadabra.science/qa/2184/generic-tex-error-bug?show=2185#a2185
<p>There are a few things going on here. Let me start with the right way to do this:</p>
<pre><code>test := e_{\mu}{}^{a};
for n in test:
display(n.ex())</code></pre>
<p>In order to display Cadabra expressions, it's almost always best to use <code>display</code>, as <code>print</code> lacks the logic to make the notebook display LaTeX expressions. The <code>display</code> function ensures that many things (mathematical expressions, plots, ...) show up in the best way in the notebook.</p>
<p>You also need <code>n.ex()</code>, not just <code>n</code>, because <code>display</code> does not (yet) understand the <code>ExNode</code> object (which <code>n</code> is). For everything it does not understand, it calls <code>str</code> on it, and then you are effectively back to what you wrote. By calling <code>n.ex()</code> you convert the <code>ExNode</code> object <code>n</code> to an <code>Ex</code> object, which <code>display</code> knows how to handle.</p>
<p>Finally: I agree it would have been useful if <code>str(n)</code> produced something printable in the notebook (so that your original code would display the three expressions in non-typeset LaTeX form). Unfortunately, by default <code>str</code> turns <code>\mu</code> into the Unicode symbol for that character, and LaTeX doesn't understand that. This is a bug, we should turn off Unicode printing in the notebook.</p>Bug reportshttps://cadabra.science/qa/2184/generic-tex-error-bug?show=2185#a2185Thu, 31 Mar 2022 08:09:30 +0000Answered: Substitution employing double overline accent?
https://cadabra.science/qa/2180/substitution-employing-double-overline-accent?show=2181#a2181
<p>That's because your first term contains</p>
<pre><code>\overline{ \overline{u_{i}} \overline{u_{j}} }</code></pre>
<p><em>not</em></p>
<pre><code>\overline{ \overline{ u_{i} u_{j} } }</code></pre>
<p>So your pattern in <code>rl2</code> does not match.</p>
<p>It's difficult to see in the LaTeX output as the two overlines merge, but if you print the tree-form
with <code>print(tree(conv))</code> you can see it.</p>General questionshttps://cadabra.science/qa/2180/substitution-employing-double-overline-accent?show=2181#a2181Thu, 03 Mar 2022 20:00:26 +0000Answered: Issue with eliminate metric
https://cadabra.science/qa/2176/issue-with-eliminate-metric?show=2177#a2177
<p>If you want to use metrics to raise/lower your indices, then you <em>cannot</em> declare them as <code>position=free</code>. The latter means that the position of indices (subscript/superscript) has no meaning and can be changed arbitrarily, without factors of the metric. But worse, it means that all your patterns collapse to a single one, because upper indices will match lower indices and vice versa.</p>
<p>If you change your first line to contain <code>position=fixed</code> then things work as expected. The <code>eliminate_metric</code> will then not do anything (since there is no metric in your expression), but <code>eliminate_kronecker</code> will replace the $g_{\mu}{}^{\mu}$ with $d$. A further <code>canonicalise</code> will remove the $\Gamma^{\mu}{}_{\mu}$.</p>Bug reportshttps://cadabra.science/qa/2176/issue-with-eliminate-metric?show=2177#a2177Sun, 27 Feb 2022 18:21:39 +0000Answered: issue installing on mac
https://cadabra.science/qa/2174/issue-installing-on-mac?show=2175#a2175
<p>A quick <code>brew search sigc++</code> brings up the <code>libsigc++</code> package. Try doing </p>
<pre><code>brew install libsigc++</code></pre>
<p>and then do the <code>cmake</code> stage again.</p>
<p>This used to be automatic when installing <code>gtkmm</code>, as the latter requires <code>sigc++</code>, but someone seems to have removed that dependency from the brew repository.</p>General questionshttps://cadabra.science/qa/2174/issue-installing-on-mac?show=2175#a2175Mon, 21 Feb 2022 09:16:44 +0000Answered: question regarding a rule involving partial derivative
https://cadabra.science/qa/2169/question-regarding-a-rule-involving-partial-derivative?show=2170#a2170
<p>Hi, I've got a similar problem before, and it is due (to my understanding) to the fact that cadabra uses the notation </p>
<p>$\partial_{ab}$ </p>
<p>to denote </p>
<p>$\partial<em>{a}\partial</em>{b}.$</p>
<p>I solved my problem by adding a <em>dummy</em> symbol that can be then set to one after the simplification (if it is still around), I used the symbol <strong>I</strong> in the <code>ex2</code> below</p>
<pre><code>{a,b,c}::Indices.
\partial{#}::PartialDerivative.
ex := \partial_{a}{ A^a } + A_a B^a + \partial_{a}{ \partial_{b}{ A^a }} B^b
+ \partial_{a}{ A^b } \partial_{b}{ B^a };
ex2 := \partial_{a}{ A^a } + A_a B^a + \partial_{a}{ I \partial_{b}{ A^a }} B^b
+ \partial_{a}{ A^b } \partial_{b}{ B^a };
rl := \partial_{a}{ A^{b} } -> 0;
substitute(ex, rl);
substitute(ex2, rl);</code></pre>
<p><a rel="nofollow" href="https://ibb.co/NyGKG9y">See the result here</a></p>
<p>Hope this can be useful.</p>
<hr>
<p><strong>Update:</strong></p>
<p>Another solution is that you could declare <code>\partial{#}::Derivative.</code> instead of like a partial derivative. The difference is that <code>Derivative</code> does not simplify the notation </p>
<p>$\partial<em>{a}\partial</em>{b}$ </p>
<p>to </p>
<p>$\partial_{ab},$</p>
<p>and the substitution works properly.</p>
<p><a rel="nofollow" href="https://ibb.co/nQ22VCG">See the updated code and result</a></p>Feature requestshttps://cadabra.science/qa/2169/question-regarding-a-rule-involving-partial-derivative?show=2170#a2170Mon, 14 Feb 2022 09:56:47 +0000Answered: converting partial derivative to covariant derivative
https://cadabra.science/qa/2167/converting-partial-derivative-to-covariant-derivative?show=2168#a2168
<p>If you want to prevent <code>canonicalise</code> from raising or lowering indices, declare those indices with the <code>position=independent</code> property (not <code>position=fixed</code>). That seems to work in your example. </p>
<p>You will still need some <code>eliminate_metric</code>, <code>eliminate_kronecker</code> and <code>sort_product</code> after that.</p>General questionshttps://cadabra.science/qa/2167/converting-partial-derivative-to-covariant-derivative?show=2168#a2168Fri, 11 Feb 2022 12:12:53 +0000Answered: Question about eliminate metric
https://cadabra.science/qa/2163/question-about-eliminate-metric?show=2164#a2164
<p>I can't reproduce that problem; the following returns the expression unchanged:</p>
<pre><code>{a,b,c,d}::Indices(position=fixed);
\partial{#}::PartialDerivative;
g{#}::Depends(\partial{#});
g^{a b}::InverseMetric;
g_{a b}::Metric;
ex:=g^{a b}\partial_{c}{g_{b d}};
eliminate_metric(ex);</code></pre>
<p>Can you post a self-contained example that shows the problem?</p>General questionshttps://cadabra.science/qa/2163/question-about-eliminate-metric?show=2164#a2164Fri, 04 Feb 2022 07:36:43 +0000Answered: copy the output and feed as another input
https://cadabra.science/qa/2092/copy-the-output-and-feed-as-another-input?show=2093#a2093
<p>Copy-paste is almost never the right solution for this kind of problem, as it means that for any change you make later, you have to go through that manual process again.</p>
<p>Instead, in those 6 files, write the final expression to disk as described in </p>
<p><a rel="nofollow" href="https://cadabra.science/notebooks/ref_import.html">https://cadabra.science/notebooks/ref_import.html</a></p>
<p>(see the "writing expressions to a file and reading them back" section) and then read them back into your main notebook. </p>General questionshttps://cadabra.science/qa/2092/copy-the-output-and-feed-as-another-input?show=2093#a2093Sun, 30 Jan 2022 12:31:38 +0000Answered: diffrentiation of an expression
https://cadabra.science/qa/2086/diffrentiation-of-an-expression?show=2090#a2090
<p>First an explanation of what happens here (feel free to skip): When you call <code>diff</code>, what you are actually doing is calling a Sympy function. In order for Sympy to act on your Cadabra expression, it will convert it to a Sympy object by calling <code>S._sympy_()</code>. However, that will produce a version of your expression in which tensor indices are replaced with <code>DN</code>+name or <code>UP</code>+name depending on the position. Once the <code>diff</code> function completes, it returns a Sympy expression, which then stays that way; it does not magically become a Cadabra <code>Ex</code> expression again.</p>
<p>So you need to define your own <code>diff</code>, which converts the Cadabra expression to Sympy form, applies the Sympy function, and then converts back to a Cadabra expression. That's easy,</p>
<pre><code>def diff(ex1, ex2):
ret = $@(ex1)$
sb = SympyBridge(ret)
sb.from_sympy( str(sympy.diff( sb.to_sympy(), ex2 ) ) )
return ret</code></pre>
<p>Then this works:</p>
<pre><code>ex := A_{a}(r) r;
diff( ex, $r$ )</code></pre>
<p>which produces a new Cadabra expression</p>
<p>$$r \partial_{r}( A_{a}(r) ) + A_{a}(r)$$</p>
<p>Final note: yes, functions like that really should be part of the <code>cdb.sympy</code> package. Lack of time...</p>General questionshttps://cadabra.science/qa/2086/diffrentiation-of-an-expression?show=2090#a2090Sat, 29 Jan 2022 21:39:58 +0000Answered: simplifying expression
https://cadabra.science/qa/2084/simplifying-expression?show=2089#a2089
<p>Hi,</p>
<p>I was able to resolve this issue. After the last command, I added <code>collect_factors()</code> which did the job.</p>General questionshttps://cadabra.science/qa/2084/simplifying-expression?show=2089#a2089Sat, 29 Jan 2022 09:12:57 +0000Answered: Bug in string_states example
https://cadabra.science/qa/2082/bug-in-string_states-example?show=2083#a2083
<p>Ouch, that's a brown paper bag one! What should happen is that a delta with different indices which have a <code>Coordinate</code> property becomes zero. Instead, it did it for every symbolic index. No idea how this slipped through the automatic tests...</p>
<p>Now fixed in github master. Since this wrong cleanup happened only for <code>Diagonal</code> objects, simply not using that property also avoids the problem (as you already observed). Thanks for reporting this.</p>Bug reportshttps://cadabra.science/qa/2082/bug-in-string_states-example?show=2083#a2083Mon, 24 Jan 2022 14:47:38 +0000Answered: Minus sign to index-dependent power
https://cadabra.science/qa/2079/minus-sign-to-index-dependent-power?show=2080#a2080
<p>It's doing the correct thing to the expression, but the result is not written in canonical form, and because of that displays incorrectly. What it's actually showing is</p>
<pre><code>- \alpha_{-1}^{\mu} { -1 }^{1}</code></pre>
<p>and because the curly brackets around the <code>-1</code> do not show, you get this weird looking result.</p>
<p>The quickest way to fix this is to add an</p>
<pre><code>expand_power(ex)</code></pre>
<p>inside your <code>bpz</code> function; that will turn <code>(-1)^1</code> into <code>(-1)</code> which then gets absorbed into product correctly. Using <code>simplify(ex)</code> will also work, but is much slower and requires a roundtrip through sympy's simplify function.</p>
<p>It's a bug of course, I have registered it as <a rel="nofollow" href="https://github.com/kpeeters/cadabra2/issues/247">https://github.com/kpeeters/cadabra2/issues/247</a>.</p>General questionshttps://cadabra.science/qa/2079/minus-sign-to-index-dependent-power?show=2080#a2080Sun, 23 Jan 2022 21:06:22 +0000Answered: Redefining a function
https://cadabra.science/qa/2063/redefining-a-function?show=2064#a2064
<p>Almost all Cadabra functions modify the expression in-place. So you first need to make a copy of the expression, and then apply the substitution.</p>
<p>There are a few other things not quite right in your example: <code>Ex</code> is a class name (so you cannot use it as the name of an expression; use <code>ex</code> with lowercase instead), and expressions must have valid Python names (so you cannot call them <code>T_{\mu\nu}^{1}</code>). </p>
<p>Here's something that works:</p>
<pre><code>ex:=Teff_{\mu \nu} = a^{0} T0_{\mu \nu}
+a^{1} T1_{\mu \nu}
+a^{2} T2_{\mu \nu}
+a^{3} T3_{\mu \nu};
T0 = rhs(ex)
substitute(T0, $a^{0}=1, a^{1}=0, a^{2}=0, a^{3}=0$);</code></pre>
<p>This sets the Python variable <code>T0</code> equal to the mathematical expression $T0_{\mu\nu}$.</p>General questionshttps://cadabra.science/qa/2063/redefining-a-function?show=2064#a2064Sun, 02 Jan 2022 22:20:43 +0000Answered: Why meld mixes different sets of variables?
https://cadabra.science/qa/2060/why-meld-mixes-different-sets-of-variables?show=2061#a2061
<p>This works as intended on my installation of Cadabra 2.3.8. Can you try that version please and let me know whether the problem persists?</p>General questionshttps://cadabra.science/qa/2060/why-meld-mixes-different-sets-of-variables?show=2061#a2061Tue, 07 Dec 2021 17:31:23 +0000Answered: Support for Apple Silicon(M1)
https://cadabra.science/qa/1981/support-for-apple-silicon-m1?show=2059#a2059
<p>The current version 2.3.8 builds from source on Apple silicon.</p>
<p>I have also updated the homebrew tap so you can install that way too.</p>Installation troublehttps://cadabra.science/qa/1981/support-for-apple-silicon-m1?show=2059#a2059Sun, 21 Nov 2021 15:28:46 +0000Answered: Expansion of covariant derivative
https://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 questionshttps://cadabra.science/qa/2041/expansion-of-covariant-derivative?show=2053#a2053Thu, 21 Oct 2021 19:24:52 +0000Answered: Run cadabra kernel in colab
https://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 questionshttps://cadabra.science/qa/2048/run-cadabra-kernel-in-colab?show=2050#a2050Sun, 17 Oct 2021 15:23:56 +0000Answered: Calling a cadabra note book in another one.
https://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 requestshttps://cadabra.science/qa/2046/calling-a-cadabra-note-book-in-another-one?show=2047#a2047Fri, 08 Oct 2021 08:25:46 +0000Answered: Strange substitution behavior in Cadabra v1
https://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 reportshttps://cadabra.science/qa/2044/strange-substitution-behavior-in-cadabra-v1?show=2045#a2045Fri, 01 Oct 2021 18:35:34 +0000Metric after coordinate transformation
https://cadabra.science/qa/2043/metric-after-coordinate-transformation
<p>Hi,
I'm trying to figure out how to use Cadabra for the following:
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<em>{r r}=(1-R/r)**(-1), g</em>{\theta \theta}=...}
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)
(or Kruskal coordinates (T,X,\theta,\phi), or whatever...)
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 </p>
<ol>
<li>make substitution rules for Y0(t,r,\theta,\phi)...Y3(t,r,\theta,\phi)</li>
<li>use the substitute and evaluate method to evaluate the inverse metric
h^{m n} = g^{\mu \nu} <em> partial_{mu}{Y^{m}} </em> partial_{nu}{Y^{n}}</li>
</ol>
<p>However</p>
<ul>
<li>
<p>Cadabra constructs the new expression for the tensor with the indices values of [t,r,\theta,\phi] instead of [0,1,2,3]</p>
</li>
<li>
<p>I can't use complete to calculate h_{m n} from h^{m n}. The complete method doesn't work.</p>
<p>{t,r,\theta,\phi}::Coordinate
{\mu,\nu,\rho,\sigma,\kappa,\xi,\zeta}::Indices(position=fixed,values=[t,r,\theta,\phi]);
{g<em>{\mu \nu},h</em>{\mu \nu}}::Metric;
{g^{\mu \nu},h^{\mu \nu}::InverseMetric;
{g<em>{\mu}^{\nu},h</em>{\mu}^{\nu}}::KroneckerDelta;
\partial{#}::PartialDerivative.
x_Y<em>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</em>{\mu}{Y^{\nu}}$, x_Y_schw);
g<em>schw := {g</em>{t t}=-c<strong>2 * (1-R0/r), g<em>{r r}=(1-R0/r)**(-1), g</em>{\theta \theta}=r<strong>2, g_{\phi \phi}=r</strong>2 * (sin(\theta))</strong>2};
complete(g_schw, $g^{\mu \nu}$);
h<em>harm := h^{\rho \sigma} -> \partial</em>{\mu}{Y^{\rho}} \partial_{\nu}{Y^{\sigma}} g^{\mu \nu};
evaluate(h_harm, g_schw + x_Y_schw,rhsonly=True);
complete(h<em>harm, $h</em>{\rho \sigma}$);</p>
</li>
</ul>General questionshttps://cadabra.science/qa/2043/metric-after-coordinate-transformationSun, 26 Sep 2021 14:02:58 +0000Answered: Substitute Affected by Unrelated Expression Definition
https://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 reportshttps://cadabra.science/qa/2027/substitute-affected-by-unrelated-expression-definition?show=2042#a2042Fri, 24 Sep 2021 11:11:51 +0000Matching expressions with variable index ranges
https://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_i and b_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 questionshttps://cadabra.science/qa/2038/matching-expressions-with-variable-index-rangesMon, 20 Sep 2021 15:31:47 +0000Problems with substitute and kronecker
https://cadabra.science/qa/2034/problems-with-substitute-and-kronecker
<p>Hi,
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.
I hope in your response and I thank you in advance</p>General questionshttps://cadabra.science/qa/2034/problems-with-substitute-and-kroneckerWed, 15 Sep 2021 09:16:11 +0000Answered: manipulating expressions: get_rhs and joining to an equation
https://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 questionshttps://cadabra.science/qa/2028/manipulating-expressions-get_rhs-and-joining-to-equation?show=2030#a2030Tue, 07 Sep 2021 09:23:53 +0000Getting list of arguments of functions
https://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
<a rel="nofollow" href="https://cadabra.science/manual/evaluate.html">https://cadabra.science/manual/evaluate.html</a>
it isn't listed.
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,
Amnon</p>Feature requestshttps://cadabra.science/qa/2029/getting-list-of-arguments-of-functionsMon, 06 Sep 2021 11:39:31 +0000Trouble with Dummy-Index Manipulation within Index Brackets and Partial Derivatives
https://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 questionshttps://cadabra.science/qa/2026/trouble-manipulation-within-brackets-partial-derivativesTue, 24 Aug 2021 04:05:58 +0000Answered: Configuring jupyterhub with cadabra2
https://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.
I had to locate the jupyterhub.service file. In my system it was in the folder
/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
(I configured a firewall rule to allow http traffic only from LAN IPs).</p>Installation troublehttps://cadabra.science/qa/2023/configuring-jupyterhub-with-cadabra2?show=2024#a2024Tue, 10 Aug 2021 21:49:22 +0000Answered: Coefficients Inconsistency with expand=False in join_gamma()
https://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 questionshttps://cadabra.science/qa/2020/coefficients-inconsistency-with-expand-false-join_gamma?show=2021#a2021Sun, 08 Aug 2021 10:15:26 +0000How to Create an Antisymmetric Metric
https://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 questionshttps://cadabra.science/qa/2019/how-to-create-an-antisymmetric-metricSun, 08 Aug 2021 08:14:34 +0000Answered: Support for plugin `Remote - WSL` in vscode
https://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 requestshttps://cadabra.science/qa/2015/support-for-plugin-remote-wsl-in-vscode?show=2016#a2016Thu, 08 Jul 2021 10:00:54 +0000Answered: how to cite cadabra2 in 2021
https://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 questionshttps://cadabra.science/qa/2013/how-to-cite-cadabra2-in-2021?show=2014#a2014Tue, 06 Jul 2021 16:02:30 +0000Answered: component_to_subrule function
https://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 reportshttps://cadabra.science/qa/2008/component_to_subrule-function?show=2009#a2009Wed, 30 Jun 2021 21:57:39 +0000Bug with isolate function
https://cadabra.science/qa/2007/bug-with-isolate-function
<p>Hello!
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
<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 reportshttps://cadabra.science/qa/2007/bug-with-isolate-functionTue, 01 Jun 2021 17:08:34 +0000Answered: Error when applying the complete algorithm in the inverse Schwarzschild metric.
https://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 questionshttps://cadabra.science/qa/2004/applying-complete-algorithm-inverse-schwarzschild-metric?show=2005#a2005Tue, 11 May 2021 09:59:13 +0000Answered: Failure of running cadabra on windows.
https://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 reportshttps://cadabra.science/qa/1259/failure-of-running-cadabra-on-windows?show=1998#a1998Tue, 13 Apr 2021 17:31:26 +0000Answered: Sum of tensors in coordinate form
https://cadabra.science/qa/1993/sum-of-tensors-in-coordinate-form?show=1994#a1994
<p>Use <code>collect_components(ex)</code>.</p>General questionshttps://cadabra.science/qa/1993/sum-of-tensors-in-coordinate-form?show=1994#a1994Fri, 09 Apr 2021 19:07:58 +0000Answered: Problem with combine
https://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 reportshttps://cadabra.science/qa/1834/problem-with-combine?show=1992#a1992Wed, 07 Apr 2021 11:35:56 +0000Answered: Canonicalizing with independent indices mixes up raised/lowered
https://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 reportshttps://cadabra.science/qa/1968/canonicalizing-independent-indices-mixes-raised-lowered?show=1991#a1991Sun, 04 Apr 2021 21:41:36 +0000Answered: About the `\commutator` operation
https://cadabra.science/qa/1986/about-the-commutator-operation?show=1990#a1990
<p>Answers to your re-stated questions: no, yes, yes. </p>General questionshttps://cadabra.science/qa/1986/about-the-commutator-operation?show=1990#a1990Sun, 04 Apr 2021 15:41:55 +0000Answered: Installing Cadabra
https://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 questionshttps://cadabra.science/qa/1978/installing-cadabra?show=1988#a1988Sun, 04 Apr 2021 13:52:36 +0000Answered: Problem with definition of the generalized delta
https://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 questionshttps://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
https://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 questionshttps://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
https://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 questionshttps://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
https://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 reportshttps://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
https://cadabra.science/qa/1961/have-python3-installation-and-want-to-run-cadabra2-on-top-of?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 questionshttps://cadabra.science/qa/1961/have-python3-installation-and-want-to-run-cadabra2-on-top-of?show=1963#a1963Sat, 06 Mar 2021 20:57:28 +0000Accessing the Weight of an object
https://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 questionshttps://cadabra.science/qa/1956/accessing-the-weight-of-an-objectWed, 03 Mar 2021 21:39:32 +0000Answered: Bug in expand_delta
https://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 reportshttps://cadabra.science/qa/1952/bug-in-expand_delta?show=1955#a1955Wed, 03 Mar 2021 21:28:26 +0000Taking out a common numerical factor
https://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 questionshttps://cadabra.science/qa/1951/taking-out-a-common-numerical-factorThu, 25 Feb 2021 16:34:53 +0000