Re: NIntegrate and replacements
- To: mathgroup at smc.vnet.net
- Subject: [mg127753] Re: NIntegrate and replacements
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Sat, 18 Aug 2012 20:36:13 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20120818074724.7753D6862@smc.vnet.net>
bc[r_, x_] := r + x^2;
"NIntegrate symbolically analyzes its input to transform oscillatory
and other integrands, subdivide piecewise functions, and select
optimal algorithms." Since sol uses numerical techniques it must be
restricted to numerical inputs.
sol[r_?NumericQ] :=
Re[x /. FindRoot[bc[r, x] == 0,
{x, 1.1` + I}]];
NIntegrate[sol[r], {r, 1, 8}]
1.28089*10^-18
sol2[r_] = Re[x /. Solve[bc[r, x] == 0, x]]
{Im[Sqrt[r]], -Im[Sqrt[r]]}
Integrate[sol2[r], {r, 1, 8}]
{0, 0}
Bob Hanlon
On Sat, Aug 18, 2012 at 3:47 AM, S-Tat <kravcov.msu at gmail.com> wrote:
> Hi everyone,
>
> 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}]
>
>
> Trying this code, I got these messages:
>
> FindRoot::nlnum: "The function value {(0.21 +2.2\ I)+r}\\n is not a list of numbers with dimensions {1} at {epseff} = {1.1 +1.` I}"
>
> ReplaceAll::reps: "{FindRoot[bc[r,epseff]==0,{epseff,1.1 +I}]}\\n is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing"
>
> Sorry if it's too dumb but I cannot see why NIntegrate couldn't just use exact value for r every time. Isn't it how numerical integration is supposed to work?
>
> Thank you
>
- References:
- NIntegrate and replacements
- From: S-Tat <kravcov.msu@gmail.com>
- NIntegrate and replacements