Cadabra Q&A - Recent questions and answers
https://cadabra.science/qa/qa
Powered by Question2AnswerCadabra in Jupyter notebook - how to store?
https://cadabra.science/qa/2956/cadabra-in-jupyter-notebook-how-to-store
<p>Hello,
I'm working with Cadabra on Jupyter notebooks, specifically via JupyterHub running on a linux system.
I save my work and shuts down the computer until my next session, but then when I open the notbook again I see that the results are fonw, only the code is saved.
I think only once I managed to somehow save a notebook with all of the results still showing when I re-open it. I don't know how I did it.</p>
<p>So my questio nis how to save a Cadabra-notebook (on a jupyterhub) with all the data still in the cache, and saved even after the computer is shut down?</p>General questionshttps://cadabra.science/qa/2956/cadabra-in-jupyter-notebook-how-to-storeSun, 20 Oct 2024 12:59:00 +0000Answered: sympy(?) errors parsing nested derivatives?
https://cadabra.science/qa/2949/sympy-errors-parsing-nested-derivatives?show=2950#a2950
<p>That problem comes from the fact that you wrote <code>\sin\phi</code>, instead of <code>\sin(\phi)</code>. In Cadabra you <em>have</em> to group function arguments. (Of course I agree the error is useless and this should be caught earlier).</p>Bug reportshttps://cadabra.science/qa/2949/sympy-errors-parsing-nested-derivatives?show=2950#a2950Tue, 01 Oct 2024 07:23:06 +0000Answered: \partial_\theta causes infinite loop(?) in server
https://cadabra.science/qa/2945/partial_-theta-causes-infinite-loop-in-server?show=2948#a2948
<p>I guess you have your answer there: add braces. In general, Cadabra is less forgiving about not wrapping arguments in braces, so just do it always. </p>
<p>Cadabra should not hang of course, will investigate. I have opened an issue at <a rel="nofollow" href="https://github.com/kpeeters/cadabra2/issues/312">https://github.com/kpeeters/cadabra2/issues/312</a>.</p>Bug reportshttps://cadabra.science/qa/2945/partial_-theta-causes-infinite-loop-in-server?show=2948#a2948Mon, 30 Sep 2024 09:58:40 +0000Answered: Custom display symbols for variables?
https://cadabra.science/qa/2940/custom-display-symbols-for-variables?show=2944#a2944
<p>Yes, use <code>LaTeXForm</code>, as in</p>
<pre><code>vr::LaTeXForm("\dot{r}").
vtheta::LaTeXForm("\dot{\theta}").
ex:= vr + vtheta;</code></pre>
<p>gives $\dot{r}+\dot{\theta}$.</p>General questionshttps://cadabra.science/qa/2940/custom-display-symbols-for-variables?show=2944#a2944Mon, 30 Sep 2024 07:19:15 +0000Answered: Gtk error messages on startup.
https://cadabra.science/qa/2941/gtk-error-messages-on-startup?show=2943#a2943
<p>I may need to see if those gtk modules should be included in the AppImage too (I have not done a lot of testing with the AppImage on systems that are truly bare, without an existing gtk installation).</p>
<p>The <code>connection to server failed</code> message happens when you restart the kernel or load a new notebook (which restarts the kernel too). This kills the existing <code>cadabra-server</code> first, and the client then reports that. I could probably remove that error as it sounds more alarming than it is.</p>Bug reportshttps://cadabra.science/qa/2941/gtk-error-messages-on-startup?show=2943#a2943Mon, 30 Sep 2024 07:15:18 +0000Answered: Simple derivative evaluation not working for me.
https://cadabra.science/qa/2939/simple-derivative-evaluation-not-working-for-me?show=2942#a2942
<p>The <code>evaluate</code> does not substitute scalar functions, only component values (which is arguably misleading, and will possibly change in the future). But you can easily work around this by first substituting and then evaluating:</p>
<pre><code>substitute(exfr, exf);
evaluate(exfr);</code></pre>
<p>In fact the 2nd line then only really calls <code>simplify</code>, so you may as well use that.</p>General questionshttps://cadabra.science/qa/2939/simple-derivative-evaluation-not-working-for-me?show=2942#a2942Mon, 30 Sep 2024 07:12:55 +0000Answered: Another "No module named 'sympy' " question.
https://cadabra.science/qa/2934/another-no-module-named-sympy-question?show=2936#a2936
<p>I have just released 2.5.6, which fixes this issue, and also includes plotting support in the AppImage version. You can find the updated AppImage in the github release assets for this release. </p>Installation troublehttps://cadabra.science/qa/2934/another-no-module-named-sympy-question?show=2936#a2936Sun, 29 Sep 2024 20:58:15 +0000Answered: Cycle freeze
https://cadabra.science/qa/2929/cycle-freeze?show=2930#a2930
<p>I cannot reproduce this. Which "today's update" are you talking about? I did not make any new release. What is the version and build number? (start the command-line <code>cadabra2</code> and look at the first line of output).</p>Bug reportshttps://cadabra.science/qa/2929/cycle-freeze?show=2930#a2930Thu, 26 Sep 2024 17:01:38 +0000Answered: Expanding sum into time and purely space components.
https://cadabra.science/qa/2927/expanding-sum-into-time-and-purely-space-components?show=2928#a2928
<p>Hi Heckfy.</p>
<p>This "anwser" is more a comment, but it might transform onto an answer after some discussion.</p>
<h1>First contact</h1>
<p>I understand what you are trying to achieve, but not your question specifically. Let me comment further.</p>
<ul>
<li>There are typographic in your code blocks, and missing components in your substitution rules (non-diagonal inverse components of the background metric).</li>
</ul>
<p>I think that the right substitution rule should be</p>
<pre><code>back := gb_{t t}=-1,
gb_{r r}=a**2/(1-k*r**2),
gb_{\theta \theta}=a**2*r**2,
gb_{\varphi \varphi}=a**2*r**2*\sin{\theta}**2,
gb_{t r}=0,
gb_{t \theta}=0,
gb_{t \varphi}=0,
gb_{r \theta}=0,
gb_{r \varphi}=0,
gb_{\theta \varphi}=0,
gb_{r t}=0,
gb_{\theta t}=0,
gb_{\varphi t}=0,
gb_{\theta r}=0,
gb_{\varphi r}=0,
gb_{\varphi \theta}=0
gb^{t t}=-1,
gb^{r r}=(1-k*r**2)/(a**2),
gb^{\theta \theta}=1/(r**2 * a**2),
gb^{\varphi \varphi}=1/(a**2 * r**2 *\sin{\theta}**2),
gb^{t r}=0,
gb^{t \theta}=0,
gb^{t \varphi}=0,
gb^{r \theta}=0,
gb^{r \varphi}=0,
gb^{\theta \varphi}=0,
gb^{r t}=0,
gb^{\theta t}=0,
gb^{\varphi t}=0,
gb^{\theta r}=0,
gb^{\varphi r}=0,
gb^{\varphi \theta}=0;</code></pre>
<ul>
<li>In your question you talk about the connection and Ricci tensor, but there is nothing in the presented code referring to those objects. Could you please update the post to include a more complete notebook?</li>
<li>The second code block in your post does not compute anything! Remind that <code>cadabra</code> is not a calculation software, but a <strong>manipulation</strong> software. That means that you have to tell it explicitly what to do. So far (at least in what you showed), it is doing nothing.</li>
</ul>
<p>Well, in short, could you improve the quality of your post: improve the statement of your question, and provide a more complete version of your code.</p>
<p>Cheers,
Dox.</p>General questionshttps://cadabra.science/qa/2927/expanding-sum-into-time-and-purely-space-components?show=2928#a2928Mon, 12 Aug 2024 09:46:46 +0000Answered: question about eliminate_metric
https://cadabra.science/qa/2920/question-about-eliminate_metric?show=2923#a2923
<p>Hi Eureka and Kasper.</p>
<p>Thank you K for the suggestions in solving the issue. I used your point to evaluate the code by Eureka. </p>
<p>I noted that the accent desappear when the <code>ex</code> got evaluated, unless the accent surround just the symbol <code>g</code> (wihtout the indices).</p>
<p>Here my code:</p>
<pre><code>{\mu,\nu,\rho}::Indices(vector, position=fixed).
g^{\mu\nu}::InverseMetric.
g_\mu^\nu::KroneckerDelta.
g^\mu_\nu::KroneckerDelta.
\delta{#}::Accent.
ex:=\delta{g}_{\mu\nu} g^{\nu\rho};
eliminate_metric(_);</code></pre>
<p>Best wishes,
Dox</p>General questionshttps://cadabra.science/qa/2920/question-about-eliminate_metric?show=2923#a2923Mon, 05 Aug 2024 14:26:20 +0000Answered: A bug of Accent
https://cadabra.science/qa/2912/a-bug-of-accent?show=2913#a2913
<p>Hi Eureka.</p>
<p>Firstly, let me point that a semi-colon is missing at the en d of the third line. So, the correct <em>code</em> should be </p>
<pre><code>{a,b}::Indices(vector).
\delta{#}::Accent.
ex := \delta{A^{a b}+B^{a b}};</code></pre>
<p>Then, let me clarify that (to my understanding) accents are a way to differentiate symbols, i.e. it has no further properties. Why is this important? Perhaps your expression should be written as </p>
<pre><code>ex := \delta{A}^{a b} + \delta{B}^{a b};</code></pre>
<p>If you are expect your <em>accent</em> to have linearity property, give assign the property of <code>Derivative</code>, i.e.</p>
<pre><code>\delta{#}::Derivative.</code></pre>
<p>If you use the <code>Derivative</code> property instead of the <code>Accent</code>, you could apply the <code>distribute</code> algorithm in your original expression</p>
<pre><code>{a,b}::Indices(vector).
\delta{#}::Derivative.
ex:=\delta{A^{a b}+B^{a b}};
distribute(ex);</code></pre>
<p>Cheers,
Dox.</p>Bug reportshttps://cadabra.science/qa/2912/a-bug-of-accent?show=2913#a2913Thu, 01 Aug 2024 08:51:17 +0000Answered: Factor out of numerical coefficient
https://cadabra.science/qa/2899/factor-out-of-numerical-coefficient?show=2911#a2911
<p>The main reason why you cannot factor out <em>only</em> a numerical factor is that Cadabra stores rational pre-factors in a special location (the 'multiplier') inside each node in the expression tree. </p>
<p>Cadabra will always rewrite expressions so that a <code>\sum</code> node will have a unit multiplier. So all multipliers are associated to the summands. This is a canonicalisation choice which many algorithms in Cadabra rely on, so it's not easy to change that. Similarly, all child nodes of a <code>\prod</code> node will have unit multiplier.</p>
<p>As soon as you have a product in your expression node, like in <code>6 A (B + C)</code>, the multiplier is associated to the <code>\prod</code> node. So you still have </p>
<pre><code>\prod{A}{ \sum{B}{C} }</code></pre>
<p>with a unit multiplier for the <code>\sum</code>,
but now the <code>\prod</code> node has multiplier 6.</p>General questionshttps://cadabra.science/qa/2899/factor-out-of-numerical-coefficient?show=2911#a2911Thu, 18 Jul 2024 13:30:43 +0000Answered: I'm trying to reproduce equation 4.6 from 4.5 in Carrolls Spacettime ;and Geometry
https://cadabra.science/qa/2901/trying-reproduce-equation-from-carrolls-spacettime-geometry?show=2902#a2902
<p>Hi ChuckW.</p>
<p>I ran your code, compared the output with the result reported in the book, and it seems that the result is correct.</p>
<p>The last piece of the puzzle is the use of the chain rule. I complemented your code with the following:</p>
<pre><code>chain_rule := \partial_{\lambda}{x^{\nu}} \partial_{\nu}{A??} -> \partial_{\lambda}{A??};
substitute(expr, chain_rule);</code></pre>
<p>Hope this suggestions works to complete your task.</p>
<p>Cheers,
Dox.</p>General questionshttps://cadabra.science/qa/2901/trying-reproduce-equation-from-carrolls-spacettime-geometry?show=2902#a2902Fri, 28 Jun 2024 08:24:56 +0000Answered: how to deal with lovelock gravity?
https://cadabra.science/qa/2898/how-to-deal-with-lovelock-gravity?show=2900#a2900
<p>Hi Eureka.</p>
<p>In the article <a rel="nofollow" href="https://arxiv.org/pdf/2210.00005">here</a>, we provide an algorithm to find the Lagrangian and field equations of the Lanczos--Lovelock models.</p>
<p>At the time we wrote the article going beyond $m=4$ would take a virtually infinite amount of time.</p>
<p>I invite you (or any person interested) to go through our algorithm, and we could discuss ways to improve its performance.</p>
<p>Cheers,
Dox (aka Oscar)</p>General questionshttps://cadabra.science/qa/2898/how-to-deal-with-lovelock-gravity?show=2900#a2900Mon, 24 Jun 2024 17:34:46 +0000Answered: substitute gives incorrect value on scalar expression
https://cadabra.science/qa/2892/substitute-gives-incorrect-value-on-scalar-expression?show=2895#a2895
<p>Good catch, stupid error, now fixed.</p>Bug reportshttps://cadabra.science/qa/2892/substitute-gives-incorrect-value-on-scalar-expression?show=2895#a2895Tue, 18 Jun 2024 06:21:38 +0000Answered: LaTeXForm fails in version 2.5.2
https://cadabra.science/qa/2893/latexform-fails-in-version-2-5-2?show=2894#a2894
<p>Properties use round brackets for their arguments, no matter how much recent C++ committees may have confused your brain with that.</p>
<pre><code>Dx{#}::LaTeXForm("Dx").</code></pre>
<p>works. The error message could probably be nicer, I agree.</p>Bug reportshttps://cadabra.science/qa/2893/latexform-fails-in-version-2-5-2?show=2894#a2894Tue, 18 Jun 2024 05:46:42 +0000Answered: Cadabra 2.5.x released
https://cadabra.science/qa/2887/cadabra-2-5-x-released?show=2888#a2888
<p>On Slackware 15, I can't compile 2.5.2 because it requires python 3.10, and I can't run AppImage because it requires glibc 2.34. Is it possible to relax the glibc requirement to at least 2.33?</p>Announcementshttps://cadabra.science/qa/2887/cadabra-2-5-x-released?show=2888#a2888Sat, 15 Jun 2024 21:21:24 +0000Answered: location of bracket blocks distribute
https://cadabra.science/qa/2876/location-of-bracket-blocks-distribute?show=2882#a2882
<p>This has been reported a number of times now, so it's time to do something about it. Now fixed in github (2.4.5.9): a newline will act as a single whitespace character and hence turn your <code>bah</code> into <code>bah: = A (B+C)</code>.</p>Bug reportshttps://cadabra.science/qa/2876/location-of-bracket-blocks-distribute?show=2882#a2882Tue, 11 Jun 2024 14:24:28 +0000Answered: leading scalar expression blocks canonicalise
https://cadabra.science/qa/2875/leading-scalar-expression-blocks-canonicalise?show=2881#a2881
<p>This was because <code>canonicalise</code> was a bit too careful. If a term in an expression contains a sum as factor, and that factor has indices, then you <em>have</em> to <code>distribute</code> first. E.g.</p>
<pre><code>(A_{m n} + B_{m n}) R_{p q}^{m n};</code></pre>
<p>But <code>canonicalise</code> was rejecting <em>any</em> sums inside a factor, like in your example, even if it has no indices. That's not necessary. </p>
<p>Now fixed in github (2.4.5.9).</p>Bug reportshttps://cadabra.science/qa/2875/leading-scalar-expression-blocks-canonicalise?show=2881#a2881Tue, 11 Jun 2024 14:16:31 +0000Answered: How to copy output as tex format in jupyter notebook?
https://cadabra.science/qa/2871/how-to-copy-output-as-tex-format-in-jupyter-notebook?show=2873#a2873
<p>Hi! You can use</p>
<pre><code> ._latex_()</code></pre>
<p>method.</p>General questionshttps://cadabra.science/qa/2871/how-to-copy-output-as-tex-format-in-jupyter-notebook?show=2873#a2873Mon, 03 Jun 2024 19:32:48 +0000Answered: How can I store the result of evaluating g(.,v) as a co-vector?
https://cadabra.science/qa/2852/how-can-i-store-the-result-of-evaluating-g-v-as-a-co-vector?show=2872#a2872
<p>Hi paul.</p>
<p>Following your approach</p>
<pre><code>{m,n,a,b,c,d,q,r,s}::Indices(values={0,1}).
g_{a b}::Metric.
g^{a b}::InverseMetric.
g:=[g_{0 0}=28, g_{0 1}=2, g_{1 0}=3, g_{1 1}=-1];
v:=[v^{0}=12, v^{1}=-11];
ex:=g_{a b} v^{a};</code></pre>
<p>You can assing the evaluated expression to a variable using <code>python</code>'s notation (the <code>=</code> asignation, not the <code>:=</code> from <code>cadabra</code>)</p>
<pre><code>evaluate(ex,join(g,v), rhsonly=True);
w = _;</code></pre>
<p>If you want to loop the components of the resulting expression, I'd use (again) <code>python</code>'s notation</p>
<pre><code>import cdb.core.component as comp
for xx in range(2):
comp.get_component(w, Ex(f"{xx}"));</code></pre>
<p>Hope this would be useful.
Dox.</p>General questionshttps://cadabra.science/qa/2852/how-can-i-store-the-result-of-evaluating-g-v-as-a-co-vector?show=2872#a2872Wed, 29 May 2024 19:08:30 +0000Answered: imp package was removed from python 3.12
https://cadabra.science/qa/2863/imp-package-was-removed-from-python-3-12?show=2868#a2868
<p>Can one of you please test the current <code>2.4.5.8</code> now on github? You will most likely need to clean your cadabra notebook cache (<code>Tools > Clear package cache</code>).</p>Bug reportshttps://cadabra.science/qa/2863/imp-package-was-removed-from-python-3-12?show=2868#a2868Mon, 20 May 2024 12:53:29 +0000Answered: Why does evaluate of metric eating vector shows only non-zero components.
https://cadabra.science/qa/2855/does-evaluate-metric-eating-vector-shows-only-zero-components?show=2865#a2865
<p>That's an intentional choice, as for most 'interesting' tensors, there will typically be far more zero components than non-zero components (e.g. Riemann tensors). I guess we could make it configurable, but I haven't had the need for that so far.</p>General questionshttps://cadabra.science/qa/2855/does-evaluate-metric-eating-vector-shows-only-zero-components?show=2865#a2865Sun, 19 May 2024 20:10:55 +0000Answered: Christoffel symbols computation in $d$ dimensions with split indices
https://cadabra.science/qa/2851/christoffel-symbols-computation-dimensions-split-indices?show=2861#a2861
<p>Hi again raulastur.</p>
<p>Perhaps this would be repetitive, since Arina already post an answer to your question... but Ok, we learn by asymptotic approximation!</p>
<h2>Modifications to your work</h2>
<p>As usual, you have to declare the objects and properties</p>
<pre><code>{\mu,\nu,\rho,\sigma,\kappa,\lambda,\eta,\chi#}::Indices(full, position=fixed, values={1,2,3,4}).
{A,B,C,D}::Indices(subspace, position=fixed, parent=full, values={2,3,4}).
{i,j, m,n,p,q,r,v#}::Indices(subspace2, position=fixed, parent=subspace, values={2,3}).
{s1,s2,s3}::Indices(subspace1, position=fixed, parent=subspace, values={4}).
\partial{#}::PartialDerivative.
g_{\mu\nu}::Metric.
g^{\mu\nu}::InverseMetric.
g_{\mu? \nu?}::Symmetric.
g^{\mu? \nu?}::Symmetric.
b_{i j}::Metric.
b^{i j}::InverseMetric.
{\delta^{\mu?}_{\nu?},\delta_{\mu?}^{\nu?}}::KroneckerDelta.
{b_{i j},b^{i j}}::Depends(\partial{#}).</code></pre>
<p>I wanted to keep your definitions almost untouched. </p>
<p>I've added the dependence of the $b$ field on the partial derivative (although it is not important in the following code.</p>
<p>Then, I assume that the long sequence of substitutions would be applied to other expressions as well, so instead of your approach, I prefer to define a set of substitution rules</p>
<pre><code>rl := { g_{1 m} -> 0, g_{1 4} -> 1, g_{m 1} -> 0, g_{m n} -> b_{m n}, g_{m 4} -> U_{m}, g^{4 1} -> 1,
g_{4 m} -> U_{m}, g_{4 4} -> f, g^{1 1} -> U_{m} b^{m n} U_{n} - f, g^{1 m} -> - U_{n} b^{n m}, g^{1 4} -> 1,
g^{m 1} -> - U_{n} b^{n m}, g^{m n} -> b^{n m}, g^{m 4} -> 0, g^{4 1} -> 1, g^{4 m} -> 0, g^{4 4} -> 0,
\partial_{1}{U_{m}} -> 0, \partial_{1 \mu?}{U_{m}} -> 0,
\partial_{\mu? 1}{U_{m}} -> 0, \partial_{\mu? 1}{b_{i j}} -> 0};</code></pre>
<p>Above, I changed the substitutions that used double question marks, <code>U??</code> or other.</p>
<p>Also include the Christoffel definition</p>
<pre><code>Gtog:= \Gamma^{\lambda?}_{\mu? \nu?} = (1/2) * g^{\lambda? \kappa} (\partial_{\nu?}{ g_{\kappa \mu?}}
+ \partial_{\mu?}{g_{\kappa \nu?}} + \partial_{\kappa}{g_{\mu? \nu?} } );</code></pre>
<p>Note that the summed index has to run over the <code>full</code> space, while the other indices have the question mark (<code>?</code>) to ensure that the rule could be applied to whatever type of index (like <code>4</code>).</p>
<p>Now, I define the expression to be manipulated,</p>
<pre><code>Gamma4ij := \Gamma^{4}_{i j};</code></pre>
<p>and expand the indices</p>
<pre><code>substitute(Gamma4ij, Gtog)
split_index(Gamma4ij, $\mu, 1, A$, repeat=True)
split_index(Gamma4ij, $A, i, 4$, repeat=True);</code></pre>
<p>Finally, I use the substitution rule <code>rl</code> to obtain the result:</p>
<pre><code>substitute(Gamma4ij, rl, repeat=True);</code></pre>
<p>The result I obtain is $\partial<em>1 b</em>{i j}$.</p>
<h3>Why?</h3>
<p>When you used the double question mark notation, <code>U??</code>, in the substitution rule, it would substitute not just the variable called <code>U</code>, but <em>any</em> variable. Look at this example:</p>
<pre><code>ex:=A_{m n} + B_{m n};
substitute(_, $A? + B? -> 0$ );
substitute(_, $M?? + N?? -> 0$ );</code></pre>
<p>Hope this would help you.</p>
<p>Dox</p>General questionshttps://cadabra.science/qa/2851/christoffel-symbols-computation-dimensions-split-indices?show=2861#a2861Fri, 17 May 2024 09:45:10 +0000Answered: why can't cadabra find cdb.sympy.calculus?
https://cadabra.science/qa/2845/why-cant-cadabra-find-cdb-sympy-calculus?show=2846#a2846
<p>Similar issue to your other question: upgrade to a more recent version.</p>General questionshttps://cadabra.science/qa/2845/why-cant-cadabra-find-cdb-sympy-calculus?show=2846#a2846Tue, 07 May 2024 21:00:04 +0000Answered: how to compute metric(vector,vector) or g(v,w) where g,v,w already defined without haqving to repeat the definitions.
https://cadabra.science/qa/2839/compute-metric-already-defined-without-haqving-definitions?show=2840#a2840
<p>If you have the rules <code>g</code> and <code>v</code> which define the component values, you can feed those into <code>evaluate</code>. For example, to compute $g_{a b} v^{a} v^{b}$ with the values of your example, do</p>
<pre><code>{m,n,a,b,c,d,q,r,s}::Indices(values={0,1}).
g_{a b}::Metric.
g^{a b}::InverseMetric.
g:={g_{0 0}=28, g_{0 1}=2, g_{1 0}=3, g_{1 1}=-1};
v:={v^{0}=12, v^{1}=-11};
ex:=g_{a b} v^{a} v^{b};
evaluate(ex, join(g,v));</code></pre>
<p>Does that answer your question?</p>General questionshttps://cadabra.science/qa/2839/compute-metric-already-defined-without-haqving-definitions?show=2840#a2840Tue, 07 May 2024 14:40:18 +0000Answered: How to calculate Christoffel symbols with metric defined by abstract matrices?
https://cadabra.science/qa/2780/calculate-christoffel-symbols-defined-abstract-matrices?show=2836#a2836
<p>Let me hint some ideas... although it is a not very helpful example.</p>
<p><strong>Comment 0:</strong> I'll stick to the suggested code, and not the written line-element.</p>
<h2>My suggestions</h2>
<p>Firstly, let's assing some properties</p>
<pre><code>{t,x,y,z}::Coordinate;
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma}::Indices(values={t,x,y,z},position=independent);
{i,j,k,l,m,n}::Indices(values={x,y,z},position=independent);
\partial{#}::PartialDerivative;
g_{\mu\nu}::Metric;
g^{\mu\nu}::InverseMetric;
h_{i j}::Metric;
h^{i j}::InverseMetric;</code></pre>
<p><strong>Comment 1:</strong> the separation between Latin and Greek indices.</p>
<p>Then, assign some dependencies,</p>
<pre><code>h_{i j}::Depends(t);
N{#}::Depends(x,y,z);</code></pre>
<p>Now, instead of trying to declare sets of components, like <code>g_{0 i}=N_i</code> for the metric, I used a detail declaration,</p>
<pre><code>ss := { g_{t t}=0,
g_{t x}=N_x,
g_{t y}=N_y,
g_{t z}=N_z,
g_{x t}=N_x,
g_{y t}=N_y,
g_{z t}=N_z,
g_{x x}=h_{x x},
g_{y y}=h_{y y},
g_{z z}=h_{z z},
g_{y z}=h_{y z},
g_{z y}=h_{y z},
};
complete(ss, $g^{\mu\nu}$);</code></pre>
<p><strong>Comment 2:</strong> for the sake of "readability" of the output, I used a simplified version of the /spacial/ submetric. If you use a complete example the output is longer.</p>
<p>Finally, you can define the Christoffel rule,</p>
<pre><code>ch:= \Gamma^{\mu}_{\nu\rho} =
1/2 g^{\mu\sigma} (
\partial_{\rho}{g_{\nu\sigma}}
+\partial_{\nu}{g_{\rho\sigma}}
-\partial_{\sigma}{g_{\nu\rho}} );</code></pre>
<p>and evaluate its components,</p>
<pre><code>evaluate(ch, ss, rhsonly=True);</code></pre>
<h3>A more complete metric</h3>
<p>Just if you want to try it</p>
<pre><code>ss := { g_{t t}=N,
g_{t x}=N_x,
g_{t y}=N_y,
g_{t z}=N_z,
g_{x t}=N_x,
g_{y t}=N_y,
g_{z t}=N_z,
g_{x x}=h_{x x},
g_{y y}=h_{y y},
g_{z z}=h_{z z},
g_{x y}=h_{x y},
g_{y x}=h_{x y},
g_{x z}=h_{x z},
g_{z x}=h_{x z},
g_{y z}=h_{y z},
g_{z y}=h_{y z},
};
complete(ss, $g^{\mu\nu}$);</code></pre>
<h3>Additional reflexions</h3>
<p>If you have evaluated the above code, you'll find that it is not very useful!</p>
<p><em>Really long expressions.</em></p>
<p>What if we don't give explicit expressions?</p>
<p><strong>TO BE CONTINUED!</strong></p>
<h2>A better method</h2>
<p>Ok, finally I came with a <em>better</em> solution.</p>
<p>Paradoxically, the <em>best</em> solution uses the <code>substitute</code> algorithm instead of the <code>evaluate</code>.</p>
<p>The problem with the above strategy is that the components have to be given explicitly, but we'd like to treat the indices like time-like and spacial.</p>
<p>Let's start with some assignation of properties:</p>
<pre><code>{t,x,y,z}::Coordinate;
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma}::Indices(higher, values={t,x,y,z},position=independent);
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma}::Integer(0..3).
{i,j,k,l,m,n}::Indices(lower, values={x,y,z},position=independent);
{i,j,k,l,m,n}::Integer(1..3);
\partial{#}::PartialDerivative;
g_{\mu\nu}::Metric(higher, signature=-1);
g^{\mu\nu}::InverseMetric(higher, signature=-1);
{g^{\mu}_{\nu},g_{\mu}^{\nu}}::KroneckerDelta(higher).
h_{i j}::Metric(lower, signature=1);
h^{i j}::InverseMetric(lower, signature=1);
{h^{i}_{j},h_{i}^{j}}::KroneckerDelta(lower).</code></pre>
<p>Then, let us define a substitution rule for the ADM decomposition of the metric and its inverse:</p>
<pre><code>ADM := { g_{t t} = - N**2 + h_{i j} N^{i} N^{j},
g_{t i} = h_{i j} N^{j},
g_{i t} = h_{i j} N^{j},
g_{i j} = h_{i j},
g^{t t} = - 1 / N**2,
g^{t i} = N^i / N**2,
g^{i t} = N^i / N**2,
g^{i j} = h^{i j} - N^{i} N^j / N**2
};
refine := { \partial_{i?}{ h_{j}^{k} } -> 0,
\partial_{i?}{ h^{k}_{j} } -> 0,};</code></pre>
<p>Note that I've defined in addition the rule <code>refine</code>, which will be useful in the next step.</p>
<p>Finally, we want to manipulate (not calculate) each component of the metric connection. My strategy would be to loop over the values of the free indices. <code>cadabra</code> uses the command <code>Ex</code> to convert a (formatted python) string into a cadabra expression. <strong>Comment 3:</strong> since curly brackets are used to call a variable within a f-string, other curly brackets have to be escaped (with double curly bracket, with makes the expressions messy).</p>
<pre><code>for mu in ["t", "i"]:
for nu in ["t", "j"]:
for rho in ["t", "k"]:
Ex(f"\Gamma^{{{mu}}}_{{{nu}{rho}}} = ");
foo = Ex(f"1/2 g^{{{mu} \sigma}} (\partial_{{{rho}}}{{ g_{{{nu} \sigma}} }} + \partial_{{{nu}}}{{ g_{{{rho} \sigma}} }} - \partial_{{\sigma}}{{ g_{{{nu} {rho}}} }})");
split_index(foo, $\mu,t,m$, repeat=True)
substitute(foo, ADM, repeat=True)
distribute(foo)
product_rule(foo)
distribute(foo)
eliminate_metric(foo)
eliminate_kronecker(foo)
sort_product(foo)
rename_dummies(foo)
substitute(foo, refine, repeat=True);
# meld(foo);</code></pre>
<p>Hope this latter method would help you!</p>
<p>Cheers,
Dox.</p>General questionshttps://cadabra.science/qa/2780/calculate-christoffel-symbols-defined-abstract-matrices?show=2836#a2836Fri, 26 Apr 2024 09:19:59 +0000convert other format to cadabra2 format
https://cadabra.science/qa/2833/convert-other-format-to-cadabra2-format
<p>From <a rel="nofollow" href="https://cadabra.science/notebooks/scalar_manipulations.html">Using Cadabra and Sympy together</a>, I learn how to convert cadabra2 format to sympy format, but how to do the reverse operation? I.e. How to convert other formals, e.g. sympy format, to cadabra2 format?</p>General questionshttps://cadabra.science/qa/2833/convert-other-format-to-cadabra2-formatWed, 24 Apr 2024 13:31:05 +0000Answered: function expand_power not work for fractional power
https://cadabra.science/qa/2804/function-expand_power-not-work-for-fractional-power?show=2832#a2832
<p>I found a way to do it. One can use function <code>refine</code> in sympy, for example,</p>
<pre><code>from sympy import refine, sqrt, Q
from sympy.abc import L
ex:=(\lambda**{-2})**{1/2};
substitute(_,$\lambda->L$);
refine(_._sympy_(), Q.positive(L));</code></pre>
<p>But there is an another question: How to transform sympy expression to cadabra2 expression?</p>General questionshttps://cadabra.science/qa/2804/function-expand_power-not-work-for-fractional-power?show=2832#a2832Wed, 24 Apr 2024 13:16:26 +0000Answered: bug of unwrap
https://cadabra.science/qa/2828/bug-of-unwrap?show=2829#a2829
<p>Hi Eureka. </p>
<p>I don't thing it is a bug, just a misunderstanding of the philosophy of <code>cadabra</code>.</p>
<p>According to the <code>unwrap</code> documentation:</p>
<blockquote>
<p>Derivatives will be set to zero if an object inside does not depend on it.</p>
</blockquote>
<p>Hence, the command is not a computational aid... I mean, stricktly speaking you have not declare any dependence for <code>u</code>! So the algorithm set its derivative to zero.</p>
<p>My advice would be to use first a substitution rule, e.g.</p>
<pre><code>rl := \partial_{u}{u} -> 1;
ex:=\partial_u{u f};
product_rule(_)
substitute(ex, rl)
unwrap(ex);</code></pre>
<p>or if your calculation is "simple", call the <code>sympy</code> module:</p>
<pre><code>from cdb.sympy.calculus import *
ex := u f;
d_ex = diff(ex);</code></pre>
<p><strong>NOTE</strong> the absence of the colon in the last assignation (it is a <code>python</code> assignation not a <code>cadabra</code> one).</p>
<p>Hope this would be useful!</p>
<p>Cheers, Dox.</p>Bug reportshttps://cadabra.science/qa/2828/bug-of-unwrap?show=2829#a2829Tue, 23 Apr 2024 09:46:30 +0000Answered: make copy expression easier
https://cadabra.science/qa/2809/make-copy-expression-easier?show=2824#a2824
<p>I would only like to add that a possible variant is </p>
<pre><code>substitute($@[ex]$, $a -> c$)</code></pre>
<p>Using square brackets also creates a copy and does not affect the original expression.</p>Feature requestshttps://cadabra.science/qa/2809/make-copy-expression-easier?show=2824#a2824Mon, 22 Apr 2024 21:42:55 +0000Answered: Instructions on keyboard shortcuts
https://cadabra.science/qa/2822/instructions-on-keyboard-shortcuts?show=2823#a2823
<p>Hi Eureka.</p>
<p>The answer to your question depends whether you are using the <code>native</code> or the <code>jupyter-notebook</code> user interface.</p>
<p>In the native user interface the help is in the menu bar, shown to the right of the listed actions. There is no CLI to comment code lines, AFAIK.</p>
<p>The <code>jupyter-notebook</code> has many key bindings, and they are not specific to <code>cadabra</code>. See for example <a rel="nofollow" href="https://defkey.com/jupyter-notebook-shortcuts">https://defkey.com/jupyter-notebook-shortcuts</a> or <a rel="nofollow" href="https://cheatography.com/weidadeyue/cheat-sheets/jupyter-notebook/">https://cheatography.com/weidadeyue/cheat-sheets/jupyter-notebook/</a>.</p>Feature requestshttps://cadabra.science/qa/2822/instructions-on-keyboard-shortcuts?show=2823#a2823Mon, 22 Apr 2024 09:11:10 +0000bug of stop evaluation
https://cadabra.science/qa/2821/bug-of-stop-evaluation
<p>When I use <code>stop evaluation</code> to stop evaluation, but it never works.</p>Bug reportshttps://cadabra.science/qa/2821/bug-of-stop-evaluationSun, 21 Apr 2024 11:50:54 +0000question about keep_weight
https://cadabra.science/qa/2814/question-about-keep_weight
<p>In the following code,</p>
<pre><code>{u,v,x}::Coordinate.
f::Coordinate.
{a,b,c,d,e,g,h,p,r#}::Indices(full,values={u,v,x},position=independent).
\partial{#}::PartialDerivative.
\nabla{#}::Derivative.
g_{a b}::Metric.
g^{a b}::InverseMetric.
g_a^b::KroneckerDelta.
g^a_b::KroneckerDelta.
g^{a b}::Symmetric.
g_{a b}::Symmetric.
{n_u,n_v,\gamma,w,\alpha,\lambda,A,B,C}::Depends({u,v,f,x}).
{u,v}::Weight(label=field,value=1);
{f}::Weight(label=field,value=2);
metric:={g_{u v}=1,
g_{v u}=1,g_{v v}=-u**2\alpha,g_{v x}=u w,
g_{x v}=u w,g_{x x}=\gamma};
complete(_,$g^{a b}$);
from cdb.sympy.calculus import *
lamb:=(g^{a b}\partial_a{u v}\partial_b{u v})**{-1/2} ;
evaluate(_,metric,rhsonly=True);
substitute(_,$v->f/u$)
simplify(_);
substitute(_,$\alpha->a,w**2\gamma**{-1}->b$);
series(_,$f$,0,5/2);
substitute(_,$\bigO(A??)->0$)
keep_weight(_,$field=1$);</code></pre>
<p>The final result is not right. There seems to be something wrong here.</p>General questionshttps://cadabra.science/qa/2814/question-about-keep_weightFri, 19 Apr 2024 03:46:06 +0000Setting Python version in cmake
https://cadabra.science/qa/2803/setting-python-version-in-cmake
<p>I'm the cadabra2 port maintainer for MacPorts. The update to version 2.4.5.6 has caused an issue:
Rather than picking up the MacPorts version of Python (it was set to 3.11 for the previous release, but should be updated to version 3.12, as that's now default), the cmake script picks up the macOS version instead (on my Ventura system, that would be 3.9.6). I can properly set <code>-DPYTHON_LIBRARIES</code> and <code>-DPYTHON_SITE_PATH</code>, but I don't see a way of choosing the path to the python binary.</p>Installation troublehttps://cadabra.science/qa/2803/setting-python-version-in-cmakeThu, 18 Apr 2024 13:39:33 +0000Answered: Error printing as mma format
https://cadabra.science/qa/2776/error-printing-as-mma-format?show=2798#a2798
<p>As I said, the MicroTeX branch is work in progress.</p>
<p>You can always copy an expression to the clipboard by using the <code>pyperclip</code> package. For instance,</p>
<pre><code>import pyperclip
ex:=A_{m n};
pyperclip.copy( ex.mma_form() )</code></pre>General questionshttps://cadabra.science/qa/2776/error-printing-as-mma-format?show=2798#a2798Thu, 18 Apr 2024 09:01:10 +0000bug of function keep_weight
https://cadabra.science/qa/2788/bug-of-function-keep_weight
<p>The following code: </p>
<pre><code>{u,v}::Weight(label=field,value=1);
ex:=(u v)**{1/2};
keep_weight(_,$field=1$);</code></pre>
<p>I get the wrong result $0$, while the following code </p>
<pre><code>{u,v}::Weight(label=field,value=1);
ex:=(u v)**{1/2}+u u;
keep_weight(_,$field=1$);</code></pre>
<p>work fine. It seems a bug.</p>Bug reportshttps://cadabra.science/qa/2788/bug-of-function-keep_weightWed, 17 Apr 2024 09:38:20 +0000Answered: The output is lost in WSL2
https://cadabra.science/qa/2775/the-output-is-lost-in-wsl2?show=2785#a2785
<p>If you know the absolute path to the file you can always use that in the <code>open</code> call, no? What do you mean with "I can't get the output there"? Does the <code>open</code> call fail or does reading from that file fail?</p>Bug reportshttps://cadabra.science/qa/2775/the-output-is-lost-in-wsl2?show=2785#a2785Wed, 17 Apr 2024 07:50:59 +0000Answered: Formula rendering in jupyter notebook 7 and jupyter lab
https://cadabra.science/qa/2773/formula-rendering-in-jupyter-notebook-7-and-jupyter-lab?show=2779#a2779
<p>According to <a rel="nofollow" href="https://docs.mathjax.org/en/latest/output/linebreaks.html">https://docs.mathjax.org/en/latest/output/linebreaks.html</a>, automatic line breaking is not yet implemented in MathJax 3. I do not know if that web page is the current status, but it would explain why formulas do not wrap.</p>General questionshttps://cadabra.science/qa/2773/formula-rendering-in-jupyter-notebook-7-and-jupyter-lab?show=2779#a2779Sat, 13 Apr 2024 13:04:45 +0000Answered: Other languages support in LaTeX cell
https://cadabra.science/qa/2756/other-languages-support-in-latex-cell?show=2777#a2777
<p>The <code>microtex</code> branch now contains a version of Cadabra which no longer relies on LaTeX for maths typesetting. You can either build that yourself, or try the new (and still experimental) AppImage builds from the download page. </p>
<p>Let me know if this helps with the issue you reported please.</p>Feature requestshttps://cadabra.science/qa/2756/other-languages-support-in-latex-cell?show=2777#a2777Sat, 13 Apr 2024 13:01:50 +0000Question about Gaussian normal coordinate
https://cadabra.science/qa/2774/question-about-gaussian-normal-coordinate
<p>When I do calculation under Gaussian normal coordinate:</p>
<p>$$
d s^2=-2 d u d v-u^2\alpha(x) d v^2-2u w_i(x) dv dx^i+\gamma_{ij}(x) d x^i d x^j\,\quad x=(uv\,,x^i)
$$</p>
<p>How to get inverse metric and others directly? I don't know how to deal with $w_i$ and $\gamma_{ij}$.</p>General questionshttps://cadabra.science/qa/2774/question-about-gaussian-normal-coordinateThu, 11 Apr 2024 07:20:30 +0000Answered: unwrap of partial derivatives
https://cadabra.science/qa/2768/unwrap-of-partial-derivatives?show=2769#a2769
<p>Hi Arina. Great question!</p>
<p>I believe that the mismatch between the expected and actual behaviour of the <code>unwrap</code> algorithm is due to the "phylosophy" of CADABRA, i.e., it is a software centred in manipulation rather than calculation.</p>
<p>The "calculation" component of CADABRA came with the release of version 2.X, through the interaction with PYTHON (in particular with <code>sympy</code>).</p>
<p>Note that if instead of <code>unwrap</code>, you pass your expression to SYMPY, using <code>map_sympy</code>, as follows</p>
<pre><code>map_sympy($\partial_{t}{a}$);</code></pre>
<p>you get the expected result (of executing a calculation).</p>
<p>Hope this can help you!</p>
<hr>
<h1>UPDATE</h1>
<p>I understand the point in your comment, hahaha.</p>
<p>It seems to me that <code>unwrap</code> is useful to "move objects out" because they are constant.</p>
<h2>Example</h2>
<p>In General Relativity the metric is covariantly constant, but its partial derivative is nonvanishing in general. So, you should assign a dependence on the partial derivative but not of the covariant derivative.</p>
<pre><code>{l,m,n}::Indices.
\partial{#}::PartialDerivative.
\nabla{#}::Derivative.
g_{m n}::Depends(\partial{#});
\Psi::Depends(\partial{#},\nabla{#});</code></pre>
<p>Now if you define the derivatives of $g \Psi$, and <code>unwrap</code>, the difference is noticeable.</p>
<pre><code>ex1 := \partial_{l}{ g_{m n} \Psi };
unwrap(ex1);
ex2 := \nabla_{l}{ g_{m n} \Psi };
unwrap(ex2);</code></pre>Bug reportshttps://cadabra.science/qa/2768/unwrap-of-partial-derivatives?show=2769#a2769Thu, 28 Mar 2024 08:32:42 +0000Answered: Question about Installation of Cadabra on Ubuntu&Conda
https://cadabra.science/qa/2762/question-about-installation-of-cadabra-on-ubuntu%26conda?show=2763#a2763
<p>First of all, I would <em>strongly</em> advise you not to run anything like this as root user, that's just asking for trouble. It's not the cause of the problem you are having, but still important advice.</p>
<p>The Conda package maintainer has unfortunately abandoned it, and therefore there has not been any update for a long time. You are far better off just installing an Ubuntu package for Cadabra for Ubuntu from the download page; those are provided by me and maintained. And it is also what is written on <a rel="nofollow" href="https://cadabra.science/jupyter.html">https://cadabra.science/jupyter.html</a> . I would remove the Conda packages first before you try this though.</p>
<p>Let me know if this gets you any further.</p>Installation troublehttps://cadabra.science/qa/2762/question-about-installation-of-cadabra-on-ubuntu%26conda?show=2763#a2763Fri, 22 Mar 2024 14:41:23 +0000Answered: The Solution of Einstein's Equation in General Dimensions
https://cadabra.science/qa/2492/the-solution-of-einsteins-equation-in-general-dimensions?show=2760#a2760
<p>The following code should be useful:</p>
<pre><code>{M,N,O,P,Q,R,S}::Indices(full, position=independent);
{\alpha,\beta,\mu,\nu,\sigma,\gamma,\lambda}::Indices(subspace1, position=independent, parent=full);
{\alpha,\beta,\mu,\nu,\sigma,\gamma,\lambda}::Integer(0..d-1).
w::Coordinate;
g_{\mu\nu}::Metric.
g^{\mu\nu}::InverseMetric.
g_{\mu\nu}::Symmetric.
g^{\mu\nu}::Symmetric.
g^{\mu}_{\nu}::KroneckerDelta.
g_{\mu}^{\nu}::KroneckerDelta.
from cdb.utils.indices import *
ex:=g_{M N} g^{M O} P^N;
replace_index(_,r"g",r'O',r'\mu');
split_index(_, $M,\mu,w$,repeat=True);
eliminate_metric(_);
eliminate_kronecker(_);
substitute(_,$P^w->A$);</code></pre>General questionshttps://cadabra.science/qa/2492/the-solution-of-einsteins-equation-in-general-dimensions?show=2760#a2760Thu, 21 Mar 2024 09:13:37 +0000Answered: how to swap indices for partial derivatives
https://cadabra.science/qa/2750/how-to-swap-indices-for-partial-derivatives?show=2751#a2751
<p>Hi bin_go.</p>
<p>I'm noting there is plenty of space in your code to improve, but I'm not here for that (in particular because I don't know your workcase scenario).</p>
<p>So, let me illustrate the use of the algorithm <code>indexsort</code> with an example inspired in your code.</p>
<h2>My example</h2>
<p>First, I'll define the indices and the symbol for the partial derivative.</p>
<pre><code>{a,b,c,d}::Indices("flat",position = free).
{a,b,c,d}::Integer(1..N).
\partial{#}::PartialDerivative.</code></pre>
<p>In this example, I'd define some functions of the "coordinates", but saying that they depends on the derivative</p>
<pre><code>{z,w,v{#}}::Depends(\partial{#});</code></pre>
<p>Define the expression</p>
<pre><code> ex := 2 \chi w**(3) M**(\xi+1) \delta{z}
\partial_{a b}{z} \partial_{a c d}{z} v_{b} v_{c} v_{d} -
2 \chi w**(3) M**(\xi+1) \delta{z}
\partial_{a b}{z} \partial_{c d a}{z} v_{b} v_{c} v_{d};</code></pre>
<p>Note that the result is not simplified, unless we sort the indices</p>
<pre><code> indexsort(ex);</code></pre>
<p>Hope this would help.</p>
<p>Cheers,
Dox.</p>General questionshttps://cadabra.science/qa/2750/how-to-swap-indices-for-partial-derivatives?show=2751#a2751Wed, 20 Mar 2024 08:25:07 +0000Answered: Hello i am a beginner in using Cadabra 2
https://cadabra.science/qa/2747/hello-i-am-a-beginner-in-using-cadabra-2?show=2748#a2748
<p>This means that the indices on the left-hand side and the right-hand side of a replacement rule do not match. For instance,</p>
<pre><code>ex:=A_{m n};
substitute(ex, $A_{m n} = B_{m}$);</code></pre>
<p>You would mess up your equations if it would allow such substitutions.</p>
<p>You <em>can</em> do this if you really want to, by using the <code>-></code> notation,</p>
<pre><code>substitute(ex, $A_{m n} -> B_{m}$);</code></pre>
<p>This will work (but may of course still be wrong).</p>
<p>If you don't get the error from something like this, please post a minimal example.</p>General questionshttps://cadabra.science/qa/2747/hello-i-am-a-beginner-in-using-cadabra-2?show=2748#a2748Sat, 16 Mar 2024 19:45:48 +0000Answered: NameError after upgrade
https://cadabra.science/qa/2745/nameerror-after-upgrade?show=2746#a2746
<p>This depends a lot on how you installed Cadabra before. Did it come from the Cadabra package in the Ubuntu repositories? Or from an earlier install from source? If you installed from a previous package, you should do</p>
<pre><code>sudo apt remove cadabra2</code></pre>
<p>to remove it (and then re-install from source).</p>
<p>If you installed from source, you will need to do some more work. Typically, when you install from source, and do not pass any installation directory parameters, things go into</p>
<pre><code>/usr/local/lib/python3.x/dist-packages/</code></pre>
<p>(replace <code>python3.x</code> with the appropriate Python version). For me this contains (among non-cadabra things),</p>
<pre><code>cadabra2.cpython-310-aarch64-linux-gnu.so
cadabra2_defaults.py
cdb_appdirs.py
cadabra2_jupyter/
cdb/
notebook/</code></pre>
<p>(names will differ on a different architecture). Erase all these (both the files and the directories). Then there is also a bunch of <code>cadabra*</code> binaries in</p>
<pre><code>/usr/local/bin/</code></pre>
<p>Finally, there is a directory</p>
<pre><code>/usr/local/share/cadabra2/</code></pre>
<p>If you erase all this and re-install from source, hopefully things go better.</p>Installation troublehttps://cadabra.science/qa/2745/nameerror-after-upgrade?show=2746#a2746Tue, 05 Mar 2024 18:15:32 +0000Output not displaying as rendered latex
https://cadabra.science/qa/2739/output-not-displaying-as-rendered-latex
<p>I am not sure when this started as far as what was upgraded. In Jupyterlab all output is showing as latex statements inside $$s and not rendering. </p>
<p>If I copy the output and paste it into a markdown cell it renders correctly. </p>
<p>I.E.
{\mu,\nu,\rho}::Indices(position=free).
x::Coordinate.
\partial{#}::Derivative.</p>
<p>F<em>{\mu\nu}::AntiSymmetric;
F</em>{\mu\nu}::Depends(x).
A_{\mu}::Depends(x,\partial{#}).
\delta{#}::Accent;</p>
<p>Output:
${}\text{Property Accent attached to}\delta{#}.$</p>
<p>Input:
S:= -1/4 \int{ F_{\mu\nu} F^{\mu\nu} }{x};</p>
<p>Output:
${} - \frac{1}{4}\int F^{\mu \nu} F_{\mu \nu}\,\,{\rm d}x$</p>
<p>If I view the file in Jupyter notebook the code renders correctly.</p>
<p>?? Thanks,
ChuckW</p>
<p>When I posted this the 2nd example output rendered correctly in the post but not in Jupyterlab?</p>Installation troublehttps://cadabra.science/qa/2739/output-not-displaying-as-rendered-latexThu, 15 Feb 2024 18:26:19 +0000How to create derivatives of coordinates with indices?
https://cadabra.science/qa/2738/how-to-create-derivatives-of-coordinates-with-indices
<p>I have two sets of coordinates, and two partial derivatives which can act on these coordinates. These should work in a way such that:</p>
<p>$$
\partial_{x^{\mu}} x^{\nu} = \delta_{\mu}^{\nu} = \partial_{a<em>{\nu}} a\</em>{\mu}.
$$</p>
<p>How would I go about implementing this in Cadabra? I've tried defining partial derivatives of corresponding coordinates directly, I've tried using notation like DX and DA to differentiate between the two and then using LaTeXform to make it more tidy but I inadvertently run into a stop of some sort. </p>
<p>Any and all help will be greatly appreciated!</p>General questionshttps://cadabra.science/qa/2738/how-to-create-derivatives-of-coordinates-with-indicesThu, 15 Feb 2024 17:28:42 +0000Answered: meld returns zero where it shouldn't?
https://cadabra.science/qa/2734/meld-returns-zero-where-it-shouldnt?show=2736#a2736
<p>There is a bug in the logic that sets terms to zero when overlapping symmetry sets contain multiple identical indices. I have disabled that logic in meld for now, as I don't have time to think this through carefully. It shouldn't influence anything else as this was strictly a shortcut to find zeroes in particular situations, which meld will still find now, only slower.</p>Bug reportshttps://cadabra.science/qa/2734/meld-returns-zero-where-it-shouldnt?show=2736#a2736Thu, 08 Feb 2024 18:44:43 +0000