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


Groups > comp.soft-sys.math.mathematica > #11417

Re: NIntegrate and replacements

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: NIntegrate and replacements
Date 2012-08-19 00:41 +0000
Message-ID <k0pcni$e34$1@smc.vnet.net> (permalink)
References <20120818074724.7753D6862@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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@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
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: NIntegrate and replacements Bob Hanlon <hanlonr357@gmail.com> - 2012-08-19 00:41 +0000

csiph-web