Efficiency Improvements in Maple 8

A number of efficiency improvements have been applied to make Maple 8 faster and use less memory.


CurveFitting[Spline]


•

In Maple 8, the Spline function in the CurveFitting package uses a more efficient algorithm for the degree 2 and the default degree 3 cases when floatingpoint data is provided. For best results, specify the input data points in the form of Vectors.



add and mul


•

The builtin procedures add and mul have been rewritten using a new algorithm for the case of adding or multiplying over a range. In some cases, the performance of these routines is an order of magnitude faster.

>

time(mul(i,i=1..10000)); # about 12s in Maple 7



convert[parfrac]


•

There is a new algorithm in the partial fraction conversion routine convert(...,parfrac,...). It is significantly more efficient for problems with multiplicities in the denominator. In addition, the new routine often provides more compact output.


The new algorithm decomposes the partial fraction decomposition into separate problems at each multiplicity, which can significantly reduce the runtime and memory consumption for problems having multiplicities (due to the O(n^3) cost of linear system solution).


The following example has a squared degree 44 polynomial in the denominator.

>

ratpol:=1/(hypergeom([44, 51],[3],1x)^2*(1+x)^3*x^5);

${\mathrm{ratpol}}{\u2254}\frac{{1}}{{{\mathrm{hypergeom}}{}\left(\left[{\mathrm{44}}{\,}{51}\right]{\,}\left[{3}\right]{\,}{1}{}{x}\right)}^{{2}}{}{\left({}{1}{+}{x}\right)}^{{3}}{}{{x}}^{{5}}}$
 (2) 
>

ratpol:=convert(ratpol,StandardFunctions):

>

length(ratpol),degree(denom(ratpol),x);

>

pfratpol := convert(ratpol,parfrac,x):


The computation time is reduced by a factor of 250, and memory usage by a factor of 80.



Polynomial Manipulation


•

