0
$\begingroup$

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 \begin{equation} \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} \end{equation} 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?

$\endgroup$
0

1 Answer 1

2
$\begingroup$

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}]

enter image description here

And your step function f:

a[1] = 10; a[2] = 1; a[3] = 1/2; a[4] = 1/4;
f[x_] = Sum[a[i] rect[x - i], {i, 1, 4}];
Plot[f[x], {x, 0, 5}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you! But I can't to represent in Mathematica the functions $\psi_{j,n}$. $\endgroup$
    – Mark
    Mar 14, 2023 at 14:33
  • $\begingroup$ Look up in the help: "guide/Wavelets" and "tutorial/DefiningYourOwnWavelet" $\endgroup$ Mar 14, 2023 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.