Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Help. Fitting 2 dimensional lists with a parametric differential
Replies: 2   Last Post: Jan 30, 2013 4:25 AM

 Messages: [ Previous | Next ]
 Bob Hanlon Posts: 906 Registered: 10/29/11
Re: Help. Fitting 2 dimensional lists with a parametric differential
Posted: Jan 28, 2013 2:24 AM

data1211 = {
{0., 0.}, {1., 3.26437*10^-6},
{2., 8.2151*10^-6}, {3., 0.0000145337},
{4., 0.000019431}, {5., 0.0000251649},
{6., 0.0000305308}, {7., 0.000035411},
{8., 0.0000401542}, {9., 0.0000449553},
{10., 0.0000499532}, {11., 0.0000545809},
{12., 0.0000592216}, {13., 0.0000640473},
{14., 0.0000690212}, {15., 0.0000740661},
{16., 0.0000782586}, {17., 0.0000822824},
{18., 0.0000861226}, {19., 0.0000898602},
{20., 0.0000937152}, {21., 0.0000978347},
{22., 0.000101408}, {23., 0.000105147},
{24., 0.000108497}, {25., 0.000111885},
{26., 0.000115624}, {27., 0.000119227},
{28., 0.000122341}, {29., 0.00012508},
{30., 0.000127729}, {31., 0.000130467},
{32., 0.000133645}, {33., 0.000136591},
{34., 0.000139623}, {35., 0.00014186},
{36., 0.000144227}, {37., 0.000146746},
{38., 0.000148986}, {39., 0.00015123},
{40., 0.000153402}, {41., 0.000155531},
{42., 0.0001574}, {43., 0.000159421},
{44., 0.000161271}, {45., 0.000162982},
{46., 0.000164705}, {47., 0.000166305},
{48., 0.000167756}};

tmax = Max[data1211[[All, 1]]];

Clear[model];
model[a_?NumericQ, b_?NumericQ] :=
y /. NDSolve[{
y'[t] == -a y[t]^2 + b (1 - y[t]),
y[0] == 0}, y, {t, 0, tmax}][[1]]

Column[{
param = FindFit[data1211,
model[a, b][t], {a, b}, t],
Plot[
Evaluate[model[a, b][t] /. param],
{t, 0, tmax},
ImageSize -> 350,
PlotRange -> All,
AxesLabel -> {"t (sec)", "Ca,mol/liter"},
BaseStyle -> {FontSize -> 15},
Epilog -> {Point[data1211]}]}] // Quiet

Bob Hanlon

On Sat, Jan 26, 2013 at 1:39 AM, <dinodeblasio@gmail.com> wrote:
> Hello everyone,
> I have the following code:
>
> Clear[y];
> Column[{model =
> DSolve[{y'[t] == -A (y[t])^2 + B (1 - y[t]), y[0] == 0}, y[t],
> t][[1]], param = FindFit[data1211, y[t] /. model, {A, B}, t],
> Plot[y[t] /. model /. param, {t, 0, Max[data1211[[All, 1]]]},
> PlotRange -> All, ImageSize -> 350, PlotStyle -> {Black},
> AxesLabel -> {"", "Ca,mol/liter"}, BaseStyle -> {FontSize -> 15},
> Epilog -> {Text["Step [1]", {50, 0.00002}],
> Text["(sec)", {140, 0.00002}], Point[data1211]}]}] // Quiet
>
> where "data1211" is a list as follows:
> {{0., 0.}, {1., 3.26437*10^-6}, {2., 8.2151*10^-6}, {3.,
> 0.0000145337}, {4., 0.000019431}, {5., 0.0000251649}, {6.,
> 0.0000305308}, {7., 0.000035411}, {8., 0.0000401542}, {9.,
> 0.0000449553}, {10., 0.0000499532}, {11., 0.0000545809}, {12.,
> 0.0000592216}, {13., 0.0000640473}, {14., 0.0000690212}, {15.,
> 0.0000740661}, {16., 0.0000782586}, {17., 0.0000822824}, {18.,
> 0.0000861226}, {19., 0.0000898602}, {20., 0.0000937152}, {21.,
> 0.0000978347}, {22., 0.000101408}, {23., 0.000105147}, {24.,
> 0.000108497}, {25., 0.000111885}, {26., 0.000115624}, {27.,
> 0.000119227}, {28., 0.000122341}, {29., 0.00012508}, {30.,
> 0.000127729}, {31., 0.000130467}, {32., 0.000133645}, {33.,
> 0.000136591}, {34., 0.000139623}, {35., 0.00014186}, {36.,
> 0.000144227}, {37., 0.000146746}, {38., 0.000148986}, {39.,
> 0.00015123}, {40., 0.000153402}, {41., 0.000155531}, {42.,
> 0.0001574}, {43., 0.000159421}, {44., 0.000161271}, {45.,
> 0.000162982}, {46., 0.000164705}, {47., 0.000166305}, {48.,
> 0.000167756}}
>
> Now I'd like to fit the equation: y'[t] == -A (y[t])^3 + B (1 - y[t]),
> by using NDsolve and find the two parameters A and B.
>
> Can anyone help on this?
> Thank really much for your help.
> Dino
>

Date Subject Author
1/28/13 Bob Hanlon
1/30/13 dinodeblasio@gmail.com