 Performance - Maple Help

 Performance frontend

The frontend command is used extensively by Maple to map expressions to the domain of rational functions.  It was rewritten for Maple 2017 to reduce time and memory usage.  The typical gain is a factor of two but for complicated expressions it runs an order of magnitude faster.  The example below runs over 30 times faster in Maple 2017.

 >
 ${0.265}$ (1.1) iratrecon - rational reconstruction

The iratrecon command for rational reconstruction has been re-engineered in the kernel to improve performance.  The first two examples below run about 9x and 5x faster, respectively.  We have also added a new fraction-free syntax that returns true or false and assigns the numerator and denominator to the fifth and sixth arguments.  By not constructing fractions, the new syntax gains an additional factor of five speedup.

 > $m≔\mathrm{prevprime}\left({2}^{60}\right)\cdot \mathrm{nextprime}\left({2}^{60}\right):$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{time}\left(\mathrm{iratrecon}\left(f,m\right)\right);$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{time}\left(\mathrm{iratrecon}\left(f,m,\mathrm{scaled}\right)\right)$
 ${5.116}$
 ${0.530}$ (2.1)
 > $b≔\mathrm{isqrt}\left(\mathrm{iquo}\left(m,2\right)\right):$
 ${0.124}$ (2.2) sprem - sparse pseudo division

The sprem command performs sparse fraction-free pseudo division on polynomials.  In previous versions of Maple, sprem(f,g,x) would multiply by lcoeff(g,x) in each division step.  In Maple 2017, sprem has been changed to compute gcds and use the smallest possible multiplier, allowing it to handle problems of much higher degree with less blowup.  When degree(g)=degree(g,x) the command calls a dedicated division routine written in C.  The example below runs about 360 times faster, and finds a multiplier that is 19x shorter.

 > $f≔\mathrm{randpoly}\left(x,\mathrm{degree}=10000,\mathrm{terms}={10}^{2}\right):$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{time}\left(\mathrm{sprem}\left(f,g,x,'m'\right)\right);$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{length}\left(m\right)$
 ${0.156}$
 ${225}$ (3.1) gcdex - extended Euclidean algorithm

For univariate polynomials, gcdex now uses a sparse primitive polynomial remainder sequence together with the new code for sprem.  For sparse structured problems the new routine is orders of magnitude faster.  The example below was previously intractable.

 > $f≔128{x}^{203}-625591465{x}^{196}-1379565483492966{x}^{189}-69051360012922713930{x}^{182}+503269676439575515122310{x}^{175}-358607771626419731119489079{x}^{168}-147952840877635699778667316508{x}^{161}-1147922766589841137530437873498{x}^{154}-3283047528072876955188179107557{x}^{147}-5494471139223382529181506689788{x}^{140}-6295323446544817875033709377526{x}^{133}-5439730226339556502298385195313{x}^{126}-4047134740954486045236505654710{x}^{119}-2699447938384037396439601445910{x}^{112}-1005987107212742027676051174393{x}^{105}+1005987107212742027676051174393{x}^{98}+2699447938384037396439601445910{x}^{91}+4047134740954486045236505654710{x}^{84}+5439730226339556502298385195313{x}^{77}+6295323446544817875033709377526{x}^{70}+5494471139223382529181506689788{x}^{63}+3283047528072876955188179107557{x}^{56}+1147922766589841137530437873498{x}^{49}+147952840877635699778667316508{x}^{42}+358607771626419731119489079{x}^{35}-503269676439575515122310{x}^{28}+69051360012922713930{x}^{21}+1379565483492966{x}^{14}+625591465{x}^{7}-128:$$\mathrm{time}\left(\mathrm{gcdex}\left(\frac{\partial }{\partial x}f,f,x,'\mathrm{inv}'\right)\right)$
 ${0.031}$ (4.1) Expand, Quo, and, Rem mod p

