This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: Testing exemple in chap.33 problems
- To: "Robin Drolet" <r_drolet at hotmail dot com>
- Subject: Re: Testing exemple in chap.33 problems
- From: Brian Gough <bjg at network-theory dot co dot uk>
- Date: Fri, 8 Jun 2001 13:51:42 +0100 (BST)
- CC: gsl-discuss at sources dot redhat dot com
- References: <F123IeSNLdcIlBUDrM50000cd26@hotmail.com>
Thanks for sending the program... the problem is in your decay_f and
decay_df functions. In the loops of those functions you need to
replace *relaxT by relaxT[i], otherwise the value does not depend on
the index i. The same applies to *sigma which should be sigma[i] in
both loops.
The iteration will then converge to the expected values.
regards
Brian Gough
diff testbestfit.c.orig testbestfit.c
61c61
< double ITcalc = I0 * exp( -( * relaxT / T1or2) );
---
> double ITcalc = I0 * exp( -(relaxT[i] / T1or2) );
87,89c87,89
< gsl_matrix_set(df,i,0,-1 * exp(-(*relaxT / T1or2))/ (*sigma));
< gsl_matrix_set(df,i,1,(-I0 * (*relaxT) * exp( -( *relaxT / T1or2))) /
< (T1or2 * T1or2 * ( *sigma)) );
---
> gsl_matrix_set(df,i,0,-1 * exp(-(relaxT[i] / T1or2))/ s);
> gsl_matrix_set(df,i,1,(-I0 * (relaxT[i]) * exp( -( relaxT[i] / T1or2))) /
> (T1or2 * T1or2 * s));
bjg|debian> ./a.out
1.000000e-06 p.cent err abs
1.000000e-06 p.cent err rel
Entrez la valeure de debut pour I(0):1
Entrez la valeure de debut pour T1 ou T2:1
.....
iter: 0 x = 1.000000e+00 1.000000e+00 |f(x)| = 6.324549e+01
status = success
iter: 1 x = 8.114600e+00 1.711493e+00 |f(x)| = 6.321516e+01
status = success
iter: 2 x = 8.336935e+00 1.719542e+00 |f(x)| = 6.321346e+01
status = success
iter: 3 x = 8.769411e+00 1.734927e+00 |f(x)| = 6.321001e+01
....
iter: 29 x = 5.000001e+00 4.999998e+02 |f(x)| = 1.204685e-05
status = success
iter: 30 x = 5.000001e+00 4.999998e+02 |f(x)| = 1.146876e-05
1.086107e-02
-5.692674e-01
-5.692674e-01
7.027986e+01
I0 = 5.000001e+00 +/- 1.042165e-01
T1 or T2 = 4.999998e+02 +/- 8.383308e+00
Status = success