MathGroup Archive 2007

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

Search the Archive

Re: on a pure function for a list of integrals


On 6/6/07, Ruth <ruth.lazkoz at ehu.es> wrote:
> Thanks, Jean-Marc, you suggest
>
> f = Block[{x, a = #1, b = #2},
>          (NIntegrate[Sqrt[a*x + b], {x, 0, #1}] & ) /@ #3] & ;
> f[2, 3, {0.1, 0.5, 0.9}]
>
> but I think there are assignments which are never used as
>
> In[1]:= f = Block[{x},
>          (NIntegrate[Sqrt[a*x + b], {x, 0, #1}] & ) /@ #3] & ;
> f[2, 3, {0.1, 0.5, 0.9}]
>
> gives me exactly the same result so the bit a = #1, b = #2 seems unnecessary

How much do you bet on that :-)

In[1]:= f =
  Block[{x}, (NIntegrate[Sqrt[a*x + b], {x, 0, #1}] & ) /@ #3] & ;
f[2, 3, {0.1, 0.5, 0.9}]

During evaluation of In[1]:= NIntegrate::inumr:The integrand Sqrt[b+a \
x] has evaluated to non-numerical values for all sampling points in \
the region with boundaries {{0,0.1}}. >>

During evaluation of In[1]:= NIntegrate::inumr:The integrand Sqrt[b+a \
x] has evaluated to non-numerical values for all sampling points in \
the region with boundaries {{0,0.5}}. >>

During evaluation of In[1]:= NIntegrate::inumr:The integrand Sqrt[b+a \
x] has evaluated to non-numerical values for all sampling points in \
the region with boundaries {{0,0.9}}. >>

During evaluation of In[1]:= General::stop:Further output of \
NIntegrate::inumr will be suppressed during this calculation. >>

Out[2]= {NIntegrate[Sqrt[a*x + b], {x, 0, 0.1}],
 NIntegrate[Sqrt[a*x + b],
     {x, 0, 0.5}], NIntegrate[Sqrt[a*x + b], {x, 0, 0.9}]}

Regards,
Jean-Marc


  • Prev by Date: Re: Segregating the elements of a list based on given lower and
  • Next by Date: Re: apparently I don't know how to use Map (or Apply or MapThread)
  • Previous by thread: on a pure function for a list of integrals
  • Next by thread: Value of E