# Calculate wavelet coefficients with Mathematica

Let $$\operatorname{rect}(x)$$ be a constant function equal to 1 with support $$[-1 / 2,1 / 2]$$. Define a step function using the sequence as $$f(x)=\sum_{k=1}^4 a_k \operatorname{rect}(x-k)$$ where $$a_1=10$$, $$a_2=1$$, $$a_3=\frac12$$ and $$a_4=\frac14$$. The Haar function is defined by $$$$\label{eq:haar} \psi(x) = \begin{cases} 1 \quad & 0 \leq x < \frac{1}{2},\\ -1 & \frac{1}{2} \leq x < 1,\\ 0 &\mbox{otherwise.} \end{cases}$$$$ The family of functions $$\mathcal{F}=\lbrace\psi_{j,n}\rbrace_{j,n\in\mathbb{Z}}$$, where $$\psi_{j,n}(x) = 2^{j / 2} \psi(2^j x-n)$$ $$x \in \mathbb{R}$$ is a wavelet system.

The wavelet coefficients are $$w_{j,n}=\left\langle f, \psi_{j, n}\right\rangle=\int_{-\infty}^{+\infty} f(x) \psi_{j, n}(x) d x$$ I would like to write a code in Mathematica to calculate the coefficients $$w_{j,n}$$ and check the correctness of the results I got by hand for them. For me the real problem here is defining step functions in Mathematica... any suggestions, please?

The a step function from -1/2 to 1/2 may be declared as:

rect[x_] = UnitStep[x + 1/2] - UnitStep[x - 1/2];
Plot[rect[x], {x, -1, 1}]


a[1] = 10; a[2] = 1; a[3] = 1/2; a[4] = 1/4;

• Thank you! But I can't to represent in Mathematica the functions $\psi_{j,n}$.