3

How do I define that a formula should not be computed, but rather displayed in Traditional format? Here are 2 examples, where the first one is displayed like I want it, but the second one is simplified.

Print["5. ", Limit[f[x]/g[x], x -> a], "=", Limit[f[x], x -> a]/Limit[g[x], x -> a], ", where ", Limit[g[x], x -> a] != 0];
Print["7. ", Limit[c, x -> a], "=", c]
Sjoerd C. de Vries
  • 15,842
  • 3
  • 40
  • 88
Margus
  • 18,332
  • 12
  • 51
  • 101

3 Answers3

5

Use HoldForm to print an expression without evaluating it.

Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
(* /*        ^^^^^^^^                      */ *)
kennytm
  • 469,458
  • 94
  • 1,022
  • 977
5

It depends a little bit on exactly what you want to do, but if you're just writing text, don't use Print. Instead, enter the text directly, making sure you are using a Text cell and not an Input cell. In the menu, select:

Format -> Style -> Text

Then type out what you want, like:

5. Limit[f[x]/g[x], x -> a] == Limit[f[x], x->a]/Limit[g[x], x -> a] where ...

Select the expression you want to convert to TraditionalForm and then in the menu again, select:

Cell -> ConvertTo -> TraditionalForm

... and you should get something like this:

You might also find the screencast on typesetting useful: http://www.wolfram.com/broadcast/screencasts/howtoentermathematicaltypesetting/

If you're actually trying to produce TraditionalForm output programmatically (e.g., with Print) you might consider using Row and TraditionalForm with HoldForm:

Print[Row[{
   "5. ",
    TraditionalForm[HoldForm[
     Limit[f[x]/g[x], x -> a] == Limit[f[x], x -> a]/Limit[g[x], x -> a]]],
   " where ..."
   }]]
Michael Pilat
  • 6,380
  • 25
  • 30
0

If I undestand you correctly -- you don't want Limit[c, x -> a] to be evaluated. Standart way to stop something from evaluation is to use "Hold".

  Print["7. ", Hold[Limit[c, x -> a]], "=", c]

But the result is not good:

  7. Hold[Limit[c, x -> a]] = c

The HoldForm command does the trick -- it holds evaluation but doesn't show up:

  Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
  7. Limit[c, x -> a] = c
Kostya
  • 1,034
  • 10
  • 23