MathGroup Archive 2013

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

Search the Archive

Increasing precision in FindRoot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131232] Increasing precision in FindRoot
  • From: Samuel Mark Young <sy81 at sussex.ac.uk>
  • Date: Wed, 19 Jun 2013 01:28:50 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

I'm trying to use FindRoot to solve an integral equation. The code I'm using is below.

Defining some variables:


Wvalues = Range[0.1, 1, 0.1];

xCritical = zSol/. {z -> 1, W -> Wvalues[[n]]};
  yCritical =xCritical/=F3;


Essentially, xCritical gives the solutions to some equation (don't worry too much about the actual equation - it just returns one positive and one negative number, say 3 and -5). Then I make the change to a variable y, which is a Gaussian variable with variance 1. I want to solve this for a number of different values for W - which is why I have defined a set containing different values of W, in the full code, a loop repeats this calculation for different values of n.


I then want to use FindRoot to solve the equation below to find sigma


=F3 /. FindRoot[(1/(Sqrt[2 Pi])) (Integrate[
       Exp[-(y^2)/2], {y, yCritical[[2]], infinity}] +
      Integrate[Exp[-(y^2)/2], {y, -infinity, yCritical[[1]]}]) == (10^-5), {=F3, 0.0001,
    10}]


This works fine, and gives the correct results - I only include it to give context to the problem, and so that you can say which bits of code I need to change to increase precision. Where I run into problems is when I want to solve for 10^-20 instead:


=F3 /. FindRoot[(1/(Sqrt[2 Pi])) (Integrate[
       Exp[-(y^2)/2], {y, yCritical[[2]], infinity}] +
      Integrate[Exp[-(y^2)/2], {y, -infinity, yCritical[[1]]}]) == (10^-20), {=F3, 0.0001,
    10}]


Underflow occurs a lot here. Mathematica seems to be having problems with the small numbers. What changes do I need to make in order to be able to solve for 10^-20? I need something that will work automatically with zero input from me - people have recommended plotting graphs first to find approx solutions etc, which I don't have time to do as I want to run this for a lot of cases. Note that I only need sigma to be found to 5 signficant figures.


I've tried fiddling around with WorkingPrecision, PrecisionGoal, and AccuracyGoal - but could be missing something simple, or another way of asking Mathematica to solve the equation. I had a similar problem when I was working with anther system - and that was cleared up just by telling it to work to 40 digits of precision with one line at the start of the code, but doesn't seem to work with Mathematica.


Thank you for any help, please contact me sy81 at sussex.ac.uk with any questions.


Regards,

Sam Young


  • Prev by Date: Re: Axes in Plot3D and ListPlot3D
  • Next by Date: Re: Increasing precision in FindRoot
  • Previous by thread: Re: Axes in Plot3D and ListPlot3D
  • Next by thread: Re: Increasing precision in FindRoot