How does this convolution algorithm work mathmatically

152 Views Asked by At

I stumbled across this code which describes how you can construct smooth functions with compact support. Unfortunately, I'm not familiar with the programming language used so I can only guess what this code does.

Here's the the main code for convenience:

p = @(h) chebfun(1/h,[-h/2 h/2]);

f = p(1);
for k = 3:5
  f = conv(f,p(2^-k));
end

and

[a,b] = domain(f);
f1 = chebfun({0, f, 0},[-1 a b 2]);
f2 = chebfun({0, newDomain(f,[a+1,b+1]), 0}, [-1 a+1 b+1 2]);

Can somebody please explain/write down the mathematically what is happening here? Related to this question I asked a few days ago.

Any help is greatly appreciated.

Note: I know how convolution (which is what is happening here in general, right?) works mathematically, I just can't "translate this code to math".

1

There are 1 best solutions below

0
On BEST ANSWER

I will only answer about the second piece of code, since the comments already cover the first one.

The language used is MATLAB with the chebfun extension (check here for more infos ). The function chebfun just creates a function. The first input is the function declaration, e.g. '1/x' or 'sin(x)' and the second input defines the domain. Chebfun then evaluates the function not on a fixed grid as matlab would do but approximates the function using a different approach based on something the makers call "Chebyshev technology" (again check their website for detailed information). Now this second code looks different then the first on due to curly brackets, they define a pice wise function. Mathematically this means for $f_1$ $$ f_1(x) = \begin{cases} 0, & x \in [-1,a] \\ f(x), & x\in (a,b] \\ 0, & x\in (b,2] \end{cases} $$ similar thing then for $f_2$: $$ f_2(x) = \begin{cases} 0, & x \in [-1,a+1] \\ f(x-1), & x\in (a+1,b+1] \\ 0, & x\in (b+1,2] \end{cases} $$

This is a padding of f with zeros to be defined on the interval $[-1,2]$ for $f_1$ and $f_2$ padds $f(x-1)$ with zeros to be defined on the whole interval.

The code does not show what is done with $f_1,f_2$ afterwards.