MathGroup Archive 2013

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

Search the Archive

Re: Rookie questions about solving for small numbers and others

  • To: mathgroup at
  • Subject: [mg131039] Re: Rookie questions about solving for small numbers and others
  • From: Peter Klamser <klamser at>
  • Date: Wed, 5 Jun 2013 03:30:01 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <>

You have two problems:

1.    Finding the root of a expression in an area  with very small numbers.

2.    In that area  with very small numbers you have a very flat gradient.

Because I can not read the expressions you posted with Mathematica 9 I can not
help you further on.


2013/6/4 Samuel Mark Young <sy81 at>:
> Hello,
> I'm trying to solve a problem involving various integrals. Essentially, I=
'm perturbing a gaussian distribution, and then trying to find a value for =
sigma (the standard deviation) for which there is a 10^-5 chance of being g=
reater than 1 (i.e. What value of sigma gives a value of 10^-5 when the pdf=
 is integrated from 1 to infinity). The aim is to find how sigma changes wi=
th the different perturbations. The code below is a shortened version of wh=
at I'm currently using - you may not need to know all the relevant details.
> Explanation: Here I'm adding a quadratic perturbation with coefficient f =
to the Gaussian variable x to make a new variable zeta. The aim here is to =
plot a graph (eventually) showing how sigma changes with f. Because I want =
to use this code to work with higher order equations (for which there is no=
 analytic solution), I use a temporary value for sigma (=1B$B&R=1B(Btem=
p - provided that the value of sigma found is close to =1B$B&R=1B(Btemp=
, this works well) and solve numerically. Similarly, the easiest way to han=
dle the in tegrations is just to find the relevant values of x for which ze=
ta>1, and integrate the Gaussian distribution over those values. I then use=
 FindRoot to find a value of sigma which satisfies the equation.
> f = 0.5;
> =1B$B&R=1B(Btemp = 0.2; The values here have been picked arbitraril=
> zeta = x + f (x^2 - =1B$B&R=1B(B^2);
> xCritical = x /. NSolve[1 == zeta /. =1B$B&R=1B(B -> =1B$B&R=
=1B(Btemp, x, Reals];
> yCritical = xCritical/=1B$B&R=1B(B; This calculates the critical va=
lues to integrate between
> =1B$B&R=1B(Btemp = =1B$B&R=1B(B /.
>   FindRoot[
>    Sum[(1/
>          Sqrt[2*Pi]) (If[(Abs[D[zeta, x]] /. x -> xCritical[[n]]) >
>           0, If[(D[zeta, x] /. x -> xCritical[[n]]) > 0, 1, -1],
>          0]) (Integrate[Exp[-(y^2)/2], {y, yCritical[[n]], =1B$B!g=1B=
(B}]), {n,
>        Length[xCritical]}]  The Sum[] command generates a series of ERFC'=
s (this code will throw up errors for certain values of f, but the full cod=
e doesn't)
>        + If[(Simplify[D[zeta, x] /. x -> xCritical[[1]]]) < 0, 1, 0] = =
10^(-5), {=1B$B&R=1B(B, 0.00001, 2}] FindRoot searches for a value of s=
igma between 0 and 2 (the solution should always lie in this range - though=
 putting in zero exactly results in divide by zero errors
> There are currently 3 problems I'm having:
> 1) Underflow occurs in the computation a lot for certain values of f
> 2) I want to be able to solve for when the integrals equal 10^-20 (as opp=
> e to 10^-5) - which is greater than machine precision. I've tried fiddlin=
g =
> with settings like AccuracyGoal, PrecisionGoal and WorkingPrecision but c=
> 't find anything that makes it work reliably (instead of a smooth curve, =
I =
> end up with jagged spikes. Its entirely possible, even likely, that I'm m=
> sing something obvious.
> 3) For negative values of f, there are no solutions to  x + f (x^2 - =1=
> R=1B(Btemp^2)=1 if =1B$B&R=1B(Btemp is too small. The problem the=
n, is th=
> at, when =1B$B&R=1B(Btemp is increased, unless there is remarkable fi=
ne tun=
> ing, the final value of sigma found is not similar to =1B$B&R=1B(Btem=
p. The=
>  only way I've found to handle this is to very slowly increment =1B$B&R=
> Btemp until there are real solutions, then use FindRoot to find a value f=
>  sigma, and compare sigma to =1B$B&R=1B(Btemp to see if they match (t=
o 4 s.=
> f. is fine). However, this takes a very long time when I want to do this =
> peatedly.
> Many thanks in advance for taking the time to read this, and any help is =
> ry well appreciated. I think I have included all the information needed, =
> t please ask if you need more. Please feel free to contact me directly at=
> y81 at with any questions.
> Regards,
> Sam Young

  • Prev by Date: Setting the Font Family and Font Size in BoxWhiskerChart
  • Next by Date: Re: Definitions missing
  • Previous by thread: Rookie questions about solving for small numbers and others
  • Next by thread: Re: Rookie questions about solving for small numbers and