<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, generate code for numerical integral</title>
    <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Wed, 10 Jun 2026 13:23:30 GMT</lastBuildDate>
    <pubDate>Wed, 10 Jun 2026 13:23:30 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, generate code for numerical integral</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, generate code for numerical integral</title>
      <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral</link>
    </image>
    <item>
      <title>the only thing i can imagine</title>
      <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral?ref=Feed:MaplePrimes:generate code for numerical integral:Comments#answer80729</link>
      <itunes:summary>the only thing i can imagine is that Maple methods can be
worked out ... having not traced through the procs it is
clear that they involve external callings for NAG routines

what exactly are you looking for?</itunes:summary>
      <description>the only thing i can imagine is that Maple methods can be
worked out ... having not traced through the procs it is
clear that they involve external callings for NAG routines

what exactly are you looking for?</description>
      <guid>80729</guid>
      <pubDate>Mon, 15 Aug 2005 01:10:00 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>On generated code and callbacks</title>
      <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral?ref=Feed:MaplePrimes:generate code for numerical integral:Comments#answer80724</link>
      <itunes:summary>If Maple were capable of generating C code that could perform calls to evalf/Int successfully, I expect it would be done in one of three ways:

&lt;ol&gt;
&lt;li&gt;Maple would generate specific C code for evaluating this particular problem numerically&lt;/li&gt;
&lt;li&gt;Maple would generate C code with a call into some external C library&lt;/li&gt;
&lt;li&gt;Maple would generate C code with a callback to itself (probably via OpenMaple)&lt;/li&gt;
&lt;/ol&gt;

In order to do task 1) and faithfully mirror Maple's behaviour, Maple would probably have to perform some sort of partial evaluation of its routines for numerical integration.  Implementing such a thing  would be a challenging problem.

At the least, the C code one is generating would (in general) require access to a C library for infinite-precision floating-point arithmetic, and any divergences between this library's implementation and Maple's (say, in the base of the representation) might lead to differences between Maple's behaviour and that of the generated code.

Either of the solutions 2) or 3) introduces a dependency on an external library, either on Maple or some other library capable of doing numerical integration.  The existing CodeGeneration translators are designed to generate code that can be executed independently of Maple and its libraries.

In any case, it sounds like what you would like is C code that could be executed independently of Maple, just using normal C double-precision floats.  In that case, the simplest solution is probably, as others have suggested, to find a stable approximation to your integral in terms of functions expressible in C (e.g. polynomials, trig functions), generate an evaluation procedure from that using unapply, and then apply CodeGeneration:-C to that.</itunes:summary>
      <description>If Maple were capable of generating C code that could perform calls to evalf/Int successfully, I expect it would be done in one of three ways:

&lt;ol&gt;
&lt;li&gt;Maple would generate specific C code for evaluating this particular problem numerically&lt;/li&gt;
&lt;li&gt;Maple would generate C code with a call into some external C library&lt;/li&gt;
&lt;li&gt;Maple would generate C code with a callback to itself (probably via OpenMaple)&lt;/li&gt;
&lt;/ol&gt;

In order to do task 1) and faithfully mirror Maple's behaviour, Maple would probably have to perform some sort of partial evaluation of its routines for numerical integration.  Implementing such a thing  would be a challenging problem.

At the least, the C code one is generating would (in general) require access to a C library for infinite-precision floating-point arithmetic, and any divergences between this library's implementation and Maple's (say, in the base of the representation) might lead to differences between Maple's behaviour and that of the generated code.

Either of the solutions 2) or 3) introduces a dependency on an external library, either on Maple or some other library capable of doing numerical integration.  The existing CodeGeneration translators are designed to generate code that can be executed independently of Maple and its libraries.

In any case, it sounds like what you would like is C code that could be executed independently of Maple, just using normal C double-precision floats.  In that case, the simplest solution is probably, as others have suggested, to find a stable approximation to your integral in terms of functions expressible in C (e.g. polynomials, trig functions), generate an evaluation procedure from that using unapply, and then apply CodeGeneration:-C to that.</description>
      <guid>80724</guid>
      <pubDate>Mon, 15 Aug 2005 18:47:18 Z</pubDate>
      <itunes:author>Stephen Forrest</itunes:author>
      <author>Stephen Forrest</author>
    </item>
    <item>
      <title>Ooura's method</title>
      <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral?ref=Feed:MaplePrimes:generate code for numerical integral:Comments#answer80713</link>
      <itunes:summary>Once i translated Ooura's double exponential integration into
Maple (find it uploaded, but i have neither cleaned up that
port nor tested it carefully). That method is quite robust.
So you can use Maple's new ability to generate a DLL and use
that as a function directly in Maple. This might give you
some of the speed improvements you are looking for.

The additional advantage is: you can test values against Maple
if you have some doubts.

For distributions usually a Gauss-Legendre method also works
well (using fixed numbers of sub-divisions), 16 point suffice. 

What i can not see is your chi^2, i thought it contains an exp
in the integrand? Just a last thought: when i try to fit some
pdf against data (to get parameters) i pass to the logarithm
(and refine later if neccessary). If you want to fit against
a cdf then i can imagine troubles (i am not sure whether this
is a stable approach, especially if you are not absolutely
convinced that your cdf is the correct one).

PS: as i do not recognize how to attach files use that link
http://www.axelvogt.de/axalom/maple/Ooura_DoubleExp_Integration.mws</itunes:summary>
      <description>Once i translated Ooura's double exponential integration into
