Prev: LaTex to Mathematica
Next: CUDA support in 7.0?
From: bulash on 21 Nov 2008 05:31 I have serious problem with an eigenvalue problem. I need symbolic solution and using ODE.m package. I wrote my notebook to mathematica but it crashes or never finish for 1 week!!! The noebook is following, best wishes: (* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 15841, 497] NotebookOptionsPosition[ 15084, 471] NotebookOutlinePosition[ 15425, 486] CellTagsIndexPosition[ 15382, 483] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{"q", ":=", "0.2353"}]], "Input", CellChangeTimes->{{3.43378011459375*^9, 3.433780115796875*^9}, { 3.43378017509375*^9, 3.433780203953125*^9}, {3.4337805716875*^9, 3.4337808100625*^9}, {3.433780850078125*^9, 3.433780852296875*^9}, { 3.433870646953125*^9, 3.433870649171875*^9}, {3.43387071484375*^9, 3.4338707170625*^9}, {3.433873282875*^9, 3.433873284*^9}, { 3.434087488609375*^9, 3.434087490875*^9}}], Cell[BoxData[ RowBox[{"n", " ", ":=", RowBox[{ RowBox[{"(", RowBox[{"q", "+", "1"}], ")"}], "/", "2"}]}]], "Input", CellChangeTimes->{{3.434908498078125*^9, 3.43490849928125*^9}}], Cell[BoxData[ RowBox[{"R", ":=", RowBox[{"7147", "/", "10000"}]}]], "Input", CellChangeTimes->{{3.433781894828125*^9, 3.433293594439677*^9}, { 3.43408750809375*^9, 3.434087510828125*^9}, {3.43408832546875*^9, 3.4340883296875*^9}, {3.43413174078125*^9, 3.434131743078125*^9}}], Cell[BoxData[ RowBox[{"G", ":=", " ", FractionBox["5", "3"]}]], "Input", CellChangeTimes->{{3.433294904984147*^9, 3.433294914948475*^9}}], Cell[BoxData[ RowBox[{"Q", ":=", " ", RowBox[{ RowBox[{"-", FractionBox["1", RowBox[{"3", "*", RowBox[{"R", "^", "3"}]}]]}], "-", RowBox[{ FractionBox["4", "3"], "*", "n", "*", RowBox[{"Log", "[", "R", "]"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ FractionBox["2", "3"], "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{ FractionBox["4", "3"], "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["28", "27"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", RowBox[{"R", "^", "3"}]}], "-", RowBox[{ FractionBox["29", "70"], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"R", "^", "5"}]}], "-", RowBox[{ FractionBox["20", "63"], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"R", "^", "7"}]}]}]}]], "Input", CellChangeTimes->{{3.433781101640625*^9, 3.43329381729012*^9}, { 3.4332946039612975`*^9, 3.433294610370514*^9}, 3.4332946715084257`*^9}], Cell[BoxData[ RowBox[{ RowBox[{"K", "[", "r_", "]"}], ":=", RowBox[{"1", "+", RowBox[{"3", "*", "Q", "*", RowBox[{"r", "^", "3"}]}]}]}]], "Input", CellChangeTimes->{{3.43378115428125*^9, 3.4337811764375*^9}, { 3.433781331796875*^9, 3.433781332625*^9}, {3.433783460203125*^9, 3.4332936258648643`*^9}, 3.4332938224875937`*^9, 3.433294676175136*^9}], Cell[BoxData[ RowBox[{ RowBox[{"A", "[", "r_", "]"}], ":=", RowBox[{"1", "-", RowBox[{ FractionBox["16", "3"], "*", "n", "*", RowBox[{"r", "^", "3"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ FractionBox["56", "5"], "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{ FractionBox["112", "15"], "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["104", "45"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", RowBox[{"r", "^", "6"}]}], "-", RowBox[{ FractionBox["90", "7"], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"r", "^", "8"}]}], "-", RowBox[{ FractionBox["44", "3"], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"r", "^", "10"}]}]}]}]], "Input", CellChangeTimes->{3.4332938273245487`*^9, 3.4332946808418465`*^9}], Cell[BoxData[ RowBox[{ RowBox[{"B", "[", "r_", "]"}], ":=", RowBox[{ FractionBox["1", "r"], RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{"4", "-", FractionBox["3", RowBox[{"K", "[", "r", "]"}]]}], ")"}], "-", RowBox[{ RowBox[{"(", RowBox[{ FractionBox["64", "3"], "-", FractionBox["20", RowBox[{"K", "[", "r", "]"}]], "-", FractionBox[ RowBox[{"12", "*", RowBox[{"Log", "[", "r", "]"}]}], RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "2"}]]}], ")"}], "*", "n", "*", RowBox[{"r", "^", "3"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ FractionBox["296", "5"], "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{ FractionBox["592", "15"], "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["1064", "45"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", RowBox[{"r", "^", "6"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ FractionBox["198", "5"], "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{ FractionBox["132", "5"], "*", "n", "*", "q"}], "-", RowBox[{ FractionBox["76", "15"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", FractionBox[ RowBox[{"r", "^", "6"}], RowBox[{"K", "[", "r", "]"}]]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"6", "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{"4", "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["28", "3"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", FractionBox[ RowBox[{"r", "^", "6"}], RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "2"}]]}], "-", RowBox[{ RowBox[{"(", RowBox[{ FractionBox[ RowBox[{"48", "*", RowBox[{ RowBox[{"(", RowBox[{"Log", "[", "r", "]"}], ")"}], "^", "2"}]}], RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "3"}]], "+", FractionBox[ RowBox[{"80", "*", RowBox[{"(", RowBox[{"Log", "[", "r", "]"}], ")"}]}], RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "2"}]]}], ")"}], "*", RowBox[{"n", "^", "2"}], "*", RowBox[{"r", "^", "6"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", FractionBox["560", "7"]}], "+", FractionBox["627", RowBox[{"14", "*", RowBox[{"K", "[", "r", "]"}]}]], "+", FractionBox["261", RowBox[{"70", "*", RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "2"}]}]]}], ")"}], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"r", "^", "8"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", FractionBox["316", "3"]}], "+", FractionBox["152", RowBox[{"3", "*", RowBox[{"K", "[", "r", "]"}]}]], "+", FractionBox["20", RowBox[{"7", "*", RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "2"}]}]]}], ")"}], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"r", "^", "10"}]}]}], ")"}]}]}]], "Input", CellChangeTimes->{{3.43378124371875*^9, 3.433781612421875*^9}, { 3.433781700234375*^9, 3.433781817984375*^9}, 3.433781852796875*^9, { 3.43378340553125*^9, 3.433783406734375*^9}, {3.43378345946875*^9, 3.4332938332030015`*^9}, {3.433294632642539*^9, 3.4332946850679235`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"L", "[", "r_", "]"}], ":=", RowBox[{ FractionBox[ RowBox[{"3", "*", "r"}], RowBox[{"G", "*", RowBox[{"K", "[", "r", "]"}]}]], RowBox[{"(", RowBox[{"1", "-", RowBox[{"4", RowBox[{"(", RowBox[{ FractionBox["1", "3"], "+", FractionBox[ RowBox[{"Log", "[", "r", "]"}], RowBox[{"K", "[", "r", "]"}]]}], ")"}], "*", "n", "*", RowBox[{"r", "^", "3"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ FractionBox["8", "5"], "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{ FractionBox["16", "15"], "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["92", "45"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", RowBox[{"r", "^", "6"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"2", "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{ FractionBox["4", "3"], "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["28", "9"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", FractionBox[ RowBox[{"r", "^", "6"}], RowBox[{"K", "[", "r", "]"}]]}], "+", RowBox[{"16", "*", RowBox[{"(", RowBox[{ FractionBox[ RowBox[{ RowBox[{"(", RowBox[{"Log", "[", "r", "]"}], ")"}], "^", "2"}], RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "2"}]], "+", FractionBox[ RowBox[{"Log", "[", "r", "]"}], RowBox[{"3", "*", RowBox[{"K", "[", "r", "]"}]}]]}], ")"}], "*", RowBox[{"n", "^", "2"}], "*", RowBox[{"r", "^", "6"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ FractionBox["10", "7"], "+", FractionBox["87", RowBox[{"70", "*", RowBox[{"K", "[", "r", "]"}]}]]}], ")"}], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"R", "^", "8"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ FractionBox["4", "3"], "+", FractionBox["20", RowBox[{"21", "*", RowBox[{"K", "[", "r", "]"}]}]]}], ")"}], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"r", "^", "10"}]}]}], ")"}]}]}]], "Input", CellChangeTimes->{{3.43378187296875*^9, 3.433781876875*^9}, { 3.433781919125*^9, 3.43378202434375*^9}, {3.433782063046875*^9, 3.4337823100625*^9}, {3.433782381171875*^9, 3.433782381703125*^9}, { 3.433783459796875*^9, 3.4332938409841905`*^9}, {3.43329469739565*^9, 3.433294716773514*^9}, {3.434101003515625*^9, 3.434101006515625*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"F", "[", "r_", "]"}], ":=", RowBox[{ FractionBox[ RowBox[{"3", "*", RowBox[{"(", RowBox[{"3", "-", FractionBox["4", "G"]}], ")"}]}], RowBox[{ RowBox[{"r", "^", "2"}], "*", RowBox[{"K", "[", "r", "]"}]}]], RowBox[{"(", RowBox[{"1", "-", RowBox[{ RowBox[{"(", RowBox[{ FractionBox["14", "3"], "+", FractionBox[ RowBox[{"4", "*", RowBox[{"Log", "[", "r", "]"}]}], RowBox[{"K", "[", "r", "]"}]]}], ")"}], "*", "n", "*", RowBox[{"r", "^", "3"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ FractionBox["42", "5"], "*", RowBox[{"q", "^", "2"}]}], "+", RowBox[{ FractionBox["84", "15"], "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["128", "45"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", RowBox[{"r", "^", "6"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"2", "*", RowBox[{"q", "^", "2"}]}], "-", RowBox[{ FractionBox["4", "3"], "*", "n", "*", "q"}], "+", RowBox[{ FractionBox["28", "9"], "*", RowBox[{"n", "^", "2"}]}]}], ")"}], "*", FractionBox[ RowBox[{"r", "^", "6"}], RowBox[{"K", "[", "r", "]"}]]}], "+", RowBox[{ RowBox[{"(", RowBox[{ FractionBox[ RowBox[{"16", "*", RowBox[{ RowBox[{"(", RowBox[{"Log", "[", "r", "]"}], ")"}], "^", "2"}]}], RowBox[{ RowBox[{"K", "[", "r", "]"}], "^", "2"}]], "+", FractionBox[ RowBox[{"56", "*", RowBox[{"Log", "[", "r", "]"}]}], RowBox[{"3", "*", RowBox[{"K", "[", "r", "]"}]}]]}], ")"}], "*", RowBox[{"n", "^", "2"}], "*", RowBox[{"r", "^", "6"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ FractionBox["129", "14"], "+", FractionBox["87", RowBox[{"70", "*", RowBox[{"K", "[", "r", "]"}]}]]}], ")"}], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"r", "^", "8"}]}], "-", RowBox[{ RowBox[{"(", RowBox[{ FractionBox["92", "9"], "+", FractionBox["20", RowBox[{"21", "*", RowBox[{"K", "[", "r", "]"}]}]]}], ")"}], "*", RowBox[{"q", "^", "2"}], "*", RowBox[{"r", "^", "10"}]}]}], ")"}]}]}]], "Input", CellChangeTimes->{{3.433782402125*^9, 3.43378244071875*^9}, { 3.433782476265625*^9, 3.433782533125*^9}, {3.433782564671875*^9, 3.433782670671875*^9}, {3.43378271084375*^9, 3.43378281521875*^9}, { 3.43378345996875*^9, 3.4332938481144433`*^9}, {3.433294727629123*^9, 3.433294743552019*^9}, 3.4332948710453453`*^9}], Cell[BoxData[ RowBox[{ RowBox[{"p", "[", "r_", "]"}], ":=", SuperscriptBox["e", RowBox[{"\[Integral]", RowBox[{ RowBox[{"(", FractionBox[ RowBox[{"B", "[", "r", "]"}], RowBox[{"A", "[", "r", "]"}]], ")"}], RowBox[{"\[DifferentialD]", "r"}]}]}]]}]], "Input", CellChangeTimes->{{3.43452129796875*^9, 3.4345213574375*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"a", "[", "r_", "]"}], ":=", RowBox[{ RowBox[{"-", FractionBox[ RowBox[{"F", "[", "r", "]"}], RowBox[{"A", "[", "r", "]"}]]}], "*", RowBox[{"p", "[", "r", "]"}]}]}]], "Input", CellChangeTimes->{{3.43461364603125*^9, 3.434613687875*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"s", "[", "r_", "]"}], ":=", RowBox[{ FractionBox[ RowBox[{"p", "[", "r", "]"}], RowBox[{"A", "[", "r", "]"}]], "*", RowBox[{"L", "[", "r", "]"}]}]}]], "Input", CellChangeTimes->{{3.434613696796875*^9, 3.4346137325625*^9}}], Cell[BoxData[ RowBox[{"ODE", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"p", "'"}], "[", "r", "]"}], "*", RowBox[{ RowBox[{"y", "'"}], "[", "r", "]"}]}], "+", RowBox[{ RowBox[{ RowBox[{"y", "''"}], "[", "r", "]"}], "*", RowBox[{"p", "[", "r", "]"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"a", "[", "r", "]"}], "+", RowBox[{ SuperscriptBox["\[Mu]", "2"], "*", RowBox[{"s", "[", "r", "]"}]}]}], ")"}], "*", RowBox[{"y", "[", "r", "]"}]}]}], "==", "0"}], ",", " ", RowBox[{"y", "[", "r", "]"}], ",", "r", ",", RowBox[{"Method", "\[Rule]", "AllSymbolic"}]}], "]"}]], "Input", CellChangeTimes->{ 3.43461378640625*^9, {3.43461395465625*^9, 3.434614033390625*^9}, { 3.434614072171875*^9, 3.43461407365625*^9}, {3.43461465365625*^9, 3.434614752796875*^9}, {3.43461958184375*^9, 3.434619618078125*^9}, { 3.434619649203125*^9, 3.43461965015625*^9}, {3.43461985528125*^9, 3.434619884265625*^9}, {3.43480108334375*^9, 3.4348011014375*^9}, { 3.43490852271875*^9, 3.434908558421875*^9}}] }, WindowSize->{616, 553}, WindowMargins->{{8, Automatic}, {Automatic, 65}}, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (April 28, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 437, 7, 31, "Input"], Cell[1008, 30, 192, 5, 31, "Input"], Cell[1203, 37, 285, 5, 31, "Input"], Cell[1491, 44, 142, 3, 45, "Input"], Cell[1636, 49, 988, 31, 79, "Input"], Cell[2627, 82, 369, 8, 31, "Input"], Cell[2999, 92, 842, 27, 79, "Input"], Cell[3844, 121, 3621, 111, 288, "Input"], Cell[7468, 234, 2662, 80, 216, "Input"], Cell[10133, 316, 2837, 87, 225, "Input"], Cell[12973, 405, 368, 11, 42, "Input"], Cell[13344, 418, 297, 9, 47, "Input"], Cell[13644, 429, 277, 8, 47, "Input"], Cell[13924, 439, 1156, 30, 55, "Input"] } ] *) (* End of internal cache information *)
From: sjoerd.c.devries on 25 Nov 2008 07:17 Bulash, I can see several problems here: First, what is this ODE package? As far as I know, differential equations are done in Mathematica using DSolve or NDsolve. Are you sure you're not using a another system's package or so (they end in .m as well)? Anyways, I don't see a statement in your program in which you load this package (Needs[ ] or <<), so don't expect Mathematica to know the ODE function automatically. And then there is the use of the set delayed construction ( := ) for all of your assignments, even involving constants. For constants, := is never essential or useful and Set ( = ) usually yields a much faster program. The difference between the two is that in an assignment like a=b+5 the right-hand side is evaluated immediately and the result is used whenever the righthand side is used. The value of b at the time of the assignment to a is used. In a:=b+5 the right-hand side is *not* evaluated until a is actually used in an evaluation. The value of b at that time is used, *not* the value at the time of the assignment to a. Your definition of p ("p[r_] := e^Integrate[B[r]/A[r], r]") has several problems: I assume you want e to be the exponential constant. That should be either entered as E or esc-ee-esc in Mathematica. The integral itself is a very complicated function and will take for ages to solve (if a solution can be found at all, of which I'm not sure). Due to the ':=' it is calculated *every* time p[r] is used. Furthermore, if you would like to evaluate p[5] this would yield e^Integrate[B[5]/A[5], 5] which is clearly nonsense (no integration variable left here). You should really use '=' here. Or perhaps you meant something like: p[r_] := E^Integrate[B[r1]/A[r1], {r1,0,r}] ? Cheers -- Sjoerd
|
Pages: 1 Prev: LaTex to Mathematica Next: CUDA support in 7.0? |