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$ Commented Jun 19, 2015 at 12:58
  • $\begingroup$ Are you aware of TraditionalForm? $\endgroup$
    – Yves Klett
    Commented Jun 19, 2015 at 12:58
  • $\begingroup$ @YvesKlett yes, but it doesn't evaluate the same, does it? $\endgroup$
    – martin
    Commented Jun 19, 2015 at 12:58
  • $\begingroup$ not foolprof, no, and just like MatrixForm an eternal source of confusion. $\endgroup$
    – Yves Klett
    Commented Jun 19, 2015 at 12:59
  • 3
    $\begingroup$ Check this tutorial. $\endgroup$
    – Karsten7
    Commented Jun 19, 2015 at 13:06

1 Answer 1

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
    Commented Jun 19, 2015 at 13:20

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.