/*
** Example using root finding approach for nonlinear fitting.
** Function is y = e^(ax) where a is the unknown.
** First calculates some points on the line given a.
** Then uses an initial guess and root finding approach to
** converge towards a fitted solution for a.
*/
#include
#include
#define TOTAL_DATA 110
#define TOTAL_ITERATIONS 50000
#define SQR(x) ((x)*(x))
main()
{
double x[TOTAL_DATA],y[TOTAL_DATA];
double an,an1,fan,fpan;
int i,j;
double truea=2.3; /* true value for a */
/* calculate some data on the true function */
for (i=0; i