MathGroup Archive 1999

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

Search the Archive

Re: Nonlinear Fit with complex model

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19632] Re: Nonlinear Fit with complex model
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Mon, 6 Sep 1999 04:20:45 -0400
  • Organization: University of Western Australia
  • References: <7qsfre$159@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

mtir at my-deja.com wrote:

> Hi,
>
> I am trying to fit a data set of real values with
> a model that involves complex numbers, i.e.
>   model[a,b,c,d]=Abs[<complex expression in
> a,b,c,d>]^2
>
> When I am using NonlinearRegress (or
> NonlinearFit) Mathematica complains that "One or
> more derivatives of the model with respect to
> parameters did not evaluate" and does not return a
> result.
>
> I suspect that the reason for this is that Abs[],
> Re[], Im[] etc. are not evaluated if the argument
> is an expression rather than a number.
>
> Does anyone know a way round this?
>
> Thanks!
> Sebastian
>
> (For those interested: I am trying to calculate
> the complex refractive index of a thin film from
> reflectance measurements as a function of angle)

In the Notebook fragment below, I show a simple trick for computing the
complex conjugate of complex expressions with real variables.  The basic

idea is to compute the conjugate using the replacement

 Complex[a_, b_] :> Complex[a, -b]

actually implemented using the built-in SuperStar function (so that you
can compute conjugates by raising them to the power *):

 SuperStar[x_] := x /. Complex[a_, b_] :> Complex[a, -b]

The point then is that Abs[z]^2 = SuperStar[z] z which enables you to
quickly and efficiently compute the type of expression you want.

Notebook[{
Cell[BoxData[
    \(TraditionalForm
    \`\(exp =
      \(b0\ \[CapitalDelta]z\
          \((Es - \[ImaginaryI]\ \[Eta]\ \[Omega])\)\)\/\(\(-m\)\
            \[Omega]\^2 + m\ \[Omega] -
          \[ImaginaryI]\ m\ \[Gamma]\ \[Omega] +
          b0\ \((Es - \[ImaginaryI]\ \[Eta]\ \[Omega])\)\); \)\)],
"Input"],

Cell[BoxData[
    \(TraditionalForm
    \`\(x_\^*\) := x /. Complex(a_, b_) \[RuleDelayed] Complex(a,
\(-b\))\)],
  "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(TraditionalForm\`\(\(exp\^*\) exp // ExpandAll\) // Simplify\)],
  "Input"],

Cell[BoxData[
    \(TraditionalForm
    \`\(b0\^2\ \[CapitalDelta]z\^2\
        \((Es\^2 + \[Eta]\^2\ \[Omega]\^2)
          \)\)\/\(\((Es\^2 + \[Eta]\^2\ \[Omega]\^2)\)\ b0\^2 +
        2\ m\ \[Omega]\
          \((\(-\[Omega]\)\ Es + Es + \[Gamma]\ \[Eta]\ \[Omega])\)\ b0
+
        m\^2\ \((\[Gamma]\^2 + \((\[Omega] - 1)\)\^2)\)\
\[Omega]\^2\)\)],
  "Output"]
}, Open  ]]
}
]

____________________________________________________________________
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia
Nedlands WA  6907                     mailto:paul at physics.uwa.edu.au
AUSTRALIA                            http://physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________




  • Prev by Date: Re: How to NDSolve the differential equation
  • Next by Date: Re: FindMinimum to minimize e . w . e
  • Previous by thread: Nonlinear Fit with complex model
  • Next by thread: Re: Nonlinear Fit with complex model