Example3 - (* Content-type: application/mathematica *) (*...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 37746, 697] NotebookOptionsPosition[ 37303, 677] NotebookOutlinePosition[ 37648, 692] CellTagsIndexPosition[ 37605, 689] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell["\<\ !!!!!!! This shows how to solve and plot a system of ODEs in Mathematica. You may use whatever software you like for you homework.\ \>", "Text", CellChangeTimes->{{3.464046966234375*^9, 3.46404702696875*^9}, { 3.467922895515625*^9, 3.46792289715625*^9}}, FontSize->16], Cell[CellGroupData[{ Cell[TextData[StyleBox["Solving a system of ODEs numerically with initial \ conditions and parameters:", FontColor->RGBColor[1, 0, 0]]], "Subsection", CellChangeTimes->{{3.463944415*^9, 3.463944455609375*^9}, { 3.467922907328125*^9, 3.4679229279375*^9}, {3.467923279890625*^9, 3.467923281078125*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", "y_", ",", "\[Alpha]_"}], "]"}], "=", RowBox[{"x", "-", RowBox[{"\[Alpha]", " ", "y"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"g", "[", RowBox[{"x_", ",", "y_", ",", "\[Beta]_"}], "]"}], "=", RowBox[{"x", "+", RowBox[{"\[Beta]", " ", "y"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"tend", "=", "10"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x0", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"y0", "=", "1"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
RowBox[{"{", RowBox[{ RowBox[{"xsol", "[", "t_", "]"}], ",", RowBox[{"ysol", "[", "t_", "]"}]}], "}"}], "=", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], "/.", "\[IndentingNewLine]", RowBox[{ RowBox[{"NDSolve", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"x", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{"f", "[", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}], ",", "5"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"y", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{"g", "[", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}], ",", RowBox[{"-", "2"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "[", "0", "]"}], "\[Equal]", "x0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", "0", "]"}], "\[Equal]", "y0"}]}], "}"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "tend"}], "}"}]}], "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}]}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"Plot", "[",
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

Example3 - (* Content-type: application/mathematica *) (*...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online