TransWikia.com

Possible bug in traditional form expression enclosed in ""

Mathematica Asked on January 12, 2021

The following:

a="FormBox[RowBox[{SuperscriptBox[":f74d", RowBox[{":f74e", " ", ":03b8"}]], "=", RowBox[{RowBox[{"x", " ", SuperscriptBox["sin", "2"]}], "+", RowBox[{"x", " ", SuperscriptBox["cos", "2"]}]}]}], TraditionalForm]";
Style[a,FontSize->20]

displays with a leading " but no trailing ". I would expect the output to be "expression" or expression but getting "expression is obviously a bug. How can I fix this?

As you can see, I am storing a math expression with typesetting that may have a collision with the = assignment operator. What is the preferred method for assigning an expression that contains an unevaluated = operator? Is using a string the only way?

using mathematica 12 cloud based IDE.

One Answer

When I copied and pasted your code into a V12.1.1 notebook on my system (MacOS 10.13.4), I got the following:

code_image

which doesn't display the problem you experienced. So I don't think there is any bug involved, just something corrupted in your notebook. You might try evaluating your expression in a clean notebook to see if that makes the problem go away.

But you also ask for recommendations of better practice. I recommend the following.

a = HoldForm[E^(I θ) == Cos[θ] + I Sin[θ]]

out.1

With this definition of a, you can still style the held expression.

Style[TraditionalForm @ a, 20, "TR"]

out.2

You can also do all kinds of other things with the expression held by a by using ReleaseHold. Here are a couple of examples:

ReleaseHold[a] // Simplify
True
{x, y} = Cases[ReleaseHold[a], u : (Sin | Cos)[θ] :> u, All]; {x, y}
{Cos[θ], Sin[θ]}

Update

It occured to me that some people might prefer

{x, y} = Simplify[ReIm[ReleaseHold[a][[2]]], θ ∈ Reals]

to the 2nd example given above; it gives the same result. Of course, this works, too:

{x, y} = FullSimplify[ReIm[ReleaseHold[a][[1]]], θ ∈ Reals]

After all, equality is equality ? (see 1st example above for for confirmation of equality).

Answered by m_goldberg on January 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP