Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: NDSolve with delayed terms in equations


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11854] Re: NDSolve with delayed terms in equations
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Fri, 3 Apr 1998 03:45:18 -0500
  • Organization: University of Western Australia
  • References: <6fsj92$gi8@smc.vnet.net>

Alban P Tsui wrote:

> I have a set of differential equations. Usually I can solve it with
> NDSolve with no problem. However, I do not know how to solve something
> like this, say
> 
> x'[t]==y[t]^2+x[t-a]
> y'[t]==y[t]x[t]
> 
> with the usuaual intial conditions and a is real and positive.
> 
> x[t-a] is a delayed term.
> 
> What is the best way to tackle this with NDSolve?

See The Mathematica Journal 5(3): 25 and 6(1): 25-26.   I have appended
a Notebook below.  In addition, Scott Herod <Scott.Herod@Colorado.EDU>
has developed a delay differential equation package which I have
attached (hopefully attachments sent to comp.soft-sys.math.mathematica
now work ok).

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________

Notebook[{

Cell[CellGroupData[{
Cell["Delay Differential Equation", "Section"],

Cell[TextData[{
  "See The ",
  StyleBox["Mathematica",
    FontSlant->"Italic"],
  " Journal ",
  StyleBox["5",
    FontWeight->"Bold"],
  "(3): 25 and ",
  StyleBox["6",
    FontWeight->"Bold"],
  "(1): 25-26."
}], "Text"],

Cell[TextData[{
  "Differential equations involving delay such as ",
  Cell[BoxData[
      FormBox[
        RowBox[{
          RowBox[{
            SuperscriptBox["q", "\[Prime]",
              MultilineFunction->None], "(", "t", ")"}], "==", 
          \(q(t - 2) - q(t)\)}], TraditionalForm]]],
  ", with the initial conditions ",
  Cell[BoxData[
      \(TraditionalForm\`q(0) == 1\)]],
  " and ",
  Cell[BoxData[
      \(TraditionalForm\`q(t_ /; t < 0) = 0\)]],
  ", can be solved iteratively in an elegant way using ",
  Cell[BoxData[
      FormBox[
        StyleBox["FixedPoint",
          "Input"], TraditionalForm]]],
  ". After entering"
}], "Text",
  CellTags->{"FixedPoint", "delay differential equation"}],

Cell[BoxData[
    \(TraditionalForm
    \`Off(NDSolve::"\<ndnum\>", InterpolatingFunction::"\<dmval\>")\)], 
  "Input",
  CellTags->"Off"],

Cell[TextData[{
  "to suppress the warning messages that arising during intermediate \
computations prior to reaching the fixed point, we use ",
  Cell[BoxData[
      FormBox[
        StyleBox["FixedPoint",
          "Input"], TraditionalForm]]],
  " to solve the equation iteratively:" }], "Text"],

Cell[BoxData[
    FormBox[
      RowBox[{
        RowBox[{"r", "=", 
          RowBox[{"FixedPoint", "[", 
            RowBox[{
              RowBox[{
                RowBox[{
                  RowBox[{"NDSolve", "[", 
                    RowBox[{
                      RowBox[{"{", 
                        RowBox[{
                          RowBox[{
                            RowBox[{
                              SuperscriptBox["q", "\[Prime]",
                                MultilineFunction->None], "(", "t",
")"}], 
                            "==", " ", \(If[t < 2, 0, #1[t - 2]] -
q(t)\)}], 
                          ",", \(q(0) == 1\)}], "}"}], ",", "q", ",", 
                      \({t, 0, 7}\)}], "]"}], "\[LeftDoubleBracket]",
\(1, 1, 
                  2\), "\[RightDoubleBracket]"}], "&"}], ",", "0"}],
"]"}]}], 
        ";"}], TraditionalForm]], "Input",
  AspectRatioFixed->True],

Cell[BoxData[
    \(TraditionalForm
    \`\(Plot[r(x), {x, 0, 7}, PlotRange \[Rule] {All, {0, 1}}]; \)\)], 
  "Input",
  AspectRatioFixed->True],

Cell[TextData[{
  "Here we use ",
  Cell[BoxData[
      FormBox[
        StyleBox[\(PlotRange \[Rule] {All, {0, 1}}\),
          "Input"], TraditionalForm]]],
  " to control the plot range in the ",
  StyleBox["x",
    FontSlant->"Italic"],
  " and ",
  StyleBox["y",
    FontSlant->"Italic"],
  " directions separately."
}], "Text",
  CellTags->"PlotRange"],

Cell["It is easy to check how well the equation is satisfied:", "Text"],

Cell[BoxData[
    FormBox[
      RowBox[{
        RowBox[{"Plot", "(", 
          RowBox[{
            RowBox[{"Evaluate", "(", 
              RowBox[{\(-\(If(t < 2, 0, r(t - 2))\)\), "+", \(r(t)\),
"+", 
                RowBox[{
                  SuperscriptBox["r", "\[Prime]",
                    MultilineFunction->None], "(", "t", ")"}]}], ")"}],
",", 
            \({t, 0, 7}\), ",", 
            \(PlotRange \[Rule] {\(-0.0005\), 0.0005}\)}], ")"}], ";"}],

      TraditionalForm]], "Input"],

Cell[TextData[{
  "We can use ",
  Cell[BoxData[
      FormBox[
        StyleBox["Nest",
          "Input"], TraditionalForm]]],
  " instead of ",
  Cell[BoxData[
      FormBox[
        StyleBox["FixedPoint",
          "Input"], TraditionalForm]]],
  " if we are sure of the number of iterations needed." }], "Text"]
}, Open  ]]
}
]

(***********************************************************************

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the
notebook  starts with the line of 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@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[     16875,        429]*)
(*NotebookOutlinePosition[     17743,        457]*) (* 
CellTagsIndexPosition[     17699,        453]*) (*WindowFrame->Normal*)


Notebook[{

Cell[CellGroupData[{
Cell["Delay Differential Equations", "Section"],

Cell[TextData[{
  "Here is an example of the solution to your delay differential
equation ",
  Cell[BoxData[
      \(TraditionalForm\`\((b = \(c = 1\))\)\)]],
  ":"
}], "Text"],

Cell[BoxData[
    FormBox[
      RowBox[{
        RowBox[{"sol", "=", 
          RowBox[{"NDelaySolve", "(", 
            RowBox[{
              RowBox[{"{", 
                RowBox[{
                  RowBox[{
                    RowBox[{
                      SuperscriptBox["x", "\[Prime]",
                        MultilineFunction->None], "(", "t", ")"}], "==",

                    \(1\/\((y(t - 30) + 1)\)\^2 - 0.1\ \(x(t)\)\)}],
",", 
                  RowBox[{
                    RowBox[{
                      SuperscriptBox["y", "\[Prime]",
                        MultilineFunction->None], "(", "t", ")"}], "==",

                    \(x(t) - 0.1\ \(y(t)\)\)}]}], "}"}], ",", 
              \({x(t) == 2, y(t) == 0.1}\), ",", \({t, 0, 720}\)}],
")"}]}], 
        ";"}], TraditionalForm]], "Input"],

Cell[BoxData[
    \(TraditionalForm
    \`\(ParametricPlot(Evaluate({x(t), y(t)} /. sol), {t, 0, 720}, 
      PlotRange \[Rule] All); \)\)], "Input"],

Cell[BoxData[
    \(TraditionalForm\`\(Plot[Evaluate(x(t) /. sol), {t, 0, 720}];
\)\)], 
  "Input"],

Cell[BoxData[
    \(TraditionalForm
    \`\(Plot(Evaluate(D[x(t) /. sol, t]), {t, 0, 720}, 
      PlotRange \[Rule] All); \)\)], "Input"],

Cell[TextData[{
  "We can convert the output to single ",
  Cell[BoxData[
      FormBox[
        StyleBox["InterpolatingFunction",
          "Input"], TraditionalForm]]],
  "s using ",
  Cell[BoxData[
      FormBox[
        StyleBox["FunctionInterpolation",
          "Input"], TraditionalForm]]],
  " as follows:"
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    \(TraditionalForm
    \`sol = {x \[Rule] 
          FunctionInterpolation(
            \(x(t) /. First(sol)\) /. t \[Rule] u, {u, 0, 720}, 
            InterpolationPoints \[Rule] 180), 
        y \[Rule] 
          FunctionInterpolation(
            \(y(t) /. First(sol)\) /. t \[Rule] u, {u, 0, 720}, 
            InterpolationPoints \[Rule] 180)}\)], "Input"],

Cell[BoxData[
    FormBox[
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x", "\[Rule]", 
            TagBox[
              RowBox[{"InterpolatingFunction", "(", 
                RowBox[{
                  RowBox[{"(", GridBox[{
                        {"0", "720.000000000000017`"}
                        },
                      ColumnAlignments->{Decimal}], ")"}], ",", 
                  "\<\"<>\"\>"}], ")"}],
              False,
              Editable->False]}], ",", 
          RowBox[{"y", "\[Rule]", 
            TagBox[
              RowBox[{"InterpolatingFunction", "(", 
                RowBox[{
                  RowBox[{"(", GridBox[{
                        {"0", "720.000000000000017`"}
                        },
                      ColumnAlignments->{Decimal}], ")"}], ",", 
                  "\<\"<>\"\>"}], ")"}],
              False,
              Editable->False]}]}], "}"}], TraditionalForm]], "Output"]
}, Open  ]],

