Re: NDSolve useless?
- To: mathgroup at smc.vnet.net
- Subject: [mg63826] Re: [mg63821] NDSolve useless?
- From: Pratik Desai <pdesai1 at umbc.edu>
- Date: Mon, 16 Jan 2006 02:16:53 -0500 (EST)
- References: <200601151043.FAA22735@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Alberto Verga wrote: >Hi, >The following code takes above a minute CPU time (it solves a set of coupled >ordinary differential equations): >In[13]:= >\!\(\(NV = 128;\)\[IndentingNewLine] >\(tf = 1. ;\)\[IndentingNewLine] >\(\[Delta] = 0.1;\)\[IndentingNewLine] >\(a = 0.01;\)\[IndentingNewLine] >\(x0 = Table[ >n/NV + a\ Sin[2 \[Pi]\ n/NV], {n, 1, NV}];\)\[IndentingNewLine] >\(y0 = Table[\(-a\)\ Sin[2 \[Pi]\ n/NV], {n, 1, NV}];\)\[IndentingNewLine] >\(difx = 2 \[Pi]\ \((x\_n[t] - x\_m[t])\);\)\[IndentingNewLine] >\(dify = 2 \[Pi] \((y\_n[t] - y\_m[t])\);\)\[IndentingNewLine] >\(deno = >2\ NV \((Cosh[dify] - Cos[difx] + \[Delta]\^2)\);\)\[IndentingNewLine] >\(equx = \(-Sinh[dify]\)/deno;\)\[IndentingNewLine] >\(equy = Sin[difx]/deno;\)\[IndentingNewLine] >\(sol = >NDSolve[Flatten[ >Table[{\[IndentingNewLine]D[x\_n[t], t] == >Sum[equx, {m, 1, NV}], \[IndentingNewLine]D[y\_n[t], t] == >Sum[equy, {m, 1, NV}], \[IndentingNewLine]x\_n[0] == >x0[\([n]\)], \[IndentingNewLine]y\_n[0] == >y0[\([n]\)]}, {n, 1, NV}]], \[IndentingNewLine]Flatten[ >Table[{x\_n, y\_n}, {n, 1, NV}]], \[IndentingNewLine]{t, 0, >tf}];\) // Timing\) >Out[24]= >{76.199 Second, Null} > > >The same problem solved with function ode45 (or compiled in C or fortran), >takes about (less than) 1 second (on >the same computer). Is there a way to optimize this kind of *numerical* >computation in Mathematica? > > Or is NDSolve useless? > > I think I read somewhere in the documentation that NDSolve code is about 1400 pages long. A bit hard to use but certainly not useless. Again that is just my opinion >(Remark: my question is not about computers but about the implementation of >NDSolve, compared for exemple with other numerical packages; if you add >Method->ExplicitRungeKutta, timing increases!) > >Alberto Verga > > > >Alberto Verga > >IRPHE - Université de Provence >49, rue F. Joliot-Curie, BP 146, >13384 Marseille, France >Tél: 33 (0) 496139751 Fax: 33 (0) 496139709 > > > > > >
- References:
- NDSolve useless?
- From: Alberto Verga <Alberto.Verga@laposte.net>
- NDSolve useless?