login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Nicer display from binomials:

fricas
(1) -> --)set output tex off
--)set output algebra on
binomial(n,m)

\label{eq1}\hbox{\axiomType{BINOMIAL}\ } \left({n , \: m}\right)(1)
Type: Expression(Integer)
fricas
opbinom := operator(operator 'binomial)$CombinatorialFunction(INT,EXPR INT)

\label{eq2}binomial(2)
Type: BasicOperator?
fricas
setProperty(opbinom, '%specialDisp::Symbol,
  ((l:List EXPR INT):OutputForm +-> paren vconcat(first(l)::OutputForm,second(l)::OutputForm)) pretend None)

\label{eq3}binomial(3)
Type: BasicOperator?
fricas
binomial(n,m)

\label{eq4}\left(
\begin{array}{c}
n 
\
m 
\
(4)
Type: Expression(Integer)

Tests from GouldBk?.pdf --rrogers, Fri, 07 Apr 2017 16:22:25 +0000 reply
http://www.dsi.unifi.it/~resp/GouldBK.pdf

fricas
binomial(5,2)-binomial(5,5-2)

\label{eq5}0(5)
Type: NonNegativeInteger?
fricas
binomial(a,b)-binomial(a,a-b)

\label{eq6}\begin{array}{@{}l}
\displaystyle
{\left(
\begin{array}{c}
a 
\
b 
\
(6)
Type: Expression(Integer)

Ah well no joy in Mudville I guess I need a special function of some sort, any comments?

simplification of binomials --Bill Page, Fri, 07 Apr 2017 21:38:48 +0000 reply
The simplifications provided by Combfunc apply only to specific integer values of the 2nd argument of a single kernel. What you want to do usually involves combinations of more than one kernel. For this you might expect something like simplify or expand to work but these commands are not aware of binomial. The next best thing might be to use some custom rules. E.g.
fricas
BS := rule
  binomial(a,a-b) == binomial(a,b)

\label{eq7}= = \left({{\left(
\begin{array}{c}
a 
\
{- b + a}
\
(7)
Type: RewriteRule?(Integer,Integer,Expression(Integer))

then we have

fricas
Is(binomial(3,3-x),lhs BS)

\label{eq8}\left[{b = x}, \:{a = 3}\right](8)
Type: List(Equation(Expression(Integer)))
fricas
BS( binomial(3,x)-binomial(3,3-x) )

\label{eq9}0(9)
Type: Expression(Integer)

This rule is already built-in

fricas
BN := rule
  binomial(-n+k-1,k | even? k) == binomial(n,k)
  binomial(-n+k-1,k | odd? k) == -binomial(n,k)

\label{eq10}\begin{array}{@{}l}
\displaystyle
\left\{{= = \left({{\left(
\begin{array}{c}
{- n + k - 1}
\
k 
\
(10)
Type: Ruleset(Integer,Integer,Expression(Integer))
fricas
binomial(-n+1,2)

\label{eq11}\frac{{{n}^{2}}- n}{2}(11)
Type: Expression(Integer)
fricas
binomial(-n+2,3)

\label{eq12}\frac{-{{n}^{3}}+{3 \ {{n}^{2}}}-{2 \  n}}{6}(12)
Type: Expression(Integer)

Cross product. Note that because pattern matching is syntactic we need to take care about the lexical ordering of the variables.

fricas
BX := rule
  binomial(k,n)*binomial(n,j) == binomial(k,j)*binomial(k-j,n-j)
  binomial(k,j)*binomial(n,k) == binomial(n,j)*binomial(n-j,k-j)

\label{eq13}\begin{array}{@{}l}
\displaystyle
\left\{{= = \left({{\%E \ {\left(
\begin{array}{c}
k 
\
n 
\
(13)
Type: Ruleset(Integer,Integer,Expression(Integer))

fricas
ex1 := binomial(x+y,y)*binomial(y,y-z)

\label{eq14}{\left({
\begin{array}{c}
y 
\
{- z + y}
\
(14)
Type: Expression(Integer)
fricas
ex2 := BX ex1

\label{eq15}{\left({
\begin{array}{c}
{y + x}
\
{- z + y}
\
(15)
Type: Expression(Integer)
fricas
eval(ex1-ex2,[x=3,y=5,z=7])

\label{eq16}0(16)
Type: Expression(Integer)




  Subject:   Be Bold !!
  ( 15 subscribers )  
Please rate this page: