Nonlinear Least Squares

Given $m$ pairs of data $(t_1,y_1),\ldots,(t_m,y_m)$ and let $y=f(\mathbf{p},t)$ be the model function of independent variable $t$ and parameters $\mathbf{p}=(p_1,\ldots,p_n)$, where $n\leqslant m$, this application finds $\mathbf{p}$ such that the model function best fit to the data in the sense of least squares, minimizing $\sum_{i=1}^m r_i^2$, where $r_i=y_i-f(\mathbf{p},t_i)$ for $i=1,\ldots,m$.

For example, assume that we have a model function $y=\exp(-p_1t)/(p_2+p_3t)$ and from an experiment we get data of $y$ and $t$ as below:

       y          t
     92.9000     0.5000
     78.7000     0.6250
     64.2000     0.7500
     64.9000     0.8750
     57.1000     1.0000
   
The calculator uses these data and the model function to find $p_1,p_2,p_3$.

Input Data

  1. The input for model function $f(p_1,\ldots,p_n,t)$, the calculator requires $x$ represent both $p$ and $t$ as below:
        x1 represent p1 
        x2 represent p2 
           ...
        xn represent pn
        x(n+1) represent t
        
    i.e. the last $x_{n+1}$ represents $t$. So from the model function above, $\exp(-p_1t)/(p_2+p_3t)$, the data input is
        exp(-x1*x4)/(x2+x3*x4)
        
  2. For the data $(y,t)$, enter $y$ in the first column and the corresponding $t$ in the second, one pair of data per line.
  3. Initial values of $p_1,\ldots,p_n$ can be entered by a user. If no data is provided, the calculator set them randomly in the interval $(0,1)$.

The data used as the example in this application is available from Ultrasonic Reference Block Study

Nonlinear Least Squares Calculator