Adding two functions represented by a table of values with a different step size?

36 Views Asked by At

Let $f(t)$ be some numerically obtained $T$-periodic function represented by a table of values over one period or a set of points $(t, y)$ with a time step $\Delta t.$

Now let's change the frequency/period of $f(t)$ by scaling the grid of values by some factor $r$, to obtain the function $z = g (r t)$ with a new period $T^* = rT$ and the time step $\Delta t^*=r\Delta t.$

The goal is to add the functions $f$ and $g$ together and to numerically integrate the sum. The problem however is that now the $t$-values for $f$ and for $g$ do not align, so it appears necessary to interpolate $g$, that is to further subdivide the grid of $t$-values so that they correspond to those of $f.$

My question is how to find the necessary subdivision of $g$ and how to map the points of $g$ to the corresponding points of $f$ in order to perform the sum?

Picture to help visualize the problem. Here for the sake of simplicity $f(t) = \sin(t)$ with the time step $\Delta t = 0.5$ (values are represented by red circles) and $g(t)=\sin(rt)$ with the scaling factor $r=0.8$ and the new time step $\Delta t^* = r\Delta t$ (values represented by red stars).

Please note that due to the nature of the problem not otherwise relevant here, it is only feasible to interpolate $g(t)$ rather than $f(t).$

1

There are 1 best solutions below

1
On

I think you want to find the set of values $g(k\Delta t)$. This can be done by Newton's interpolating formula or by a Lagrange polynomial and can use anything from two or more of the existing $g(t)$ as the known values.

Of course, I wonder if this is necessary if what you really want is an integral. The integral of a sum is equal to the sum of the integrals.

So $\int_0^a (f+g)dt = \int_0^a f dt +\int_0^a g dt = \int_0^a f dt +\int_0^a f(rt) dt$