Choose n items from a list. Returns list of size binomial(#a,n) of lists.
fricas
choose(a,n) ==
j:=[i for i in 1..n]
r:=[[a(j(i)) for i in 1..n]]
k:=n
while k>0 and j(k)+n-k<#a repeat
j(k):=j(k)+1
for i in k..n-1 repeat j(i+1):=j(i)+1
r:=concat(r,[a(j(i)) for i in 1..n])
k:=n; while j(k)+n-k>=#a and k>1 repeat k:=k-1
if binomial(#a,n)~=#r then error "error in choose"
return r
Type: Void
- 3 The Main Result
fricas
sum(x)==reduce(+,x,0)
Type: Void
fricas
product(x)==reduce(*,x,1)
Type: Void
fricas
-- specify n
f(i,j) == sum [ product x for x in choose([r[q]::Expression Integer for q in 1..n|q~=j],n-i-1)]
Type: Void
fricas
groupPolyCoeff(i) == (-1)^(i+n+1)*reduce(+,[exp(r[j])/reduce(*,[r[j]-r[m] for m in 1..n | j~=m])*f(i,j) for j in 1..n])
Type: Void
Polynomial of degree 2
fricas
n:=2
fricas
eq2_3a:= g[0]=groupPolyCoeff(0)
fricas
Compiling function choose with type (List(Expression(Integer)),
Integer) -> List(List(Expression(Integer)))
fricas
Compiling function product with type List(Expression(Integer)) ->
Expression(Integer)
fricas
Compiling function sum with type List(Expression(Integer)) ->
Expression(Integer)
fricas
Compiling function f with type (NonNegativeInteger,PositiveInteger)
-> Expression(Integer)
fricas
Compiling function groupPolyCoeff with type NonNegativeInteger ->
Expression(Integer)
Type: Equation(Expression(Integer))
fricas
eq2_3b:= g[1]=groupPolyCoeff(1)
fricas
Compiling function f with type (PositiveInteger,PositiveInteger) ->
Expression(Integer)
fricas
Compiling function groupPolyCoeff with type PositiveInteger ->
Expression(Integer)
Type: Equation(Expression(Integer))
Polynomial of degree 3
fricas
n:=3
fricas
eq3_3a:= g[0]=groupPolyCoeff(0)
Type: Equation(Expression(Integer))
fricas
factor(numer rhs %)/factor(denom rhs %)
Type: Fraction(Factored(SparseMultivariatePolynomial
?(Integer,
Kernel(Expression(Integer)))))
fricas
eq3_3b:= g[1]=groupPolyCoeff(1)
Type: Equation(Expression(Integer))
fricas
factor(numer rhs %)/factor(denom rhs %)
Type: Fraction(Factored(SparseMultivariatePolynomial
?(Integer,
Kernel(Expression(Integer)))))
fricas
eq3_3c:= g[2]=groupPolyCoeff(2)
Type: Equation(Expression(Integer))
fricas
factor(numer rhs %)/factor(denom rhs %)
Type: Fraction(Factored(SparseMultivariatePolynomial
?(Integer,
Kernel(Expression(Integer)))))
Polynomial of degree 4
fricas
n:=4
fricas
eq4_2:= g[0]=groupPolyCoeff(0)
Type: Equation(Expression(Integer))
fricas
eq4_3:= g[1]=groupPolyCoeff(1)
Type: Equation(Expression(Integer))
fricas
eq4_4:= g[2]=groupPolyCoeff(2)
Type: Equation(Expression(Integer))
fricas
eq4_5:= g[3]=groupPolyCoeff(3)
Type: Equation(Expression(Integer))
Old
fricas
eq42 := _
-r2*r3*r4*exp(r1)/((r1-r2)*(r1-r3)*(r1-r4)) + _
-r1*r3*r4*exp(r2)/((r2-r1)*(r2-r3)*(r2-r4)) + _
-r1*r2*r4*exp(r3)/((r3-r1)*(r3-r2)*(r3-r4)) + _
-r1*r2*r3*exp(r4)/((r4-r1)*(r4-r2)*(r4-r3))
Type: Expression(Integer)
three
fricas
htrigs eval(eq42, [r3=-r1,r4=-r2])
Type: Expression(Integer)
fricas
htrigs limit(%,r2=r1)
Type: Expression(Integer)
fricas
eq43 :=
(r2*r3 + r3*r4 + r4*r2)*exp(r1)/((r1-r2)*(r1-r3)*(r1-r4)) + _
(r1*r3 + r3*r4 + r4*r1)*exp(r2)/((r2-r1)*(r2-r3)*(r2-r4)) + _
(r1*r2 + r2*r4 + r4*r1)*exp(r3)/((r3-r1)*(r3-r2)*(r3-r4)) + _
(r1*r2 + r2*r3 + r3*r1)*exp(r4)/((r4-r1)*(r4-r2)*(r4-r3))
Type: Expression(Integer)
fricas
htrigs eval(eq43, [r3=-r1,r4=-r2])
Type: Expression(Integer)
fricas
htrigs limit(%,r2=r1)
Type: Expression(Integer)