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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.