<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, compiled as much as possible expression</title>
    <link>http://www.mapleprimes.com/posts/128104-Compiled-As-Much-As-Possible-Expression</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Thu, 11 Jun 2026 06:42:02 GMT</lastBuildDate>
    <pubDate>Thu, 11 Jun 2026 06:42:02 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, compiled as much as possible expression</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, compiled as much as possible expression</title>
      <link>http://www.mapleprimes.com/posts/128104-Compiled-As-Much-As-Possible-Expression</link>
    </image>
    <item>
      <title>innaccurate timings</title>
      <link>http://www.mapleprimes.com/posts/128104-Compiled-As-Much-As-Possible-Expression?ref=Feed:MaplePrimes:compiled as much as possible expression:Comments#comment128108</link>
      <itunes:summary>&lt;p&gt;The timings are not accurate. If you change the order of the three timed calculations then the opposite conclusion seems to hold: that the regular computation (plain old eval) is faster than what you've compiled.&lt;/p&gt;
&lt;p&gt;This is not surprising. The Compiler does not actually do anything to unevaluated lowercase int calls, or even evalf/Int. All that may happen is a callback into regular Maple to evaluate it.&lt;/p&gt;
&lt;p&gt;Here are the timings I see in 64bit Maple 15.01 on Windows 7, when I do the three calls with your original order:&lt;/p&gt;
&lt;pre&gt;CodeTools:-Usage(CompiledH(1.0, 0.001, 3.0));
memory used=0.88MiB, alloc change=0.56MiB, cpu time=31.00ms, real time=31.00ms
                      11.9983264989999992

CodeTools:-Usage(eval(H, [y=1.0, a=0.001, b=3.0]));
memory used=0.55MiB, alloc change=383.93KiB, cpu time=0ns, real time=0ns
                          11.99832650

CompiledHGlobalEvalCover:=(y,a,b)-&amp;gt;eval(CompiledH(y,a,b)):
CodeTools:-Usage(evalhf(CompiledHGlobalEvalCover(1.0, 0.001, 3.0)));
memory used=70.82KiB, alloc change=63.99KiB, cpu time=0ns, real time=0ns
                      11.9983264989999992
&lt;/pre&gt;
&lt;p&gt;And here is what happens when I change the order, and do a complete session relaunch and restart:&lt;/p&gt;
&lt;pre&gt;CompiledHGlobalEvalCover:=(y,a,b)-&amp;gt;eval(CompiledH(y,a,b)):
CodeTools:-Usage(evalhf(CompiledHGlobalEvalCover(1.0, 0.001, 3.0)));
memory used=0.88MiB, alloc change=0.56MiB, cpu time=32.00ms, real time=31.00ms
                      11.9983264989999992

CodeTools:-Usage(CompiledH(1.0, 0.001, 3.0));
memory used=2.64KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns
                      11.9983264989999992

CodeTools:-Usage(eval(H, [y=1.0, a=0.001, b=3.0]));
memory used=0.55MiB, alloc change=383.93KiB, cpu time=0ns, real time=0ns
                          11.99832650
&lt;/pre&gt;
&lt;p&gt;So it does look like regular evaluation of H at those values of a,b,y performs much the same at the same speed as what you've done specially, in a fresh session. You can also check that nothing very special has been accomplished by setting a trace on `evalf/int` before calling CompiledHGlobalEvalCover.&lt;/p&gt;
&lt;p&gt;Yet another way is:&lt;/p&gt;
&lt;pre&gt;restart:

H := y^2+a^2+b^2 + Int(x-&amp;gt;exp(x^6), 0..a,method=_d01ajc)+LerchPhi(y/(y+1),a,b):

CodeTools:-Usage(evalf(subs([y=1.0, a=0.001, b=3.0],H)));
memory used=0.76MiB, alloc change=0.56MiB, cpu time=31.00ms, real time=33.00ms
                          11.99832650
&lt;/pre&gt;
&lt;p&gt;As far as I can tell, mosty what you've done is notice and use (in an overcomplicated way) the fact that evalhf and the Compiler'd runtimes can call back into Maple for things that they otherwise do not handle specially. (In evalhf's case, this can be done by wrapping with eval). In the Compiler's case, it can be done using lexical scoping, but then it'd be much easier to simply do it as:&lt;/p&gt;
&lt;pre&gt;restart:

H := y^2+a^2+b^2 + int(exp(x^6), x=0..a) + LerchPhi(y/(y+1),a,b):

Hfun := unapply(H,[y,a,b]):
Hfuncomp := Compiler:-Compile((y,a,b)-&amp;gt;Hfun(y,a,b)):
Warning, the function names {Hfun} are not recognized in the target language

CodeTools:-Usage(Hfuncomp(1.0,0.001,3.0));
memory used=0.88MiB, alloc change=0.56MiB, cpu time=31.00ms, real time=32.00ms
                      11.9983264999999992
&lt;/pre&gt;</itunes:summary>
      <description>The latest comments added to the Post, compiled as much as possible expression</description>
      <guid>128108</guid>
      <pubDate>Fri, 25 Nov 2011 20:26:16 Z</pubDate>
      <itunes:author>Pseudomodo</itunes:author>
      <author>Pseudomodo</author>
    </item>
    <item>
      <title>@Pseudomodo Totally agree with timings.&amp;nbsp;</title>
      <link>http://www.mapleprimes.com/posts/128104-Compiled-As-Much-As-Possible-Expression?ref=Feed:MaplePrimes:compiled as much as possible expression:Comments#comment128109</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/128104-Compiled-As-Much-As-Possible-Expression#comment128108"&gt;@Pseudomodo&lt;/a&gt; &lt;br&gt;Totally agree with timings.&amp;nbsp; Those remember/caching goes god know where. Anyway, int itself will not be faster,&amp;nbsp; of course, but message is, that you can directly compile other non-int part. And timings then should be average ones for every procedure with respect to different orders (and restart of course within every order change). But i thought it's unesrtood.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;About lexical scoping: the idea is to minimize lexical scoping itsef (i didn't say that it becomes 0 at all). For relatively long H it will be essential. You understand that say string x86 instructions (movs, and so on) are muuch slower than even fpu instructions. Besides no operators grabbing will be present (while operands will be present in both cases).&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, compiled as much as possible expression</description>
      <guid>128109</guid>
      <pubDate>Fri, 25 Nov 2011 21:03:25 Z</pubDate>
      <itunes:author>icegood</itunes:author>
      <author>icegood</author>
    </item>
    <item>
      <title>update</title>
      <link>http://www.mapleprimes.com/posts/128104-Compiled-As-Much-As-Possible-Expression?ref=Feed:MaplePrimes:compiled as much as possible expression:Comments#comment128281</link>
      <itunes:summary>&lt;p&gt;&lt;a href="/view.aspx?sf=128281/426071/ex.mw"&gt;ex.mw&lt;/a&gt;&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, compiled as much as possible expression</description>
      <guid>128281</guid>
      <pubDate>Thu, 01 Dec 2011 09:28:05 Z</pubDate>
      <itunes:author>icegood</itunes:author>
      <author>icegood</author>
    </item>
  </channel>
</rss>