Finding X to minimise summed integral of two equations

I have two equations. In this example I'll make them linear, and later see if the solution generalises to different forms of equation:

$$y_1=-0.1x + 0.65$$ $$y_2=0.15x - 0.825$$

I'm interesting in small ranges of these graphs, say 0.5-2.5 of $y_1$ and the same range +7 of $y_2$. We assume the value of the equation outside of its range is 0.

I want to find a value for x such that the summed integration of $y_1$ from that point up to the end of its valid range, and the integration of $y_2$ from $(x+7)$ down to the start of its valid range, is minimal.

I hope that makes sense. I've sort of fried my brain getting the problem into these terms, and now can't see the solution for the trees.

-

Integrating both equations gives:

$$\int y_1 dx = -0.05x^2 + 0.65x$$ $$\int y_2 dx = 0.075x^2 - 0.825x$$

The summed integrations for some value of x with respect to $y_1$ is then:

$$s=\int_x^2.5 y_1 dx + \int_7.5^{x+7} y_2 dx$$

The integration for the upper bound of $y_1$ and the lower bound of $y_2$ are constants. We'll call them $u_1$ and $l_2$. Expanding the above equation gives:

$$s=-0.025x^2+0.425x+u_1+l_2+2.1$$

If $u_1=1.3125$ and $l_2=-1.96875$, the final equation we need to minimise is:

$$s=-0.025x^2+0.425x+1.44375$$

The minimum value of $s$ for the range 0.5-2.5 is 1.65 at $x=0.5$.

-
You've answered your own question. Great! Problem? – Raskolnikov Jan 27 '11 at 12:53
Yeah, it just clicked after asking the question. I'll leave it all here for reference, and maybe if anyone else comes up with more comprehensive solutions. – tenpn Jan 27 '11 at 13:01
Just out of curiosity, what is the motivation for the problem? – Raskolnikov Jan 27 '11 at 13:03
It's complicated. I have a large discrete data set, and I want to find x such that the average of the data points around x is lowest. I've already found the data point to center around, but I want higher resolution than the data set gives me. This method should allow me to step slightly to either side of the central data point and find the real best position. Does that make sense? – tenpn Jan 27 '11 at 13:28