|
|
last edited 9 years ago by test1 |
1 2 | ||
Editor: test1
Time: 2015/01/03 16:04:51 GMT+0 |
||
Note: |
added:
'univariate' applied to rational function produces rational function. Given actual
value Axiom/FriCAS can see that rational function is a polynomial and retract it.
But in a loop FriCAS has only expression producing rational functions and can
not predict that the result will be a polynomial.
The following is a very surprising for a novice, and a bit surprising for me:
(1) -> c 0==1; c 1==1; c n==c(n-1)+s*(reduce(+,[q^k*c(k)*c(n-1-k) for k in 1..n-1]));
c 5
Internal Error The function * with signature (%,Integer) -> % is missing from domain Fraction(Polynomial (Integer))
Note that the type of c 5
is FRAC POLY INT
. This is, because Axiom is not smart enough to realize inside the loop that is a polynomial if is nonnegative. The following is more surprising, though:
coefficient(univariate(c(5),s), 3)
>> System error: The function BOOT::|*1;c;1;initial| is undefined.
Axiom manages - after a lot of trying- to coerce univariate(c(5),s)
to a SUP FRAC POLY INT
. Wow.
[coefficient(univariate(c(n),s), 1) for n in 0..4]
>> System error: The function BOOT::|*1;c;1;initial| is undefined.
But why does it give up here?
Martin
univariate
applied to rational function produces rational function. Given actual
value Axiom/FriCAS can see that rational function is a polynomial and retract it.
But in a loop FriCAS has only expression producing rational functions and can
not predict that the result will be a polynomial.
Zq:=SUP(INT)
(1) |
q:Zq := monomial(1,1)
Compiled code for c has been cleared.
(2) |
Zqs:=SUP(Zq)
(3) |
s:Zqs := monomial(1$Zq,1)
(4) |
macro mac(n) == c(n-1) + s*(reduce(+,[q^k*c(k)*c(n-1-k) for k in 1..n-1]))
c(n: Integer): Zqs == (n=0 or n=1 => 1; mac n)
Function declaration c : Integer -> SparseUnivariatePolynomial( SparseUnivariatePolynomial(Integer)) has been added to workspace. 1 old definition(s) deleted for function or rule c
c 0
Compiling function c with type Integer -> SparseUnivariatePolynomial (SparseUnivariatePolynomial(Integer))
(5) |
c 1
(6) |
c 2
(7) |
mac 2
(8) |
I don't know but the output of c(2) is wrong. I would have expected "? ? + 1" in accordance to mac(2). So the typed form of you example doesn't work. And the output looks ugly anyway. :-(
Ralf
-
operation for the upper bound, it is not defined for NNI or PI. Axiom is smart enough to detect the types of the step and the bounds. Because of that it is assumed that the result of (n-1) is an Integer.
Here I even don't define the type of the function:
)clear all
All user variables and function definitions have been cleared. c 0==1; c 1==1; c n==c(n-1)+s*(reduce(+,[q^k*c(k)*c(n-1-k) for k in 1..(n-1)::NNI]));
[coefficient(univariate(c(n),s), 1) for n in 0..4]
Compiling function c with type Integer -> Polynomial(Integer)
Compiling function G36 with type Integer -> Boolean
(9) |
I don't know why it gives up in your exemple though.
Greg