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


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

Re: NIntegrate and replacements

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-08-19 00:41 +0000
Last post2012-08-19 00:41 +0000
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#11417 — Re: NIntegrate and replacements

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-08-19 00:41 +0000
SubjectRe: NIntegrate and replacements
Message-ID<k0pcni$e34$1@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@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
>

[toc] | [standalone]


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


csiph-web