2
$\begingroup$

Bug introduced in 13.0 or earlier. Fixed in 13.2.0 or earlier.


Why do I get this error? I don't do any calculation with this. I just want to use TeXForm and then wrap MaTeX around it.

TeXForm["\!\(\*SubsuperscriptBox[\(\[Integral]\), \(0\), \
\(2\)]\)\!\(\*SubsuperscriptBox[\(\[Integral]\), \(-\*FractionBox[\
\(\[Pi]\), \(2\)]\), FractionBox[\(\[Pi]\), \
\(2\)]]\)\!\(\*TagBox[FractionBox[RowBox[{SuperscriptBox[\"r\", \
\"2\"], \" \", RowBox[{\"(\", RowBox[{\"cos\", \" \", \"\[Theta]\"}], \
\")\"}], \" \", \
SuperscriptBox[RowBox[{\"(\", RowBox[{RowBox[{\"-\", \"1\"}], \"+\", \
RowBox[{\"r\", \" \", RowBox[{\"(\", RowBox[{\"sin\", \" \", \"\
\[Theta]\"}], \")\"}]}]}], \
\")\"}], \"3\"]}], RowBox[{\"1\", \"+\", SuperscriptBox[\"r\", \
\"2\"]}]],HoldForm]\)dr d\[Theta] = -\!\(\*FractionBox[\(16\\ \
\[Pi]\), \(3\)]\)"]

enter image description here

And this is the result when I run in another computer.

enter image description here

$\endgroup$
7
  • 1
    $\begingroup$ Why do you use TeXForm on a string? $\endgroup$
    – Carl Woll
    Apr 16, 2022 at 21:44
  • $\begingroup$ @CarlWoll I think I tried without string but I got error so I added the string mark. $\endgroup$
    – hana
    Apr 16, 2022 at 21:45
  • 3
    $\begingroup$ The infinite recursion is a bug, pure and simple. I will report it. $\endgroup$ Apr 17, 2022 at 18:06
  • 1
    $\begingroup$ The answer to the question raised in the subject header, which I'm sure I'll need to delete soon, is "Because TeXForm hates us and wants us to be miserable". $\endgroup$ Apr 17, 2022 at 21:12
  • 1
    $\begingroup$ @bmf TexForm breaks this law by actually increasing misery. Think of it as entropy I guess. $\endgroup$ Apr 18, 2022 at 17:47

1 Answer 1

4
$\begingroup$

In light of the comment by @Daniel Lichtblau the following is a workaround to the bug that is present

Edit: addressing all the comments

edit1

The code is given below:

MaTeX[TeXForm[
  HoldForm@
    Integrate[(r^2 Cos[\[Theta]] (-1 + r (Sin[\[Theta]]))^3)/(
     1 + r^2), {r, 0, 2}, {\[Theta], -Pi/2, Pi/2}] == 
   Integrate[(r^2 Cos[\[Theta]] (-1 + r (Sin[\[Theta]]))^3)/(
    1 + r^2), {r, 0, 2}, {\[Theta], -Pi/2, Pi/2}]]]

Original answer


I am not 100% sure why it happens. I checked that by copying and pasting your code in my notebook, I also had the errors. I think it has to do with the HoldForm and perhaps the RowBox. See below:

I started coding your expression afresh. It worked fine.

res

The code used

TeXForm["\!\(\*SuperscriptBox[SubscriptBox[\(\[Integral]\), \(0\)], \
\(2\)]\)\!\(\*SuperscriptBox[SubscriptBox[\(\[Integral]\), \
\(-\*FractionBox[\(\[Pi]\), \(2\)]\)], FractionBox[\(\[Pi]\), \(2\)]]\
\) \!\(\*FractionBox[\(\((cos\\\ \[Theta])\) \*SuperscriptBox[\((\(-1\
\) + r \((sin\\\ \[Theta])\))\), \(3\)]\), \(1 + \*SuperscriptBox[\(r\
\), \(2\)]\)]\) dr d\[Theta]=-\!\(\*FractionBox[\(16  \[Pi]\), \(3\)]\
\)"]

Note that I grabbed the code posted here and tried it in a fresh kernel and worked with no issues.

res2

$\endgroup$
8
  • $\begingroup$ thanks, your code works in my another computer but if I copied my code above then I also got error. $\endgroup$
    – hana
    Apr 16, 2022 at 21:41
  • 1
    $\begingroup$ @hana yes, it makes sense. It probably has something to do with HoldForm and/or RowBox as I mentioned in my answer. Not sure how you got those though. $\endgroup$
    – bmf
    Apr 16, 2022 at 21:43
  • $\begingroup$ Oh, yea, I forgot to remove it. I used it to replace Cos[x] to cos(x) form. $\endgroup$
    – hana
    Apr 16, 2022 at 21:44
  • 1
    $\begingroup$ @hana ok, so it seems that this is causing the issue. I wrapped my code around MaTex and works fine. You can try MaTeX[TeXForm[codefromabove]] just to make sure. $\endgroup$
    – bmf
    Apr 16, 2022 at 21:47
  • 1
    $\begingroup$ oh, that is great and I didn't get that was what you were saying. $\endgroup$
    – hana
    Apr 16, 2022 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.