It is often necessary to transform a polynomial into a list or Vector of coefficients. Using the natural [seq(coeff(p,x,i),i=0..degree(p,x))] command for a polynomial p in x leads to O(n^2) behavior (where n=degree(p,x)). There are now two routines, PolynomialTools[CoefficientVector] and PolynomialTools[CoefficientList], that perform this operation in O(n) time. In fact, if the polynomial is sparse, it is performed in O(#terms), as the examples below show.

${p}{\u2254}{{x}}^{{5}}{}{13}{}{x}{+}{1}$
 (4) 
>

time(CoefficientVector(p,x));

>

time(CoefficientVector(1+x+x^1000000000,x,storage=sparse));



orthopoly


•

In Maple 8, the orthopoly package uses a more efficient algorithm to compute orthogonal polynomials for algebraic and complex rational values of the variable x.

>

time( orthopoly[L](400,x) ); # about 1000 seconds in Maple 7

>

time( orthopoly[P](600,1/3) ); # about 800 seconds in Maple 7



LinearAlgebra[LeastSquares]


•

The LeastSquares routine in the LinearAlgebra package in Maple 8 contains a highly efficient indirect sparse real solver for floatingpoint problems. In particular, it is very efficient for sparse problems with densities less than 15 percent.



fsolve


•

In Maple 8, the fsolve routine efficiently solves univariate polynomials for all roots at higher than default settings of the Digits environment variable.

•

The following fsolve computation requires only approximately 30 percent of the time required in Maple 7.

>

p := randpoly(x,degree=100,dense):



Boolean Evaluation


•

Evaluation of symbolic boolean expressions has been significantly optimized, so that the complexity is no longer exponential in time and space.

>

time(a1 and a2 and a3 and a4 and a5 and a6 and a7 and a8 and a9 and a10 and a11 and a12 and a13 and a14 and a15 and a16 and a17 and a18 and a19 and a20 and a21 and a22 and a23 and a24 and a25 and a26 and a27 and a28 and a29 and a30); # about 100 seconds in Maple 7



Sparse Random Matrix Generation


•

Generation of sparse random Matrices is much faster in Maple 8. A new algorithm is used when density < 1.

>

time( LinearAlgebra:RandomMatrix(1000,1000,
density=.1,outputoptions=[datatype=float[8],storage=sparse]) );



Linear Algebra


>

A := LinearAlgebra[RandomMatrix](50,50,density=.1):

>

time(LinearAlgebra[SmithForm](A));



Polynomial Resultants



The resultant routine for Z[x] has been changed to use a probabilistic method because the coefficient bounds on the resultant, based on the determinant of Sylvester's matrix, were too large and led to inefficiency. For example, the resultant of the two cyclotomic polynomials below is 1 but the coefficient bound used was an integer of length 315 digits. The new code is about 500 times faster in this worst case example for the coefficient bound.

>

Phi := numtheory[cyclotomic]:

>

f := Phi(1001,z): degree(f,z);

>

g := Phi(30,z): degree(g,z);



Rational Function Reconstruction



The ratrecon routine reconstructs from u(x) and m(x) a rational function n(x)/d(x) satisfying n(x)/d(x) == u(x) mod m(x). It can be used for Pade approximation and to interpolate a rational function from sufficiently many values of the function. We have modified the implementation to use the monic Euclidean algorithm for improved efficiency.

${f}{\u2254}\frac{{1}}{{}{{x}}^{{2}}{}{x}{+}{1}}$
 (15) 
>

T := convert(taylor(f,x),polynom);

${T}{\u2254}{8}{}{{x}}^{{5}}{+}{5}{}{{x}}^{{4}}{+}{3}{}{{x}}^{{3}}{+}{2}{}{{x}}^{{2}}{+}{x}{+}{1}$
 (16) 
${}\frac{{1}}{{{x}}^{{2}}{+}{x}{}{1}}$
 (17) 
>

X := [seq(i,i=0..4)]; Y := [seq(eval(f,x=i),i=0..4)];

${X}{\u2254}\left[{0}{\,}{1}{\,}{2}{\,}{3}{\,}{4}\right]$
 
${Y}{\u2254}\left[{1}{\,}{\mathrm{1}}{\,}{}\frac{{1}}{{5}}{\,}{}\frac{{1}}{{11}}{\,}{}\frac{{1}}{{19}}\right]$
 (18) 
>

ratrecon( interp(X,Y,x), mul( xxval, xval=X ), x );

${}\frac{{1}}{{{x}}^{{2}}{+}{x}{}{1}}$
 (19) 


Polynomial GCDs



We have improved the efficiency of the computation of the greatest common divisors of polynomials in Z[x,y] and Q(alpha)[x], that is, bivariate polynomials over the integers and univariate polynomials over an algebraic number field with one field extension. The main improvement for Z[x,y] is in the treatment of the content of the polynomials in the modular algorithm. The new algorithm is always fast when the GCD is small. For Q(alpha)[x], it is improved by (i) using rational reconstruction, (ii) avoiding the inversion of the leading coefficients of the input, and (iii) performing the trial divisions using integer arithmetic.



Miscellaneous


•

Maple 8 has improved management facilities for large expressions with many common subexpressions.

>

F := proc(n) option remember; if n<2 then n else x*F(n1)+F(n2) fi end:

>

f := proc()
local e1, e2, e3, e4, L;
e1 := F(30); e2 := F(31);
e3 := F(32); e4 := F(33);
L := [[e1,e2],[e3,e4]];
map(nops,L);
end:

•

A thirdorder iterative scheme is used in Maple 8 to compute the square root of a floatingpoint number. In addition to speed improvements, the new algorithm implements IEEEstyle exact rounding (for all rounding modes). This means that a Maple float is evaluated to the current setting of Digits, and then treated as exact for the purposes of computation (this is part of the standard Maple floatingpoint model). The result is rounded is such a way that it would be correct, even if the square root were first computed to infinite precision. For example, since sqrt(0.9999999999) = .9999999999499999999987..., the correct (default) rounding of this result to 10 digits is 0.9999999999, which is the result Maple returns.

•

Toplevel access to rtable elements has been optimized.

•

In Maple 8, there are great efficiency improvements for evaluating large, highly recursive expressions at a point using eval(expr, x=a). In previous releases, eval() visits every node in the expression tree. In Maple 8, it visits every unique subexpression once, even if it occurs many times in the expression.


