<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Any way to reclaim NAG (_d01akc) allocated memory ?</title>
    <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Sat, 13 Jun 2026 02:19:26 GMT</lastBuildDate>
    <pubDate>Sat, 13 Jun 2026 02:19:26 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Any way to reclaim NAG (_d01akc) allocated memory ?</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Any way to reclaim NAG (_d01akc) allocated memory ?</title>
      <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated</link>
    </image>
    <item>
      <title>Some observations</title>
      <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated?ref=Feed:MaplePrimes:Any way to reclaim NAG (_d01akc) allocated memory ?:Comments#answer128598</link>
      <itunes:summary>&lt;pre&gt;Some observations, while waiting for more, specific informations about your task.&lt;br&gt;&lt;br&gt;Let me write w for your variable dz, being positive and large.&lt;br&gt;&lt;br&gt;Your kmin is positive and small, so you do not need 'piecewise' in the definition&lt;br&gt;for your function f.&lt;br&gt;&lt;br&gt;Also I would avoid to involve 'evalhf' in its definition, the NAG routine will do&lt;br&gt;that for you, if possible.&lt;br&gt;&lt;br&gt;Roughly your kmax turns out to be of magnitude ~ 30*Pi and your task writes as&lt;br&gt;&lt;br&gt;&amp;nbsp; Int(F(k)*cos(k*w),k = kmin .. kmax) for F = k -&amp;gt; BK0(k*rho1)/BK0(k*a)&lt;br&gt;&lt;br&gt;So it is a finite cosine transform.&lt;br&gt;&lt;br&gt;If w is large, then this may be a highly oscillating integrand - already for the&lt;br&gt;cosinus term. And if F is oscillating as well (BK0 = BesselK ?) this may even be&lt;br&gt;worse. But that heavily depends on the concrete setting (if F has poles ...).&lt;br&gt;&lt;br&gt;Changing coordinates w = t*Pi/k it becomes&lt;br&gt;&lt;br&gt;&amp;nbsp; Pi/w * Int( F(t*Pi/w) * cos(t*Pi), t = 1/2 .. kmax/Pi*w )&lt;br&gt;&lt;br&gt;so the upper bound is roughly 30*w and w is large.&lt;br&gt;&lt;br&gt;There are special methods for these highly oscillating integrals, it may be that&lt;br&gt;NAG's method as 'working horse' is not appropriate.&lt;/pre&gt;</itunes:summary>
      <description>&lt;pre&gt;Some observations, while waiting for more, specific informations about your task.&lt;br&gt;&lt;br&gt;Let me write w for your variable dz, being positive and large.&lt;br&gt;&lt;br&gt;Your kmin is positive and small, so you do not need 'piecewise' in the definition&lt;br&gt;for your function f.&lt;br&gt;&lt;br&gt;Also I would avoid to involve 'evalhf' in its definition, the NAG routine will do&lt;br&gt;that for you, if possible.&lt;br&gt;&lt;br&gt;Roughly your kmax turns out to be of magnitude ~ 30*Pi and your task writes as&lt;br&gt;&lt;br&gt;&amp;nbsp; Int(F(k)*cos(k*w),k = kmin .. kmax) for F = k -&amp;gt; BK0(k*rho1)/BK0(k*a)&lt;br&gt;&lt;br&gt;So it is a finite cosine transform.&lt;br&gt;&lt;br&gt;If w is large, then this may be a highly oscillating integrand - already for the&lt;br&gt;cosinus term. And if F is oscillating as well (BK0 = BesselK ?) this may even be&lt;br&gt;worse. But that heavily depends on the concrete setting (if F has poles ...).&lt;br&gt;&lt;br&gt;Changing coordinates w = t*Pi/k it becomes&lt;br&gt;&lt;br&gt;&amp;nbsp; Pi/w * Int( F(t*Pi/w) * cos(t*Pi), t = 1/2 .. kmax/Pi*w )&lt;br&gt;&lt;br&gt;so the upper bound is roughly 30*w and w is large.&lt;br&gt;&lt;br&gt;There are special methods for these highly oscillating integrals, it may be that&lt;br&gt;NAG's method as 'working horse' is not appropriate.&lt;/pre&gt;</description>
      <guid>128598</guid>
      <pubDate>Sat, 10 Dec 2011 19:53:44 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>gc</title>
      <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated?ref=Feed:MaplePrimes:Any way to reclaim NAG (_d01akc) allocated memory ?:Comments#answer128622</link>
      <itunes:summary>&lt;p&gt;Run gc()! Already checked on EvalMapleProc from c. It works.&lt;/p&gt;