Cell[BoxData[
    FormBox[
      RowBox[{
        RowBox[{"Plot", "(", 
          RowBox[{
            RowBox[{"Evaluate", "(", 
              RowBox[{
                RowBox[{
                  SuperscriptBox["x", "\[Prime]",
                    MultilineFunction->None], "[", "t", "]"}], "/.",
"sol"}], 
              ")"}], ",", \({t, 0, 720}\), ",", \(PlotRange \[Rule]
All\)}], 
          ")"}], ";"}], TraditionalForm]], "Input"],

Cell["We can now plot the solutions,", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\(ParametricPlot(Evaluate({x(t), y(t)} /. sol), {t, 0, 720}, 
      PlotRange \[Rule] All); \)\)], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    FormBox[
      RowBox[{"Chop", "(", 
        RowBox[{
          RowBox[{
            RowBox[{"{", 
              RowBox[{"t", ",", 
                RowBox[{
                  SuperscriptBox["x", "\[DoublePrime]",
                    MultilineFunction->None], "(", "t", ")"}]}], "}"}], 
            "/.", 
            RowBox[{"RootsInRange", "(", 
              RowBox[{
                RowBox[{
                  RowBox[{
                    SuperscriptBox["x", "\[Prime]",
                      MultilineFunction->None], "(", "t", ")"}], "/.", 
                  "sol"}], ",", \({t, 0, 720}\)}], ")"}]}], "/.",
"sol"}], 
        ")"}], TraditionalForm]], "Input"],

