MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

how to use Findminimum with a function defined numerically through a parameter

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15607] how to use Findminimum with a function defined numerically through a parameter
  • From: "pascal vallotton" <Pascal.Vallotton at epfl.ch>
  • Date: Thu, 28 Jan 1999 04:23:35 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear members
I have defined the following function which describes the decay of the
fluorescence after a light pulse in a sample containg a dye molecule
which transmits its excitation to neighbouring fluorophores, the
unknown concentration of which is Conc

d[t_] := Exp[(-t/tau)-eps Conc (t/tau)^(1/3) ]

In this equation, tau is the average lifetime of the donor molecule in
the absence of the neighbouring acceptor molecules.

With my fluorimeter, I measure the fourier transform ( the phase lag
introduced by the interaction of the exciting light with the sample as
well as its demodulation) of the latter function at several 
frequencies experimentally chosen.

Therefore, d(t) is linked to the phases phi[] and modulation  values
mod[] by the following equations.

num[[i]]=NIntegrate[ d[t] Sin[2 Pi freqs[[i]] 1000000
t],{t,0,0.0000001}]; dum[[i]]=NIntegrate[ d[t] Cos[2 Pi
freqs[[i]]1000000 t],{t,0,0.0000001}];
norm[[i]]=NIntegrate[Exp[-t/tau],{t,0,0.00001}];

phi[[i]]=ArcTan[num[[i]]/dum[[i]]]*360/(2 Pi);
mod[[i]]=((num[[i]]/norm[[i]])^2+(dum[[i]]/norm[[i]])^2)^0.5,

the point is that these funtions are numerically computed and they
depend parametrically on the concentration  conc through d(t).

Now, to find the real concentration, I need to find it so that it best
fits to the observed results for the phase and demodulation. The
chisquare function is thus defined:

chi[[k]]=Sum[(1/iphases[[i]])^2 (phi[[i]]-phases[[i]])^2,{i,numboffreq}]

where iphases[i ] describes the experimentally measured standard
deviation in the phase value, phi[i] are for each frequency the
calculated value using the transform and assuming a trial concentration
and phases[i] contains the measured values.

Now my trouble is that the function FindMinimum[chi] refuses to give an
answer. I suspect that this is because it ¨fails¨ to consider chi as a
normal function of the concentration that  needs to be computed
numerically for each value.

The current version of the program uses a loop to increase the
concentration, then fits the points by a polynomial and finds its
minimum. This will get highly time consuming when the system gets more
complex (several lifetimes) and there must be a better way???

I have attached the complete version of the program as well as well as
the experimental files that are to be analyed. Thanks for any help

pascal vallotton
lcppm chem dpt
epfl
lausanne
switzerland

	filename="transfer.nb"

(***********************************************************************

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the
notebook =

starts with the line of stars above.

To get the notebook into a Mathematica-compatible application, do one of
=

the following:

* Save the data starting with the line of stars above into a file
  with a name ending in .nb, then open the file inside the application;

* Copy the data starting with the line of stars above to the
  clipboard, then use the Paste menu command inside the application.

Data for notebooks contains only printable 7-bit ASCII and can be sent
directly in email or through ftp in text mode.  Newlines can be CR, LF
or CRLF (Unix, Macintosh or MS-DOS style).

NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the
word CacheID, otherwise Mathematica-compatible applications may try to
use invalid cache data.

For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
  web: http://www.wolfram.com
  email: info at wolfram.com
  phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from Wolfram
Research.
***********************************************************************)

(*CacheID: 232*)


(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[      5078,        117]*)
(*NotebookOutlinePosition[      5728,        140]*) (* 
CellTagsIndexPosition[      5684,        136]*) (*WindowFrame->Normal*)


