0
$\begingroup$

I encounter a really weird effect in Mathematica and I don't know what the wrong thing is nor how to correct it. I work with vectors of four components and I have a minimal set of definitions that I need to use.

gd = {{0, -1/2, 0, 0}, {-1/2, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
gu = Inverse[gd];
customdot[x1u_, x2u_] := x1u.gd.x2u;
invertdot[x1d_, x2d_] := x1d.gu.x2d;

And then, at some point I need to define a function $ I_{\mu\nu}(x) = g_{\mu\nu}-2\frac{x_{\mu}x_{\nu}}{x^2}$ where $g_{\mu\nu}$ is just a 4x4 matrix and $x$ and 4-vector. I do this as

capitali[\[Mu]_, \[Nu]_, vec_] := gd[[\[Mu], \[Nu]]] -  2 (vec[[\[Mu]]] vec[[\[Nu]]])/invertdot[vec, vec]

Now, something really weird happen. I can call this function once say $capitali[1,1,\{s1,s2,s3,s4\}]$ and I get the correct output. But then, if I try to call it a second time, say $capitali[1,2,\{s1,s2,s3,s4\}]$, then it only output $capitali[1,2,\{s1,s2,s3,s4\}]$ but does not evaluate. In the meantime, it does the same with every other previous definition that I may have.

In[14]:= capitali[2, 1, {s1, s2, s3, s4}]

Out[14]= -(1/2) - (2 s1 s2)/(-4 s1 s2 + s3^2 + s4^2)

In[15]:= capitali[1, 2, {s1, s2, s3, s4}]

Out[15]= capitali[1, 2, {s1, s2, s3, s4}]

In[16]:= sd

Out[16]= sd

I checked a bit, changed the name of the function, rerun the kernel, but everything I tried failed. After a bit more of investigation, it seeems that my function change me from the global context to another smaller context and I have no clue how this could happen.

Is there anyone that might have a clue?

$\endgroup$
  • $\begingroup$ Sorry, I had a problem and was still editing the question. Now it's finished $\endgroup$ – Ezareth Dec 30 '18 at 14:31
  • $\begingroup$ I can't reproduce the issue - Did you try to restart the kernel? $\endgroup$ – Lukas Lang Dec 30 '18 at 14:32
  • $\begingroup$ I did restart the kernel as well as reboot the computer. Maybe I should reinstall Mathematica $\endgroup$ – Ezareth Dec 30 '18 at 14:34
  • $\begingroup$ Can you add the output of Trace@capitali[1, 2, {s1, s2, s3, s4}] to the question? $\endgroup$ – Lukas Lang Dec 30 '18 at 14:38
  • $\begingroup$ How Do I copy/paste a large output in a nice form? $\endgroup$ – Ezareth Dec 30 '18 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.