Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg21861] Re: [mg21848] NDSolve and numeric-only computation
  • From: "Benjamin A. Jacobson" <bjacobson at illumitech.com>
  • Date: Wed, 2 Feb 2000 22:54:18 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I see this sort of thing a lot when using NDSolve with complicated
expressions, and particularly when evaluating RHS includes functions like
FindRoot, which cannot be evaluated symbolically.  The trick is to suppress
evaluation when the argument of RHS is symbolic.  You can do this by
defining RHS only for numeric arguments:

RHS[arg_?NumericQ]:=...

I'm not sure why this is necessary, but it is.  I surmise that NDSolve
initially attempts to evaluate the expression symbolically before it begins
substituting real values.  It would be interesting to hear from anyone who
really understands this.

Ben Jacobson
At 06:53 PM 1/30/00 -0500, you 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: Double-sided printing, one side at a time ....
  • Next by Date: Re: Problem with definite integrals having symbolic limits
  • Previous by thread: Re: NDSolve and numeric-only computation
  • Next by thread: Creating Raster Image Animation