MathGroup Archive 2000

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

Search the Archive

Re: NDSolve and numeric-only computation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21875] Re: NDSolve and numeric-only computation
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 2 Feb 2000 22:54:31 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <872j7n$cie@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Carl,

first of all. I think that your compilation by hand is done my
NDSolve[].
The problem is that you can't give a compiled function a Pattern[] for
the
argument.
But you may  define

RHS = Compile[{{x, _Real}}, x^2]

fun[x_?NumericQ] := RHS[x]

and NDSolve[] run without a prolem

NDSolve[{x'[t] == fun[x[t]], x[0] == 0}, x[t], {t, 0, 1}]

Hope that helps
  Jens

Carl Bumiller wrote:
> 
>     I have a question about NDSolve and numeric-only computation.
> 
>     First I have defined     RHS=Compile[{{x,_Real}},........]  where ........
> is some complicated expression, then I ran
>                 NDSolve[{x'[t]==RHS[x[t]],x[0]==1},{x},{t,0,1}]
> and got the error message
> 
>     CompiledFunction::cfr:
>             Cannot use compiled code;  Argument x[t] at position 1
>                 should be a machine-size real number.
> 
> This suggests that NDSolve is trying to solve symbolically rather than
> numerically.  How do I get NDSolve to evaluate RHS numerically rather
> than symbolically??   When I try Compiled->True or Compiled->False
> with NDSolve, I get the same error message.  Since RHS is complicated,
> its symbolic evaluation is time comsuming although the equation is
> eventually solved.  I am running Mathematica 3.0 for Digital Unix.
> 
> Carl Bumiller
> bumi314 at aol.com


  • Prev by Date: Re: How to Break[] out of nested loops?
  • Next by Date: Re: Fitting a function to a list (newbie)
  • Previous by thread: Re: How to Break[] out of nested loops?
  • Next by thread: Re: NDSolve and numeric-only computation