given a set of data (e.g. {x,y} pairs) and a theoretical model described by
a differential equation (with some free parameters) that cannot be solved analytically, I am searching for
a way to somehow use Mathematica to fit the numerical solution of the equation
to the data set.
Unfortunately I failed to utilize FindFit and NDSolve on this behalf (which might very well be due to my lack
of experience with Mathematica...).
Any suggestions on how to do this?
Kind regards,
Timm
Clear@stFit;
stFit[in_] :== Module[
{modFit,
soly,
data == Table[{t, Exp[-in*t]}, {t, 0, 10, .01}]
},
modFit[omega_?NumberQ] :==
modFit[omega] == (y /.
First@NDSolve[{y'[x] + omega*y[x] ==== 0, y[0] ==== 1},
y, {x, 0, 10}]);
FindFit[data, modFit[a][x], a, x]
]
should work.
This just does the obvious thing: it defines modFit which, given a number omega returns the numerical solution to the ode y'[x]+omega*y[x]====0 (ie, Exp[-omega*t]). It then fits it to the data I've generated in the beginning.
Since FindFit will call modFit many times with the same omega (use Sow and Reap to see that), memoization speeds this up immensely.
Where precisely had you gotten stuck? It's easy to look at the mess I posted and get confused (it's written in a hurry and without much thought), so perhaps you could be more specific.
So this thread can be considered as "solved".
Kind regards
Timm
On 21.10.2010, at 17:49, Joerg Roesgen wrote:
> Hi Timm,
>
> you can use FindFit. Under FindFit in the documentation you have Applications -> Differential Equations. This is probably what you want to read.
>
> Best,
> J=F6rg
>
> On Oct 21, 2010, at 7:01 , Timm Florian Gloger wrote:
>
>> Hi list,
>>
>> given a set of data (e.g. {x,y} pairs) and a theoretical model described by
>> a differential equation (with some free parameters) that cannot be solve d analytically, I am searching for