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


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

Increasing precision in FindRoot

Started bySamuel Mark Young <sy81@sussex.ac.uk>
First post2013-06-19 05:23 +0000
Last post2013-06-20 08:01 +0000
Articles 2 — 2 participants

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


Contents

  Increasing precision in FindRoot Samuel Mark Young <sy81@sussex.ac.uk> - 2013-06-19 05:23 +0000
    Re: Increasing precision in FindRoot Frank K <fkampas@gmail.com> - 2013-06-20 08:01 +0000

#14940 — Increasing precision in FindRoot

FromSamuel Mark Young <sy81@sussex.ac.uk>
Date2013-06-19 05:23 +0000
SubjectIncreasing precision in FindRoot
Message-ID<kprf9b$16b$1@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@sussex.ac.uk with any questions.


Regards,

Sam Young

[toc] | [next] | [standalone]


#14942

FromFrank K <fkampas@gmail.com>
Date2013-06-20 08:01 +0000
Message-ID<kpucs9$9f5$1@smc.vnet.net>
In reply to#14940
The integrals can be done symbolically.  I'd do that and then put the result inside FindRoot.  That may help.   

[toc] | [prev] | [standalone]


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


csiph-web