curve fitting: works badly? [message #3672] |
Mon, 06 March 1995 08:19  |
feil
Messages: 1 Registered: March 1995
|
Junior Member |
|
|
I try to use CURVEFIT to get some simple data fitted to an harmonic
oscillator.
Somehow things don't work very good.
these are the datapoints:
i x(i) y(i)
0 8 6.5550 -0.3052
1 8 6.6233 -0.3076
2 8 6.6915 -0.3088
3 8 6.7598 -0.3091
4 8 6.8281 -0.3086
5 8 6.8281 -0.3086
6 8 6.8964 -0.3074
7 8 6.9647 -0.3054
the calling sequence:
;;-------------------- fit to harmonic oscillator ------------------------
a = fltarr(3)
; start estimates
a(0) = etot(icnt/2)
dx = lattice(1)-lattice(0)
a(1) = (etot(2)+etot(0)-2*etot(1))/(dx*dx)
a(2) = lattice(icnt/2)
w = fltarr(icnt)
for i = 0,icnt-1 do begin
w(i) = 1.
end
yfit = mod_curvefit(lattice,etot,w,a)
and the finction itself:
;
; the harmonic oscillator function
;
;
;
pro FUNCT,x,a,f,pder
f = a(0) + a(1)*(x-a(2))^2
PDER = FLTARR(N_ELEMENTS(X),3) ;YES, MAKE ARRAY.
PDER(*,0) = 1.0 ;COMPUTE PARTIALS
PDER(*,1) = (x-a(2))^2
PDER(*,2) = 2*a(1)*(x-a(2))
end
RETURN
end
Simple isn't it.
I never get a decent fit!!!!
HELP HELP
Hans
--
Dr.H.Feil
Philips Research Laboratories, WB-121 | phone : +31-40-742701
Prof. Holstlaan 4 | fax : +31-40-743365
5656 AA Eindhoven, The Netherlands | email : feil@prl.philips.nl
|
|
|