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?