Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11415 > unrolled thread

Re: NIntegrate and replacements

Started byBill Rowe <readnews@sbcglobal.net>
First post2012-08-19 00:37 +0000
Last post2012-08-19 00:37 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: NIntegrate and replacements Bill Rowe <readnews@sbcglobal.net> - 2012-08-19 00:37 +0000

#11415 — Re: NIntegrate and replacements

FromBill Rowe <readnews@sbcglobal.net>
Date2012-08-19 00:37 +0000
SubjectRe: NIntegrate and replacements
Message-ID<k0pcfu$e2l$1@smc.vnet.net>
On 8/18/12 at 3:47 AM, kravcov.msu@gmail.com (S-Tat) wrote:

>I have a simple question. There is my code, it integrates a function
>which is a solution of the equation:

>bc[r_, x_] := r + x^2;
>sol[r_] := Re[x /. FindRoot[bc[r, x] == 0, {x, 1.1 + I}]];
>NIntegrate[sol[r], {r, 1, 8}]

Change the definition for sol to be

sol[r_?NumericQ]:=Re[x /. FindRoot[bc[r, x] == 0, {x, 1.1 + I}]]

THe problem with your code is Mathematica wants to evaluate
sol[r] before r is given a numeric value by NIntegrate causing
the error. Adding the test ?NumericQ prevents sol from returning
values when non-numeric arguments are supplied.

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web