MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NDSolve with (compiled) numerical functions

  • To: mathgroup at
  • Subject: [mg78011] Re: NDSolve with (compiled) numerical functions
  • From: "Michael Weyrauch" <michael.weyrauch at>
  • Date: Thu, 21 Jun 2007 05:46:30 -0400 (EDT)
  • References: <f5arol$974$>


yes, of course, this is possible. I solved some rather complicated (huge) system of
ODE's using Compile[] to define them , and it works perfectly. In this case I could compare with
some code written in C using standard numerical libraries, and after some tweaking of
the Mathematica code, it was only slightly slower than the C code. 
(Huge means about 100000 coupled equations in my case.)

It is, however, very important to make sure that the Compile really is done properly. Not everything
in Mathematica compiles. It may be worth the effort to inspect the Compiled code in order to check
that it really does not fall back to standard Mathematica evaluation. If this happens, it  may get very slow...

Michael Weyrauch

<stefan.floerchinger at> schrieb im Newsbeitrag news:f5arol$974$1 at
> Dear Newsgroup
> Is it possible to solve (ordinary, first order, coupled) Differential
> equations numericaly with NDSolve, if the "right hand side" of the
> equation is given as a numerical, compiled function? To be concrete,
> my equations have the form
> x'[t] == beta_x[ t, x[t], y[t], z[t], ...]
> y'[t] == beta_y[ t, x[t], y[t], z[t], ...]
> z'[t] == beta_z[ t, x[t], y[t], z[t], ...]
> ...
> The functions beta_x, beta_y etc. are very complicated objects. I
> would like to compile them in advance or perhaps use mathlink to
> evaluate them externally.
> Best regards
> Stefan

  • Prev by Date: Re: question
  • Next by Date: Mind+Mathematica
  • Previous by thread: NDSolve with (compiled) numerical functions
  • Next by thread: v5.2 preferred for stability over v6.0