Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6986
| From | Bert RAM Aerts <bert.ram.aerts@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Problems with a first order differential equation |
| Date | 2011-12-07 11:20 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jbni5t$488$1@smc.vnet.net> (permalink) |
| References | <jb4p9j$gsc$1@smc.vnet.net> |
On 30 nov, 09:25, Pippo <dinodebla...@yahoo.it> wrote:
> Dear all,
>
> I have a list of values (2-dimensional). data={{xi,yi}...}
> And I finally am able to fit them as the example below:
> and find the parameters A and B
> -----------------------------------
> Clear[y];
> data = {{1, 0.033}, {2, 0.054}, {5, 0.088}};
> With[{C = 1/9},
> Column[{
> model = DSolve[
> {y'[t] == -A (y[t])^2 + B (C - y[t]), y[0] == 0},
> y[t], t][[1]],
> param = FindFit[data, y[t] /. model, {A, B}, t],
> Plot[y[t] /. model /. param, {t, 0, Max[data[[All, 1]]]},
> ImageSize -> 400, AxesLabel -> {"t", "y[t]"},
> Epilog -> {Red, AbsolutePointSize[5], Point[data]}]}]] // Quiet
> ---------------------------
> Thanks to Bob Hanlon.
>
> However I would like to fit the same data by using different exponents of the term y[t])^2 which appear on the right hand side of the differential equation:
> for example I'd like to use:
>
> {y'[t] == -A (y[t])^3 + B (C - y[t]), y[0] == 0},
> or
> {y'[t] == -A (y[t])^(2.5) + B (C - y[t]), y[0] == 0},
>
> Is that anyway to fit a list of two-dimensional by using the models above?
>
> Thanks.
> Dino
The book Mathematica Navigator from Heikki Ruskeep=E4=E4 3rd edition on
page 879 gives you the answer:
Clear["Global`*"]; c = 1/9; data = {{1, 0.033}, {2, 0.054}, {5,
0.088}};
model[a_?NumericQ, b_?NumericQ] :=
model[a, b] =
y /. NDSolve[{y'[t] == -a (y[t])^3 + b (c - y[t]), y[0] == 0},
y, {t, 0, 6}][[1]]
param = FindFit[data, model[a, b][t], {{a, 1}, {b, 1}}, t]
{a -> 3.23777, b -> 0.341321}
Plot[model[a, b][t] /. param, {t, 0, 6},
Epilog -> {Red, AbsolutePointSize[5], Point[data]}]
Kind regards,
Bert
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Problems with a first order differential equation Pippo <dinodeblasio@yahoo.it> - 2011-11-30 08:25 +0000 Re: Problems with a first order differential equation Bert RAM Aerts <bert.ram.aerts@gmail.com> - 2011-12-07 11:20 +0000
csiph-web