MathGroup Archive 2005

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

Search the Archive

Re: How to cope with tiny numbers in FindRoot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63204] Re: How to cope with tiny numbers in FindRoot
  • From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
  • Date: Mon, 19 Dec 2005 07:00:57 -0500 (EST)
  • Organization: Open University, U.K.
  • References: <dnrn37$pvo$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

<dkjk at bigpond.net.au> a écrit dans le message de news:
dnrn37$pvo$1 at smc.vnet.net...
| Hi group,
|
| I'm trying to numerically determine the solution of an equation whose
| coefficients are of the order 10^-100 or less. I've been running into
| all sorts of errors relating to MaxIterations and step size but so far
| I haven't been able to find any useful information in the Mathematica
| book. If you're interested in the notebook i'm using, you can find it
| here:
|
| http://users.bigpond.net.au/jdstokes/theory2.nb
|
| Thanks
|
| James.
|

Hi James,



Having read more carefully your mail and notebook, I may suggest some
options that should help *FindRoot* to deal with small coefficients:



1 - Try not to use the package _RealsOnly_ so Mathematica is free to use the
full range of its internal algorithms (even those that might involve at some
stage use the complex plane).



2 - Enter all the numeric values as exact numbers, 1/2 or 606992/10^5 rather
than 0.5 or 6.06992 for instance.



3 - Use the optional parameters *WorkingPrecision* and *MaxIteration* with
sufficiently high values: I have done some test with 1000 and 500
respectively and got solutions for {omega-ro, 1, 10, 10} and {omega-z, 1,
30, 10}.



Best regards,

/J.M.



(************** Content-type: application/mathematica **************
                     CreatedBy='Mathematica 5.2'

                    Mathematica-Compatible Notebook

This notebook can be used with any Mathematica-compatible
application, such as Mathematica, MathReader or Publicon. The data
for the notebook starts with the line containing stars above.

To get the notebook into a Mathematica-compatible application, do
one of the following:

* Save the data starting with the line of stars above into a file
  with a name ending in .nb, then open the file inside the
  application;

* Copy the data starting with the line of stars above to the
  clipboard, then use the Paste menu command inside the application.

Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode.  Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).

NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing
the word CacheID, otherwise Mathematica-compatible applications may
try to use invalid cache data.

For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
  web: http://www.wolfram.com
  email: info at wolfram.com
  phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from
Wolfram Research.
*******************************************************************)

(*CacheID: 232*)


(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[     10648,        254]*)
(*NotebookOutlinePosition[     11292,        276]*)
(*  CellTagsIndexPosition[     11248,        272]*)
(*WindowFrame->Normal*)



