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

What is the optimal linear regression (w and w/o y-intercept) for a quadratic curve w.r.t. mean square error.

Mathematically speaking:


$$y = x^2$$


$$x = [-a,a]$$.

What is the best approximation for straight line equations of the form.

$$y = \alpha x$$


$$y = \alpha x + \beta$$.

cftool in MATLAB can solve it numerically, but I had rather have a closed form analytical solution if it exists.

share|cite|improve this question
Since $y=\alpha x$ is a subset of $y=\alpha x+\beta$ (set $\beta=0$), you would naturally choose this unless you had a good reason to specify that the line must pass through the origin. – Daryl Mar 9 '13 at 9:43
I need it to pass through the origin – aiao Mar 9 '13 at 9:44
I don't have the time to verify, but because your actual function is even $(x^2)$ and the approximation is the odd function $y=\alpha x+\beta$, you should always find that $\alpha=0$. I cannot verify that claim at the moment however. – Daryl Mar 9 '13 at 9:50
up vote 2 down vote accepted

How do you measure error? Do you want to do a least squares fit? Then you have to minimize

$$\int_{-a}^a(x^2-(\alpha x+\beta))^2dx$$

which can easily be done by solving the below system for $\alpha$ and $\beta$

$$\frac{\partial}{\partial \alpha}\int_{-a}^a(x^2-(\alpha x+\beta))^2dx=0$$ $$\frac{\partial}{\partial \beta}\int_{-a}^a(x^2-(\alpha x+\beta))^2dx=0.$$

share|cite|improve this answer
lower limit of integral should be $-a$ :) – Aang Mar 9 '13 at 10:26
Of course, ;-) otherwise the answer is REALLY easy. – Fixed Point Mar 9 '13 at 10:45

It would be the line $y=\alpha x$ such that $$\int_{-a}^a\big|x^2-\alpha x\big|dx$$ is minimum

share|cite|improve this answer

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.