Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*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 1999

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

Search the Archive

About stochastic differential equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19572] About stochastic differential equations
  • From: Dimitris Kugiumtzis <dimitris at mpipks-dresden.mpg.de>
  • Date: Wed, 1 Sep 1999 23:07:05 -0400
  • Sender: owner-wri-mathgroup at wolfram.com


Some time ago I posted a question for how to solve (using
NDSolve) differential equations with noise.

I got some response and I solved the problem (I believe) thanks to
David Park who sent me a notebook. Since some others showed
interest in this problem I attach the notebook (with his permission).
Blimbaum Jerry pointed an easier way to solve the problem (which
I did not test because I had already implemented the notebook
of David):
soln = NDSolve[{x'[t] == Random[] + Sin[t], x[0] == 1}, x[t], {t, 0,
5}] // First
Plot[x[t] /. soln, {t, 0, 5}, PlotRange -> All];

Thanks also to Jens-Peer Kuska and Robert L. Thrash for their
comments.

I should say that I was pleased to get all this response.

Dimitris


--
Dimitris Kugiumtzis
Max-Planck-Institute for Physics of Complex Systems
Noethnitzer Str. 38, 01187 Dresden, Germany
office tel: +49-351-8712211, fax: +49-351-8711199
home tel  : +49-351-4702378, mob: +49-171-1646864
official e-mail: dimitris at mpipks-dresden.mpg.de
lifetime e-mail: dimitris.kugiumtzis at iname.com
http://www.mpipks-dresden.mpg.de/~dimitris





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

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 4.0,
MathReader 4.0, or any compatible application. 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[     16862,        495]*)
(*NotebookOutlinePosition[     18742,        552]*)
(*  CellTagsIndexPosition[     18466,        541]*)
(*WindowFrame->Normal*)



