# Narrowing the range of an interpolating function while keeping integral the same?

Consider an interpolating function derived from some data, e.g.

data = Table[{x, Cos[2 π/1000 x] // N}, {x, -250, 250}];
fun[x_] = Piecewise[{{Interpolation[data][x], Min[data[[;; , 1]]] <= x <= Max[data[[;; , 1]]]}}]


As it is, the interpolation shows a hump that goes to zero at x=-250 and x=250:

Plot[fun[x], {x, -500, 500}] Now I would like to change (manipulate) the interpolation function such that e.g. the function goes to zero at x=-100 and x=100 instead while the hight increases proportionally such as to keep the integral constant

Integrate[fun[x],{x,-Infinity,Infinity}]


318.31

Here a rough sketch how the result should look like How can I do this with mathematica?

EDIT:

Naively, I could always do

targetA = NIntegrate[fun[x], {x, -Infinity, Infinity}];
transfA = NIntegrate[fun[x 5/2.], {x, -Infinity, Infinity}];
newfun[x_] = fun[x 5/2] targetA/transfA;
Plot[{fun[x], newfun[x]}, {x, -500, 500}] But I wonder if there is a less pedestrian way of doing that?

The area under your curve is

Integrate[Cos[2 Pi/1000 x],{x,-250,250}]==1000/Pi


Scale your curve by a factor s

s=4;
Integrate[s*Cos[2 Pi/1000 x/s],{x,-250/s,250/s}]==1000/Pi


and that will hold for any positive value of s.

• Note that Cos is chosen for convenience here, to illustrate the point. In actual application the data does not follow a known function. – Kagaratsch Sep 12 at 4:20
• For your unknown function does scaling down the horizontal extent by a factor of s and scaling up the vertical extent by a factor of s still yield the same area? For sufficiently nice functions that should be true. It might be amusing to try to find functions where that does not hold. – Bill Sep 12 at 4:22
• Oh, I see! That is a good point, I'll check. – Kagaratsch Sep 12 at 4:23
• Oh, in fact, $\int dx f(x)=a\int dy f(a y)$ for $x=ay$ makes total sense for anything smooth! You're right, my question is kind of silly, this should work most of the time (and indeed it works for the relevant data). – Kagaratsch Sep 12 at 4:28
• I want to be VERY clear. I was NOT being critical of you or your question or implying that it was in any way silly. We sometimes get so wrapped up in grinding through the calculus or through the programming that we sometimes miss the insight and understanding that lies hidden just below the surface. – Bill Sep 12 at 4:33