Cell[BoxData[
    FormBox[
      RowBox[{"(", GridBox[{
            {"27.2039138529931623`", \(-0.0668401333638436678`\)},
            {"90.230629482772624`", "0.000524608105330956853`"},
            {"138.10881774383740732858854801787`20", 
              \(-0.0163934521358727369`\)},
            {"192.397732776974876`", "0.000650078955409766123`"},
            {"239.849443248961335`", \(-0.0110245544758795666`\)},
            {"292.42211808764523`", "0.000687255320468167951`"},
            {"339.646993853659375651426495`16.1998", 
              \(-0.00929887486320799006`\)},
            {"391.714067623583659`", "0.000702271753830611356`"},
            {"438.747796802485723`", \(-0.00883300374486826278`\)},
            {"490.54013656405040476297736`17.2977", 
              "0.000696082557874924656`"},
            {"537.774797268086235`", \(-0.00817482899297009879`\)},
            {"589.295055609321583`", "0.000711382971689221221`"},
            {"636.32493434106311269715661183`18.9013", 
              \(-0.00804635985400770259`\)},
            {"687.95031605147698883229168132`17.6194", 
              "0.000701814491873760193`"}
            },
          ColumnAlignments->{Decimal}], ")"}], TraditionalForm]],
"Output"] }, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
    FormBox[
      RowBox[{"Chop", "(", 
        RowBox[{
          RowBox[{
            RowBox[{"{", 
              RowBox[{"t", ",", 
                RowBox[{
                  SuperscriptBox["y", "\[DoublePrime]",
                    MultilineFunction->None], "(", "t", ")"}]}], "}"}], 
            "/.", 
            RowBox[{"RootsInRange", "(", 
              RowBox[{
                RowBox[{
                  RowBox[{
                    SuperscriptBox["y", "\[Prime]",
                      MultilineFunction->None], "(", "t", ")"}], "/.", 
                  "sol"}], ",", \({t, 0, 720}\)}], ")"}]}], "/.",
"sol"}], 
        ")"}], TraditionalForm]], "Input"],

Cell[BoxData[
    FormBox[
      RowBox[{
      \(FindRoot::"frsec"\), \( : \ \), 
        "\<\"Secant method failed to converge to the prescribed accuracy
\ after \\!\\(TraditionalForm\\`15\\) iterations.\"\>"}],
TraditionalForm]], 
  "Message"],

Cell[BoxData[
    FormBox[
      RowBox[{"(", GridBox[{
            {"32.079077494292984437299213272708`20", 
              \(-0.488421591407015664`\)},
            {"101.927707349670315`", "0.0104581784280207656`"},
            {"145.50224025994904`", \(-0.092850604838999331`\)},
            {"203.2621253168322255078237503767`20", 
              "0.00998292513380283175`"},
            {"247.34668827705692706331319641322`19.8649", 
              \(-0.06452577646111747`\)},
            {"303.0344548728934341852436773479`19.2697", 
              "0.00971639390554673276`"},
            {"347.236986154527403603753286293`18.443", 
              \(-0.0560356362292422804`\)},
            {"402.109556868586803`", "0.00943540213857637155`"},
            {"446.4804453305434037702070782`16.884", 
              \(-0.0532569526232672618`\)},
            {"500.97478920064975227433023974`18.0289", 
              "0.00948780858115572733`"},
            {"545.387107332214441157702822238`19.0049", 
              \(-0.0494614167423600825`\)},
            {"599.687090144818398584902752`16.1509", 
              "0.00936390281392491274`"},
            {"644.00900680523105828355873729`19.1646", 
              \(-0.0493558084943091479`\)},
            {"698.2240299219334929148317314684`19.5118", 
              "0.00940319809864354638`"}
            },
          ColumnAlignments->{Decimal}], ")"}], TraditionalForm]],
"Output"] }, Closed]],

Cell[CellGroupData[{

Cell["Code", "Subsection",
  InitializationCell->True],

Cell["\<\
Scott A. Herod
Applied Mathematics
University of Colorado, Boulder
Scott.Herod@Colorado.EDU\
\>", "Text",
  InitializationCell->True],

Cell["Here is the code:", "Text",
  InitializationCell->True],

Cell[BoxData[
    \(TraditionalForm\`\(Options[NDelaySolve]\  = \ {Verbose\  -> \
False}; 
    \)\)], "Input",
  InitializationCell->True],

Cell[BoxData[
    \(TraditionalForm
    \`\(NDelaySolve[eqnConst_, \ initsConst_, \ indinterval_, \
opts___]\  := 
      \n\ \ Module[{\n\ \ \ \ error\  = \ "\<Something is wrong\>", \n\
\ \ \ 
          ind\  = \ indinterval[\([1]\)], \n\ \ \ \ 
          start\  = \ indinterval[\([2]\)], \n\ \ \ \ 
          stop\  = \ indinterval[\([3]\)], \n\ \ \ \ 
          eqn\  = \ Flatten[{eqnConst}], \n\ \ \ \ 
          inits\  = \ Flatten[{initsConst}], \n\ \ \ \ tau, \ deps, \ 
          numdeps, \ dtymes, \ delayedfs, \ numb, \n\ \ \ \ numbdelay, \

          delaynum, \ onedelay, \ forcedterms, \ sol, \n\ \ \ \ funcs, \

          witchlist, \ g, \ numiters, \ subs, \ senteqn, \n\ \ \ \ i, j,
k1, 
          k2}, \n\ \ \n\ \ deps\  = \ Map[Part[#, 1]\ &, \ inits]; \n\ \

        numdeps\  = \ Length[deps]; \n\ \ \n\ \ 
        printQ\  = \ \(Verbose\  /. \ {opts}\)\  /. \
Options[NDelaySolve]; \n
        \ \ If[printQ, Print["\<eqn = \>", \ eqn]]; \n\ \ 
        If[printQ, Print["\<inits = \>", \ inits]]; \n\ \ 
        If[printQ, \ Print["\<interval = \>"\ , \ indinterval]]; \n\ \ 
        If[printQ, \ Print["\<ind = \>"\ , \ ind]]; \n\ \ 
        If[printQ, \ Print["\<start = \>"\ , \ start]]; \n\ \ 
        If[printQ, \ Print["\<stop = \>"\ , \ stop]]; \n\ \ 
        If[printQ, \ Print["\<deps = \>", \ deps]]; \n\ \ \n\ \ 
        dtymes\  = \ 
          Map[\ \((ind - #)\)&, \n\ \ \ \ 
            Union[Flatten[
                delayedfs\  = \ 
                  Map[Cases[#, \ _Plus, \ Infinity]&, \n\ \ \ \ \ \ 
                    Map[Cases[eqn, #, \ Infinity]\ &, \ 
                      deps\  /. \ ind\  -> \ Plus[__]]]\n\ \ \ \ ]]];
\n\ \ \n
        \ \ If[printQ, Print["\<dtymes = \>", \ dtymes]]; \n\n\ \ 
        dtymes\  = \ 
          Sort[\n\ \ \ \ 
            Map[If[MemberQ[{Integer, \ Rational, \ Real}, \ Head[#]], #,
\n
                  \ \ \ \ If[Head[\((numb\  = \ N[#])\)]\  === \ Real, \

                    numb, \ error]]\ &, dtymes]]; \n\ \ \ \ \n\ \ 
        If[printQ, Print["\<dtymes = \>", \ dtymes]]; \n\n\ \ 
        If[MemberQ[dtymes, error], Return[error]]; \n\ \ 
        If[\((tau\  = \ dtymes[\([1]\)])\)\  <= \ 0, \ Return[error]];
\n\ \ 
        onedelay\  = \ \((\((numbdelay\  = \ Length[dtymes])\)\  == \
1)\); \n
        \n\ \ delayedfs\  = \ Map[Union, delayedfs]; \n\ \ \ \ 
        If[printQ, Print["\<delayedfs = \>", \ delayedfs]]; \n\ \ \n\ \ 
        forcedterms\  = \ 
          Table[Table[deps[\([i]\)]\  /. \ ind\  -> \ delayedfs[\([i,
j]\)], 
              \n\ \ \ \ {j, 1, Length[delayedfs[\([i]\)]]}], 
            \ {i, 1, Length[delayedfs]}]; \n\ \ 
        If[printQ, \ Print["\<forcedterms = \>", \ forcedterms]]; \n\ \
\n\ \ 
        delayedfs\  = \ N[delayedfs]; \n\ \ 
        delaynum\  = \ Map[Length, \ delayedfs]; \n\ \ \n\ \ \n\ \ 
        funcs\  = \ Map[Apply[Rule, #]&, \ inits]; \n\ \ 
        If[printQ, \ Print["\<funcs = \>", \ funcs]]; \n\ \ 
        witchlist\  = \ 
          Table[Which[
              Evaluate[ind\  <= \ start, \n\ \ \ \ 
                deps[\([i]\)]\  /. \ funcs[\([i]\)]]\ ], \ {i, 1,
numdeps}]; 
        \n\ \ g\  = \ Map[Function[Evaluate[ind], \ #]\ &, \ witchlist];
\n
        \ \ numiters\  = \ Ceiling[\((stop\  - \ start)\)/tau]; \n\n\ \ 
        For[j\  = \ 1, \ j\  <= \ numiters, \(j++\), \n\ \ \ \ 
          jt\  = \ N[start\  + \ j*tau]; \n\ \ \ \ 
          If[printQ, \ Print["\<jt = \>", \ jt]]; \n\ \ \n\ \ \ \ 
          sub\  = \ 
            Flatten[Table[\n\ \ \ \ \ \ 
                Table[forcedterms[\([k2, k1]\)]\  -> \ 
                    \(g[\([k2]\)]\)[delayedfs[\([k2, k1]\)]], \n
                  \ \ \ \ \ \ {k1, 1, delaynum[\([k2]\)]}], 
                \ {k2, 1, Length[delaynum]}]]; \n\ \ \ \n\ \ \ \ 
          ics\  = \ 
            Table[\((deps[\([i]\)]\  /. \ ind\  -> \ jt\  - \ tau)\)\ 
== \n
                \ \ \ \ \ \ \(g[\([i]\)]\)[jt\  - \ tau], 
              \ {i, 1, Length[deps]}]; \n\ \ \ \ \ \ \n\ \ \ \ 
          senteqn\  = \ Union[eqn\  /. \ sub, \ ics]; \n\ \ \ \ \n\ \ \
\ 
          If[printQ, \ Print["\<senteqn \>", \ j, \ "\< = \>", \
senteqn]]; \n
          \n\ \ \ \ 
          sol\  = \ 
            Flatten[\n\ \ \ \ \ \ 
              NDSolve[senteqn, \ deps, \ {ind, \ jt\  - \ tau, \ jt},
opts]]; 
          \n\n\ \ \ \ 
          If[onedelay, \n\ \ \ \ \ \ 
            witchlist\  = \ 
              Table[Join[witchlist[\([i]\)], \ \n\ \ \ \ \ \ \ \ 
                  Apply[Which, {ind\  <= \ jt, \n\ \ \ \ \ \ \ \ 
                      deps[\([i]\)]\  /. \ sol}]], \ {i, 1, numdeps}];
\n
            \ \ \ \ \ \ 
            g\  = \ Map[Function[Evaluate[ind], \ #]\ &, \n\ \ \ \ \ \ \
\ 
                Table[
                  Apply[Which, {ind\  <= \ jt, \n\ \ \ \ \ \ \ \ 
                      deps[\([i]\)]\  /. \ sol}], \ {i, 1, numdeps}]],
\n
            \ \ \ \ \ \ 
            g\  = \ Map[Function[Evaluate[ind], \ #]\ &, \n\ \ \ \ \ \ \
\ 
                Table[Join[g[\([i, 2]\)], \ 
                    Apply[Which, {ind\  <= \ jt, \n\ \ \ \ \ \ \ \ 
                        deps[\([i]\)]\  /. \ sol}]], \ {i, 1,
numdeps}]]\n
            \ \ \ \ ]\n\ \ ]; \n\ \ 
        If[onedelay, \n\ \ \ \ 
          g\  = \ Map[Function[Evaluate[ind], \ #]\ &, \ witchlist]]; \n
        \ \ \ \ \ \ \ \ \n{Thread[Rule[deps, Through[g[ind]]]]}\n\n];
\)\)], 
  "Input",
  InitializationCell->True],

Cell[CellGroupData[{

Cell["RootsInRange", "Subsubsection",
  InitializationCell->True],

Cell[BoxData[
    \(TraditionalForm\`Needs["\<Utilities`FilterOptions`\>"]\)],
"Input",
  InitializationCell->True],

Cell[BoxData[
    \(TraditionalForm
    \`\(RootsInRange[d_, {l_, \ lmin_, \ lmax_}, opts___] := 
      Module[{s, p, t, \n\ \ \ f = Function[l, Evaluate[d]]}, \ \n\ \ 
        s = Plot[f[l], \ {l, \ lmin, \ lmax}, \ Compiled \[Rule] False,
\ \n
            \ \ \ \ \ \ \ \ Evaluate[FilterOptions[Plot, \ opts]], \n
            \ \ \ \ \ \ \ \ DisplayFunction \[Rule] Identity]; \n\ \ 
        p = Cases[s, \ Line[{t__}] \[Rule] t, \ Infinity]; \n\ \ 
        p = Map[First, \ \n\ \ \ \ \ \ \ \ 
            Select[Split[p, \ Sign[Last[#2]] == \(-Sign[Last[#1]]\)&],
\n
              \ \ \ \ \ \ \ \ Length[#1] == 2\ &\ ], {\n\ \ \ \ \ \ \ \
\ \ 
              2}]; \n\ \ 
        Apply[FindRoot[f[l] == 0, \ {l, \ ##1}, \n\ \ \ \ \ \ 
              Evaluate[FilterOptions[FindRoot, \n\ \ \ \ \ \ opts]], 
              WorkingPrecision \[Rule] 20]\ &, \ p, \n\ \ \ \ \ \ \
{1}]\n
        \ \ ]; \)\)], "Input",
  InitializationCell->True]
}, Closed]]
}, Closed]]
}, Open  ]]
},
FrontEndVersion->"Macintosh 3.0",
ScreenRectangle->{{0, 800}, {0, 580}}, AutoGeneratedPackage->None,
WindowSize->{520, 485},
WindowMargins->{{92, Automatic}, {Automatic, 13}},
MacintoshSystemPageSetup->"\<\
00<0001804P000000c@2@?oeooH3?`990dL5N`?P0080001804P000000`d26P01
0000I00000400@410?l00BL?00400@0000000000000000P801T1T0000000H000
00000000004000000000000000000082\>"
]


(***********************************************************************
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[1731, 51, 47, 0, 50, "Section"], Cell[1781, 53, 176, 5, 30,
"Text"],
Cell[1960, 60, 810, 19, 82, "Input"], Cell[2773, 81, 149, 3, 28,
"Input"], Cell[2925, 86, 99, 2, 28, "Input"],
Cell[3027, 90, 137, 3, 28, "Input"], Cell[3167, 95, 326, 12, 46,
"Text"],

Cell[CellGroupData[{
Cell[3518, 111, 380, 9, 82, "Input"], Cell[3901, 122, 939, 25, 43,
"Output"] }, Open  ]],
Cell[4855, 150, 435, 11, 28, "Input"], Cell[5293, 163, 46, 0, 30,
"Text"],
Cell[5342, 165, 149, 3, 28, "Input"],

Cell[CellGroupData[{
Cell[5516, 172, 682, 18, 28, "Input"], Cell[6201, 192, 1236, 23, 273,
"Output"] }, Closed]],

Cell[CellGroupData[{
Cell[7474, 220, 682, 18, 25, "Input"], Cell[8159, 240, 246, 6, 37,
"Message"], Cell[8408, 248, 1425, 29, 273, "Output"] }, Closed]],

Cell[CellGroupData[{
Cell[9870, 282, 54, 1, 30, "Subsection",
  InitializationCell->True],
Cell[9927, 285, 143, 6, 78, "Text",
  InitializationCell->True],
Cell[10073, 293, 61, 1, 30, "Text",
  InitializationCell->True],
Cell[10137, 296, 138, 3, 28, "Input",
  InitializationCell->True],
Cell[10278, 301, 5407, 96, 1738, "Input",
  InitializationCell->True],

Cell[CellGroupData[{
Cell[15710, 401, 65, 1, 42, "Subsubsection",
  InitializationCell->True],
Cell[15778, 404, 115, 2, 28, "Input",
  InitializationCell->True],
Cell[15896, 408, 939, 16, 280, "Input",
  InitializationCell->True]
}, Closed]]
}, Closed]]
}, Open  ]]
}
]
*)



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



  • Prev by Date: Re: fractional simplification
  • Next by Date: Graphics to File, color, postscript etc.
  • Prev by thread: Re: NDSolve with delayed terms in equations
  • Next by thread: Re: Animation?