&lt;p&gt;P.S. Problem not in neither evalhf nor in &lt;span class="mainBody document"&gt; _d01akc&lt;/span&gt; itself. &lt;span class="mainBody document"&gt;NAG &lt;/span&gt;itself is very good. Problem in native eval environment. And you must eun evalf because Int itself&amp;nbsp; not accesible from evalhf environment.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Run gc()! Already checked on EvalMapleProc from c. It works.&lt;/p&gt;
&lt;p&gt;P.S. Problem not in neither evalhf nor in &lt;span class="mainBody document"&gt; _d01akc&lt;/span&gt; itself. &lt;span class="mainBody document"&gt;NAG &lt;/span&gt;itself is very good. Problem in native eval environment. And you must eun evalf because Int itself&amp;nbsp; not accesible from evalhf environment.&lt;/p&gt;</description>
      <guid>128622</guid>
      <pubDate>Sun, 11 Dec 2011 18:09:28 Z</pubDate>
      <itunes:author>icegood</itunes:author>
      <author>icegood</author>
    </item>
    <item>
      <title>thoughts</title>
      <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated?ref=Feed:MaplePrimes:Any way to reclaim NAG (_d01akc) allocated memory ?:Comments#answer128698</link>
      <itunes:summary>&lt;p&gt;I think you need not care so much for memory (if you are in Maple), &lt;br&gt;the system should care. Have you tried 'forget'?&lt;/p&gt;
