MathGroup Archive 2007

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

Search the Archive

Re: a problem about NDSolve and NIntegrate


lynn wrote:
> I'm tring to solve a diffrential equation with
> 
> its upper boundary as a variable.
> 
> and then I want to integrate it, and define
> 
> it as a funcion with two variable.
> 
> However, I don't know why it doesn't work at the second step.
> 
> 
> my equation is as following,
> 
> f[c_?NumberQ]:=y[x]/.NDSolve[{eqn,y[0]==1,y'[0]==0},y,{x,0,c},MaxSteps-
>> 10000][[1]]
> 
> n[w_NumberQ,c_NumberQ]:=NIntegrate[c*y[x]*(r-w)],{r,w,1}]
------^(1)------^(1)-----------------------------^(2)
1. To apply a test function (predicate) to a pattern, you must use an 
question mark '?' (as you did when defining f).
2. Extraneous square bracket.

A /syntacticly/ correct code is

n[w_?NumberQ, c_?NumberQ] := NIntegrate[c*y[x]*(r - w), {r, w, 1}]

<snip>

-- 
Jean-Marc


  • Prev by Date: RE: How to get the real and imaginary parts of a power series?
  • Next by Date: Re: Simplifying the exponents
  • Previous by thread: Re: a problem about NDSolve and NIntegrate
  • Next by thread: Re: a problem about NDSolve and NIntegrate