Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6781 > unrolled thread

Re: How to solve or approximate a first order differential equation ?

Started byBob Hanlon <hanlonr357@gmail.com>
First post2011-11-27 09:17 +0000
Last post2011-11-29 12:04 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: How to solve or approximate a first order differential equation ? Bob Hanlon <hanlonr357@gmail.com> - 2011-11-27 09:17 +0000
    Re: How to solve or approximate a first order differential equation ? Dino <dinodeblasio@gmail.com> - 2011-11-28 10:57 +0000
    Re: How to solve or approximate a first order differential equation ? Dino <dinodeblasio@gmail.com> - 2011-11-28 10:54 +0000
      Re: How to solve or approximate a first order differential equation ? Ray Koopman <koopman@sfu.ca> - 2011-11-29 12:04 +0000

#6781 — Re: How to solve or approximate a first order differential equation ?

FromBob Hanlon <hanlonr357@gmail.com>
Date2011-11-27 09:17 +0000
SubjectRe: How to solve or approximate a first order differential equation ?
Message-ID<jasv6s$762$1@smc.vnet.net>
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


Bob Hanlon


On Sat, Nov 26, 2011 at 5:09 AM, Dino <dinodeblasio@gmail.com> wrote:
> Hello everyone,
>
> I have this first order differential equation:
>
> y'[t] = -A (y[t])^2 + B (C - y[t])
>
> where A and B are unknown constants and C is known constant.
> One condition is y[0]==0
>
> A and B should be determined by fitting a list of {y[i],t[i]} values.
>
> For this reason i would like to approximate my differential equation
> with a function which I could use to fit the data and find A and B.
>
> I don't know how to do this.
> Any help is highly appreciated.
>
> Thanks,

[toc] | [next] | [standalone]


#6789

FromDino <dinodeblasio@gmail.com>
Date2011-11-28 10:57 +0000
Message-ID<javpeq$jc5$1@smc.vnet.net>
In reply to#6781
Hello and thank you very much for the reply,

My list of data is very large and it gives me some errors,
I was thinking to reduce the number of points and put some constraints
to the list terms so that I could have this work. Should I use Select
or Cases? (But I dont know how to do it)

I copied here the first terms:
data= {{1.1795*10^-12, 0.}, {1.1795*10^-12, 0.000011918}, {1., \
0.0000276853}, {1., 0.000027194}, {1., 0.0000242474}, {1., \
0.0000267025}, {1., 0.0000281765}, {1., 0.0000276853}, {1., \
0.000031607}, {1., 0.0000276853}, {1., 0.000027194}, {2., \
0.0000262109}, {2., 0.0000232628}, {2., 0.0000379602}, {2., \
0.0000355202}, {2., 0.0000311167}, {2., 0.000035031}, {2., \
0.0000306263}, {2., 0.0000374716}, {2., 0.0000360052}, {3., \
0.0000306263}, {3., 0.0000203098}, {3., 0.0000355202}, {3., \
0.0000384486}}

Thanks again.
Dino

[toc] | [prev] | [next] | [standalone]


#6795

FromDino <dinodeblasio@gmail.com>
Date2011-11-28 10:54 +0000
Message-ID<javp9t$jap$1@smc.vnet.net>
In reply to#6781
Hello and thanks for your reply,

I have a list like this(these are the first terms:
data = {{1.1795*10^-12, 0.}, {1.1795*10^-12, 0.000011918}, {1.,
  0.0000276853}, {1., 0.000027194}, {1., 0.0000242474}, {1.,
  0.0000267025}, {1., 0.0000281765}, {1., 0.0000276853}, {1.,
  0.000031607}, {1., 0.0000276853}, {1., 0.000027194}, {2.,
  0.0000262109}, {2., 0.0000232628}, {2., 0.0000379602}, {2.,
  0.0000355202}, {2., 0.0000311167}, {2., 0.000035031}, {2.,
  0.0000306263}, {2., 0.0000374716}, {2., 0.0000360052}, {3.,
  0.0000306263}, {3., 0.0000203098}, {3., 0.0000355202}, {3.,
  0.0000384486}, {3., 0.0000345417}, {3., 0.0000345417}, {3.,
  0.0000237551}, {3., 0.0000252315}, {3., 0.0000257192}, {4.,
  0.0000237551}, {4., 0.0000267025}}

and it gives me some errors. Is that possible to keep only a selected
amount of data, because it would be easier to work with a less amount
of data.
Furthermore the first terms {xi, ...} are repeated because there are
more measures for each second. How to keep only one value for each
{xi, ...} ?
In conclusion I would like to keep only for example 50 terms from the
list of data and make the model work as you showed.

Thanks,

[toc] | [prev] | [next] | [standalone]


#6799

FromRay Koopman <koopman@sfu.ca>
Date2011-11-29 12:04 +0000
Message-ID<jb2hou$5ah$1@smc.vnet.net>
In reply to#6795
On Nov 28, 2:54 am, Dino <dinodebla...@gmail.com> wrote:
> Hello and thanks for your reply,
>
> I have a list like this(these are the first terms:
> data = {{1.1795*10^-12, 0.}, {1.1795*10^-12, 0.000011918},
> {1., 0.0000276853}, {1., 0.000027194}, {1., 0.0000242474},
> {1., 0.0000267025}, {1., 0.0000281765}, {1., 0.0000276853},
> {1., 0.000031607}, {1., 0.0000276853}, {1., 0.000027194},
> {2., 0.0000262109}, {2., 0.0000232628}, {2., 0.0000379602},
> {2., 0.0000355202}, {2., 0.0000311167}, {2., 0.000035031},
> {2., 0.0000306263}, {2., 0.0000374716}, {2., 0.0000360052},
> {3., 0.0000306263}, {3., 0.0000203098}, {3., 0.0000355202},
> {3., 0.0000384486}, {3., 0.0000345417}, {3., 0.0000345417},
> {3., 0.0000237551}, {3., 0.0000252315}, {3., 0.0000257192},
> {4., 0.0000237551}, {4., 0.0000267025}}
>
> and it gives me some errors. Is that possible to keep only a selected
> amount of data, because it would be easier to work with a less amount
> of data.
> Furthermore the first terms {xi, ...} are repeated because there are
> more measures for each second. How to keep only one value for each
> {xi, ...} ?

Use the means:

{#, Mean@Cases[data,{#,_}][[All,2]]}& /@ Union@data[[All,1]]

{{1.1795*^-12, 5.959*^-6},
 {1., 0.0000275753},
 {2., 0.0000325783},
 {3., 0.0000298549},
 {4., 0.0000252288}}

> In conclusion I would like to keep only for example 50 terms from the
> list of data and make the model work as you showed.
>
> Thanks,

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web