Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*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 2004

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

Search the Archive

RE: SetDelayed and NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47825] RE: [mg47805] SetDelayed and NIntegrate
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 29 Apr 2004 00:33:41 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Mukhtar,

On your second question...

With[{x = 2}, Plot[w, {q, 0, 1}]]

replaces every occurrence of x in the body of the With by 2. But there are
no occurrences of x in the body of the statement. So x never gets replaced.
The following would work.

With[{x = 2}, Plot[q^x, {q, 0, 1}]]

or (it's almost always better to define expressions as functions with
arguments)..

Clear[w]
w[q_, x_] := q^x
With[{x = 2}, Plot[w[q, x], {q, 0, 1}]]

On your first question it would be nice if you gave a more complete case.
What is f[x,y]? In any case NIntegrate should evaluate to a single value and
you haven't specified enough to do that. I think you want Integrate instead.
Also, you will probably want Set, instead of DelayedSet, for g and h,
otherwise FindRoot will have to keep repeating the integration and
differentiation (I think). In a case like that you should check out each
step at a time before putting all the steps together.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Mukhtar Bekkali [mailto:mbekkali at iastate.edu]
To: mathgroup at smc.vnet.net

Very simple question.   Is it possible in Mathematica 5 to execute this
code?

f[x_,y_]:=f[x,y]  (*where f[x,y] is some known function*)
g[x_]:=NIntegrate[f[x,y],{y,0,1}]
h[x_]:=D[g[x],x]
FindRoot[h[x]==0,x]

I get a message that Integrand is not numeric and FindRoot stops.   I would
like to make clear that I do not want to use Integrate.

My other question is why this code does not work

w=q^x;
With[{x=2},Plot[w,{q,0,1}]

Thanks. Mukhtar Bekkali





  • Prev by Date: Re: The unstable LinearSolve
  • Next by Date: Gaussian integration broken - bug 4
  • Previous by thread: Re: SetDelayed and NIntegrate
  • Next by thread: FindRoot cannot find obvious solution