MathGroup Archive 2011

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

Search the Archive

Re: NDSolve and NumericQ

  • To: mathgroup at
  • Subject: [mg116335] Re: NDSolve and NumericQ
  • From: DrMajorBob <btreat1 at>
  • Date: Fri, 11 Feb 2011 04:16:05 -0500 (EST)

Here's a start:

aa[y_, s_] = Sin[y[s]] + y'[s]/s;
DSolve[{aa[y, s] == 0, y[0] == 1}, y, s]

{{y -> Function[{s}, 2 ArcCot[E^(s^2/2) Cot[1/2]]]}}


On Thu, 10 Feb 2011 04:24:34 -0600, Simon Pearce  
<Simon.Pearce at> wrote:

> Hi Mathgroup,
> I have a differential equation in terms of y[S] which contains several  
> complicated piecewise functions inside the ODE. I currently then use  
> NDSolve in order to find a solution for y. This works, but takes  about  
> 10 seconds to solve.
> I'd like to speed this up, and I'm wondering if NDSolve is trying to  
> differentiate the piecewise function explicitly, as has been mentioned  
> before in the group  
> (  
> The solution given there is to use ?NumericQ to prevent evaluation  
> without supplying the value, common enough (and an entirely separate  
> issue on the group - can't we have an option in FindRoot and related  
> functions so we can turn this off?). But I'm having trouble in doing  
> this and using NDSolve, the method I'm trying to use currently .
> So a test problem:
> AA[y_, S_?NumericQ] := Sin[y[S]] + y'[S]/S
> NDSolve[{AA[y, S] == 0, y[0] == 1}, y, {S, 0, 1}]
> Giving the error "NDSolve::dvnoarg: The function y appears with no  
> arguments", as it tries to evaluate for a general S. It works if I take  
> the ?NumericQ out of the definition, but that isn't what I'm trying to  
> do.
> As an example of a function which doesn't work if we take the ?NumericQ  
> out of the definition:
> BB[y_, S_?NumericQ] :=  Sin[y[S]] + y'[S]/S + NIntegrate[(Sqrt[t] +  
> Sin[t]), {t, 0, S}]
> NDSolve[{BB[y, S] == 0, y[0] == 1},y, {S, 0, 1}]
> Same error again.
> CC[y_, S_] :=  Sin[y[S]] + y'[S]/S + NIntegrate[(Sqrt[t] + Sin[t]), {t,  
> 0, S}]
> NDSolve[{CC[y, S] == 0, y[0] == 1},y, {S, 0, 1}]
> This gives errors on the NIntegrate which suggest to me that NDSolve is  
> doing something to the equation before putting values in for S. The  
> result is correct, but isn't immediate.
> Anyone have any idea how to do this?
> Thanks,
> Simon Pearce
> University of Nottingham
> This message and any attachment are intended solely for the addressee  
> and may contain confidential information. If you have received this  
> message in error, please send it back to me, and immediately delete  
> it.   Please do not use, copy or disclose the information contained in  
> this message or in any attachment.  Any views or opinions expressed by  
> the author of this email do not necessarily reflect the views of the  
> University of Nottingham.  This message has been checked for viruses but  
> the contents of an attachment may still contain software viruses which  
> could damage your computer system: you are advised to perform your own  
> checks. Email communications with the University of Nottingham may be  
> monitored as permitted by UK legislation.

DrMajorBob at

  • Prev by Date: Re: Another point about Mathematica 8.0
  • Next by Date: Re: Apply a rule to an expression only once
  • Previous by thread: Re: NDSolve and NumericQ
  • Next by thread: Re: NDSolve and NumericQ