# Narrowing the gap between two curves I want to raise the lower graph toward the upper graph to make the points of the lower graph as close as possible to those of the upper graph, in other words, to make the graphs "match" as closely as possible.

Any idea of how to do this in mathematical way? I tried taking the means of both graph then translating the lower graph by the percentage difference of the means, but this doesn't give me what I want.

• I come up with an idea similar to Riemann integral, but it's only an idea. Let's call $f$ and $g$ the functions whose graps are the blue one and the red one, respectively. Divide the domain in $n$ intervals with the same lenght. In each one of those intervals, change the value of $f$ on all the interval to be the mean of the values of $g$ in the same interval. With this, $f$ will become a piecewise function, where in each interval is as closely as possible to the graph of $g$. Finally, let $n$ tend to $\infty$. Mar 2 at 16:01
• I think this question is a bit underspecified. When you say translate, do you mean shift by a constant value? In this case, just add the minimum of the difference of the functions to the lower one. If that's not what you mean, then note that you could trivially just let the blue function be the red function, and they would match exactly, so you must want to preserve some features of the original function, what are those features? Mar 2 at 16:15

I believe you want to vertically translate the blue curve such that the signed area between the two curves is zero. This is equivalent to translating the blue curve upwards by the average value of the difference between the two curves. To do this:

• if the red and blue curves respectively represent $$y=f(x)$$ and $$y=g(x)$$ and the horizontal interval of interest is $$[a,b],$$ then translate the blue curve upwards by $$\frac1{b-a}\int_a^b f(x)-g(x)\,\mathrm dx.\tag1$$ on the interval $$[2,4],$$ translating this blue curve upwards by $$0.5$$ units (obtained from evaluation $$(1)$$) gives the green curve, which is its closest "match" to this red curve.

• The resulting average percentage increase of $$g(x)$$ is $$\frac1{(b-a)^2}\int_a^bf(x)-g(x)\,\mathrm dx\int_a^b\frac1{|g(x)|}\,\mathrm dx.$$
In the above example, this equals $$59.3\%.$$