Notebook[{

Cell[CellGroupData[{
Cell[BoxData[
    RowBox[{\( (*\ Needs["\<Miscellaneous`RealOnly`\>"]\ *) \),
      "\[IndentingNewLine]",
      RowBox[{\(a = \(1\/2\) \[Lambda];\), "\[IndentingNewLine]",
        StyleBox[\(\[Epsilon] = 885418782\/10\^8*10\^\(-12\);\),
          "DisplayFormula",
          FontVariations->{"CompatibilityType"->0}],
        "\[IndentingNewLine]",
        StyleBox[\(M =
              1500*\((4/3)\)*\[Pi]*\((10^\((\(-6\))\))\)^3;\),
          "DisplayFormula",
          FontVariations->{"CompatibilityType"->0}],
        "\[IndentingNewLine]",
        RowBox[{
          RowBox[{
            StyleBox["Q",
              "DisplayFormula",
              FontVariations->{"CompatibilityType"->0}],
            StyleBox["=",
              "DisplayFormula",
              FontVariations->{"CompatibilityType"->0}],
            RowBox[{
              StyleBox["8",
                "DisplayFormula",
                FontVariations->{"CompatibilityType"->0}],
              StyleBox["*",
                "DisplayFormula",
                FontVariations->{"CompatibilityType"->0}],
              StyleBox[\(10\^3\),
                "DisplayFormula",
                FontVariations->{"CompatibilityType"->0}],
              StyleBox["*",
                "DisplayFormula",
                FontVariations->{"CompatibilityType"->0}],
              FractionBox[
                StyleBox["16",
                  "DisplayFormula",
                  FontVariations->{"CompatibilityType"->0}], "10"],
              StyleBox["*",
                "DisplayFormula",
                FontVariations->{"CompatibilityType"->0}],
              StyleBox[\(10\^\(-19\)\),
                "DisplayFormula",
                FontVariations->{"CompatibilityType"->0}]}]}],
          StyleBox[";",
            "DisplayFormula",
            FontVariations->{"CompatibilityType"->0}]}],
        "\[IndentingNewLine]",
        StyleBox[
          RowBox[{
            RowBox[{"\[Lambda]", "=",
              TagBox[\(606992\/10\^5*10\^\(-4\)\),
                ScientificForm]}], ";"}],
          "DisplayFormula",
          FontVariations->{"CompatibilityType"->0}],
        "\[IndentingNewLine]",
        RowBox[{
          RowBox[{
            StyleBox["l",
              "DisplayFormula",
              FontVariations->{"CompatibilityType"->0}],
            StyleBox["=",
              "DisplayFormula",
              FontVariations->{"CompatibilityType"->0}],
            RowBox[{
              FractionBox[
                StyleBox["3",
                  "DisplayFormula",
                  FontVariations->{"CompatibilityType"->0}], "2"],
              StyleBox["\[Lambda]",
                "DisplayFormula",
                FontVariations->{"CompatibilityType"->0}]}]}],
          StyleBox[";",
            "DisplayFormula",
            FontVariations->{"CompatibilityType"->0}]}],
        "\[IndentingNewLine]", \(\[Delta] = l;\),
        "\[IndentingNewLine]", \(z0w = \(l\ q\ Q\)\/\(3\ \((\(-q\)\ Q \
- 4\ a\^3\ M\ \[Pi]\ \[Epsilon]\ \[Omega]z\^2)\)\) + \((2\^\(1/3\)\ l\
\^2\ q\^2\ Q\^2)\)/\((3\ \((\(-q\)\ Q -
                        4\ a\^3\ M\ \[Pi]\ \[Epsilon]\ \
\[Omega]z\^2)\)\ \((2\ l\^3\ q\^3\ Q\^3 + 54\ a\^3\ q\^2\ Q\^4 + 432\ \
a\^6\ M\ \[Pi]\ q\ Q\^3\ \[Epsilon]\ \[Omega]z\^2 + 864\ a\^9\ M\^2\ \
\[Pi]\^2\ Q\^2\ \[Epsilon]\^2\ \[Omega]z\^4 + \[Sqrt]\((\(-4\)\ l\^6\ \
q\^6\ Q\^6 + \((2\ l\^3\ q\^3\ Q\^3 + 54\ a\^3\ q\^2\ Q\^4 + 432\ \
a\^6\ M\ \[Pi]\ q\ Q\^3\ \[Epsilon]\ \[Omega]z\^2 + 864\ a\^9\ M\^2\ \
\[Pi]\^2\ Q\^2\ \[Epsilon]\^2\ \[Omega]z\^4)\)\^2)\))\)\^\(1/3\))\) + \
\(1\/\(3\ 2\^\(1/3\)\ \((\(-q\)\ Q -
                          4\ a\^3\ M\ \[Pi]\ \[Epsilon]\ \
\[Omega]z\^2)\)\)\) \((\((2\ l\^3\ q\^3\ Q\^3 + 54\ a\^3\ q\^2\ Q\^4 \
+ 432\ a\^6\ M\ \[Pi]\ q\ Q\^3\ \[Epsilon]\ \[Omega]z\^2 + 864\ a\^9\ \
M\^2\ \[Pi]\^2\ Q\^2\ \[Epsilon]\^2\ \[Omega]z\^4 + \[Sqrt]\((\(-4\)\ \
l\^6\ q\^6\ Q\^6 + \((2\ l\^3\ q\^3\ Q\^3 + 54\ a\^3\ q\^2\ Q\^4 + \
432\ a\^6\ M\ \[Pi]\ q\ Q\^3\ \[Epsilon]\ \[Omega]z\^2 + 864\ a\^9\ M\
\^2\ \[Pi]\^2\ Q\^2\ \[Epsilon]\^2\ \
\[Omega]z\^4)\)\^2)\))\)\^\(1/3\))\);\),
        "\[IndentingNewLine]", \(z01w =
            Q\^2\/\(4*\[Pi]*\[Epsilon]*M*\[Omega]z\^2*z0w\^2\);\),
        "\[IndentingNewLine]", \(z02w = z0w + z01w;\),
        "\[IndentingNewLine]", \(\[Rho]0 = \((\(Q\^2 - q*Q\)\/\(2*\
\[Pi]*\[Epsilon]*M*\[Omega]\[Rho]\^2\))\)\^\(1/3\);\),
        "\[IndentingNewLine]", \(matrix =
            Table[\((q /.
                    FindRoot[
                      Q\^2\/\(4*\[Pi]*\[Epsilon]*Abs[z0w]\) - \(\(q*
                                  Q\)\/\(4*\[Pi]*\[Epsilon]*
                                  a\)\) \((3\/2 - \((z0w + \
l)\)\^2\/\(2  a\^2\))\) +
                          1\/2*M*\(\[Omega]z\^2\) \((z01w\^2 +
                                z02w\^2)\) ==
                        Q\^2\/\(4*\[Pi]*\[Epsilon]*Abs[\[Rho]0]\) - \
\(2*q*Q\)\/\(4*\[Pi]*\[Epsilon]*\@\(\[Rho]0\^2 + l\^2\)\) + \((1/4)\)
                            M*\[Omega]\[Rho]\^2*\[Rho]0\^2, {q,
                        Q/50}, WorkingPrecision \[Rule] 1000,
                      MaxIterations \[Rule] 500])\)/
                Q, {\[Omega]\[Rho], 1, 100, 10}, {\[Omega]z, 1, 30,
                10}];\)}]}]], "Input"],

Cell[BoxData[
    RowBox[{\(General::"spell1"\), \(\(:\)\(\ \)\), "\<\"Possible \
spelling error: new symbol name \\\"\\!\\(z01w\\)\\\" is similar to \
existing symbol \\\"\\!\\(z0w\\)\\\". \\!\\(\\*ButtonBox[\\\"More\
\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\\\", \
ButtonFrame->None, ButtonData:>\\\"General::spell1\\\"]\\)\"\>"}]], \
"Message"],

Cell[BoxData[
    RowBox[{\(General::"spell1"\), \(\(:\)\(\ \)\), "\<\"Possible \
spelling error: new symbol name \\\"\\!\\(z02w\\)\\\" is similar to \
existing symbol \\\"\\!\\(z0w\\)\\\". \\!\\(\\*ButtonBox[\\\"More\
\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\\\", \
ButtonFrame->None, ButtonData:>\\\"General::spell1\\\"]\\)\"\>"}]], \
"Message"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    \(TableForm[N[matrix, 30],
      TableHeadings \[Rule] {{"\<\[Omega]\[Rho]\>"}, \
{"\<\[Omega]z\>"}}]\)], "Input"],

Cell[BoxData[
    TagBox[GridBox[{
          {"\<\"\"\>", "\<\"\[Omega]z\"\>", "\<\"\"\>", "\<\"\"\>"},
          {"\<\"\[Omega]\[Rho]\"\>", \
\(-0.000023814287803707108345667434327291205767807064`30. \), \
\(-0.001611115291634802865665689946456878376561092729`30. \), \
\(-0.00574052888721641076810937873575232747118115111`30. \)},
          {"\<\"\"\>", \
\(-0.000078836017288107335962200052755322821138327414`30. \), \
\(-0.002803602057857407051794466764219764387754797231`30. \), \
\(-0.008220077206347541634617700704781356629322971134`30. \)},
          {"\<\"\"\>", \
\(-0.000108798160940359529554392165612578991061751677`30. \),
            "0.002275281457182875234232146198174223409873874125`30.", \
\(-9.341300708835000303650511362822014288330072`30.*^-1239\)},
          {"\<\"\"\>", \
\(-0.000131870205021544727724774448523178620486297119`30. \),
            "0.004210932610281802432455722809214526157864308647`30.",
            "0.008073470613731339574112838681111569321351702517`30."},\

          {"\<\"\"\>", \
\(-0.000151279525591783407354967578871218994460546032`30. \),
            "0.005959932134658083202084129616342988600641739825`30.",
            "0.015844853411968870475063083301638903694891925639`30."},\

          {"\<\"\"\>", \
\(-0.000168325859243845327232748778235396015852432262`30. \),
            "0.007587152907123081613263880700917617810676656534`30.",
            "0.023572450028521687047447474764263832022169106103`30."},\

          {"\<\"\"\>", \
\(-0.000183686702799964260113425226517697136807707932`30. \),
            "0.009127401923419887634763262424855518782888441044`30.",
            "0.031371239260005233421740810449902238737053202997`30."},\

          {"\<\"\"\>", \
\(-0.000197767991120026314921931830292077734137867555`30. \),
            "0.010601929501706465363516821118554516509937210999`30.",
            "0.03931738233285007483412112004622943832878699789`30."},
          {"\<\"\"\>", \
\(-0.000210835548825440302147201551331138337344536205`30. \),
            "0.012024836554728306490431772213655023839530759194`30.",

            "0.047470791423067219135024458096575516872060199443`30."},\

          {"\<\"\"\>", \
\(-0.000223074593450490158300420418534812432443320228`30. \),
            "0.01340604525412333112315965928284591159462191827`30.",
            "0.055884216582738498793686146419767637808337830786`30."}
          },
        RowSpacings->1,
        ColumnSpacings->3,
        RowAlignments->Baseline,
        ColumnAlignments->{Left}],
      Function[ BoxForm`e$,
        TableForm[
        BoxForm`e$, TableHeadings -> {{"\[Omega]\[Rho]"}, {
          "\[Omega]z"}}]]]], "Output"]
}, Open  ]]
},
FrontEndVersion->"5.2 for Microsoft Windows",
ScreenRectangle->{{0, 1280}, {0, 717}},
WindowSize->{1272, 683},
WindowMargins->{{0, Automatic}, {Automatic, 0}}
]

(*******************************************************************
Cached data follows.  If you edit this Notebook file directly, not
using Mathematica, you must remove the line containing CacheID at
the top of  the file.  The cache data will then be recreated when
you save this file from within Mathematica.
*******************************************************************)

(*CellTagsOutline
CellTagsIndex->{}
*)

(*CellTagsIndex
CellTagsIndex->{}
*)

(*NotebookFileOutline
Notebook[{

Cell[CellGroupData[{
Cell[1776, 53, 5282, 115, 630, "Input"],
Cell[7061, 170, 357, 6, 22, "Message"],
Cell[7421, 178, 357, 6, 22, "Message"]
}, Open  ]],

Cell[CellGroupData[{
Cell[7815, 189, 133, 3, 30, "Input"],
Cell[7951, 194, 2681, 57, 201, "Output"]
}, Open  ]]
}
]
*)



(*******************************************************************
End of Mathematica Notebook file.
*******************************************************************)





  • Prev by Date: Re: Gray's Differential Geometry error?
  • Next by Date: NDSolve
  • Previous by thread: Re: How to cope with tiny numbers in FindRoot
  • Next by thread: Simplify Enterprise NAS with Global File Virtualization