I want every output expression in a notebook to use //PowerExpand and also to format numbers as scientific. Is there a way to do this without explicitly calling ScientificForm[] and //PowerExpand on every input?

i.e. I want to be able to enter

In: 4.3*^-5*Sqrt[M]*(L*n^2)^{3/4}
Out: {0.000043 \Sqrt[M] (L n^2)^(3/4)}

and instead get,

Out: 4.3e-5 M^(1/2} L^(3/4} n^(3/2)

Aside: is there a way to make mathematica never use radical symbols, and to use exponents instead?

  • 1
    $\begingroup$ I suggest re-posting your final line as a separate question. It seems both interesting and potentially difficult. $\endgroup$
    – Mr.Wizard
    May 31, 2014 at 20:12
  • $\begingroup$ Great idea, I've posted a new question here $\endgroup$ May 31, 2014 at 23:17

2 Answers 2



$PrePrint = ScientificForm@PowerExpand@# &

You would get the desired output. To return to normal just type:

$PrePrint =.
  • $\begingroup$ Thanks! This is working on a new notebook, but when I put it into my existing notebook, and re-run my cells - they keep the same format. Any ideas? $\endgroup$ May 30, 2014 at 19:43

It seems you are using a variation of my comments-in-output code from Notebook formatting - easier descriptions for equations and results? The variation you are using does not actually produce any formal output; it merely prints the evaluated form as a side-effect. Despite its name $PrePrint does not affect the lines produced by Print, as these are not considered output.

You can either add ScientificForm and PowerExpand to your modified $PreRead function:

$PreRead = Replace[#, 
    RowBox[{body__, ";", note_String?(StringMatchQ[#, "\"*\""] &)}] :> 
     Print[ScientificForm @ PowerExpand @ ToExpression@RowBox@{body}, Spacer[50], 
      Style[ToExpression@note, Italic, Red]]] &;

Or as I would prefer you can add it to my original code:

$note = Null;

$PreRead =
    RowBox[{body__, ";", note_String?(StringMatchQ[#, "\"*\""] &)}] :>
     ($note = Style[ToExpression@note, Italic, Red]; RowBox[{body}])
  ] &;

$PrePrint = 
  If[$note =!= Null,
    # &[Row[{Pane@#, Spacer[50], $note}], $note = Null],
  ] & @ ScientificForm @ PowerExpand @ # &;
  • $\begingroup$ Thanks so much! This made everything work perfectly. I'm giving the 'accepted' answer to eldo as he did most appropriately answer the question I (naively) asked. $\endgroup$ May 31, 2014 at 19:54
  • $\begingroup$ @zhermes You're welcome, and no problem. $\endgroup$
    – Mr.Wizard
    May 31, 2014 at 20:08

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.