Expansion of  has been optimized in the case where $p$ is a prime and $k\ge p$, using the Frobenius map . The expansion below previously took a few seconds but is now instantaneous.  Quo and Rem have also been improved for multivariate polynomials and the division below runs about 90x faster.

 > $f≔\mathrm{Expand}\left({\left({x}^{3}+yz+z+yy+xz\right)}^{4}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}7:$
 memory used=75.71KiB, alloc change=0 bytes, cpu time=78.00ms, real time=140.00ms, gc time=0ns
 > $r≔\mathrm{CodeTools}:-\mathrm{Usage}\left(\mathrm{Rem}\left(g,f,x,'q'\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}7\right):$
 memory used=13.05KiB, alloc change=0 bytes, cpu time=16.00ms, real time=4.00ms, gc time=0ns normal

Maple 2017 includes a powerful new algorithm for simplifying large multivariate rational expressions using normal.  Previous versions of Maple could not do this problem automatically.

 > $\mathrm{unassign}\left('g'\right):$
 > $\mathrm{s1}≔\frac{\mathrm{l2}g{\mathrm{a22}}^{3}-\mathrm{l1}g\mathrm{a12}\mathrm{a21}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{n22}\mathrm{a21}{\mathrm{a22}}^{2}+\mathrm{l2}\mathrm{n11}\mathrm{a21}{\mathrm{a22}}^{2}+2\mathrm{l2}g\mathrm{a12}{\mathrm{a22}}^{2}-\mathrm{l1}g\mathrm{a12}{\mathrm{a22}}^{2}+\mathrm{l2}{g}^{2}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{n11}\mathrm{n22}{\mathrm{a22}}^{2}+\mathrm{l2}\mathrm{n11}{\mathrm{a22}}^{2}+\mathrm{l1}\mathrm{n22}\mathrm{a12}{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l1}\mathrm{n11}\mathrm{a12}{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l2}g{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l1}g{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}-\mathrm{l2}{g}^{2}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l1}{g}^{2}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{n11}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{n11}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}-2\mathrm{l2}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-2\mathrm{l1}\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l2}g\mathrm{a21}\mathrm{a22}+\mathrm{l2}g{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l1}g{\mathrm{a12}}^{2}\mathrm{a22}+\mathrm{l2}{g}^{2}\mathrm{a12}\mathrm{a22}-\mathrm{l1}{g}^{2}\mathrm{a12}\mathrm{a22}-\mathrm{l2}\mathrm{n11}\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{l1}\mathrm{n11}\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a22}-\mathrm{l1}\mathrm{n11}\mathrm{a12}\mathrm{a22}+\mathrm{l1}g\mathrm{a12}{\mathrm{a21}}^{3}+\mathrm{l1}{g}^{2}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}-\mathrm{l1}\mathrm{n11}\mathrm{n22}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l1}\mathrm{n22}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}-\mathrm{l2}g\mathrm{a12}{\mathrm{a21}}^{2}+2\mathrm{l1}g\mathrm{a12}{\mathrm{a21}}^{2}-\mathrm{l2}{g}^{2}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l1}{g}^{2}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l2}\mathrm{n11}\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l1}\mathrm{n11}\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l1}\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}g\mathrm{a12}\mathrm{a21}+\mathrm{l1}g\mathrm{a12}\mathrm{a21}}{\mathrm{l2}g\mathrm{a12}\mathrm{a21}{\mathrm{a22}}^{2}-\mathrm{l1}g\mathrm{a12}\mathrm{a21}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{n22}\mathrm{a21}{\mathrm{a22}}^{2}+\mathrm{l1}\mathrm{n22}\mathrm{a21}{\mathrm{a22}}^{2}+\mathrm{l1}\mathrm{l2}g\mathrm{a12}{\mathrm{a22}}^{2}-\mathrm{l1}g\mathrm{a12}{\mathrm{a22}}^{2}-\mathrm{l1}\mathrm{l2}\mathrm{n22}{\mathrm{a22}}^{2}+\mathrm{l1}\mathrm{n22}{\mathrm{a22}}^{2}+\mathrm{l2}\mathrm{n11}\mathrm{a12}{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l1}\mathrm{n11}\mathrm{a12}{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l2}g{\mathrm{a21}}^{2}\mathrm{a22}+\mathrm{l1}g{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l1}\mathrm{l2}g{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}+2\mathrm{l2}g{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}-\mathrm{l1}g{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{l2}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}-2\mathrm{l2}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-2\mathrm{l1}\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l1}\mathrm{l2}g\mathrm{a21}\mathrm{a22}-\mathrm{l2}g\mathrm{a21}\mathrm{a22}+2\mathrm{l1}g\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{l2}g{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l1}g{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l1}\mathrm{l2}\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{l1}\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{l1}\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a22}-\mathrm{l1}\mathrm{n11}\mathrm{a12}\mathrm{a22}-\mathrm{l1}\mathrm{l2}g\mathrm{a22}+\mathrm{l1}g\mathrm{a22}-\mathrm{l1}\mathrm{l2}\mathrm{n11}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l2}\mathrm{n11}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l1}\mathrm{l2}g\mathrm{a12}{\mathrm{a21}}^{2}-\mathrm{l2}g\mathrm{a12}{\mathrm{a21}}^{2}-\mathrm{l1}\mathrm{l2}g{\mathrm{a12}}^{3}\mathrm{a21}+\mathrm{l2}g{\mathrm{a12}}^{3}\mathrm{a21}+\mathrm{l1}\mathrm{l2}\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l1}\mathrm{l2}\mathrm{n11}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l2}\mathrm{n11}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l1}\mathrm{l2}g\mathrm{a12}\mathrm{a21}-\mathrm{l2}g\mathrm{a12}\mathrm{a21}}:$$\mathrm{s2}≔\frac{\mathrm{l2}g\mathrm{a12}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{n22}{\mathrm{a22}}^{2}+\mathrm{l2}{\mathrm{a22}}^{2}-\mathrm{l1}g{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l2}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l1}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l2}g\mathrm{a21}\mathrm{a22}+\mathrm{l2}g{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l1}g{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l2}\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{l1}\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{l2}\mathrm{a12}\mathrm{a22}-\mathrm{l1}\mathrm{a12}\mathrm{a22}-\mathrm{l1}\mathrm{n11}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l1}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l1}g\mathrm{a12}{\mathrm{a21}}^{2}+\mathrm{l2}\mathrm{n11}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l1}\mathrm{n11}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l1}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}g\mathrm{a12}\mathrm{a21}+\mathrm{l1}g\mathrm{a12}\mathrm{a21}}{\mathrm{l2}g\mathrm{a12}{\mathrm{a22}}^{2}-g\mathrm{a12}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{n22}{\mathrm{a22}}^{2}+\mathrm{n22}{\mathrm{a22}}^{2}-\mathrm{l1}g{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}+g{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{n22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{n11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l2}g\mathrm{a21}\mathrm{a22}+g\mathrm{a21}\mathrm{a22}+\mathrm{l2}g{\mathrm{a12}}^{2}\mathrm{a22}-g{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l2}\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{n22}\mathrm{a12}\mathrm{a22}+\mathrm{l2}\mathrm{n11}\mathrm{a12}\mathrm{a22}-\mathrm{n11}\mathrm{a12}\mathrm{a22}-\mathrm{l2}g\mathrm{a22}+g\mathrm{a22}-\mathrm{l1}\mathrm{n11}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{n11}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l1}g\mathrm{a12}{\mathrm{a21}}^{2}-g\mathrm{a12}{\mathrm{a21}}^{2}-\mathrm{l1}g{\mathrm{a12}}^{3}\mathrm{a21}+g{\mathrm{a12}}^{3}\mathrm{a21}+\mathrm{l1}\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{n22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l1}\mathrm{n11}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{n11}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l1}g\mathrm{a12}\mathrm{a21}-g\mathrm{a12}\mathrm{a21}}:$$\mathrm{s3}≔\frac{\mathrm{l2}\mathrm{p21}{\mathrm{a22}}^{3}-\mathrm{l1}\mathrm{p21}\mathrm{a12}\mathrm{a21}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{p22}\mathrm{a21}{\mathrm{a22}}^{2}+\mathrm{l2}\mathrm{p11}\mathrm{a21}{\mathrm{a22}}^{2}+2\mathrm{l2}\mathrm{p21}\mathrm{a12}{\mathrm{a22}}^{2}-\mathrm{l1}\mathrm{p21}\mathrm{a12}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{p11}\mathrm{p22}{\mathrm{a22}}^{2}+\mathrm{l2}\mathrm{p12}\mathrm{p21}{\mathrm{a22}}^{2}+\mathrm{l2}\mathrm{p11}{\mathrm{a22}}^{2}+\mathrm{l1}\mathrm{p22}\mathrm{a12}{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l1}\mathrm{p11}\mathrm{a12}{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l2}\mathrm{p12}{\mathrm{a21}}^{2}\mathrm{a22}-\mathrm{l1}\mathrm{p21}{\mathrm{a12}}^{2}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{p11}\mathrm{p22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{p11}\mathrm{p22}\mathrm{a12}\mathrm{a21}\mathrm{a22}-2\mathrm{l2}\mathrm{p22}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l1}\mathrm{p22}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l2}\mathrm{p12}\mathrm{p21}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l1}\mathrm{p12}\mathrm{p21}\mathrm{a12}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{p11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-2\mathrm{l1}\mathrm{p11}\mathrm{a12}\mathrm{a21}\mathrm{a22}-\mathrm{l2}\mathrm{p12}\mathrm{a21}\mathrm{a22}+\mathrm{l2}\mathrm{p21}{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l1}\mathrm{p21}{\mathrm{a12}}^{2}\mathrm{a22}-\mathrm{l2}\mathrm{p11}\mathrm{p22}\mathrm{a12}\mathrm{a22}+\mathrm{l1}\mathrm{p11}\mathrm{p22}\mathrm{a12}\mathrm{a22}+\mathrm{l2}\mathrm{p12}\mathrm{p21}\mathrm{a12}\mathrm{a22}-\mathrm{l1}\mathrm{p12}\mathrm{p21}\mathrm{a12}\mathrm{a22}+\mathrm{l2}\mathrm{p11}\mathrm{a12}\mathrm{a22}-\mathrm{l1}\mathrm{p11}\mathrm{a12}\mathrm{a22}+\mathrm{l1}\mathrm{p12}\mathrm{a12}{\mathrm{a21}}^{3}-\mathrm{l1}\mathrm{p11}\mathrm{p22}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l1}\mathrm{p22}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}+\mathrm{l1}\mathrm{p12}\mathrm{p21}{\mathrm{a12}}^{2}{\mathrm{a21}}^{2}-\mathrm{l2}\mathrm{p12}\mathrm{a12}{\mathrm{a21}}^{2}+2\mathrm{l1}\mathrm{p12}\mathrm{a12}{\mathrm{a21}}^{2}+\mathrm{l2}\mathrm{p11}\mathrm{p22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l1}\mathrm{p11}\mathrm{p22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}\mathrm{p22}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l1}\mathrm{p22}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}\mathrm{p12}\mathrm{p21}{\mathrm{a12}}^{2}\mathrm{a21}+\mathrm{l1}\mathrm{p12}\mathrm{p21}{\mathrm{a12}}^{2}\mathrm{a21}-\mathrm{l2}\mathrm{p12}\mathrm{a12}\mathrm{a21}+\mathrm{l1}\mathrm{p12}\mathrm{a12}\mathrm{a21}}{\mathrm{l2}\mathrm{p21}\mathrm{a12}\mathrm{a21}{\mathrm{a22}}^{2}-\mathrm{l1}\mathrm{p21}\mathrm{a12}\mathrm{a21}{\mathrm{a22}}^{2}-\mathrm{l2}\mathrm{p22}\mathrm{a21}{\mathrm{a22}}^{2}+\mathrm{l1}\mathrm{p22}\mathrm{a21}}$