MathGroup Archive 2003

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

Search the Archive

Re: NonlinearFit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42221] Re: NonlinearFit
  • From: gohtk at rocketmail.com (goh tat kean)
  • Date: Tue, 24 Jun 2003 01:27:08 -0400 (EDT)
  • References: <bd6j0m$ca7$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Andy,

Not too sure whether I am on the right track.  

You defined a function, 
Re[a Exp[I Pi*b/180]/(x - c + I d)^2.5]

To use NonlinearFit, you need to extract the real part of the
function.

Assume you have a function of 3 + 4 I, the real part of this function
is 3.

Consider the following,
(3 + 4 I)*Conjugate[3 + 4 I]
= 3^2 - 4 I^2

One can obtain 3 from the above by taking square root of the real
part,
(3^2)^0.5
= 3

Let us use the above described method on your function,
a Exp[I Pi*b/180]/(x - c + I d)^2.5

(a Exp[I Pi*b/180]/(x - c + I d)^2.5)*Conjugate[a Exp[I Pi*b/180]/(x -
c + I d)^2.5]

Expand the complex function,
ComplexExpand[%, TargetFunctions -> {Re, Im}]

Take out the real part of the expanded complex function and square
root it,
(a^2 Cos[2.5 ArcTan[-c + x, -d]] Cos[
        2.5 ArcTan[-c + x, d]]/(d^2 + (x - c)^2)^2.5 - (a^2 Sin[
        2.5 ArcTan[-c + x, -d]] Sin[
          2.5 ArcTan[-c + x, d]]/(d^2 + (x - c)^2)^2.5))^0.5

Load in the NonlinearFit package,
<< Statistics`NonlinearFit`

Start the fitting,
ft1 = NonlinearFit[data1, (a^2 Cos[2.5 ArcTan[-c + x, -d]] Cos[
        2.5 ArcTan[-c + x, d]]/(d^2 + (x - c)^2)^2.5 - (a^2 Sin[
        2.5 ArcTan[-c + x, -d]] Sin[
          2.5 ArcTan[-c + x, d]]/(d^2 + (x - c)^2)^2.5))^0.5, x, {a,
b, c, d}, ShowProgress -> True]

Plot of the experimental and fitted curves,
gex = ListPlot[data1]
gft = Plot[ft1, {x, 1, 10}]
Show[gex, gft]

Hope this can help. Good luck!

Regards,
tat kean

lamp02 at hotmail.com (Andrew Kang) wrote in message news:<bd6j0m$ca7$1 at smc.vnet.net>...
> Hi,
> 
> Please could someone assist me in curve fitting.
> 
> I have imported a x,y file as follows:
> 
> data1 = ReadList["data.txt",{Real,Real}]
> 
> Now I wish to fit a curve of the form below to it:
> 
>  Re[a Exp[I Pi*b/180]/(x - c + I d)^2.5]
> 
>  ,where a, b, c, d are parameters to be determined (real numbers), and
> 'I' means the imaginary part of a complex number.
> 
>  I tried the following but it doesn't work:
> 
> <<Statistics`NonlinearFit` 
> 
> NonlinearFit[data1, Re[a Exp[I Pi*b/180]/(x - c + I
> d)^2.5],{x},{{a,0,0001},{b,120},{c,1.26},{d,0.05}}]
> 
>  Please help me.
> 
>  Thanks is advance
> 
>  Andy


  • Prev by Date: Mathematica 5
  • Next by Date: Re: fitting problem... iteration??
  • Previous by thread: Re: NonlinearFit
  • Next by thread: Re: NonlinearFit