Maple (find it uploaded, but i have neither cleaned up that
port nor tested it carefully). That method is quite robust.
So you can use Maple's new ability to generate a DLL and use
that as a function directly in Maple. This might give you
some of the speed improvements you are looking for.

The additional advantage is: you can test values against Maple
if you have some doubts.

For distributions usually a Gauss-Legendre method also works
well (using fixed numbers of sub-divisions), 16 point suffice. 

What i can not see is your chi^2, i thought it contains an exp
in the integrand? Just a last thought: when i try to fit some
pdf against data (to get parameters) i pass to the logarithm
(and refine later if neccessary). If you want to fit against
a cdf then i can imagine troubles (i am not sure whether this
is a stable approach, especially if you are not absolutely
convinced that your cdf is the correct one).

PS: as i do not recognize how to attach files use that link
http://www.axelvogt.de/axalom/maple/Ooura_DoubleExp_Integration.mws</description>
      <guid>80713</guid>
      <pubDate>Tue, 16 Aug 2005 21:20:30 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>Ooura vs NAG</title>
      <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral?ref=Feed:MaplePrimes:generate code for numerical integral:Comments#comment86898</link>
      <itunes:summary>I am not familiar with Ooura's double exponential integration.
Is it better than the NAG method you have suggested before?

I have just attached the M9.5 worksheet that generates the 
stack limit error to the initial 
message of this thread (it seems that this is the only place
where it is possible to attach files).

An initial run in an old PC with the addition of 
method = _d01ajc seemed promising: it did not issued stack 
error message when it used to. 

As said before, I am evaluating options whether I can make 
these calculations from within Maple or eventually export 
pieces of code and run from outside.

And besides fitting I will need to make confidence intervals 
calculations for the parameters, confidence contour plots, 
etc. I am not aware of any package for this stuff within 
Maple, and sounds that I should look for that elsewhere. 

Any suggestion is also welcome.

 </itunes:summary>
      <description>I am not familiar with Ooura's double exponential integration.
Is it better than the NAG method you have suggested before?

I have just attached the M9.5 worksheet that generates the 
stack limit error to the initial 
message of this thread (it seems that this is the only place
where it is possible to attach files).

An initial run in an old PC with the addition of 
method = _d01ajc seemed promising: it did not issued stack 
error message when it used to. 

As said before, I am evaluating options whether I can make 
these calculations from within Maple or eventually export 
pieces of code and run from outside.

And besides fitting I will need to make confidence intervals 
calculations for the parameters, confidence contour plots, 
etc. I am not aware of any package for this stuff within 
Maple, and sounds that I should look for that elsewhere. 

Any suggestion is also welcome.

 </description>
      <guid>86898</guid>
      <pubDate>Wed, 17 Aug 2005 05:30:46 Z</pubDate>
      <itunes:author>jakubi</itunes:author>
      <author>jakubi</author>
    </item>
    <item>
      <title>it is not 'versus' ...</title>
      <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral?ref=Feed:MaplePrimes:generate code for numerical integral:Comments#comment90160</link>
      <itunes:summary>The posted coded is almost a naked one and as thus may be faster
(may be a Gauss method would be sufficient). But it is on you to care
whether it is appropriate - a lib like NAG is expected to do that
for you. If you are sure enough to get rid off 'overhead' ...
Personally i would look for a stable / reliable solution first and
care for tuning later.

I will look at your sheet later that evening.
</itunes:summary>
      <description>The posted coded is almost a naked one and as thus may be faster
(may be a Gauss method would be sufficient). But it is on you to care
whether it is appropriate - a lib like NAG is expected to do that
for you. If you are sure enough to get rid off 'overhead' ...
Personally i would look for a stable / reliable solution first and
care for tuning later.

I will look at your sheet later that evening.
</description>
      <guid>90160</guid>
      <pubDate>Wed, 17 Aug 2005 17:15:45 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>a question on the uploaded sheet</title>
      <link>http://www.mapleprimes.com/questions/43738-Generate-Code-For-Numerical-Integral?ref=Feed:MaplePrimes:generate code for numerical integral:Comments#comment90162</link>
      <itunes:summary>Alejandro,

Hm ... i do not have the GlobalOptimization Toolbox (=GOT ?) and
never worked with it, so can only guess what the syntax means.

Could you describe what you want to have for that 54 data points?

For me it looks like M is some regularization, the s are weights
and you want to maximize/minimize a squared sum (log likelihood?).

What is your original problem? To find beta,lambda,sigma,P,B s.th.
exp(m/r) ~ DL(z) ? What means the fct v? May be you have some plots
and typical solutions (or some values close or expected).

What i see is quite expensive, as for each evaluation of chin 54
integrals are to be computed. And if that GOT is going to look
for gradients numerical it may let you wait a long time :-)</itunes:summary>
      <description>Alejandro,

Hm ... i do not have the GlobalOptimization Toolbox (=GOT ?) and
never worked with it, so can only guess what the syntax means.

Could you describe what you want to have for that 54 data points?

For me it looks like M is some regularization, the s are weights
and you want to maximize/minimize a squared sum (log likelihood?).

What is your original problem? To find beta,lambda,sigma,P,B s.th.
exp(m/r) ~ DL(z) ? What means the fct v? May be you have some plots
and typical solutions (or some values close or expected).

What i see is quite expensive, as for each evaluation of chin 54
integrals are to be computed. And if that GOT is going to look
for gradients numerical it may let you wait a long time :-)</description>
      <guid>90162</guid>
      <pubDate>Wed, 17 Aug 2005 21:53:28 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
  </channel>
</rss>