On Mon, Feb 01, 2021 at 10:20:40PM -0500, Tobias Neumann wrote:
> >
> > BTW: Logically Expression(Complex(Fraction(Integer)))
> > is the same as Expression(Complex(Integer)), but the
> > second is usually more efficient. So I wonder why
> > you use Expression(Complex(Fraction(Integer))).
> >
>
> I haven't looked at the internal representation, but from the way the
> interpreter/REPL presents
> it, Complex(Fraction(Integer)) seems more natural to me because it doesn't
> seem to
> have to keep track of a (possibly huge) denominator. On the other hand just
> saving one (but possibly huge)
> denominator is probably cheaper.
Well, it is natural to think that many small denominators are
more efficient. It happens in artificial examples. But
experimental evidence indicates that normally single large
denominator is more efficient.
> If they are logically the same,
Yes, both are fields containing Complex(Integer). In particular
Expression(Complex(Integer)) effectively contains isomorphic copy
of Fraction(Complex(Integer)). By field theory Fraction(Complex(Integer))
and Complex(Fraction(Integer)) are isomorphic. Currently
FriCAS builds internal representation in recursive way based
on type that you gave, so at machine level all domains above
are different.
Not exactly. There are two conditions above joined by AND. The second is
(has
(Expression (Complex (Fraction (Integer))))
(SIGNATURE coerce ((Expression (Complex (Fraction (Integer)))) (Symbol))))
'has' above asks if domain in second line satisfies type condition
in third line. 'SIGNATURE' is conditions requesting function with
given name, that is 'coerce' having given return type and
argument types. Types are given as Lisp list, first is return type
than argument types. Second type is 'Symbol', so it is argument type.
First is Expression(Complex(Fraction(Integer))) so it is retrun type.
This is limitiation of Spad compiler, sometimes it can not infer
that needed conditions are satisfied. Possible workaround it to
use runtime test like:
if ECFI has coerce : Symbol -> ECFI and
ECFI has _^ : (ECFI, Fraction (Integer)) -> ECFI then
a_fun(f, expo) == approximate(f, expo)
else
a_fun(f, expo) == error "impossible"
Drawback of this is that 'a_fun' must be exported (this is compiler
limitation, you can not have conditions for internal functions).
Yes.
> I'm currently not in need of any of such functions, but just
> curious/interested:
>
> What is the difference between these two packages?
VectorIntegerReconstructor is doing reconstruction of rational
numbers from integers modulo another integer.
VectorModularReconstructor is doing reconstruction of rational
functions with coefficients from prime field from polynomials
modulo another polynomial.
Logically you can view both packages as instances of generic
package that takes base ring (which must be a PID) as parameter.
In case of VectorModularReconstructor base ring is ring of
integers. In case of VectorModularReconstructor base ring
is ring of univariate polynomials over a prime filed.
At abstract level, if you correctly state what packages are
doing, then both packages are doing "the same thing" but
for different types.
There are two separate packages because type specific version
are more efficient. Also, for efficiency prime is passed
as extra parameter to all functions from VectorModularReconstructor,
so signatures of functions differ.
> "Each evaluation is done module machine sized prime p"
> I am (not yet) particularly familiar with polynomial/rational
> reconstruction. Does that
> restrict the highest degree of the numerator or denominator in practice,
Yes, there are restrictions. Basically packages ignore possibility
of overflow and it is caller responsibility to choose data size and
prime so that there will be no overflow. In itself using machine
size primes seem to be rather mild restriction: there is a lot
of machine sized primes. But current situation is worse, one
needs to keep sufficient safety margin to avoid overflow in
intermediate steps. Let me add that for FriCAS main interest
in low degrees (say < 100). Code works fine for degrees of
order of few thousends. In practice limitations came from
compute time (think hours or days) and memory. In cases
where this was used cofficients of polynomials had size proportional
to degree and there were several polynomials. Memory use
were in gigabytes.
> or
> does that mean
> that just more probes are necessary? It seems like these routines are able
> to handle the multivariate case?
Yes. More precisely, they are ignorant about other variables
except for main variable, but handle several polynomials
at once ("Vector" in name is becase there are doing several
computations logically in parallel). One can use the
routines to recursively perform multivariate reconstruction.
> Are these packages in a "working" condition so that I can use them with
> "little" effort as a black box?
The packages are rather intesively used, by guessing package and
for gcd of polynomials with algebraic coefficients. Concerning
use: they are low level packages where main issue is speed and
not user convenience. Hence restrictions, long parameter lists,
etc.
--
Waldek Hebisch