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

Evaluate and HoldAll

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24219] Evaluate and HoldAll
  • From: Andre Heinemann <andre at aflo4.ifw-dresden.de>
  • Date: Sat, 1 Jul 2000 03:21:50 -0400 (EDT)
  • Organization: IFW
  • Sender: owner-wri-mathgroup at wolfram.com

Hi mathgroup

Attributes[NIntegrate] gives: {HoldAll, Protected}

In THE BOOK (or online Help) one can find:

*****************************************************************************

*You can use Evaluate to evaluate the arguments of a HoldAll function in
a controlled way.  *
*****************************************************************************

So I built:

rseq = Sequence[a1, a2, a3]
lseq = Sequence[a1_?NumericQ, a2_?NumericQ, a3_?NumericQ]

My Function f[r, rseq]

gives the output: (e.g.) a1 Exp[a2 - a3 r]
(I know that I can use Integrate here, instead of Nintegrate but it is
for testing)

Clear[test]
test[q_, lseq] := NIntegrate[Evaluate[f[r, rseq]], {r, 0, 10^5}]

test[0.1, 1, 0.2, 0.5 ]  presented:

NIntegrate::"inum" :  ... Integrand ... is not numerical at r = .... and
so on

NIntegrate[f[r, rseq],{r, 0, 10^5}]

Ok, I can see that the integrand is not numerical  and so I tried:

Clear[test]
test[q_, lseq] := NIntegrate[a1 Exp[a2 - a3 r] , {r, 0, 10^5}] and

test[0.1, 1, 0.2, 0.5 ] works very well and finds: 2.442805516320 as the
answer !

What is the point here ? I think my understanding of Evaluate[] is false
but
how can I solve the problem ?

I would be glad to have an explanation or a hint.

Andre

--
+-----------------------------------+-----------------------------+
| mobil tel.   --------------       |  Andre Heinemann            |
| priv. tel.   (0351) 25 23 574     |  Institut fuer Festkoerper- |
| Tel.: (++49) (351) 4659 - 686     |  und Werkstofforschung      |
| Fax:  (++49) (351) 4659 - 452     |  Helmholtzstr. 20, R2.140   |
| email: a.heinemann at ifw-dresden.de |  Postfach 27 00 16          |
|                                   |  D-01171 Dresden (Germany)  |
+-----------------------------------+-----------------------------+



  • Prev by Date: Re: Unix Sound Problems
  • Next by Date: RE: making a plane
  • Previous by thread: Re: Unix Sound Problems
  • Next by thread: Re: Evaluate and HoldAll