Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: Re: NIntegrate-FindRoot acting up in version 5.1

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57106] Re: [mg57006] Re: NIntegrate-FindRoot acting up in version 5.1
  • From: "John Roberts" <jlr-d at jlr-d.cnc.net>
  • Date: Mon, 16 May 2005 01:29:48 -0400 (EDT)
  • References: <d5sja8$nm3$1@smc.vnet.net> <200505120633.CAA08913@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hello Anton:

Thanks for your help! The input changes with ?NumberQ that you suggested 
worked, NIntegrate in Mathematica 5.1 now gets the correct result with no error 
messages or warnings.

About the only difference I can see now between Mathematica 5.1 and 4.1
when doing numerical calculations is when I do a double integral with
NIntegrate in Mathematica 5.1 it issues a single inum warning about the
integrand of the inner integral not being numerical --but it keeps running
and gets the correct result, so it does not appear to be anything serious.

----- Original Message ----- 
From: "antononcube" <antononcube at gmail.com>
To: mathgroup at smc.vnet.net
Subject: [mg57106] [mg57006] Re: NIntegrate-FindRoot acting up in version 5.1


> Hi,
>
> Your problem might be solved if you define a function, like
>
> fang[ang_?NumberQ]:= (eqn = FindRoot[ len == c b r / v, {b, 0},
> WorkingPrecision->100, AccuracyGoal->80 ] ; beta = b  /.  eqn;  fnax)
>
> and use the command
>
> NIntegrate[fang[ang], {ang,  0,  3Pi/2,  2Pi},  WorkingPrecision->80,
> AccuracyGoal->9 ]
>
> I hope this will work (can't say without the actual inputs).
>
> Anton Antonov,
> Wolfram Research, Inc.
>
>
> John Roberts wrote:
>> I originally made the input shown below in Mathematica 4.1.1. Version
>
>> 4.1.1 ran it flawlessly and always produced the correct result from
>> NIntegrate with no warnings or error messages. Now, when I run the
> same
>> notebook with version 5.1.0 it crashes and gives the "FindRoot:
> :nlnum"
>> message shown below:
>>
>> In1:   len = Sqrt[ (z^2 + (x Cos[ang] + r Sin[b] )^2  + (-r Cos[b] -
> x
>> Sin[ang])^2 ] ;
>>
>> In2:  speed = NIntegrate[ (eqn = FindRoot[ len == c b r / v, {b,
>> 0}, WorkingPrecision->100,
>>         AccuracyGoal->80 ] ; beta = b  /.  eqn;  fnax) , {ang,  0,
>> 3Pi/2,  2Pi},  WorkingPrecision->80,  AccuracyGoal->9 ]
>>
>> Out2: FindRoot: :nlnum : The function value {0. + Sqrt[0.0172266 +
> (0. +
>> 0.05 <<1>>)^2 + (-0.125 - 0.05 Sin[<<1>>])^2]
>>          is not a list of numbers with dimensions {1} at {b} = {0.}.
>>
>> As can be seen from the input shown above, NIntegrate integrates the
>> expression fnax with respect to the angle ang. But fnax is also a
>> function of the initial angle beta or b (beta = b), so each time
>> NIntegrate calculates the value of fnax it must first use FindRoot to
>
>> find the value of beta that corresponds to the value of ang that it
> is
>> using. I did not include the expression for fnax here because it is
>> rather large, but there is nothing exotic about fnax, it is just a
> lot
>> of terms with Sin and Cos functions.
>>
>> All of the values z, x, r, c v are input with 120 decimal places of
>> precision or with infinite precision (no decimal point).
>>
>> It should also be noted that I checked the FindRoot part alone
> (without
>> NIntegrate) at various points along the range of integration from ang
>
>> = 0 to ang = 2 Pi, and FindRoot got the correct value of beta at
>> every point with no warnings or error messages; so the problem
> appears
>> to be associated with how NIntegrate uses FindRoot in Mathematica 5.1
>
>> rather than with FindRoot itself.
>>
>>
>> Thanks in advance for any help you can give me,
>>
>> John R.
>
>
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.11.8 - Release Date: 5/10/2005
>
> 


  • Prev by Date: Vector of functions in ordinary differential equations
  • Next by Date: Re: Integrate gives wrong answer
  • Previous by thread: Re: NIntegrate-FindRoot acting up in version 5.1
  • Next by thread: Re: Re: Folding Deltas, and evaluation scheme of Mathematica