0
$\begingroup$

How can I display an expression in unevaluated form?

TraditionalForm[2*3^3 + 5^2]

I´d like to obtain 2*3^3 + 5^2 displayed in traditional form without being evaluated to obtain 79.


Added after bobthechemist's answer

How could I obtain the behavior I want from a String (The expression is stored in a string)?

a = "2*3^3+5^2"
Defer[a]
Defer[ToExpression[a]]
$\endgroup$
4
  • 1
    $\begingroup$ Defer is what you are looking for, I think. $\endgroup$ Commented Nov 13, 2020 at 18:54
  • $\begingroup$ @bobthechemist Yes!. Thank you. You can answer and I set as the solution. $\endgroup$
    – Mika Ike
    Commented Nov 13, 2020 at 18:56
  • $\begingroup$ @bobthechemist and how to obtain that from a expression as a String?. a = "2*3^3+5^2" Defer[a] Defer[ToExpression[a]] $\endgroup$
    – Mika Ike
    Commented Nov 13, 2020 at 19:00
  • 1
    $\begingroup$ I don't think that will be possible, since the superscripts are not a standard font. I'm not well versed with the underlying mechanisms for formatting in Mathematica, but that output has a bunch of Boxes that probably can't be turned into strings easily. $\endgroup$ Commented Nov 13, 2020 at 19:06

3 Answers 3

3
$\begingroup$

Don't use TraditionalForm in this case; rather, use Defer.

$\endgroup$
4
$\begingroup$

The documentation for ToExpression says

quote

So

a = "2*3^3+5^2";
ToExpression[a, TraditionalForm, Defer]

gives

result

$\endgroup$
3
$\begingroup$

HoldForm is beter.

a = 2*3^3 + 5^2 // HoldForm
a // TraditionalForm
8 a // TraditionalForm
8 a // ReleaseHold
$\endgroup$

Your Answer

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

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