Re: how use NDSolve with an ODE having parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg39707] Re: [mg39691] how use NDSolve with an ODE having parameters
- From: Selwyn Hollis <selwynh at earthlink.net>
- Date: Mon, 3 Mar 2003 04:25:24 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Murray,
I can't get NonlinearRegress to work either, but using FindMinimum on
the least squares error seems to work. Here's the general idea:
model[x_, a_, b_] := (y /. First@NDSolve[{ your DE, y[0] == initval},
y, {t, 0, 2}])[x]
LSE[a_, b_] := Sum[(data[[i, 2]] - model[data[[i, 1]], a, b])^2, {i,
Length[data]}]
FindMinimum[LSE[a, b], {a, a1, a2}, {b, b1, b2}]
---
Selwyn Hollis
On Saturday, March 1, 2003, at 10:05 PM, Murray Eisenberg wrote:
> This is a simplification of a question asked by a colleage. He wants
> to
> use as the model function argument to NonlinearRegress (from
> Statistics`NonlinearFit1) a solution of an initial-value problem for a
> differential equation, where the differential equation depends on a
> parameter.
>
> The catch is that the differential equation cannot be solved
> explicitly,
> so he has to resort to solving the initial-value problem by means of
> NDSolve. Of course, NDSolve will not do anything if the differential
> equation involves symbolic parameters. Thus the IDEA of what he wants
> to do is to use the "resulting function" from something like
>
> y[t]/.First@NDSolve[{y'[t] == a y[t] + b, y[0] == 1.}, y[t], {t, 0.,
> 1.}]
>
> -- where two parameters a and b are involved -- as the model. Of
> course
> if NDSolve above is changed to DSolve, no difficulty. But in the
> ACTUAL
> problem at issue, with a much more complicated differential equation,
> DSolve does nothing.
>
> Is there some way to make this work?
>
> There are evidently two difficulties:
>
> (1) How to deal with NDSolve when the differential equation involves
> parameters (perhaps there's something regarding use of Hold that will
> help?); and
>
> (2) For each pair of particular values of the parameters, the result
> from NDSolve is an InterpolatingPolynomial object and NOT the sort of
> "expression in the variable" that seems to be required for the model
> argument to NonlinearRegress. How should the InterpolatingPolynomial
> object be massaged to allow it to be used as an ordinary expression in
> the variable?
>
> --
> Murray Eisenberg murray at math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2859 (W)
> 710 North Pleasant Street
> Amherst, MA 01375
>
>