Notebook[{

Cell[CellGroupData[{
Cell["Stochastic Differential Equations", "Title"],

Cell["\<\
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/\
\>", "Subtitle"],

Cell[BoxData[
    \(<< Graphics`Colors`\)], "Input"],

Cell[TextData[{
  "This is an example of simulating two differential equations with random \
noise present. It is from ",
  StyleBox["Flux Induced Biochemical Differentiation, J. theor. Biol (1975) \
54, 363-379. ",
    FontSlant->"Italic"],
  StyleBox["The  random noise is generated in advance of each simulation. If \
the random noise is not going to be entirely random but depend on the \
variables of your equations, other than t, then I don't know if it can be \
done in ",
    FontVariations->{"CompatibilityType"->0}],
  StyleBox["Mathematica",
    FontSlant->"Italic",
    FontVariations->{"CompatibilityType"->0}],
  StyleBox[".",
    FontVariations->{"CompatibilityType"->0}]
}], "Text"],

Cell["\<\
Perhaps you can you this as a model for working out your system.\
\>", "Text"],

Cell[CellGroupData[{

Cell["Simulating the Differentiation of Two Cells", "Section"],

Cell[CellGroupData[{

Cell["A Random Noise Generator", "Subsection"],

Cell[TextData[{
  "This generates a random noise function for ",
  Cell[BoxData[
      \(0 \[LessEqual] t \[LessEqual] 500\)]],
  "."
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    \(ran = 
      Interpolation[
        Transpose[{Range[0, ranmax = 500], 
            Table[Random[Real, {\(-1.0\), 1.0}], {i, 0, ranmax}]}], 
        InterpolationOrder \[Rule] 0]\)], "Input"],

Cell[BoxData[
    TagBox[\(InterpolatingFunction[{{0.`, 500.`}}, "<>"]\),
      False,
      Editable->False]], "Output"]
}, Open  ]],

Cell[BoxData[
    \(\(Plot[ran[t], {t, 0, 500}, 
        ImageSize \[Rule] {7, 4.5} 50];\)\)], "Input"]
}, Closed]],

Cell[CellGroupData[{

Cell["The Differential Equations", "Subsection"],

Cell["\<\
These are the equations. (Two cells being driven by a flux g0, with enzymatic \
mechanisms exchanging material between the cells with the specified rate \
equation, and also material leaving the cells with rate constant a. If the \
flux is high enough the cells are driven to different concentrations of \
material. Which cell obtains the higher concentration depends upon the \
noise.)\
\>", "Text"],

Cell[BoxData[{
    \(Clear[ran]\), "\[IndentingNewLine]", 
    \(\(rate[x1_, x2_, V_, Km_, 
          Keq_] := \((\(V\ x1\)\/\(Km + x1\))\) \((x2\/\(Keq + x2\))\);\)\), \
"\n", 
    \(\(deqns = \n\t{\(x1'\)[t] == 
            g0[t] - a\ x1[t] - rate[x1[t], x2[t], V, Km, Keq] + 
              rate[x2[t], x1[t], V, Km, Keq] + r\ ran[t\/p], \n\t\t\(x2'\)[
              t] == g0[t] - a\ x2[t] - rate[x2[t], x1[t], V, Km, Keq] + 
              rate[x1[t], x2[t], V, Km, Keq] - r\ ran[t\/p], \n\t\tx1[0] == 
            x10, \n\t\tx2[0] == x20};\)\)}], "Input"]
}, Closed]],

Cell[CellGroupData[{

Cell["Simulating Differentiation", "Subsection"],

Cell["\<\
This is a time dependent driving function for the cells (input flow to each \
cell).\
\>", "Text"],

Cell[BoxData[{
    \(Clear[g0]\), "\n", 
    \(g0[t_ /; t < 10] := 1\), "\n", 
    \(g0[t_ /; 10 \[LessEqual] t < 20] := 1 + 0.3 \((t - 10)\)\), "\n", 
    \(g0[t_ /; t \[GreaterEqual] 20] := 4\)}], "Input"],

Cell[BoxData[
    \(\(Plot[g0[t], {t, 0, 100}, PlotStyle \[Rule] Blue, 
        AxesLabel \[Rule] {t, g0}, PlotRange \[Rule] {\(-0.1\), 5.1}, 
        ImageSize \[Rule] {7.0, 4.5} 50, Background \[Rule] Antique, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"g0Differentiation"],

Cell["\<\
This runs a specific simulation. The noise is regenerated each time the \
simulation is done.\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(ran = 
        Interpolation[
          Transpose[{Range[0, ranmax = 100], 
              Table[Random[Real, {\(-1.0\), 1.0}], {i, 0, ranmax}]}], 
          InterpolationOrder \[Rule] 0];\)\), "\n", 
    \(\(data = \n\t{V \[Rule] 100.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            100.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 
            0.001, \n\t\tp \[Rule] 1, \n\t\tx10 \[Rule] 
            1.2, \n\t\tx20 \[Rule] 0.8};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 100}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 8000]\)}], "Input",
  CellTags->"DifferentiationSimulation"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell["This plots the result...", "Text"],

Cell[BoxData[
    \(\(Plot[Evaluate[{x1[t], x2[t]} /. dsol], {t, 0, 100}, 
        PlotStyle \[Rule] {Blue, EnglishRed}, Frame \[Rule] True, 
        FrameLabel \[Rule] {"\<time\>", "\<x1 and x2\>"}, 
        PlotLabel \[Rule] "\<Flux Driven Differentiation of Two Cells\>", 
        Background \[Rule] Antique, ImageSize \[Rule] {7.0, 4.5} 50, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"DifferentiationPlot"],

Cell["\<\
If you evaluate the last two cells a number of times you will see that \
sometimes the blue cell is on top and sometimes on the bottom.\
\>", "Text"]
}, Closed]],

Cell[CellGroupData[{

Cell["Falling Off Catastrophe Points", "Subsection"],

Cell["This is another behavior of the system...", "Text"],

Cell[BoxData[{
    \(Clear[g0]\), "\n", 
    \(g0[t_ /; t < 200] := 0.25  t\), "\n", 
    \(g0[t_ /; t \[GreaterEqual] 200] := 
      50.0 - 0.25 \((t - 200)\)\)}], "Input"],

Cell[BoxData[
    \(\(Plot[g0[t], {t, 0, 400}, PlotStyle \[Rule] Blue, 
        AxesLabel \[Rule] {t, g0}, PlotRange \[Rule] All, 
        ImageSize \[Rule] {7.0, 4.5} 50, Background \[Rule] Antique, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"g0Catastrophe"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(ran = 
        Interpolation[
          Transpose[{Range[0, ranmax = 500], 
              Table[Random[Real, {\(-1.0\), 1.0}], {i, 0, ranmax}]}], 
          InterpolationOrder \[Rule] 0];\)\), "\n", 
    \(\(data = \n\t{V \[Rule] 70.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            20.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 0.005, \n\t\tp \[Rule] 
            1, \n\t\tx10 \[Rule] 1.0, \n\t\tx20 \[Rule] 1.0};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 400}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 12000]\)}], "Input",
  CellTags->"CatastropheSimulation"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 400.`}}, "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 400.`}}, "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell[BoxData[
    \(\(Plot[Evaluate[{x1[t], x2[t]} /. dsol], {t, 0, 400}, 
        PlotStyle \[Rule] {Blue, EnglishRed}, Frame \[Rule] True, 
        FrameLabel \[Rule] {"\<time\>", "\<x1 and x2\>"}, 
        PlotLabel \[Rule] "\<Falling Off Catastrophes\>", 
        Background \[Rule] Antique, ImageSize \[Rule] {7.0, 4.5} 55, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"CatastrophePlot"]
}, Closed]]
}, Closed]],

Cell[CellGroupData[{

Cell["What I learned from your question", "Section"],

Cell["\<\
Even though Method is not shown as an option for NDSolve, it is an option. I \
think the options are Automatic (which is adaptive, I think), RungeKutta, \
Adams and Gear. RungeKutta seems to work OK. WRI doesn't tell us too much \
about this because maybe things will change in future releases.\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    \(Options[NDSolve]\)], "Input"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{\(AccuracyGoal \[Rule] Automatic\), 
        ",", \(Compiled \[Rule] True\), 
        ",", \(DifferenceOrder \[Rule] Automatic\), 
        ",", \(InterpolationPrecision \[Rule] Automatic\), 
        ",", \(MaxRelativeStepSize \[Rule] 1\), 
        ",", \(MaxSteps \[Rule] Automatic\), ",", 
        RowBox[{"MaxStepSize", "\[Rule]", 
          InterpretationBox["\[Infinity]",
            DirectedInfinity[ 1]]}], ",", \(Method \[Rule] Automatic\), 
        ",", \(PrecisionGoal \[Rule] Automatic\), 
        ",", \(SolveDelayed \[Rule] False\), 
        ",", \(StartingStepSize \[Rule] Automatic\), 
        ",", \(StoppingTest \[Rule] None\), 
        ",", \(WorkingPrecision \[Rule] 16\)}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell["The Differential Equations", "Subsection"],

Cell["\<\
These are the equations. (Two cells being driven by a flux g0, with enzymatic \
mechanisms exchanging material between the cells with the specified rate \
equation, and also material leaving the cells with rate constant a. If the \
flux is high enough the cells are driven to different concentrations of \
material. Which cell obtains the higher concentration depends upon the \
noise.)\
\>", "Text"],

Cell["\<\
Here the equations have been changed to evaluate Random dynamically. I had to \
use a trick to keep Random from being evaluated. If you try to use Random \
directly it will be evaluated once when deqns are evaluated.\
\>", "Text"],

Cell[BoxData[
    \(Clear[ran, deqns]\)], "Input"],

Cell[BoxData[{
    \(\(rate[x1_, x2_, V_, Km_, 
          Keq_] := \((\(V\ x1\)\/\(Km + x1\))\) \((x2\/\(Keq + x2\))\);\)\), \
"\[IndentingNewLine]", 
    \(\(ran[t_] := If[t > 0, Random[Real, {\(-1\), 1}], 0];\)\), "\n", 
    \(\(deqns := \n\t{\(x1'\)[t] == 
            g0[t] - a\ x1[t] - rate[x1[t], x2[t], V, Km, Keq] + 
              rate[x2[t], x1[t], V, Km, Keq] + r\ ran[t], \n\t\t\(x2'\)[t] == 
            g0[t] - a\ x2[t] - rate[x2[t], x1[t], V, Km, Keq] + 
              rate[x1[t], x2[t], V, Km, Keq] - r\ ran[t], \n\t\tx1[0] == 
            x10, \n\t\tx2[0] == x20};\)\)}], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(deqns\)], "Input"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{
        RowBox[{
          RowBox[{
            SuperscriptBox["x1", "\[Prime]",
              MultilineFunction->None], "[", "t", "]"}], 
          "==", \(g0[t] + r\ If[t > 0, Random[Real, {\(-1\), 1}], 0] - 
            a\ x1[t] - \(V\ x1[t]\ x2[t]\)\/\(\((Km + x1[t])\)\ \((Keq + \
x2[t])\)\) + \(V\ x1[t]\ x2[t]\)\/\(\((Keq + x1[t])\)\ \((Km + x2[t])\)\)\)}],
         ",", 
        RowBox[{
          RowBox[{
            SuperscriptBox["x2", "\[Prime]",
              MultilineFunction->None], "[", "t", "]"}], 
          "==", \(g0[t] - r\ If[t > 0, Random[Real, {\(-1\), 1}], 0] - 
            a\ x2[t] + \(V\ x1[t]\ x2[t]\)\/\(\((Km + x1[t])\)\ \((Keq + \
x2[t])\)\) - \(V\ x1[t]\ x2[t]\)\/\(\((Keq + x1[t])\)\ \((Km + x2[t])\)\)\)}],
         ",", \(x1[0] == x10\), ",", \(x2[0] == x20\)}], "}"}]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell["Simulating Differentiation", "Subsection"],

Cell["\<\
This is a time dependent driving function for the cells (input flow to each \
cell).\
\>", "Text"],

Cell[BoxData[{
    \(Clear[g0]\), "\n", 
    \(g0[t_ /; t < 10] := 1\), "\n", 
    \(g0[t_ /; 10 \[LessEqual] t < 20] := 1 + 0.3 \((t - 10)\)\), "\n", 
    \(g0[t_ /; t \[GreaterEqual] 20] := 4\)}], "Input"],

Cell[BoxData[
    \(\(Plot[g0[t], {t, 0, 100}, PlotStyle \[Rule] Blue, 
        AxesLabel \[Rule] {t, g0}, PlotRange \[Rule] {\(-0.1\), 5.1}, 
        ImageSize \[Rule] {7.0, 4.5} 50, Background \[Rule] Antique, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"g0Differentiation"],

Cell[TextData[{
  "This runs a specific simulation. Using ",
  Cell[BoxData[
      \(Method \[Rule] Automatic\)]],
  " does not work."
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(data = \n\t{V \[Rule] 100.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            100.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 
            0.001, \n\t\tp \[Rule] 1, \n\t\tx10 \[Rule] 
            1.2, \n\t\tx20 \[Rule] 0.8};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 100}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 8000, Method \[Rule] Automatic]\)}], "Input",
  CellTags->"DifferentiationSimulation"],

Cell[BoxData[
    \(NDSolve::"ndcf" \(\(:\)\(\ \)\) 
      "Repeated convergence test failure at \!\(t\) == \
\!\(62.477993540396476`\); unable to continue."\)], "Message"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            
            TagBox[\(InterpolatingFunction[{{0.`, 62.477993540396476`}}, 
                "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            
            TagBox[\(InterpolatingFunction[{{0.`, 62.477993540396476`}}, 
                "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell[TextData[{
  "But using ",
  Cell[BoxData[
      \(Method \[Rule] RungeKutta\)]],
  " works. However it is slower than generating the noise in advance."
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(data = \n\t{V \[Rule] 100.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            100.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 
            0.001, \n\t\tp \[Rule] 1, \n\t\tx10 \[Rule] 
            1.2, \n\t\tx20 \[Rule] 0.8};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 100}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 8000, Method \[Rule] RungeKutta]\)}], "Input",
  CellTags->"DifferentiationSimulation"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell["This plots the result...", "Text"],

Cell[BoxData[
    \(\(Plot[Evaluate[{x1[t], x2[t]} /. dsol], {t, 0, 100}, 
        PlotStyle \[Rule] {Blue, EnglishRed}, Frame \[Rule] True, 
        FrameLabel \[Rule] {"\<time\>", "\<x1 and x2\>"}, 
        PlotLabel \[Rule] "\<Flux Driven Differentiation of Two Cells\>", 
        Background \[Rule] Antique, ImageSize \[Rule] {7.0, 4.5} 50, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"DifferentiationPlot"],

Cell["\<\
If you evaluate the last two cells a number of times you will see that \
sometimes the blue cell is on top and sometimes on the bottom.\
\>", "Text"]
}, Open  ]]
}, Closed]]
}, Open  ]]
},
FrontEndVersion->"4.0 for Microsoft Windows",
ScreenRectangle->{{0, 1024}, {0, 683}},
WindowSize->{627, 530},
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->{
  "g0Differentiation"->{
    Cell[4981, 160, 308, 5, 70, "Input",
      CellTags->"g0Differentiation"],
    Cell[13366, 392, 308, 5, 70, "Input",
      CellTags->"g0Differentiation"]},
  "DifferentiationSimulation"->{
    Cell[5434, 174, 679, 14, 330, "Input",
      CellTags->"DifferentiationSimulation"],
    Cell[13848, 408, 497, 9, 250, "Input",
      CellTags->"DifferentiationSimulation"],
    Cell[15239, 451, 498, 9, 250, "Input",
      CellTags->"DifferentiationSimulation"]},
  "DifferentiationPlot"->{
    Cell[6593, 206, 443, 7, 130, "Input",
      CellTags->"DifferentiationPlot"],
    Cell[16217, 478, 443, 7, 130, "Input",
      CellTags->"DifferentiationPlot"]},
  "g0Catastrophe"->{
    Cell[7526, 233, 292, 5, 70, "Input",
      CellTags->"g0Catastrophe"]},
  "CatastropheSimulation"->{
    Cell[7843, 242, 661, 13, 330, "Input",
      CellTags->"CatastropheSimulation"]},
  "CatastrophePlot"->{
    Cell[8941, 271, 423, 7, 110, "Input",
      CellTags->"CatastrophePlot"]}
  }
*)

(*CellTagsIndex
CellTagsIndex->{
  {"g0Differentiation", 17473, 511},
  {"DifferentiationSimulation", 17666, 516},
  {"DifferentiationPlot", 17961, 523},
  {"g0Catastrophe", 18148, 528},
  {"CatastropheSimulation", 18253, 531},
  {"CatastrophePlot", 18362, 534}
  }
*)

(*NotebookFileOutline
Notebook[{

Cell[CellGroupData[{
Cell[1739, 51, 50, 0, 105, "Title"],
Cell[1792, 53, 90, 4, 122, "Subtitle"],
Cell[1885, 59, 52, 1, 30, "Input"],
Cell[1940, 62, 698, 16, 90, "Text"],
Cell[2641, 80, 88, 2, 33, "Text"],

Cell[CellGroupData[{
Cell[2754, 86, 62, 0, 53, "Section"],

Cell[CellGroupData[{
Cell[2841, 90, 46, 0, 47, "Subsection"],
Cell[2890, 92, 145, 5, 33, "Text"],

Cell[CellGroupData[{
Cell[3060, 101, 211, 5, 110, "Input"],
Cell[3274, 108, 121, 3, 29, "Output"]
}, Open  ]],
Cell[3410, 114, 103, 2, 30, "Input"]
}, Closed]],

Cell[CellGroupData[{
Cell[3550, 121, 48, 0, 31, "Subsection"],
Cell[3601, 123, 410, 7, 90, "Text"],
Cell[4014, 132, 558, 10, 240, "Input"]
}, Closed]],

Cell[CellGroupData[{
Cell[4609, 147, 48, 0, 31, "Subsection"],
Cell[4660, 149, 108, 3, 33, "Text"],
Cell[4771, 154, 207, 4, 90, "Input"],
Cell[4981, 160, 308, 5, 70, "Input",
  CellTags->"g0Differentiation"],
Cell[5292, 167, 117, 3, 33, "Text"],

Cell[CellGroupData[{
Cell[5434, 174, 679, 14, 330, "Input",
  CellTags->"DifferentiationSimulation"],
Cell[6116, 190, 419, 11, 48, "Output"]
}, Open  ]],
Cell[6550, 204, 40, 0, 33, "Text"],
Cell[6593, 206, 443, 7, 130, "Input",
  CellTags->"DifferentiationPlot"],
Cell[7039, 215, 159, 3, 52, "Text"]
}, Closed]],

Cell[CellGroupData[{
Cell[7235, 223, 52, 0, 31, "Subsection"],
Cell[7290, 225, 57, 0, 33, "Text"],
Cell[7350, 227, 173, 4, 70, "Input"],
Cell[7526, 233, 292, 5, 70, "Input",
  CellTags->"g0Catastrophe"],

Cell[CellGroupData[{
Cell[7843, 242, 661, 13, 330, "Input",
  CellTags->"CatastropheSimulation"],
Cell[8507, 257, 419, 11, 48, "Output"]
}, Open  ]],
Cell[8941, 271, 423, 7, 110, "Input",
  CellTags->"CatastrophePlot"]
}, Closed]]
}, Closed]],

Cell[CellGroupData[{
Cell[9413, 284, 52, 0, 33, "Section"],
Cell[9468, 286, 318, 5, 71, "Text"],

Cell[CellGroupData[{
Cell[9811, 295, 49, 1, 30, "Input"],
Cell[9863, 298, 757, 15, 105, "Output"]
}, Open  ]],

Cell[CellGroupData[{
Cell[10657, 318, 48, 0, 47, "Subsection"],
Cell[10708, 320, 410, 7, 90, "Text"],
Cell[11121, 329, 240, 4, 52, "Text"],
Cell[11364, 335, 50, 1, 30, "Input"],
Cell[11417, 338, 596, 10, 205, "Input"],

Cell[CellGroupData[{
Cell[12038, 352, 38, 1, 30, "Input"],
Cell[12079, 355, 866, 18, 151, "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{
Cell[12994, 379, 48, 0, 31, "Subsection"],
Cell[13045, 381, 108, 3, 33, "Text"],
Cell[13156, 386, 207, 4, 90, "Input"],
Cell[13366, 392, 308, 5, 70, "Input",
  CellTags->"g0Differentiation"],
Cell[13677, 399, 146, 5, 33, "Text"],

Cell[CellGroupData[{
Cell[13848, 408, 497, 9, 250, "Input",
  CellTags->"DifferentiationSimulation"],
Cell[14348, 419, 172, 3, 42, "Message"],
Cell[14523, 424, 507, 15, 48, "Output"]
}, Open  ]],
Cell[15045, 442, 169, 5, 33, "Text"],

Cell[CellGroupData[{
Cell[15239, 451, 498, 9, 250, "Input",
  CellTags->"DifferentiationSimulation"],
Cell[15740, 462, 419, 11, 48, "Output"]
}, Open  ]],
Cell[16174, 476, 40, 0, 33, "Text"],
Cell[16217, 478, 443, 7, 130, "Input",
  CellTags->"DifferentiationPlot"],
Cell[16663, 487, 159, 3, 52, "Text"]
}, Open  ]]
}, Closed]]
}, Open  ]]
}
]
*)




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

--------------8AAB8EAB10A822084B24C553


--------------AEFC719D6E6960B45DD6EE67

Some time ago I posted a question for how to solve (using
NDSolve) differential equations with noise.

I got some response and I solved the problem (I believe) thanks to
David Park who sent me a notebook. Since some others showed
interest in this problem I attach the notebook (with his permission).
Blimbaum Jerry pointed an easier way to solve the problem (which
I did not test because I had already implemented the notebook
of David):
soln = NDSolve[{x'[t] == Random[] + Sin[t], x[0] == 1}, x[t], {t, 0,
5}] // First
Plot[x[t] /. soln, {t, 0, 5}, PlotRange -> All];

Thanks also to Jens-Peer Kuska and Robert L. Thrash for their
comments.

I should say that I was pleased to get all this response.

Dimitris


--
Dimitris Kugiumtzis
Max-Planck-Institute for Physics of Complex Systems
Noethnitzer Str. 38, 01187 Dresden, Germany
office tel: +49-351-8712211, fax: +49-351-8711199
home tel  : +49-351-4702378, mob: +49-171-1646864
official e-mail: dimitris at mpipks-dresden.mpg.de
lifetime e-mail: dimitris.kugiumtzis at iname.com
http://www.mpipks-dresden.mpg.de/~dimitris



--------------AEFC719D6E6960B45DD6EE67

<HTML>
Some time ago I posted a question for how to solve (using
<BR>NDSolve)&nbsp;differential equations with noise.

<P>I&nbsp;got some response and I solved the problem (I&nbsp;believe) thanks
to
<BR>David Park who sent me a notebook. Since some others showed
<BR>interest in this problem I&nbsp;attach the notebook (with his permission).
<BR>Blimbaum Jerry pointed an easier way to solve the problem (which
<BR>I&nbsp;did not test because I had already implemented the notebook
<BR>of David):
<BR>soln = NDSolve[{x'[t] == Random[] + Sin[t], x[0] == 1}, x[t], {t, 0,
<BR>5}] // First
<BR>Plot[x[t] /. soln, {t, 0, 5}, PlotRange -> All];

<P>Thanks also to Jens-Peer Kuska and Robert L. Thrash for their
<BR>comments.

<P>I&nbsp;should say that I&nbsp;was pleased to get all this response.&nbsp;

<P>Dimitris
<BR>&nbsp;
<PRE>--&nbsp;
Dimitris Kugiumtzis
Max-Planck-Institute for Physics of Complex Systems
Noethnitzer Str. 38, 01187 Dresden, Germany
office tel: +49-351-8712211, fax: +49-351-8711199
home tel&nbsp; : +49-351-4702378, mob: +49-171-1646864
official e-mail: dimitris at mpipks-dresden.mpg.de
lifetime e-mail: dimitris.kugiumtzis at iname.com
<A HREF="http://www.mpipks-dresden.mpg.de/~dimitris";>http://www.mpipks-dresden.mpg.de/~dimitris</A></PRE>
&nbsp;</HTML>

--------------AEFC719D6E6960B45DD6EE67--

--------------8AAB8EAB10A822084B24C553

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

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 4.0,
MathReader 4.0, or any compatible application. 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[     16862,        495]*)
(*NotebookOutlinePosition[     18742,        552]*)
(*  CellTagsIndexPosition[     18466,        541]*)
(*WindowFrame->Normal*)



Notebook[{

Cell[CellGroupData[{
Cell["Stochastic Differential Equations", "Title"],

Cell["\<\
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/\
\>", "Subtitle"],

Cell[BoxData[
    \(<< Graphics`Colors`\)], "Input"],

Cell[TextData[{
  "This is an example of simulating two differential equations with random \
noise present. It is from ",
  StyleBox["Flux Induced Biochemical Differentiation, J. theor. Biol (1975) \
54, 363-379. ",
    FontSlant->"Italic"],
  StyleBox["The  random noise is generated in advance of each simulation. If \
the random noise is not going to be entirely random but depend on the \
variables of your equations, other than t, then I don't know if it can be \
done in ",
    FontVariations->{"CompatibilityType"->0}],
  StyleBox["Mathematica",
    FontSlant->"Italic",
    FontVariations->{"CompatibilityType"->0}],
  StyleBox[".",
    FontVariations->{"CompatibilityType"->0}]
}], "Text"],

Cell["\<\
Perhaps you can you this as a model for working out your system.\
\>", "Text"],

Cell[CellGroupData[{

Cell["Simulating the Differentiation of Two Cells", "Section"],

Cell[CellGroupData[{

Cell["A Random Noise Generator", "Subsection"],

Cell[TextData[{
  "This generates a random noise function for ",
  Cell[BoxData[
      \(0 \[LessEqual] t \[LessEqual] 500\)]],
  "."
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    \(ran = 
      Interpolation[
        Transpose[{Range[0, ranmax = 500], 
            Table[Random[Real, {\(-1.0\), 1.0}], {i, 0, ranmax}]}], 
        InterpolationOrder \[Rule] 0]\)], "Input"],

Cell[BoxData[
    TagBox[\(InterpolatingFunction[{{0.`, 500.`}}, "<>"]\),
      False,
      Editable->False]], "Output"]
}, Open  ]],

Cell[BoxData[
    \(\(Plot[ran[t], {t, 0, 500}, 
        ImageSize \[Rule] {7, 4.5} 50];\)\)], "Input"]
}, Closed]],

Cell[CellGroupData[{

Cell["The Differential Equations", "Subsection"],

Cell["\<\
These are the equations. (Two cells being driven by a flux g0, with enzymatic \
mechanisms exchanging material between the cells with the specified rate \
equation, and also material leaving the cells with rate constant a. If the \
flux is high enough the cells are driven to different concentrations of \
material. Which cell obtains the higher concentration depends upon the \
noise.)\
\>", "Text"],

Cell[BoxData[{
    \(Clear[ran]\), "\[IndentingNewLine]", 
    \(\(rate[x1_, x2_, V_, Km_, 
          Keq_] := \((\(V\ x1\)\/\(Km + x1\))\) \((x2\/\(Keq + x2\))\);\)\), \
"\n", 
    \(\(deqns = \n\t{\(x1'\)[t] == 
            g0[t] - a\ x1[t] - rate[x1[t], x2[t], V, Km, Keq] + 
              rate[x2[t], x1[t], V, Km, Keq] + r\ ran[t\/p], \n\t\t\(x2'\)[
              t] == g0[t] - a\ x2[t] - rate[x2[t], x1[t], V, Km, Keq] + 
              rate[x1[t], x2[t], V, Km, Keq] - r\ ran[t\/p], \n\t\tx1[0] == 
            x10, \n\t\tx2[0] == x20};\)\)}], "Input"]
}, Closed]],

Cell[CellGroupData[{

Cell["Simulating Differentiation", "Subsection"],

Cell["\<\
This is a time dependent driving function for the cells (input flow to each \
cell).\
\>", "Text"],

Cell[BoxData[{
    \(Clear[g0]\), "\n", 
    \(g0[t_ /; t < 10] := 1\), "\n", 
    \(g0[t_ /; 10 \[LessEqual] t < 20] := 1 + 0.3 \((t - 10)\)\), "\n", 
    \(g0[t_ /; t \[GreaterEqual] 20] := 4\)}], "Input"],

Cell[BoxData[
    \(\(Plot[g0[t], {t, 0, 100}, PlotStyle \[Rule] Blue, 
        AxesLabel \[Rule] {t, g0}, PlotRange \[Rule] {\(-0.1\), 5.1}, 
        ImageSize \[Rule] {7.0, 4.5} 50, Background \[Rule] Antique, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"g0Differentiation"],

Cell["\<\
This runs a specific simulation. The noise is regenerated each time the \
simulation is done.\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(ran = 
        Interpolation[
          Transpose[{Range[0, ranmax = 100], 
              Table[Random[Real, {\(-1.0\), 1.0}], {i, 0, ranmax}]}], 
          InterpolationOrder \[Rule] 0];\)\), "\n", 
    \(\(data = \n\t{V \[Rule] 100.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            100.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 
            0.001, \n\t\tp \[Rule] 1, \n\t\tx10 \[Rule] 
            1.2, \n\t\tx20 \[Rule] 0.8};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 100}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 8000]\)}], "Input",
  CellTags->"DifferentiationSimulation"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell["This plots the result...", "Text"],

Cell[BoxData[
    \(\(Plot[Evaluate[{x1[t], x2[t]} /. dsol], {t, 0, 100}, 
        PlotStyle \[Rule] {Blue, EnglishRed}, Frame \[Rule] True, 
        FrameLabel \[Rule] {"\<time\>", "\<x1 and x2\>"}, 
        PlotLabel \[Rule] "\<Flux Driven Differentiation of Two Cells\>", 
        Background \[Rule] Antique, ImageSize \[Rule] {7.0, 4.5} 50, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"DifferentiationPlot"],

Cell["\<\
If you evaluate the last two cells a number of times you will see that \
sometimes the blue cell is on top and sometimes on the bottom.\
\>", "Text"]
}, Closed]],

Cell[CellGroupData[{

Cell["Falling Off Catastrophe Points", "Subsection"],

Cell["This is another behavior of the system...", "Text"],

Cell[BoxData[{
    \(Clear[g0]\), "\n", 
    \(g0[t_ /; t < 200] := 0.25  t\), "\n", 
    \(g0[t_ /; t \[GreaterEqual] 200] := 
      50.0 - 0.25 \((t - 200)\)\)}], "Input"],

Cell[BoxData[
    \(\(Plot[g0[t], {t, 0, 400}, PlotStyle \[Rule] Blue, 
        AxesLabel \[Rule] {t, g0}, PlotRange \[Rule] All, 
        ImageSize \[Rule] {7.0, 4.5} 50, Background \[Rule] Antique, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"g0Catastrophe"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(ran = 
        Interpolation[
          Transpose[{Range[0, ranmax = 500], 
              Table[Random[Real, {\(-1.0\), 1.0}], {i, 0, ranmax}]}], 
          InterpolationOrder \[Rule] 0];\)\), "\n", 
    \(\(data = \n\t{V \[Rule] 70.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            20.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 0.005, \n\t\tp \[Rule] 
            1, \n\t\tx10 \[Rule] 1.0, \n\t\tx20 \[Rule] 1.0};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 400}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 12000]\)}], "Input",
  CellTags->"CatastropheSimulation"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 400.`}}, "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 400.`}}, "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell[BoxData[
    \(\(Plot[Evaluate[{x1[t], x2[t]} /. dsol], {t, 0, 400}, 
        PlotStyle \[Rule] {Blue, EnglishRed}, Frame \[Rule] True, 
        FrameLabel \[Rule] {"\<time\>", "\<x1 and x2\>"}, 
        PlotLabel \[Rule] "\<Falling Off Catastrophes\>", 
        Background \[Rule] Antique, ImageSize \[Rule] {7.0, 4.5} 55, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"CatastrophePlot"]
}, Closed]]
}, Closed]],

Cell[CellGroupData[{

Cell["What I learned from your question", "Section"],

Cell["\<\
Even though Method is not shown as an option for NDSolve, it is an option. I \
think the options are Automatic (which is adaptive, I think), RungeKutta, \
Adams and Gear. RungeKutta seems to work OK. WRI doesn't tell us too much \
about this because maybe things will change in future releases.\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    \(Options[NDSolve]\)], "Input"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{\(AccuracyGoal \[Rule] Automatic\), 
        ",", \(Compiled \[Rule] True\), 
        ",", \(DifferenceOrder \[Rule] Automatic\), 
        ",", \(InterpolationPrecision \[Rule] Automatic\), 
        ",", \(MaxRelativeStepSize \[Rule] 1\), 
        ",", \(MaxSteps \[Rule] Automatic\), ",", 
        RowBox[{"MaxStepSize", "\[Rule]", 
          InterpretationBox["\[Infinity]",
            DirectedInfinity[ 1]]}], ",", \(Method \[Rule] Automatic\), 
        ",", \(PrecisionGoal \[Rule] Automatic\), 
        ",", \(SolveDelayed \[Rule] False\), 
        ",", \(StartingStepSize \[Rule] Automatic\), 
        ",", \(StoppingTest \[Rule] None\), 
        ",", \(WorkingPrecision \[Rule] 16\)}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell["The Differential Equations", "Subsection"],

Cell["\<\
These are the equations. (Two cells being driven by a flux g0, with enzymatic \
mechanisms exchanging material between the cells with the specified rate \
equation, and also material leaving the cells with rate constant a. If the \
flux is high enough the cells are driven to different concentrations of \
material. Which cell obtains the higher concentration depends upon the \
noise.)\
\>", "Text"],

Cell["\<\
Here the equations have been changed to evaluate Random dynamically. I had to \
use a trick to keep Random from being evaluated. If you try to use Random \
directly it will be evaluated once when deqns are evaluated.\
\>", "Text"],

Cell[BoxData[
    \(Clear[ran, deqns]\)], "Input"],

Cell[BoxData[{
    \(\(rate[x1_, x2_, V_, Km_, 
          Keq_] := \((\(V\ x1\)\/\(Km + x1\))\) \((x2\/\(Keq + x2\))\);\)\), \
"\[IndentingNewLine]", 
    \(\(ran[t_] := If[t > 0, Random[Real, {\(-1\), 1}], 0];\)\), "\n", 
    \(\(deqns := \n\t{\(x1'\)[t] == 
            g0[t] - a\ x1[t] - rate[x1[t], x2[t], V, Km, Keq] + 
              rate[x2[t], x1[t], V, Km, Keq] + r\ ran[t], \n\t\t\(x2'\)[t] == 
            g0[t] - a\ x2[t] - rate[x2[t], x1[t], V, Km, Keq] + 
              rate[x1[t], x2[t], V, Km, Keq] - r\ ran[t], \n\t\tx1[0] == 
            x10, \n\t\tx2[0] == x20};\)\)}], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(deqns\)], "Input"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{
        RowBox[{
          RowBox[{
            SuperscriptBox["x1", "\[Prime]",
              MultilineFunction->None], "[", "t", "]"}], 
          "==", \(g0[t] + r\ If[t > 0, Random[Real, {\(-1\), 1}], 0] - 
            a\ x1[t] - \(V\ x1[t]\ x2[t]\)\/\(\((Km + x1[t])\)\ \((Keq + \
x2[t])\)\) + \(V\ x1[t]\ x2[t]\)\/\(\((Keq + x1[t])\)\ \((Km + x2[t])\)\)\)}],
         ",", 
        RowBox[{
          RowBox[{
            SuperscriptBox["x2", "\[Prime]",
              MultilineFunction->None], "[", "t", "]"}], 
          "==", \(g0[t] - r\ If[t > 0, Random[Real, {\(-1\), 1}], 0] - 
            a\ x2[t] + \(V\ x1[t]\ x2[t]\)\/\(\((Km + x1[t])\)\ \((Keq + \
x2[t])\)\) - \(V\ x1[t]\ x2[t]\)\/\(\((Keq + x1[t])\)\ \((Km + x2[t])\)\)\)}],
         ",", \(x1[0] == x10\), ",", \(x2[0] == x20\)}], "}"}]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell["Simulating Differentiation", "Subsection"],

Cell["\<\
This is a time dependent driving function for the cells (input flow to each \
cell).\
\>", "Text"],

Cell[BoxData[{
    \(Clear[g0]\), "\n", 
    \(g0[t_ /; t < 10] := 1\), "\n", 
    \(g0[t_ /; 10 \[LessEqual] t < 20] := 1 + 0.3 \((t - 10)\)\), "\n", 
    \(g0[t_ /; t \[GreaterEqual] 20] := 4\)}], "Input"],

Cell[BoxData[
    \(\(Plot[g0[t], {t, 0, 100}, PlotStyle \[Rule] Blue, 
        AxesLabel \[Rule] {t, g0}, PlotRange \[Rule] {\(-0.1\), 5.1}, 
        ImageSize \[Rule] {7.0, 4.5} 50, Background \[Rule] Antique, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"g0Differentiation"],

Cell[TextData[{
  "This runs a specific simulation. Using ",
  Cell[BoxData[
      \(Method \[Rule] Automatic\)]],
  " does not work."
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(data = \n\t{V \[Rule] 100.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            100.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 
            0.001, \n\t\tp \[Rule] 1, \n\t\tx10 \[Rule] 
            1.2, \n\t\tx20 \[Rule] 0.8};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 100}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 8000, Method \[Rule] Automatic]\)}], "Input",
  CellTags->"DifferentiationSimulation"],

Cell[BoxData[
    \(NDSolve::"ndcf" \(\(:\)\(\ \)\) 
      "Repeated convergence test failure at \!\(t\) == \
\!\(62.477993540396476`\); unable to continue."\)], "Message"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            
            TagBox[\(InterpolatingFunction[{{0.`, 62.477993540396476`}}, 
                "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            
            TagBox[\(InterpolatingFunction[{{0.`, 62.477993540396476`}}, 
                "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell[TextData[{
  "But using ",
  Cell[BoxData[
      \(Method \[Rule] RungeKutta\)]],
  " works. However it is slower than generating the noise in advance."
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(data = \n\t{V \[Rule] 100.0, \n\t\tKm \[Rule] 1.0, \n\t\tKeq \[Rule] 
            100.0, \n\t\ta \[Rule] 1.0, \n\t\tr \[Rule] 
            0.001, \n\t\tp \[Rule] 1, \n\t\tx10 \[Rule] 
            1.2, \n\t\tx20 \[Rule] 0.8};\)\), "\n", 
    \(\(seqns = deqns /. data;\)\), "\n", 
    \(dsol = 
      NDSolve[seqns, {x1, x2}, {t, 0, 100}, AccuracyGoal \[Rule] 2, 
        MaxSteps \[Rule] 8000, Method \[Rule] RungeKutta]\)}], "Input",
  CellTags->"DifferentiationSimulation"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{"{", 
        RowBox[{
          RowBox[{"x1", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}], ",", 
          RowBox[{"x2", "\[Rule]", 
            TagBox[\(InterpolatingFunction[{{0.`, 100.`}}, "<>"]\),
              False,
              Editable->False]}]}], "}"}], "}"}]], "Output"]
}, Open  ]],

Cell["This plots the result...", "Text"],

Cell[BoxData[
    \(\(Plot[Evaluate[{x1[t], x2[t]} /. dsol], {t, 0, 100}, 
        PlotStyle \[Rule] {Blue, EnglishRed}, Frame \[Rule] True, 
        FrameLabel \[Rule] {"\<time\>", "\<x1 and x2\>"}, 
        PlotLabel \[Rule] "\<Flux Driven Differentiation of Two Cells\>", 
        Background \[Rule] Antique, ImageSize \[Rule] {7.0, 4.5} 50, 
        Prolog \[Rule] {AbsoluteThickness[3]}];\)\)], "Input",
  CellTags->"DifferentiationPlot"],

Cell["\<\
If you evaluate the last two cells a number of times you will see that \
sometimes the blue cell is on top and sometimes on the bottom.\
\>", "Text"]
}, Open  ]]
}, Closed]]
}, Open  ]]
},
FrontEndVersion->"4.0 for Microsoft Windows",
ScreenRectangle->{{0, 1024}, {0, 683}},
WindowSize->{627, 530},
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->{
  "g0Differentiation"->{
    Cell[4981, 160, 308, 5, 70, "Input",
      CellTags->"g0Differentiation"],
    Cell[13366, 392, 308, 5, 70, "Input",
      CellTags->"g0Differentiation"]},
  "DifferentiationSimulation"->{
    Cell[5434, 174, 679, 14, 330, "Input",
      CellTags->"DifferentiationSimulation"],
    Cell[13848, 408, 497, 9, 250, "Input",
      CellTags->"DifferentiationSimulation"],
    Cell[15239, 451, 498, 9, 250, "Input",
      CellTags->"DifferentiationSimulation"]},
  "DifferentiationPlot"->{
    Cell[6593, 206, 443, 7, 130, "Input",
      CellTags->"DifferentiationPlot"],
    Cell[16217, 478, 443, 7, 130, "Input",
      CellTags->"DifferentiationPlot"]},
  "g0Catastrophe"->{
    Cell[7526, 233, 292, 5, 70, "Input",
      CellTags->"g0Catastrophe"]},
  "CatastropheSimulation"->{
    Cell[7843, 242, 661, 13, 330, "Input",
      CellTags->"CatastropheSimulation"]},
  "CatastrophePlot"->{
    Cell[8941, 271, 423, 7, 110, "Input",
      CellTags->"CatastrophePlot"]}
  }
*)

(*CellTagsIndex
CellTagsIndex->{
  {"g0Differentiation", 17473, 511},
  {"DifferentiationSimulation", 17666, 516},
  {"DifferentiationPlot", 17961, 523},
  {"g0Catastrophe", 18148, 528},
  {"CatastropheSimulation", 18253, 531},
  {"CatastrophePlot", 18362, 534}
  }
*)

(*NotebookFileOutline
Notebook[{

Cell[CellGroupData[{
Cell[1739, 51, 50, 0, 105, "Title"],
Cell[1792, 53, 90, 4, 122, "Subtitle"],
Cell[1885, 59, 52, 1, 30, "Input"],
Cell[1940, 62, 698, 16, 90, "Text"],
Cell[2641, 80, 88, 2, 33, "Text"],

Cell[CellGroupData[{
Cell[2754, 86, 62, 0, 53, "Section"],

Cell[CellGroupData[{
Cell[2841, 90, 46, 0, 47, "Subsection"],
Cell[2890, 92, 145, 5, 33, "Text"],

Cell[CellGroupData[{
Cell[3060, 101, 211, 5, 110, "Input"],
Cell[3274, 108, 121, 3, 29, "Output"]
}, Open  ]],
Cell[3410, 114, 103, 2, 30, "Input"]
}, Closed]],

Cell[CellGroupData[{
Cell[3550, 121, 48, 0, 31, "Subsection"],
Cell[3601, 123, 410, 7, 90, "Text"],
Cell[4014, 132, 558, 10, 240, "Input"]
}, Closed]],

Cell[CellGroupData[{
Cell[4609, 147, 48, 0, 31, "Subsection"],
Cell[4660, 149, 108, 3, 33, "Text"],
Cell[4771, 154, 207, 4, 90, "Input"],
Cell[4981, 160, 308, 5, 70, "Input",
  CellTags->"g0Differentiation"],
Cell[5292, 167, 117, 3, 33, "Text"],

Cell[CellGroupData[{
Cell[5434, 174, 679, 14, 330, "Input",
  CellTags->"DifferentiationSimulation"],
Cell[6116, 190, 419, 11, 48, "Output"]
}, Open  ]],
Cell[6550, 204, 40, 0, 33, "Text"],
Cell[6593, 206, 443, 7, 130, "Input",
  CellTags->"DifferentiationPlot"],
Cell[7039, 215, 159, 3, 52, "Text"]
}, Closed]],

Cell[CellGroupData[{
Cell[7235, 223, 52, 0, 31, "Subsection"],
Cell[7290, 225, 57, 0, 33, "Text"],
Cell[7350, 227, 173, 4, 70, "Input"],
Cell[7526, 233, 292, 5, 70, "Input",
  CellTags->"g0Catastrophe"],

Cell[CellGroupData[{
Cell[7843, 242, 661, 13, 330, "Input",
  CellTags->"CatastropheSimulation"],
Cell[8507, 257, 419, 11, 48, "Output"]
}, Open  ]],
Cell[8941, 271, 423, 7, 110, "Input",
  CellTags->"CatastrophePlot"]
}, Closed]]
}, Closed]],

Cell[CellGroupData[{
Cell[9413, 284, 52, 0, 33, "Section"],
Cell[9468, 286, 318, 5, 71, "Text"],

Cell[CellGroupData[{
Cell[9811, 295, 49, 1, 30, "Input"],
Cell[9863, 298, 757, 15, 105, "Output"]
}, Open  ]],

Cell[CellGroupData[{
Cell[10657, 318, 48, 0, 47, "Subsection"],
Cell[10708, 320, 410, 7, 90, "Text"],
Cell[11121, 329, 240, 4, 52, "Text"],
Cell[11364, 335, 50, 1, 30, "Input"],
Cell[11417, 338, 596, 10, 205, "Input"],

Cell[CellGroupData[{
Cell[12038, 352, 38, 1, 30, "Input"],
Cell[12079, 355, 866, 18, 151, "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{
Cell[12994, 379, 48, 0, 31, "Subsection"],
Cell[13045, 381, 108, 3, 33, "Text"],
Cell[13156, 386, 207, 4, 90, "Input"],
Cell[13366, 392, 308, 5, 70, "Input",
  CellTags->"g0Differentiation"],
Cell[13677, 399, 146, 5, 33, "Text"],

Cell[CellGroupData[{
Cell[13848, 408, 497, 9, 250, "Input",
  CellTags->"DifferentiationSimulation"],
Cell[14348, 419, 172, 3, 42, "Message"],
Cell[14523, 424, 507, 15, 48, "Output"]
}, Open  ]],
Cell[15045, 442, 169, 5, 33, "Text"],

Cell[CellGroupData[{
Cell[15239, 451, 498, 9, 250, "Input",
  CellTags->"DifferentiationSimulation"],
Cell[15740, 462, 419, 11, 48, "Output"]
}, Open  ]],
Cell[16174, 476, 40, 0, 33, "Text"],
Cell[16217, 478, 443, 7, 130, "Input",
  CellTags->"DifferentiationPlot"],
Cell[16663, 487, 159, 3, 52, "Text"]
}, Open  ]]
}, Closed]]
}, Open  ]]
}
]
*)




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



  • Prev by Date: LaTeX Output
  • Next by Date: Re: Wavelet Explorer
  • Previous by thread: Re: LaTeX Output
  • Next by thread: Re: About stochastic differential equations