3
$\begingroup$

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.

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

1 Answer 1

5
$\begingroup$
Format[binom[a_, b_]] := TraditionalForm@Binomial[a, b]

Now

binom[a, b]

$a \choose b$

and

With[{a = 10, b = 5}, binom[a, b]]
252
$\endgroup$
1
  • $\begingroup$ perfect - thank you! $\endgroup$
    – martin
    Jun 19, 2015 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.