Re: Iterating NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg7138] Re: [mg7117] Iterating NDSolve
- From: seanross at worldnet.att.net
- Date: Tue, 13 May 1997 01:57:39 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Darrmis wrote: > > Can anyone help? I set up a system of two equations after defining the > expressions f and g. NDSolve[{t'[v]==g, t[0]==10000,x'[v]==f, > x[0]==0,{t,x},{v,0,20}] > > The problem is, both f and g also depend on a parameter that > I call theta (theta actually represents a chemical concentration, this is > a kinetics problem). I can simply vary theta in my definition of f and g > and solve the equations several times to see how solution varies with > theta. I did this (by rewriting the input for theta and the NDsolve > command about 50 times to vary theta from 0 to 50). I can then evaluate > x[v] at several values of v for each theta and make a list for each theta > and apply the function ListPlot3D. This is very inefficient way to graph > x[v,theta]. Is there a simple way to do this in 3 or 4 command lines. > > I'd like in general to numerically solve ODE's and then plot results as > function of two variables. (Is it possible to define a function of the > variable theta as the solution to the NDSolve command? When I try to do > this I get error message.). Any help would be greatly appreciated. A couple of thoughts: 1- have you tried a symbolic solution? I don't know how complicated the functions f and g are. 2-If that doesn't work, try what I call a "symbolic numeric" solution. This involves taking your favorite numerical differential equation method(Eulers, Midpoint, Runga-Kutta etc.) and carrying it out a few terms symbolically. This should be especially easy in mathematica using a recursion formalism. You can test the method for accuracy to see how many terms you actually need by checking your results with NDSolve. One advantage to this method is that you can use the Compile function on the result and speed up execution.