In a similar vein to my previous question, is it possible to define a function that displays differently to its default? eg I would really like Binomial[a,b] to be displayed as $a \choose b$, but still function as normal during calculation. I tried binom[a_, b_] := Binomial[a, b]//MatrixForm but that didn't work.

eg If I enter binom[a,b], I would like it to display as MatrixForm[{a,b}], but when I type in With[{a=10,b=5},binom[a,b]] I would like the output 252.

  • 2
    $\begingroup$ Interpretation[ ]? $\endgroup$ – Dr. belisarius Jun 19 '15 at 12:58
  • $\begingroup$ Are you aware of TraditionalForm? $\endgroup$ – Yves Klett Jun 19 '15 at 12:58
  • $\begingroup$ @YvesKlett yes, but it doesn't evaluate the same, does it? $\endgroup$ – martin Jun 19 '15 at 12:58
  • $\begingroup$ not foolprof, no, and just like MatrixForm an eternal source of confusion. $\endgroup$ – Yves Klett Jun 19 '15 at 12:59
  • 3
    $\begingroup$ Check this tutorial. $\endgroup$ – Karsten 7. Jun 19 '15 at 13:06
Format[binom[a_, b_]] := TraditionalForm@Binomial[a, b]


binom[a, b]

$a \choose b$


With[{a = 10, b = 5}, binom[a, b]]
  • $\begingroup$ perfect - thank you! $\endgroup$ – martin Jun 19 '15 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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