MathGroup Archive 2001

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

Search the Archive

Re: NIntegrate embedded in a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28138] Re: NIntegrate embedded in a function
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sun, 1 Apr 2001 00:08:01 -0500 (EST)
  • References: <9a43r9$ctl@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mike,

This only constructe the NIntegrate[...] for acceptable x, numbers.
I have put in some extra options to deal with precision problems - no
guarantee that these are the best to use.

foo[x_?NumberQ]:= NIntegrate[Cos[y^2],{y,0,x}]

bar=FunctionInterpolation[foo[z],{z,0,10},
    InterpolationPrecision->2,
    PrecisionGoal\[Rule]2
    ]

InterpolatingFunction[{{0.,10.}},<>]

Plot[bar[x],{x,0,10}, PlotRange\[Rule]All]

But the above approach does a lot of work: why not use NDSolve?

bar2= y/.(NDSolve[{y'[x]==Cos[x^2],y[0]\[Equal]0},y,{x,0,10}][[1]])

InterpolatingFunction[{{0.,10.}},<>]

Plot[bar2[x],{x,0,10}, PlotRange\[Rule]All]

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Mike Yukish" <may106 at psu.edu> wrote in message
news:9a43r9$ctl at smc.vnet.net...
> I want to write a function along the lines of...
>
> foo[x_] := NIntegrate[Cos[y^2],{y,0,x}]
>
> so the function argument is the limit of the integral. Then make a
> surrogate for it...
>
> bar = FunctionInterpolation[foo[z],{z,0,10}]
>
> This works, and I get a bar[ ] function that matches foo[ ] over the
> domain, but first I get a whole bunch of errors along the lines of....
>
> NIntegrate::nlim : "y = z is not a valid limit of integration."
>
> Is there any way to avoid these errors other than turning them off? Some
> sort of evaluation order trickery?
>
>
>
>




  • Prev by Date: RE: Re: Defining a flat, orderless, one-identical function?
  • Next by Date: Novice question regarding variable naming and subscripts
  • Previous by thread: Re: NIntegrate embedded in a function
  • Next by thread: raster formats