&lt;p&gt;For BesselK 0: you can try evalhf'ing Ooura's code (or even compile it).&lt;/p&gt;
&lt;p&gt;The usual way for such tasks is to approximate F =BK0(..)/BK0(...).&lt;br&gt;If your a and rho are constant that could be done once.&lt;/p&gt;
&lt;p&gt;Since that F is like exp * 1/k one could try a ChebPade approximation&lt;br&gt;(I think, that is what Ooura does in some sense).&lt;/p&gt;
&lt;p&gt;If one 'factors' it into partial fractions over the Reals, then Maple can&lt;br&gt;find Int( F*cos ) symbolically in terms of &lt;a href="http://www.maplesoft.com/support/help/search.aspx?term=Si,"&gt;?Si,&lt;/a&gt; &lt;a href="http://www.maplesoft.com/support/help/search.aspx?term=Ci"&gt;?Ci&lt;/a&gt; and that evaluation&lt;br&gt;will be fast (and would avoid special methods for high oscillations).&lt;/p&gt;
&lt;p&gt;PS: I do not understand, why replying to a post sometimes works&lt;br&gt;and sometimes creates a new branch in the thread ... :-(&lt;br&gt;Can some admin shift it place, please ...&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;I think you need not care so much for memory (if you are in Maple), &lt;br&gt;the system should care. Have you tried 'forget'?&lt;/p&gt;
&lt;p&gt;For BesselK 0: you can try evalhf'ing Ooura's code (or even compile it).&lt;/p&gt;
&lt;p&gt;The usual way for such tasks is to approximate F =BK0(..)/BK0(...).&lt;br&gt;If your a and rho are constant that could be done once.&lt;/p&gt;
&lt;p&gt;Since that F is like exp * 1/k one could try a ChebPade approximation&lt;br&gt;(I think, that is what Ooura does in some sense).&lt;/p&gt;
&lt;p&gt;If one 'factors' it into partial fractions over the Reals, then Maple can&lt;br&gt;find Int( F*cos ) symbolically in terms of &lt;a href="http://www.maplesoft.com/support/help/search.aspx?term=Si,"&gt;?Si,&lt;/a&gt; &lt;a href="http://www.maplesoft.com/support/help/search.aspx?term=Ci"&gt;?Ci&lt;/a&gt; and that evaluation&lt;br&gt;will be fast (and would avoid special methods for high oscillations).&lt;/p&gt;
&lt;p&gt;PS: I do not understand, why replying to a post sometimes works&lt;br&gt;and sometimes creates a new branch in the thread ... :-(&lt;br&gt;Can some admin shift it place, please ...&lt;/p&gt;</description>
      <guid>128698</guid>
      <pubDate>Tue, 13 Dec 2011 01:56:28 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>I think I have the solution to my problem</title>
      <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated?ref=Feed:MaplePrimes:Any way to reclaim NAG (_d01akc) allocated memory ?:Comments#answer128703</link>
      <itunes:summary>&lt;p&gt;I think I have the solution to my problem to this unusual memory consumption.&lt;br&gt;This is not elegant in the mathematical sense but practical.&lt;br&gt;&lt;br&gt;in evalf(Int(f, kmin..kmax, method = _d01akc,epsilon=eps,maxintervals=1000000))&lt;br&gt;&lt;br&gt;maxintervals=1000000 appears to create&amp;nbsp;the problem. I will never use it again.&lt;br&gt;&lt;br&gt;I used &lt;br&gt;&lt;br&gt;evalf(Int(f, kmin..kmax, method = _d01akc,epsilon=eps) # eps =1e-12&lt;br&gt;&lt;br&gt;and divided the interval kmin..kmax in subintervals not presenting more than 2000 oscillations&lt;br&gt;and avoiding this way the default maximum subinterval limit of 500&amp;nbsp;in _d01akc.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Thank you for your support and good advice.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;I think I have the solution to my problem to this unusual memory consumption.&lt;br&gt;This is not elegant in the mathematical sense but practical.&lt;br&gt;&lt;br&gt;in evalf(Int(f, kmin..kmax, method = _d01akc,epsilon=eps,maxintervals=1000000))&lt;br&gt;&lt;br&gt;maxintervals=1000000 appears to create&amp;nbsp;the problem. I will never use it again.&lt;br&gt;&lt;br&gt;I used &lt;br&gt;&lt;br&gt;evalf(Int(f, kmin..kmax, method = _d01akc,epsilon=eps) # eps =1e-12&lt;br&gt;&lt;br&gt;and divided the interval kmin..kmax in subintervals not presenting more than 2000 oscillations&lt;br&gt;and avoiding this way the default maximum subinterval limit of 500&amp;nbsp;in _d01akc.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Thank you for your support and good advice.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/p&gt;</description>
      <guid>128703</guid>
      <pubDate>Tue, 13 Dec 2011 03:50:56 Z</pubDate>
      <itunes:author>Louis Lamarche</itunes:author>
      <author>Louis Lamarche</author>
    </item>
    <item>
      <title>played with it, again</title>
      <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated?ref=Feed:MaplePrimes:Any way to reclaim NAG (_d01akc) allocated memory ?:Comments#answer128743</link>
      <itunes:summary>&lt;pre&gt;Using Ooura's intdeo (for oscillating factors) and Maple's BesselK I get &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10940&lt;strong&gt;8&lt;/strong&gt;897877946e-3 &lt;br&gt;(or -0.10940&lt;strong&gt;8&lt;/strong&gt;897877997e-3 depending on treating the tail towards infinity)&lt;br&gt;&lt;br&gt;while the reported Maple result through NAG + Ooura's BesselK0 is&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10940&lt;strong&gt;3&lt;/strong&gt;613457678e-3&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;intdeo&lt;/span&gt; is his implementation for 'double exponential integration'&lt;br&gt;for oscillating factors to an integrand g(x) * sin(omega * x + theta)&lt;br&gt;where one provides the function g and frequency = omega = dz,&lt;br&gt;integrals are taken over a range ] constant ... infinity [&lt;/pre&gt;</itunes:summary>
      <description>&lt;pre&gt;Using Ooura's intdeo (for oscillating factors) and Maple's BesselK I get &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10940&lt;strong&gt;8&lt;/strong&gt;897877946e-3 &lt;br&gt;(or -0.10940&lt;strong&gt;8&lt;/strong&gt;897877997e-3 depending on treating the tail towards infinity)&lt;br&gt;&lt;br&gt;while the reported Maple result through NAG + Ooura's BesselK0 is&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10940&lt;strong&gt;3&lt;/strong&gt;613457678e-3&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;intdeo&lt;/span&gt; is his implementation for 'double exponential integration'&lt;br&gt;for oscillating factors to an integrand g(x) * sin(omega * x + theta)&lt;br&gt;where one provides the function g and frequency = omega = dz,&lt;br&gt;integrals are taken over a range ] constant ... infinity [&lt;/pre&gt;</description>
      <guid>128743</guid>
      <pubDate>Wed, 14 Dec 2011 02:01:03 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>Conclusions</title>
      <link>http://www.mapleprimes.com/questions/128564-Any-Way-To-Reclaim-NAG-d01akc-Allocated?ref=Feed:MaplePrimes:Any way to reclaim NAG (_d01akc) allocated memory ?:Comments#answer128778</link>
      <itunes:summary>&lt;p&gt;1) Dont use &lt;strong&gt;maxintervals&lt;/strong&gt;, you will eat all your memory (onless you have only one value to compute).&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Split the integration interval&lt;br&gt;2) The results for this case appears good with a relative difference of 1.2e-10.&lt;br&gt;&lt;br&gt;The kmin=0.000224399475256414 to kmax =91.5632886852008 was splitted in 52 intervals.&lt;br&gt;NAG (_d01akc) + Ooura's BK0 now gives -0.0001094036134482&lt;strong&gt;12&lt;/strong&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compared with the previous one&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;-0.0001094036134&lt;strong&gt;57678&lt;/strong&gt;&amp;nbsp; obtained with maxintervals=1000000&lt;br&gt;&lt;br&gt;putting kl=kmax in the following expression for the tail of the integral form kmax to infinity&lt;br&gt;with the more precise values for&amp;nbsp;&lt;br&gt;&lt;br&gt;rho1=0.323147799002253 and a = 0.01785 and dz=7000&lt;/p&gt;
&lt;p&gt;&lt;img class="math" src="http://www.mapleprimes.com/MapleImage.ashx?f=93042debee0d5c1983ed6457118c925c.gif" alt="sqrt(a/rho1)*(cos(kl*dz)*(rho1-a)-sin(kl*dz)*dz)*exp(-kl*(rho1-a))/((rho1-a)^2+dz^2)"&gt;&lt;/p&gt;
&lt;p&gt;I obtain NAG (_d01akc) + Ooura's BK0 kmin..infinity = &amp;minus;0.0001094036134482&lt;strong&gt;36&lt;br&gt;&lt;br&gt;&lt;/strong&gt;Axel Vogt used used &lt;strong&gt;a=0.323&lt;/strong&gt; and obtained&amp;nbsp; intdeo + BesselK(0,x) : -0.0001094088978&lt;strong&gt;77997&lt;/strong&gt;&lt;br&gt;For this case Ooura BK0 + NAG(_d01akc) gives&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.0001094088978&lt;strong&gt;65057&lt;br&gt;&lt;br&gt;&lt;/strong&gt;This appears coherent.&lt;br&gt;&lt;br&gt;Again thanks a lot for your help.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;1) Dont use &lt;strong&gt;maxintervals&lt;/strong&gt;, you will eat all your memory (onless you have only one value to compute).&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Split the integration interval&lt;br&gt;2) The results for this case appears good with a relative difference of 1.2e-10.&lt;br&gt;&lt;br&gt;The kmin=0.000224399475256414 to kmax =91.5632886852008 was splitted in 52 intervals.&lt;br&gt;NAG (_d01akc) + Ooura's BK0 now gives -0.0001094036134482&lt;strong&gt;12&lt;/strong&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compared with the previous one&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;-0.0001094036134&lt;strong&gt;57678&lt;/strong&gt;&amp;nbsp; obtained with maxintervals=1000000&lt;br&gt;&lt;br&gt;putting kl=kmax in the following expression for the tail of the integral form kmax to infinity&lt;br&gt;with the more precise values for&amp;nbsp;&lt;br&gt;&lt;br&gt;rho1=0.323147799002253 and a = 0.01785 and dz=7000&lt;/p&gt;
&lt;p&gt;&lt;img class="math" src="http://www.mapleprimes.com/MapleImage.ashx?f=93042debee0d5c1983ed6457118c925c.gif" alt="sqrt(a/rho1)*(cos(kl*dz)*(rho1-a)-sin(kl*dz)*dz)*exp(-kl*(rho1-a))/((rho1-a)^2+dz^2)"&gt;&lt;/p&gt;
&lt;p&gt;I obtain NAG (_d01akc) + Ooura's BK0 kmin..infinity = &amp;minus;0.0001094036134482&lt;strong&gt;36&lt;br&gt;&lt;br&gt;&lt;/strong&gt;Axel Vogt used used &lt;strong&gt;a=0.323&lt;/strong&gt; and obtained&amp;nbsp; intdeo + BesselK(0,x) : -0.0001094088978&lt;strong&gt;77997&lt;/strong&gt;&lt;br&gt;For this case Ooura BK0 + NAG(_d01akc) gives&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.0001094088978&lt;strong&gt;65057&lt;br&gt;&lt;br&gt;&lt;/strong&gt;This appears coherent.&lt;br&gt;&lt;br&gt;Again thanks a lot for your help.&lt;/p&gt;</description>
      <guid>128778</guid>
      <pubDate>Wed, 14 Dec 2011 21:55:13 Z</pubDate>
      <itunes:author>Louis Lamarche</itunes:author>
      <author>Louis Lamarche</author>
    </item>
  </channel>
</rss>