Notebook[{
Cell[BoxData[{
    \( (*\
      this\ program\ serves\ the\ aalysis\ of\ time\ resolved\ decay\ =
in\
        vesicles\ *) \n
    \n (*\ enter\ here\ the\ relevant\ data\ *) \n (*\
      file\ containing\ time\ resolved\ data\ in\ ascii\ code\ produced\
= by\
        iss\ *) \nusefile = "\<C:\Temp\Trans.txt\>";
    \n (*\ nombre\ de\ fr\[EAcute]quences\ mesur\[EAcute]es\ *) \n
    numboffreq = 7; \
    \n (*\ forster\ radius\ for\ the\ donor\ acceptor\ pair\ in\ meters\
= *) \n
    ro = 0.0000000059\ ;
    \n (*\ lifetime\ of\ the\ donor\ in\ the\ absence\ of\ acceptor\ *)
= \n
    tau = 0.000000006; \n
    \n (*\ initial\ concentration\ in\ natural\ units\ *) \nConc = 0;
    \n (*\ Wolbers\ constant\ *) \neps\  = \ 4.25409\ ; \n
    \n (*\ initialisation\ des\ variables\ par\ lecture\ du\ fichier\ *)
= \n\
    s1\  = \ OpenRead[usefile]; \ \nReadList[s1, \ String, \ 2]; \ \n
    S1\  = \ ReadList[s1, \ \ Number, \ \ RecordLists\  -> \ True]; \n
    freqs\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    phases\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    moduls\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    iphases\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    imoduls\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    Do[freqs[\([i]\)]\  = \ S1[\([i, 1]\)], \ {i, \ numboffreq}]\),
    \(Do[phases[\([i]\)]\  = \ S1[\([i, 2]\)], \ {i, \ numboffreq}]\), =

    \(Do[moduls[\([i]\)]\  = \ S1[\([i, 3]\)], \ {i, \ numboffreq}]\), =

    \(Do[iphases[\([i]\)]\  = \ S1[\([i, 4]\)], \ {i, \ numboffreq}]\ =
\),
    \(Do[imoduls[\([i]\)]\  = \ S1[\([i, 5]\)], \ {i, \ numboffreq}]\n
    \n (*\ fonction\ d\[EAcute]crivant\ la\ d\[EAcute]croissance\ de\ =
la\
        fluorescence\ en\ pr\[EAcute]sence\ des\ accepteurs\ *) \),
    \(d[t_]\  := \
      Exp[\((\(-t\)/tau)\) - eps\ Conc\ \((t/tau)\)^\((1/3)\)\ ]\ =
\n\n\)}],
  "Input"],

Cell[BoxData[
    \(\(\n (*\
      d\[EAcute]claration\ des\ tableaux\ qui\ contiendront\ les\ =
valeurs\
        calcul\[EAcute]es\ \[AGrave]\ comparer\ aux\ spectres\ *) \ \n
    num\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    dum\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    norm\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    phi\  = \ Table[i, \ {i, \ numboffreq}]; \ \n
    mod\  = \ Table[i, \ {i, \ numboffreq}]; \nchi = \ Table[i, \ = {i,
\ 50}];
    \)\)], "Input"],

Cell[BoxData[{
    \(\n\nConc = 0\),
    \(Do[Conc = Conc + \ 0.1;
      Do[\n (*\ calcul\ des\ transformations\ de\ fourier\ *) \n
        num[\([i]\)] =
          NIntegrate[\
            d[t]\ Sin[2\ Pi\ freqs[\([i]\)]\ 1000000\ t], {t, 0, =
0.0000001}];
        \ndum[\([i]\)] =
          NIntegrate[\
            d[t]\ Cos[2\ Pi\ freqs[\([i]\)] 1000000\ t], {t, 0, =
0.0000001}];
        \nnorm[\([i]\)] = NIntegrate[Exp[\(-t\)/tau], {t, 0, =
0.00001}];
        \n (*\ calcul\ de\ la\ phase\ et\ de\ la\ modulations\
            calcul\[EAcute]e\ *) \n
        phi[\([i]\)] = ArcTan[num[\([i]\)]/dum[\([i]\)]]*360/\((2\ =
Pi)\); \n
        mod[\([i]\)] =
          \((\((num[\([i]\)]/norm[\([i]\)])\)^2 +
                \((dum[\([i]\)]/norm[\([i]\)])\)^2)\)^0.5, {i, =
numboffreq}];
      \n (*\ calcul\ du\ chisquare\ pour\ le\ guess\ =
pr\[EAcute]c\[EAcute]dent
          \ *) \t\nchi[\([k]\)] =
        Sum[\((1/iphases[\([i]\)])\)^2\
            \((phi[\([i]\)] - phases[\([i]\)])\)^2, {i, numboffreq}], =
{k, 10}]
      \n\)}], "Input"]
},
FrontEndVersion->"Microsoft Windows 3.0", ScreenRectangle->{{0, 800},
{0, 572}}, WindowSize->{724, 458},
WindowMargins->{{-22, Automatic}, {Automatic, 5}} ]


(***********************************************************************
Cached data follows.  If you edit this Notebook file directly, not
using Mathematica, you must remove the line containing CacheID at the
top of the file.  The cache data will then be recreated when you save
this file =

from within Mathematica.
***********************************************************************)

(*CellTagsOutline
CellTagsIndex->{}
*)

(*CellTagsIndex
CellTagsIndex->{}
*)

(*NotebookFileOutline
Notebook[{
Cell[1709, 49, 1835, 32, 730, "Input"], Cell[3547, 83, 476, 9, 190,
"Input"], Cell[4026, 94, 1048, 21, 290, "Input"] }
]
*)



(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)


	filename="Trans.txt"

* trans.txt
*DATA: FREQ      PHASE      MOD      DELTAP      DELTAM
     5.0000000     7.450    0.981      0.021      0.001
    29.1700000    29.410    0.734      0.021      0.001
    53.3300000    37.740    0.587      0.031      0.001
    77.5000000    42.720    0.499      0.056      0.002
   101.6700000    46.670    0.440      0.050      0.002
   125.8300000    49.590    0.390      0.053      0.002
   150.0000000    52.060    0.358      0.036      0.001



  • Prev by Date: Re: harder parts of list
  • Next by Date: Re: change the solution to a differential equation into a user defined function - question.nb (0/1)
  • Previous by thread: Re: Block vs. Module
  • Next by thread: FD-TD software