Re: Increasing precision in FindRoot

*To*: mathgroup at smc.vnet.net*Subject*: [mg131233] Re: Increasing precision in FindRoot*From*: Ray Koopman <koopman at sfu.ca>*Date*: Thu, 20 Jun 2013 04:43:52 -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

Let Erfc do the integrals. Solve for Log[sigma], not sigma. x = {-5,3}; e = 10^-5; Clear[logsigma]; FindRoot[ Erfc[ x[[2]]/(E^logsigma*Sqrt@2)] + Erfc[-x[[1]]/(E^logsigma*Sqrt@2)] == 2e, {logsigma,-5,0}] sigma = E^logsigma /. % (Erfc[x[[2]]/(sigma*Sqrt@2)] + Erfc[-x[[1]]/(sigma*Sqrt@2)])/2 {logsigma -> -0.351804} 0.703418 9.999999999981747`*^-6 x = {-5,3}; e = 10^-20; Clear[logsigma]; FindRoot[ Erfc[ x[[2]]/(E^logsigma*Sqrt@2)] + Erfc[-x[[1]]/(E^logsigma*Sqrt@2)] == 2e, {logsigma,-5,0}] sigma = E^logsigma /. % (Erfc[x[[2]]/(sigma*Sqrt@2)] + Erfc[-x[[1]]/(sigma*Sqrt@2)])/2 {logsigma -> -1.12734} 0.323892 1.0000000000000201`*^-20 ----- Samuel Mark Young <sy81 at sussex.ac.uk> wrote: > > 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

**Increasing precision in FindRoot**

**Re: Axes in Plot3D and ListPlot3D**

**Increasing precision in FindRoot**

**Re: Increasing precision in FindRoot**