Cadabra Q&A - Recent questions and answers
http://cadabra.science/qa/qa
Powered by Question2AnswerAnswered: Failure of running cadabra on windows.
http://cadabra.science/qa/1259/failure-of-running-cadabra-on-windows?show=1998#a1998
<p>Windows is no longer supported, I do not have the time for it anymore. Volunteers welcome to bring this back to life.</p>
Bug reportshttp://cadabra.science/qa/1259/failure-of-running-cadabra-on-windows?show=1998#a1998Tue, 13 Apr 2021 16:31:26 +0000Answered: Sum of tensors in coordinate form
http://cadabra.science/qa/1993/sum-of-tensors-in-coordinate-form?show=1994#a1994
<p>Use <code>collect_components(ex)</code>.</p>
General questionshttp://cadabra.science/qa/1993/sum-of-tensors-in-coordinate-form?show=1994#a1994Fri, 09 Apr 2021 18:07:58 +0000Answered: Problem with combine
http://cadabra.science/qa/1834/problem-with-combine?show=1992#a1992
<p>I can confirm the behaviour of your code. </p>
<p><strong>Just a comment:</strong> It seems that <code>combine</code> privilege the position of the indices (lower like a covariant and upper like contravariant) over the <code>property</code> of the objects. </p>
<p><img src="https://ibb.co/BVCM67P" alt="cadabra_combine"></p>
Bug reportshttp://cadabra.science/qa/1834/problem-with-combine?show=1992#a1992Wed, 07 Apr 2021 10:35:56 +0000Answered: Canonicalizing with independent indices mixes up raised/lowered
http://cadabra.science/qa/1968/canonicalizing-independent-indices-mixes-raised-lowered?show=1991#a1991
<p>The algorithm does funny things if you declare indices <code>independent</code> but then not stick to Einstein conventions of having only one upper and one lower index. In your example, the <code>b</code> index appears as subscript twice. It tried to keep those two <code>b</code>s as lower indices, but as a result, it had to raise the index on <code>X</code>.</p>
<p>I would classifyl this as undefined behaviour, though perhaps a warning would have been appropriate. I don't think I will spend time on 'fixing' this, especially because it isn't even clear what the right fix should do.</p>
Bug reportshttp://cadabra.science/qa/1968/canonicalizing-independent-indices-mixes-raised-lowered?show=1991#a1991Sun, 04 Apr 2021 20:41:36 +0000Answered: About the `\commutator` operation
http://cadabra.science/qa/1986/about-the-commutator-operation?show=1990#a1990
<p>Answers to your re-stated questions: no, yes, yes. </p>
General questionshttp://cadabra.science/qa/1986/about-the-commutator-operation?show=1990#a1990Sun, 04 Apr 2021 14:41:55 +0000Answered: Installing Cadabra
http://cadabra.science/qa/1978/installing-cadabra?show=1988#a1988
<p>There are instructions on the download page; it's a few lines of <code>brew install</code> and related in a terminal.</p>
<p>If that does not work, please get back here with some details on where it fails.</p>
General questionshttp://cadabra.science/qa/1978/installing-cadabra?show=1988#a1988Sun, 04 Apr 2021 12:52:36 +0000Answered: Support for Apple Silicon(M1)
http://cadabra.science/qa/1981/support-for-apple-silicon-m1?show=1982#a1982
<p>Lucky you. Donations for the purchase of M1 hardware can be made by paypal ;-)</p>
<p>What is the dependency you are struggling with?</p>
Installation troublehttp://cadabra.science/qa/1981/support-for-apple-silicon-m1?show=1982#a1982Tue, 23 Mar 2021 17:21:43 +0000Answered: Problem with definition of the generalized delta
http://cadabra.science/qa/1974/problem-with-definition-of-the-generalized-delta?show=1976#a1976
<p>The help for <code>KroneckerDelta</code> states that indices are 'paired' in the way it comes out here. It is perhaps more transparent if you write upper and lower indices, so</p>
<p>$$2 \delta_{a}{}^{b}{}_{c}{}^{d} = \delta_{a}{}^{b} \delta_{c}{}^{d} - \delta_{c}{}^{b} \delta_{a}{}^{d}.$$</p>
<p>Your version just has all indices moved to subscript position.</p>
<p>It's all a matter of convention of course (there's nothing wrong with defining things 'your' way), but this is the convention Cadabra uses.</p>
General questionshttp://cadabra.science/qa/1974/problem-with-definition-of-the-generalized-delta?show=1976#a1976Tue, 16 Mar 2021 17:53:57 +0000Answered: Copy output to mathematica
http://cadabra.science/qa/1967/copy-output-to-mathematica?show=1973#a1973
<p>If you click the expression, there is no feedback, but you can then paste into another application.</p>
<p>Alternatively, write your expressions into a file. Or use the <code>map_mma</code> functionality (only available if you build Cadabra from source yourself and pass <code>-DENABLE_MATHEMATICA=ON</code> to <code>cmake</code>).</p>
General questionshttp://cadabra.science/qa/1967/copy-output-to-mathematica?show=1973#a1973Sat, 13 Mar 2021 14:39:14 +0000Answered: Same problem with jupyter kernel in Ubuntu 20.04.2 LTS
http://cadabra.science/qa/1971/same-problem-with-jupyter-kernel-in-ubuntu-20-04-2-lts?show=1972#a1972
<p>For any problem that involves a Cadabra kernel which does not want to start, please send the relevant error lines which are printed to the terminal. So start the sage notebook using</p>
<pre><code>./sage -notebook
</code></pre>
<p>from a terminal, and copy-paste the output into an email to <code>info@cadabra.science</code>.</p>
<p>I have just tried the above with the current Cadabra on an Ubuntu 18.04 system with Sage 9.2, and it works, so it is definitely possible.</p>
General questionshttp://cadabra.science/qa/1971/same-problem-with-jupyter-kernel-in-ubuntu-20-04-2-lts?show=1972#a1972Fri, 12 Mar 2021 21:24:28 +0000Answered: Maximum column width for input
http://cadabra.science/qa/1958/maximum-column-width-for-input?show=1964#a1964
<p>Can you run <code>cadabra2-gtk</code> from inside <code>gdb</code> and get me a backtrace when this happens? I suspect it crashes in gtk itself.</p>
Bug reportshttp://cadabra.science/qa/1958/maximum-column-width-for-input?show=1964#a1964Sat, 06 Mar 2021 21:31:06 +0000Answered: I have a Python3 installation, and I want to run Cadabra2 on top of it
http://cadabra.science/qa/1961/have-python3-installation-and-want-run-cadabra2-on-top-of-it?show=1963#a1963
<p>Cadabra does not need Conda (I am not using Conda myself either). A standard build from source will produce a Jupyter kernel which runs with the Python installation which is picked up at build time.</p>
<p>Your main problem will be that you are trying to do this on Windows 10. Building Cadabra from source on that platform is far from trivial, and I have no idea how to do that such that it builds against the version of Python shipped with SageMath. In addition, SageMath is a bit of a weird beast to start with, as it tends to ship with <em>everything</em> it needs, including compilers. That is only changing slowly recently, but I am not following this very closely.</p>
<p>Your best bet, if you insist on staying with Windows, may be to ask people on the SageMath mailing list how to build a mixed C++/Python program like Cadabra from source. A better choice may be to switch to Linux, as that platform really is much more friendly for software like this.</p>
<p>Feel free to get in touch wagain ith more technical questions if you decide to give this a shot.</p>
General questionshttp://cadabra.science/qa/1961/have-python3-installation-and-want-run-cadabra2-on-top-of-it?show=1963#a1963Sat, 06 Mar 2021 20:57:28 +0000Accessing the Weight of an object
http://cadabra.science/qa/1956/accessing-the-weight-of-an-object
<p>Is there a way to access the weight of an object?</p>
<p>I've figured out that I can do</p>
<pre><code>X::Weight(label=dimension,value=2);
Weight.get($X$,label=dimension);
</code></pre>
<p>to determine that the Weight attribute has been set. But is there a way to find out that X has weight 2?</p>
General questionshttp://cadabra.science/qa/1956/accessing-the-weight-of-an-objectWed, 03 Mar 2021 21:39:32 +0000Answered: Bug in expand_delta
http://cadabra.science/qa/1952/bug-in-expand_delta?show=1955#a1955
<p>This only seems to happen when the delta appears at the very top of the expression (so not in a product or sum). Now fixed on github, thanks for reporting.</p>
Bug reportshttp://cadabra.science/qa/1952/bug-in-expand_delta?show=1955#a1955Wed, 03 Mar 2021 21:28:26 +0000Taking out a common numerical factor
http://cadabra.science/qa/1951/taking-out-a-common-numerical-factor
<p>Is there a way to somehow conveniently take out the total numerical factor, because factor_out does not work for me. For example:</p>
<pre><code>{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,u,v,w#}::Indices(full, values={t,x,y,z}, position=independent).
{t, x, y, z}::Coordinate.
ex:= -\frac{1}{4} A_{x} + -\frac{1}{4}A_{y};
factor_out(ex, $-\frac{1}{4}$);
</code></pre>
<p>does nothing</p>
General questionshttp://cadabra.science/qa/1951/taking-out-a-common-numerical-factorThu, 25 Feb 2021 16:34:53 +0000Non-Leibniz differential operators
http://cadabra.science/qa/1950/non-leibniz-differential-operators
<p>Hi Everyone.</p>
<p>I am trying to use Cadabra2 with weighted tensor densities. Specifically I'd need to introduce a "non-standard" differential operator, i.e. an operator that does not satisfy the usual Leibniz product rule, but picks up a correction term in addition to the usual product rule.</p>
<p>Is there a way to introduce such a "differentiation" operator in Cadabra?</p>
<p>I tried to just declare dependency with</p>
<blockquote>
<p>::Depends(D{#});</p>
</blockquote>
<p>for the tensors, and then define the differentiation rules case-by-case, but cadabra seems to misunderstand index positions. For example</p>
<blockquote>
<p>_ := D^{A}{Y<em>{A} V} = D^{A}{Y</em>{A}} V + Y<em>{A} D^{A}{V} + N X^{A} D^{B}{Y</em>{A}} D_{B}{V} ;</p>
</blockquote>
<p>produces a "free indices do not match" error message, but if I truncate off the last two terms,</p>
<blockquote>
<p>_ := D^{A}{Y<em>{A} V} = D^{A}{Y</em>{A}} V ;</p>
</blockquote>
<p>the error message disappears. Also, the error message disappears if I run D_#::Derivative; first.</p>
<p>Many Thanks!</p>
General questionshttp://cadabra.science/qa/1950/non-leibniz-differential-operatorsThu, 18 Feb 2021 11:38:03 +0000Answered: Displaying the result in jupyter notebook
http://cadabra.science/qa/1943/displaying-the-result-in-jupyter-notebook?show=1949#a1949
<p>I increased the buffer size of mathjax as described in this question and it worked.</p>
<p><a rel="nofollow" href="https://stackoverflow.com/questions/22751772/mathjax-in-ipython-notebook-fails-for-fairly-large-equations">https://stackoverflow.com/questions/22751772/mathjax-in-ipython-notebook-fails-for-fairly-large-equations</a></p>
General questionshttp://cadabra.science/qa/1943/displaying-the-result-in-jupyter-notebook?show=1949#a1949Wed, 17 Feb 2021 10:36:14 +0000Answered: Repeated derivatives
http://cadabra.science/qa/1938/repeated-derivatives?show=1940#a1940
<p>That simplification should have happened automatically. Can you email me (<code>info@cadabra.science</code>) the code that leads to that non-zero result?</p>
General questionshttp://cadabra.science/qa/1938/repeated-derivatives?show=1940#a1940Sat, 13 Feb 2021 11:02:41 +0000Problems in compiling Cadabra from source
http://cadabra.science/qa/1937/problems-in-compiling-cadabra-from-source
<p>Hi</p>
<p>When I was trying to build the Cadabra from the source, I did find certain errors during the build, and that I cannot open the application at all. </p>
<p>The building process I was following is exactly from <a rel="nofollow" href="https://github.com/kpeeters/cadabra2#windows">here</a>, and after I input the code<br>
<code>cmake --build . --config RelWithDebInfo --target install</code> , I found these errors:</p>
<blockquote>
<p><code>C:\Dev\cadabra2\core\DisplayTerminal.cc(18,14): error C2001: newline in constant [C:\Dev\cadabra2\build\core\cadabra2.v
cxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(19,14): error C2001: newline in constant [C:\Dev\cadabra2\build\core\cadabra2.v
cxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(18,14): error C2064: term does not evaluate to a function taking 1 arguments [C
:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(20,4): error C2059: syntax error: ';' [C:\Dev\cadabra2\build\core\cadabra2.vcxp
roj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(662,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(663,20): error C2065: 'it': undeclared identifier [C:\Dev\cadabra2\build\core\c
adabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(664,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(664,53): error C2143: syntax error: missing ';' before '{' [C:\Dev\cadabra2\bui
ld\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(664,53): error C2447: '{': missing function header (old-style formal list?) [C:
\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(672,6): error C2143: syntax error: missing ';' before '<<' [C:\Dev\cadabra2\bui
ld\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(672,6): error C4430: missing type specifier - int assumed. Note: C++ does not s
upport default-int [C:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(674,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,22): error C2065: 'it': undeclared identifier [C:\Dev\cadabra2\build\core\c
adabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,24): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int [C:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,25): error C2440: 'initializing': cannot convert from 'initializer list' to
'int' [C:\Dev\cadabra2\build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(676,16): message : The initializer contains too many elements [C:\Dev\cadabra2\
build\core\cadabra2.vcxproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(679,2): error C2059: syntax error: 'if' [C:\Dev\cadabra2\build\core\cadabra2.vc
xproj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(681,2): error C2059: syntax error: '}' [C:\Dev\cadabra2\build\core\cadabra2.vcx
proj]
C:\Dev\cadabra2\core\DisplayTerminal.cc(681,2): error C2143: syntax error: missing ';' before '}' [C:\Dev\cadabra2\buil
d\core\cadabra2.vcxproj]</code></p>
</blockquote>
<p>And after the installation is complete, I tried to run <code>ctest</code>, which gives that all 47 tests were failed. Therefore, I would like to know what was going on during the compilation.</p>
<p>The OS I am using is Windows 10, with Anaconda 2020.07(Conda 4.9.2), Texlive 6.3.2, and Visual Studio 16.8.5 installed. The exact process conducted was:</p>
<ol>
<li>Doing <code>git clone</code> from the provided link</li>
<li>Executing <code>C:\Dev\cadabra2\build>cmake -DCMAKE_TOOLCHAIN_FILE=C:/Dev/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_INSTALL_PREFIX=C:\Cadabra -G "Visual Studio 16 2019" -A x64 ..</code></li>
<li>Executing cmake command shown in the link from very above, giving error on DisplayTerminal.cc mentioned before.</li>
</ol>
Installation troublehttp://cadabra.science/qa/1937/problems-in-compiling-cadabra-from-sourceFri, 12 Feb 2021 21:27:10 +0000Answered: Evaluate function kernel crash
http://cadabra.science/qa/1926/evaluate-function-kernel-crash?show=1936#a1936
<p>You have defined both <code>x</code> and <code>y</code> as <code>Indices</code>, but also as <code>Coordinate</code>. This makes the definition of that <code>box</code> ambiguous,</p>
<pre><code>box := h^{a b} (\partial_{a b}{p} - \Gamma^{y}_{a b}\partial_{y}{p});
</code></pre>
<p>as it contains a <code>y</code> which could either be an index or a fixed index value. The checks in Cadabra to catch this kind of problem are not strong enough to prevent the crash.</p>
<p>If you drop <code>x</code> and <code>y</code> from your index set and write e.g. <code>c</code> in the definition of <code>box</code> all seems well.</p>
<p>Also note that you really need a space (or star) between <code>h^{a b}</code> and the bracket that follows, otherwise it gets interpreted as <code>h^{a b}</code> with an argument, not as two factors.</p>
Bug reportshttp://cadabra.science/qa/1926/evaluate-function-kernel-crash?show=1936#a1936Fri, 12 Feb 2021 21:08:56 +0000Answered: Cadabra2 kernel for jupyter
http://cadabra.science/qa/1930/cadabra2-kernel-for-jupyter?show=1931#a1931
<p>It can't find the cadabra kernel module, set your <code>PYTHON_PATH</code> so it picks it up.</p>
Installation troublehttp://cadabra.science/qa/1930/cadabra2-kernel-for-jupyter?show=1931#a1931Tue, 09 Feb 2021 18:34:06 +0000Answered: Access to parts of equality
http://cadabra.science/qa/1918/access-to-parts-of-equality?show=1920#a1920
<p>You could wrap this in an outer loop which iterates over the two sides of the equality, e.g.</p>
<pre><code>ex:= A+B = C
for sides in ex.top().children():
for element in sides.terms():
element.multiplier *= 2
</code></pre>
<p>which turns <code>ex</code> into</p>
<pre><code>2A + 2B = 2C
</code></pre>
<p>If you only wanted to e.g. touch the right-hand side, do something like</p>
<pre><code>ch = ex.top().children()
next(ch)
next(ch)
for element in ch.terms():
element.multiplier *= 2
</code></pre>
General questionshttp://cadabra.science/qa/1918/access-to-parts-of-equality?show=1920#a1920Wed, 27 Jan 2021 17:39:22 +0000Answered: Installation error v2.3.6.5 on Ubuntu 18.04
http://cadabra.science/qa/1915/installation-error-v2-3-6-5-on-ubuntu-18-04?show=1917#a1917
<p>Configure with</p>
<pre><code> cmake -DENABLE_MATHEMATICA=OFF ..
</code></pre>
<p>For some reason the script which tries to locate Mathematica messes up other parts of the CMake procedure.</p>
Installation troublehttp://cadabra.science/qa/1915/installation-error-v2-3-6-5-on-ubuntu-18-04?show=1917#a1917Sun, 24 Jan 2021 15:45:20 +0000Answered: Meld function
http://cadabra.science/qa/1888/meld-function?show=1914#a1914
<p>This has been fixed in 2.3.6.4.</p>
Bug reportshttp://cadabra.science/qa/1888/meld-function?show=1914#a1914Sat, 23 Jan 2021 21:49:05 +0000Answered: Labelling Objects
http://cadabra.science/qa/1908/labelling-objects?show=1913#a1913
<p>From 2.3.6.5 (which I have just pushed to github) you can use the auto-declare syntax for this, using the <code>#</code> character after the name. So e.g.</p>
<pre><code>T#^{a b c}_{e f}::TableauSymmetry(shape={1,1}, indices={3,4});
ex:=T1^{a b c}_{e f} T2^{e f g}_{h i} + T1^{a b c}_{e f} T2^{f e g}_{h i};
canonicalise(ex);
</code></pre>
<p>to produce zero.</p>
General questionshttp://cadabra.science/qa/1908/labelling-objects?show=1913#a1913Sat, 23 Jan 2021 21:47:18 +0000Answered: Coordinate indices mess up diagonal tensor?
http://cadabra.science/qa/1911/coordinate-indices-mess-up-diagonal-tensor?show=1912#a1912
<p>Cadabra used to only handle <code>Diagonal</code> with numerical indices. I have just pushed a fix (2.3.6.5) which also handles symbolic indices like in your first example.</p>
Bug reportshttp://cadabra.science/qa/1911/coordinate-indices-mess-up-diagonal-tensor?show=1912#a1912Sat, 23 Jan 2021 21:45:19 +0000Answered: Tab for autocomplete crashes Cadabra
http://cadabra.science/qa/1909/tab-for-autocomplete-crashes-cadabra?show=1910#a1910
<p>This was fixed in 2.3.6 but I forgot to generate new packages; now available.</p>
Bug reportshttp://cadabra.science/qa/1909/tab-for-autocomplete-crashes-cadabra?show=1910#a1910Sun, 17 Jan 2021 12:46:50 +0000Changing the settings
http://cadabra.science/qa/1897/changing-the-settings
<p>Hello, I would like to know if you can change the color of the cursor, as it is almost transparent I cannot see.</p>
General questionshttp://cadabra.science/qa/1897/changing-the-settingsThu, 07 Jan 2021 22:33:47 +0000Answered: explicit_indices used in two trace
http://cadabra.science/qa/1887/explicit_indices-used-in-two-trace?show=1893#a1893
<p>The first problem arises because you did not tell <code>tr</code> over which indices it traces. If you have <code>ImplicitIndex</code> objects inside the trace which have an explicit form listed, then you also need to specify the indices on which <code>tr</code> acts, otherwise it takes those objects out. Perhaps the default is not entirely logical, apologies. So this is easily fixed by using</p>
<pre><code>tr{#}::Trace(indices=vector).
</code></pre>
<p>instead.</p>
<p>The second problem was a bug, thanks for reporting it. It is now fixed on github with version 2.3.5.4.</p>
General questionshttp://cadabra.science/qa/1887/explicit_indices-used-in-two-trace?show=1893#a1893Mon, 28 Dec 2020 22:39:30 +0000Answered: Question about Kronecker delta
http://cadabra.science/qa/1889/question-about-kronecker-delta?show=1890#a1890
<p>You cannot use <code>\delta{#}</code> for the Kronecker delta <em>and</em> the variational delta at the same time. By making <code>\delta{#}</code> a <code>Derivative</code>, the <code>\delta_{m1}^{m3}</code> gets interpreted as 'a second-order derivative in the <code>m1</code> and <code>m3</code> directions, acting on nothing', which is zero.</p>
<p>The least confusing is if you rename your variational delta (you can still use a <code>LaTeXForm</code> property to make it print as a $\delta$ symbol). Alternatively, be a bit less generic with your patterns, as in the working example below.</p>
<pre><code>{a,b,c,d,e,f,g,h,i,j,k,l,m,n,q,r,s,u,v,w,z#}::Indices(position=independent).
h_{m n}::Metric.
h^{m n}::InverseMetric.
\delta^{m?}_{n?}::KroneckerDelta.
\delta_{m?}^{n?}::KroneckerDelta.
\partial{#}}::PartialDerivative.
{\nabla{#}, \delta{A??}}::Derivative.
delh_{m n}::Depends(\nabla{#}, \partial{#}).
delh^{m n}::Depends(\nabla{#}, \partial{#}).
h_{m n}::Depends(\partial{#}, \delta{#}).
h^{m n}::Depends(\partial{#}, \delta{#}).
\Dh::LaTeXForm("\sqrt{-h}").
delh{#}::LaTeXForm("\delta h").
ex:= \nabla_{a}{\nabla_{b}{delh^{c a}}} h_{c d} h^{d b};
substitute(ex, $h_{m1 m2} h^{m2 m3} -> \delta_{m1}^{m3}$);
</code></pre>
<p>To understand why this works, remember that the pattern <code>#</code> stands for 'any number of arguments', while <code>A??</code> stands for 'any object'. </p>
General questionshttp://cadabra.science/qa/1889/question-about-kronecker-delta?show=1890#a1890Mon, 21 Dec 2020 20:38:24 +0000Only write out one index summation
http://cadabra.science/qa/1878/only-write-out-one-index-summation
<p>I have a basic question based on <a rel="nofollow" href="https://cadabra.science/qa/1851/manipulate-matrix.">https://cadabra.science/qa/1851/manipulate-matrix.</a> I have seen that you have updated some codes related to the above question a few days ago, but I still have the following question: How to just expand the dummy indices <code>a,b</code> and don't touch the indices $\mu,\nu$ in the following expression?</p>
<p>$$<br>
L:=D_{\mu} B^a D_{\nu}B^b D_{\mu} B^a D_{\nu}B^b,<br>
$$ </p>
<p>where <code>a,b</code> and $\mu,\nu$ are the different index types, and $B^a$ is <code>SelfNonCommuting</code>.</p>
General questionshttp://cadabra.science/qa/1878/only-write-out-one-index-summationFri, 18 Dec 2020 02:04:16 +0000Answered: Only one window can be opened
http://cadabra.science/qa/1868/only-one-window-can-be-opened?show=1869#a1869
<p>You should be able to start <code>cadabra2-gtk</code> multiple times; that certainly works on Ubuntu 18.04 on bare metal. Using <code>File / New</code> is not intended to open an extra window (essentially, every instance of <code>cadabra2-gtk</code> has one kernel, and if you want more than one kernel you just start a new instance).</p>
<p>Or are you talking about the Jupyter kernel?</p>
Bug reportshttp://cadabra.science/qa/1868/only-one-window-can-be-opened?show=1869#a1869Sun, 13 Dec 2020 11:39:49 +0000Answered: Windows 10 version still doesn't work
http://cadabra.science/qa/1305/windows-10-version-still-doesnt-work?show=1856#a1856
<p>I have updated the Windows installer to Cadabra 2.3.5. All feedback is welcome; I would like to make the windows version part of the regular release process, but that requires that we have a sufficient number of machines on which it is tested. </p>
<p>Download from <a rel="nofollow" href="https://cadabra.science/packages/windows/">https://cadabra.science/packages/windows/</a> .</p>
Installation troublehttp://cadabra.science/qa/1305/windows-10-version-still-doesnt-work?show=1856#a1856Tue, 08 Dec 2020 20:24:53 +0000Answered: Windows 10 64-bit install not working yet
http://cadabra.science/qa/755/windows-10-64-bit-install-not-working-yet?show=1855#a1855
<p>I have updated the Windows installer to Cadabra 2.3.5. All feedback is welcome; I would like to make the windows version part of the regular release process, but that requires that we have a sufficient number of machines on which it is tested. </p>
<p>Download from <a rel="nofollow" href="https://cadabra.science/packages/windows/">https://cadabra.science/packages/windows/</a> .</p>
Installation troublehttp://cadabra.science/qa/755/windows-10-64-bit-install-not-working-yet?show=1855#a1855Tue, 08 Dec 2020 20:23:29 +0000Field Function
http://cadabra.science/qa/1852/field-function
<p>Hello everyone! <br>
In my computations I need to define some arbitrary field function, for example F, which dependes on field of my theory p(x). I tryed to define p like a coordinate and then set that pi depends on all other coordinates, as follows:</p>
<pre><code>{t, x, y, p}::Coordinate.
p::Depends(t,x,y).
K::Depends(t,x,y, p).
</code></pre>
<p>But then I take the derivative with respect to p, I am getting a vector index so it doesn't work for me. I've tryed to define some 'special' derivative for p, but this interferes with further calculations in components. I also tryed to write something like </p>
<pre><code>map_sympy(F, 'Function("F")(p))
</code></pre>
<p>but it didn't work. It seems to me that I don't see some very simple option.</p>
General questionshttp://cadabra.science/qa/1852/field-functionFri, 04 Dec 2020 20:58:06 +0000manipulate matrix
http://cadabra.science/qa/1851/manipulate-matrix
<p>I don't know how to manipulate matrix easily in Cadabra. For example, some Lagrangian like</p>
<p>$$<br>
L=Tr(\partial_{\mu}{A}\partial^{\mu}{A}),<br>
$$</p>
<p>where $A=diag(a, b)$, the right result is</p>
<p>$$ <br>
L=\partial_{\mu}{a}\partial^{\mu}{a}+\partial_{\mu}{b}\partial^{\mu}{b}.<br>
$$</p>
<p>How to implement the above steps in Cadabra? I have a try</p>
<pre><code>{\mu,\nu}::Indices(vector).
{c,d,e,f}::Indices(values={1,2}).
\partial{#}::Derivative.
g_{c d}::Metric.
g^{c d}::InverseMetric.
metric:={g_{1 1}=1,g_{2 2}=1};
complete(_,$g^{c d}$);
A:={A_{1 1}=a,A_{2 2}=b};
{a,b}::Depends(\partial{#}).
L:=g^{c d}(\partial_{\mu}{A}\partial^{\mu}{A})_{c d};
expand(_);
evaluate(_,metric+A);
</code></pre>
<p>but it doesn't work.</p>
General questionshttp://cadabra.science/qa/1851/manipulate-matrixFri, 27 Nov 2020 07:47:56 +0000Answered: Random index
http://cadabra.science/qa/1843/random-index?show=1844#a1844
<p>Your <code>upindex</code> object is a string. In order to pull a symbol with a python name into a Cadabra maths expression with the <code>@(...)</code> operator, it needs to be a Cadabra <code>Ex</code> object. So convert your <code>upindex</code> to an <code>Ex</code> and it should work: instead of </p>
<pre><code>upindex = random.choice(indeces)
</code></pre>
<p>use</p>
<pre><code>upindex = Ex( random.choice(indeces) )
</code></pre>
General questionshttp://cadabra.science/qa/1843/random-index?show=1844#a1844Wed, 11 Nov 2020 17:49:37 +0000Answered: What is the correct way to tell Cadabra a vector has unit norm?
http://cadabra.science/qa/1840/what-is-the-correct-way-to-tell-cadabra-a-vector-has-unit-norm?show=1841#a1841
<p>Yes, that's expected; most algorithms will only do 'one step at a time'. If you want to apply the substitution for all matches in one shot, use the <code>repeat=True</code> flag, so</p>
<pre><code>a:= k_i k_i k_{\beta} k_{\beta};
N:= k_i k_i = 1;
substitute(a,N, repeat=True);
</code></pre>
<p>An alternative is to use a <code>converge</code> block, though for this example that's overkill. In essence, a <code>converge</code> block will apply a series of instructions until the expression no longer changes. For your case,</p>
<pre><code>a:= k_i k_i k_{\beta} k_{\beta};
N:= k_i k_i = 1;
converge(a):
substitute(a,N)
;
</code></pre>
<p>Both of these will produce the intended '1' as result.</p>
General questionshttp://cadabra.science/qa/1840/what-is-the-correct-way-to-tell-cadabra-a-vector-has-unit-norm?show=1841#a1841Wed, 11 Nov 2020 15:56:02 +0000meld kernel crash
http://cadabra.science/qa/1836/meld-kernel-crash
<p>Sometimes, then I am running meld(); it shows kernel crashed, for example:</p>
<pre><code>{a,b,c,d,e,i,k,m,n,p,q,r,s,t,u,v,w,x,y,z,m#}::Indices(position=independent);
{a,b,c,d,e,i,k,m,n,p,q,r,s,t,u,v,w,x,y,z,m#}::Integer(1..3);
\partial{#}::PartialDerivative.
h_{m? n?}::Metric.
h^{m? n?}::InverseMetric.
h_{m? n?}::Symmetric.
h^{m? n?}::Symmetric.
\delta^{m?}_{n?}::KroneckerDelta.
\delta_{m?}^{n?}::KroneckerDelta.
F_{m? n?}::AntiSymmetric.
\pi::Depends(\partial{#}).
\phi::Depends(\partial{#}).
A_{m?}::Depends(\partial{#}).
h_{m n}::Depends(\partial{#}).
h^{m n}::Depends(\partial{#}).
\psi::Depends(\partial{#}).
\Gamma^{\alpha}_{\mu\nu}::TableauSymmetry(shape={2}, indices={1,2}).
\Gamma^{m}_{n q}::TableauSymmetry(shape={2}, indices={1,2}).
ex := 1/2 h^{a b} F_{n b} \partial_{a}(\pi) \partial_{m}(\psi) (\phi)**2 + 1/2 h^{a b} F_{m b} \partial_{a}(\pi) \partial_{n}(\psi) (\phi)**2-A_{m} \partial_{a}(\phi) \partial_{b}(\pi) \partial_{n}(\psi) \phi h^{a b}-A_{n} \partial_{a}(\phi) \partial_{b}(\pi) \partial_{m}(\psi) \phi h^{a b};
rename_dummies(_);
meld(_);
</code></pre>
<p>I'm not sure, but may be it happens only in a case of combination rename_dummies and meld.</p>
General questionshttp://cadabra.science/qa/1836/meld-kernel-crashWed, 11 Nov 2020 13:39:45 +0000Answered: About LaTeX print outcome in v2.2.3
http://cadabra.science/qa/1825/about-latex-print-outcome-in-v2-2-3?show=1831#a1831
<p>The first one was caused by the new code to print products, which handles Young tableaux correctly but decided to print all products as tensor products too. The second one has been around for some time and has to do with the <code>\varphi</code>, which was not treated as a Greek character. </p>
<p>Both fixed now in github/master.</p>
General questionshttp://cadabra.science/qa/1825/about-latex-print-outcome-in-v2-2-3?show=1831#a1831Tue, 03 Nov 2020 09:10:53 +0000Eliminate symmetric Gammas in Majorana bilinears
http://cadabra.science/qa/1815/eliminate-symmetric-gammas-in-majorana-bilinears
<p>I am working in d=11 supergravity with the following convention for the charge-conjugation matrix:<br>
$$C^T=-C $$</p>
<p>$$ (C\Gamma^{m1\dots mr})^T=+C\Gamma^{m1\dots mr} \quad r=(1,2)mod4 $$</p>
<p>and with an anticommuting Majorana spinor $\eta$.</p>
<p>How to set automatically to zero all the expressions of the type<br>
$$\bar \eta \Gamma^{m1\dots mr} \eta=0\qquad r=(1,2)mod4 $$<br>
when for ex. $\Gamma^{m1\dots mr}$ is the result of a "join_gamma()"? </p>
General questionshttp://cadabra.science/qa/1815/eliminate-symmetric-gammas-in-majorana-bilinearsMon, 02 Nov 2020 17:42:11 +0000Answered: Installation on Windows Subsystem for Linux (WSL)
http://cadabra.science/qa/1811/installation-on-windows-subsystem-for-linux-wsl?show=1812#a1812
<p>I am a Windows user too. I suggest you to create an Ubuntu virtual machine using VM ware on top of which install Ubuntu 20.04 (lts). The last two versions of Cadabra2 for Ubuntu 20.04 should run without any problems.</p>
Installation troublehttp://cadabra.science/qa/1811/installation-on-windows-subsystem-for-linux-wsl?show=1812#a1812Mon, 02 Nov 2020 17:00:21 +0000Answered: Trouble encountered after updating to v2.3.2
http://cadabra.science/qa/1797/trouble-encountered-after-updating-to-v2-3-2?show=1798#a1798
<p>What happens with <code>cadabra2</code> (the command-line client)? On which system is this, and I assume you installed from source?</p>
Installation troublehttp://cadabra.science/qa/1797/trouble-encountered-after-updating-to-v2-3-2?show=1798#a1798Mon, 02 Nov 2020 09:50:00 +0000Answered: cadabra-client: connection failed
http://cadabra.science/qa/634/cadabra-client-connection-failed?show=1791#a1791
<p>For anyone running into this problem: this is a network issue, by which the <code>cadabra2-gtk</code> process is unable to reach the <code>cadabra-server</code>. Try the following:</p>
<ul>
<li>Start <code>cadabra-server</code> by hand from a separate terminal window. This spits out two lines; a number and a uuid identifier. That first number is the port to which the server has bound.</li>
<li><p>Try to connect to that port by hand using</p>
<pre><code>telnet localhost [port]
</code></pre>
<p>Then report here whether the connection is achieved or not.</p></li>
<li><p>If the connection failed, check whether <code>/etc/hosts</code> contains a line</p>
<pre><code>127.0.0.1 localhost
</code></pre></li>
</ul>
<p>On WSL it is conceivable that the windows firewall prevents these connections from being created.</p>
Installation troublehttp://cadabra.science/qa/634/cadabra-client-connection-failed?show=1791#a1791Sun, 01 Nov 2020 15:47:40 +0000Question about eliminate_metric
http://cadabra.science/qa/1784/question-about-eliminate_metric
<p>Hello. I noticed that even when I'm writing the position = independent index properties, the eliminate_metric command can contract the expression indeces inside the partial derivative and outside, as in the following example:</p>
<pre><code>{\mu,\nu,\rho,\sigma,\kappa,\lambda,\eta,\chi#}::Indices(full, position=independent);
{m,n,p,q,r,s,t,u,v,w,x,y,z,m#}::Indices(subspace, position=independent, parent=full);
{\mu,\nu,\rho,\sigma,\kappa,\lambda,\eta,\chi#}::Integer(1..4);
{m,n,p,q,r,s,t,u,v,w,x,y,z,m#}::Integer(1..3);
\partial{#}::PartialDerivative.
\nabla{#}::Derivative.
g_{\mu\nu}::Metric.
g^{\mu\nu}::InverseMetric.
g_{\mu? \nu?}::Symmetric.
g^{\mu? \nu?}::Symmetric.
h_{m n}::Metric.
h^{m n}::InverseMetric.
\delta^{\mu?}_{\nu?}::KroneckerDelta.
\delta_{\mu?}^{\nu?}::KroneckerDelta.
\delta^{m?}_{n?}::KroneckerDelta.
\delta_{m?}^{n?}::KroneckerDelta.
\delta^{\mu?}_{n?}::KroneckerDelta.
\delta_{\mu?}^{n?}::KroneckerDelta.
F_{m n}::AntiSymmetric.
\pi::Depends(\nabla{#}).
def tidy (expr):
converge(expr):
distribute(expr)
product_rule(expr)
canonicalise(expr)
return expr
def expand_nabla(ex):
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():
t2:= @(arg);
if index.parent_rel==sub:
t1:= -\Gamma^{\rho}_{@(dindex) @(index)};
t2[index]:= _{\rho};
else:
t1:= \Gamma^{@(index)}_{@(dindex) \rho};
t2[index]:= ^{\rho};
ret += Ex(str(nabla.multiplier)) * t1 * t2
nabla += ret
return ex
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?} } );
box:= g^{\mu \nu} \nabla_{\mu}{\nabla_{\nu}{\pi}};
expand_nabla(_);
substitute(_,Gtog);
tidy(box);
split_index(_, $\mu, m1, 4$, repeat=True)
substitute(_, $\partial_{4}{A??} -> 0$, repeat=True)
substitute(_, $\partial_{4 m?}{A??} -> 0$, repeat=True)
substitute(_, $\partial_{m? 4}{A??} -> 0$, repeat=True)
canonicalise(_);
substitute(_, $g_{4 4} -> \phi**{2}$ )
substitute(_, $g_{m 4} -> \phi**{2} A_{m}$ )
substitute(_, $g_{4 m} -> \phi**{2} A_{m}$ )
substitute(_, $g_{m n} -> h_{m n} + \phi**{2} A_{m} A_{n}$ )
substitute(_, $g^{4 4} -> \phi**{-2} + A_{m} h^{m n} A_{n}$ )
substitute(_, $g^{m 4} -> - h^{m n} A_{n}$ )
substitute(_, $g^{4 m} -> - h^{m n} A_{n}$ )
substitute(_, $g^{m n} -> h^{m n}$ );
tidy(box);
substitute(_, $\partial_{p}{h^{n m}} h_{q m} -> - \partial_{p}{h_{q m}} h^{n m}$ )
collect_factors(_)
sort_product(_)
converge(box):
substitute(_, $h_{m1 m2} h^{m3 m2} -> \delta_{m1}^{m3}$, repeat=True )
eliminate_kronecker(_)
canonicalise(_)
;
substitute(_, $\partial_{n}{A_{m}} -> 1/2*\partial_{n}{A_{m}} + 1/2*F_{n m} + 1/2*\partial_{m}{A_{n}}$ )
distribute(_)
sort_product(_)
canonicalise(_)
rename_dummies(_);
meld(_);
eliminate_metric(_);
eliminate_metric(_);
</code></pre>
<p>And at the end I get:<br>
<img src="https://sun9-40.userapi.com/impg/UZghUKwfJihpLs-VuumoSxX4U3_4wWaPu1gIWw/7VFkPkc0Naw.jpg?size=984x179&quality=96&proxy=1&sign=dd1ae5f8bce563f35199ea74a631de96" alt="result"><br>
This is all very long, but I wanted to show the whole path that leads to the error. In fact, this kind of result is obtained with almost any option when I use eliminate_metric more than once in my program. <br>
Is this some kind of bug or am I doing something wrong?</p>
Bug reportshttp://cadabra.science/qa/1784/question-about-eliminate_metricWed, 28 Oct 2020 14:14:26 +0000Answered: question about factor_in
http://cadabra.science/qa/1777/question-about-factor_in?show=1779#a1779
<p>You can use <code>sympy.factor</code>, e.g.</p>
<pre><code>ex:= A C + B C - A D - B D;
ex=Ex(sympy.factor(ex).__str__())
</code></pre>
<p>(I should probably add automatic conversion from sympy objects to <code>Ex</code>, so that you can avoid the <code>__str__()</code>).</p>
General questionshttp://cadabra.science/qa/1777/question-about-factor_in?show=1779#a1779Sun, 11 Oct 2020 15:48:17 +0000Question about meld
http://cadabra.science/qa/1776/question-about-meld
<p>The following codes seem to have encountered some problems when using algorithm 'meld':</p>
<pre><code>{\mu,\nu}::Indices(vector).
tr{#}::Trace.
u^{\mu}::SelfNonCommuting.
u^{\mu}::ImplicitIndex.
ex:=A tr{u^{\mu} u^{\nu} u^{\mu} u^{\nu}}+B tr{ u^{\mu} u^{\mu} u^{\nu} u^{\nu}};
meld(_);
factor_in(_,$A,B$);
</code></pre>
General questionshttp://cadabra.science/qa/1776/question-about-meldSun, 11 Oct 2020 12:02:30 +0000Answered: About LaTeXForm
http://cadabra.science/qa/1772/about-latexform?show=1773#a1773
<p>Well spotted. <code>LaTeXForm</code> wasn't handling the multiplier attribute correctly. A fix is on github now (2.3.1.8).</p>
General questionshttp://cadabra.science/qa/1772/about-latexform?show=1773#a1773Sat, 10 Oct 2020 16:24:35 +0000evaluate and propertes
http://cadabra.science/qa/1769/evaluate-and-propertes
<p>Hello.<br>
In this code</p>
<pre><code>{a,b,c}::Indices(values={1,2,3,4,5,6,7,8}).
f_{a b c}::AntiSymmetric.
ex:= 2 i f_{a b c} s_{c};
ru1:=f_{1 2 3}=1, f_{3 4 5}=1/2, f_{4 5 8}= 1/2 \sqrt(3);
evaluate(ex,ru1);
</code></pre>
<p>rule <code>f_{3 4 5}= f_{4 5 3}</code> not used (is true <code>[]_{45}=i \sqrt(3) s_{8} + i s_{3}</code>).</p>
<p>How to get around it?</p>
<p>Thank you.</p>
General questionshttp://cadabra.science/qa/1769/evaluate-and-propertesMon, 05 Oct 2020 15:45:30 +0000Answered: Indices in a cycle
http://cadabra.science/qa/1766/indices-in-a-cycle?show=1767#a1767
<p>This does not work (as you wrote it) because the mathematical symbols <code>i, j, k</code> in the mathematical expression <code>e_{i j k} s_{k}</code> are not the same as the python symbols of the same name over which you do the loops. In Cadabra, symbols appearing in mathematical expressions are not Python objects (unlike, for example, in SymPy). If this sounds weird, think about the object <code>e_{i j k}</code>. That is clearly not a Python object. Cadabra's maths input language is not Python.</p>
<p>Of course you can still do what you want, using the much more powerful <code>evaluate</code> algorithm. You would write</p>
<pre><code>{i,j,k}::Indices(values={1,2,3});
\epsilon_{i j k}::EpsilonTensor();
ex:=\epsilon_{i j k} s_{k};
evaluate(ex);
</code></pre>
<p>The <code>evaluate</code> does the index loops for you; the output will show that e.g. the <code>i=1, j=2</code> component of your expression equals <code>s_3</code>.</p>
<p>If you had wanted to do other component value substitutions too, you can add them as rules to the <code>evaluate</code> function. For instance, if $s=(a,b,c)$, then use (instead of the last line above)</p>
<pre><code>evaluate(ex, $s_{1}=a, s_{2}=b, s_{3}=c$);
</code></pre>
<p>Hope this helps.</p>
General questionshttp://cadabra.science/qa/1766/indices-in-a-cycle?show=1767#a1767Sat, 03 Oct 2020 12:33:34 +0000