Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few points for which I have to obtain a best fit. (I tried to use the least squares curve fitting method as Robert says, however, since it seems to be fitting rather poorly, any other suitable method would also work for me.)

However, the function is recursive and looks like this -

$$f(x+1)= f(x) + k_1(f(x)-k_2)^3$$

where the starting point $f(1)$ is known and fitting needs to be done only for positive integral values of $x$, from $1$ upto some natural no. $n$

I don't understand how would I apply the matrix method of minimizing the norm $\min(\lVert Ax-B\rVert^2)$ since I would have to consider all possible combinations of powers of $k_1$ and $k_2$ which makes my $x$ matrix terribly complex with every iteration.

This suggests that least square curve fitting is probably not the best way of doing this.
I tried to find other questions related to recursive curve fitting here, but I couldn't find any similar situation. Please help me solve this.

share|cite|improve this question
do you observe $f(x)$ for $x=1,2,...,n$? – mpiktas Sep 25 '12 at 10:33

The parameters enter nonlinearly into your equation. However, fortunately you can rewrite your equation in such a way that you have linear parameters:

$$ (f(x+1) - f(x))^{1/3} = a f(x) - b $$ where $k_1 = a^3$ and $k_2 = b/a$.

So you can apply least squares to these linear equations in $a$ and $b$ for $x$ from $1$ to $n$.

EDIT: I tried some data that seem close to what you had in your picture:

$$ y = [237,130,120, 113, 111, 110] $$

Linear least squares for the residuals $(y_{i+1} - y_i)^{1/3} - a y_i + b$, $i = 1 \ldots,5$, in Maple produces $$ a = -.0273525754168209,\ b = -1.67458695987193$$ which corresponds to $$ k_1 = - 0.0000204641953284227606,\ k_2= 61.2222774036158200$$ I then tried nonlinear least squares for the residuals $ y_{i+1} - y_i - k_1 (y_i - k_2)^3$, $i=1 \ldots 5$, using the above as initial values (this is often necessary because the nonlinear least squares algorithms often provide only a local minimum rather than the global minimum). The result was $$ k_1 =- 0.0000166852730695581124, k_2 = 51.1767746591434971 $$

The recursion using initial value $237$ and parameters from the linear least squares produces the values $$ 237, 125.855961638565, 120.330463855443, 116.104385196179, 112.721501867265, 109.926405798693$$ while the recursion using parameters from the nonlinear least squares produces $$ 237, 129.938505804843, 121.786225982822, 115.912389815574, 111.385883230420, 107.744051206183$$

share|cite|improve this answer
Thanks Robert for your answer. However, could there be a method for solving this with higher accuracy? When I calculated $k_1$ and $k_2$ using this least square method, they were not as accurate as the solution I already have (and consequently they fit the actual data points rather poorly). I can give you the data points and the solution if you would like. – Pushpak Dagade Sep 25 '12 at 9:12
I have added a picture for convenience here - – Pushpak Dagade Sep 25 '12 at 12:23
You could try nonlinear least squares rather than linear least squares. In Maple this can be done using LSSolve in the Optimization package. – Robert Israel Sep 25 '12 at 18:43
Thanks Robert for the effort. I might take some time to verify this. I'll get back to you soon. This indeed looks promising. – Pushpak Dagade Sep 26 '12 at 9:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.