Well, 'coefficients' or coercion from NemoInteger to Integer should
be quite cheap. 'length' on Integer is _very_ cheap. I asked
for this to make sure that 'p^750' is actually computed. 'degree'
of 'p^750' is simply '750*degree(p)' so can be computed without
computing 'p^750'. Also, Julia folks put floating point computations
in various places. Correctly computing lenghts of coefficients
from floating point result is possible, but unlikely.
Using known "fast" algoritm FriCAS should be able to compute
'p^(5*750)' on your machine in about 1.5s. The algorithm
is:
1) convert polynomial to an integer by evaluation in x = 2^bl
where bl is bound of size of coefficients of the power
2) compute integer power
3) convert integer back to polynomial
When done literally, it would take probably about 6-7 seconds
of which 4 sec is for computing power and the rest is for
convertion. In principle convertion back should be very fast,
but using only operations available at Lisp level one needs
to do shifting and masking which creates a lot of intermediate
integers which are not needed later.
One can make it faster by noticing that coefficients of your
polynomial make arithmetic progression with step 4. So one can
reduce amount of work by factor of 4.
Using attached routines computation is:
)set messages time on
pt := 13*x^2 + 2*x + 2
pt5 := pt^5
bl := 15751
i5 := eval(pt5, x = 2^bl);
i5_750 := i5^750;
pt5_750 := int_to_pol(i5_750, bl);
p5_750 := multiplyExponents(pt5_750, 4)*monomial(1, 5*750)$UP('x, INT);
reduce(_+, map(length, coefficients(p5_750)))
You should see that only steps that take significant time are
computation of 'i5_750' (main cost) and 'int_to_pol' call.
Similar approach works for multiplication, but is such case one also
needs faster routine for converting polynomials to integers.
> I
> should not have used the word "arithmetic" this morning, my mistake,
> sorry, what I meant is that I have not implemented all
> _primitive_routines, all polynomial manipulation/information routines.
>
> With p^5^750, and the different coercions, FriCAS silently stop and
> the process returns to the bash shell :-(
Well, '5^750' is _much_ larger than '5*750', so that is huge computation
expected to overflow memory of any possible computer (unless implementaion
is lazy and do not compute actual result).
--
Waldek Hebisch