3

I'm struggling with a discrepancy that Wolfram and Maple are giving me. To make everything comprehensible, I describe in the following what I did step by step.

When I let Wolfram calculate the Fourier Transform of the function:

$$H(z)=\sqrt{\frac{2}{\pi z}}e^{i \left(z-\frac{\pi}{4}\right)}$$

by using H[z_]:=Sqrt[2/(Pi*z)]*E^(I(z-Pi/4)); FourierTransform[H[z],z,w], I obtain:

$$ \frac{(1+i) e^{-\frac{1}{4} (i \pi )} (\text{sgn}(w+1)+1)}{\sqrt{2 \pi } \sqrt{\left| w+1\right| }} $$

But when I use Matlab with the following code:

syms x v A w;

% We make the following substitutions: % A=sqrt(2/pi) and f = A/sqrt(x) * exp(i*(x-pi/4)); f_FT = fourier(f)

then Matlab yields f_FT=(2^(1/2)*(-1i)^(1/2)*A*pi^(1/2)*(sign(w-1)+1)*(1/2-1i/2))/abs(w-1)^(1/2) which after resubstitution of my variable $A$ leads to:

$$ \frac{2\sqrt{-i}\cdot(\text{sgn}(w+1)+1)\cdot\left(\frac{1}{2}-\frac{i}{2}\right)}{\sqrt{\left| w+1\right| }} $$

Plotting both results using

w = 0:1:1000;
H1 = ((1+i)*exp(-i*pi/4).*(sign(w+1)+1))./(sqrt(2*pi).*sqrt(abs(w+1)));
H2 = (2*sqrt(-i).*(sign(w-1)+1)).*(1/2-i/2)./(sqrt(abs(w-1)));

figure; hold on; plot(w, abs(H1), 'LineWidth', 1.5); plot(w, abs(H2), 'LineWidth', 1.5); xlim([0 1000]) ylim([0 3]) legend('Wolfram', 'Matlab'); grid on;

lead to the following chart:

enter image description here

Why we have such a kind of discrepancy?

Remark (inspired by Steven Clark):

Dividing the result that I obtained from Matlab by $\sqrt{2\pi}$ and when I accordingly define H2 = (2*sqrt(-i).*(sign(w-1)+1)).*(1/2-i/2)./(sqrt(2*pi).*sqrt(abs(w-1))), then both charts are graphically identical:

enter image description here

  • 8
    Have you checked the documentation to see which conventions for the Fourier transform that the programs use? – Hans Lundmark Sep 01 '21 at 07:37
  • Thank you for that hint. Truely spoken - I didn't check that, but will definitey take a look at this. Nevertheless I am wondering why such a discrepancy (in the chart) can emerge. –  Sep 01 '21 at 07:39
  • 5
    What's strange about that? They just seem to differ by a factor of $\sqrt{2\pi} \approx 2.5$, probably due to different conventions. – Hans Lundmark Sep 01 '21 at 07:59
  • Ok thank you for this clarification - I am a bit new to the area of Fourier Transforms. And if you say that these deviations are normal/usual, then this is a very valuable finding for me too. –  Sep 01 '21 at 08:05
  • 1
    I have transformed my comment into a full-fledged answer, explaining how you can get directly an answer without resorting to software (that are very useful in other circumstances). – Jean Marie Sep 02 '21 at 13:39
  • Thank you very much - it rounds everything up and it clarifies the different bahavior of both tools additionally to the already very useful hints by Hans Lundmark. –  Sep 02 '21 at 13:42
  • See https://en.wikipedia.org/wiki/Fourier_transform#Tables_of_important_Fourier_transforms for an overview of the different common definitions. – Hyperplane Sep 02 '21 at 14:33
  • @HansLundmark The Latex for the Matlab result doesn't match the Matlab result or the formula for $h2$. While the ratio of the absolute values of the two Latex formulas may be $\sqrt{2\pi}$, I believe the ratio of the absolute values of the actual results only converge to $\sqrt{2\pi}$ as $\omega\to\infty$. – Steven Clark Sep 02 '21 at 15:46

2 Answers2

1

Knowing the linearity of Fourier Transform, it's better to remove at first the non-essential factor $\sqrt{\frac{2}{\pi}}e^{-i \pi/4}$ which obscures the global computation.

The proportionnality of the two Fourier transforms, due to different definitions has been thoroughly analysed by @Steven Clark.

I would like to show here that this issue can be followed by referring to known properties of Fourier Transform (that can be found in Tables), meaning in fact that one can bypass the use of software.

In the following, I will not be fully rigorous because I want only to convey the main ideas.

What is the core of the question ? Obtaining the Fourier Transform of $\frac{1}{\sqrt{t}}$ multiplied by $e^{-i(\color{red}{-1})t}$ This kind of multiplication gives rise, in the (frequency) $w$ domain to a shift by $\color{red}{-1}$. As the F. T. of $\frac{1}{\sqrt{t}}$ is $\frac{1}{\sqrt{w}}$ (up to a multiplicative factor, see here with an interesting connection with Fresnel integral) it's not surprising to find $\frac{1}{\sqrt{w}}$ shifted by $\color{red}{-1}$, i.e., $\frac{1}{\sqrt{w-(\color{red}{-1})}}$.

Now, how can be explained the presence of the numerator $sign(w+1)+1$ (which, in particular is $0$ for $w<-1$) ? It is a "testimony" of the fact that this Fourier transform is valid for a certain domain of the variable ; in fact, this Fourier transform should be considered

  • with $|t|$ instead of $t$.

  • in the sense of distributions. Have you heard about this ?

Jean Marie
  • 81,803
  • Thank you for your additional remarks. I have not yet heard about using $||t||$ instead of $t$. But I can make a plot in order to see its impact. How would the final formula of the transform then look like? The term $sign(w+1)+1$ would be removed then? –  Sep 02 '21 at 13:56
  • Is $|t|$ the same as absolute value of $t$, i.e. $|t|$? – Steven Clark Sep 02 '21 at 15:47
  • Although the two Latex formulas may be proportional, the two actual results are not proportional as the Latex formula for the Matlab result is not consistent with the actual Matlab result or the formula for $H2$. – Steven Clark Sep 02 '21 at 16:03
  • @StevenClark: Your comment is intersting - I added another chart (into the question area) where I divided the second fucntion H2 by $\sqrt{2\pi}$. Both charts seems to be aligned now. –  Sep 02 '21 at 16:50
  • @EldarSultanow The new formula for $h2$ is not identical which can be seen as a slight difference in the new chart but which is more obvious if you plot the two formulas or the difference between the two formulas over a smaller range (e.g. $0<w<20$). I believe there's actually an error in the result of one of the two Fourier transforms. – Steven Clark Sep 02 '21 at 17:08
  • ok now it becomes interesting - I doublechecked the latex and still do not see the flaw. But I am now recognizing the slight difference of both charts. –  Sep 02 '21 at 18:14
  • 1
    @EldarSultanow You can't separate things out as suggested by this answer because $\sqrt{\frac{2}{\pi\ t}}=\sqrt{\frac{2}{\pi}}\frac{1}{\sqrt{t}}$ is only valid for $\Re(t)>0$. The correct relationship is $\sqrt{\frac{2}{\pi\ t}}=\sqrt{\frac{2}{\pi}}\sqrt{\frac{1}{t}}$ which for $t<0$ is equivalent to $\sqrt{\frac{2}{\pi\ t}}=-\sqrt{\frac{2}{\pi}}\frac{1}{\sqrt{t}}$. – Steven Clark Sep 02 '21 at 22:18
  • Thank you for this clarification. It makes now clear where my flaw resides. –  Sep 05 '21 at 10:40
1

Another answer has been posted which provides some valuable theoretical insight, but this answer more specifically addresses the actual question.


The relationship $\sqrt{\frac{2}{\pi\ z}}=\sqrt{\frac{2}{\pi}}\frac{1}{\sqrt{z}}$ is only valid for $\Re(z)>0$. The correct relationship is $\sqrt{\frac{2}{\pi\ z}}=\sqrt{\frac{2}{\pi}}\sqrt{\frac{1}{z}}$ which for $z<0$ is equivalent to $\sqrt{\frac{2}{\pi\ z}}=-\sqrt{\frac{2}{\pi}}\frac{1}{\sqrt{z}}$.


Therefore there appears to be a problem in the assumptions for the Matlab evaluation of the Fourier transform of $H(z)=\sqrt{\frac{2}{\pi z}}e^{i \left(z-\frac{\pi}{4}\right)}$.


Using the same false assumption Mathematica evaluates the following statement as True where $H2(\omega)$ is the result of the Matlab Fourier transform evaluation as defined in the question above. The selection of Fourier parameters is described further below.


$\text{Assuming}\left[\omega \in \mathbb{R},\text{FullSimplify}\left[\sqrt{\frac{2}{\pi }} \text{FourierTransform}\left[\frac{e^{i \left(z-\frac{\pi }{4}\right)}}{\sqrt{z}},z,\omega ,\text{FourierParameters}\to \{1,-1\}\right]=\text{H2}(\omega )\right]\right]$


Mathematica defines the Fourier transform as illustrated in formula (1) below (see Details and Options at Wolfram FourierTransform) where the default Fourier parameters $\{a,b\}=\{0,1\}$ result in Formula (2) below and the Fourier parameters $\{a,b\}=\{1,-1\}$ result in Formula (3) below.


$$\mathcal{F}_x[f(x)](\omega)=\sqrt{\frac{| b| }{(2 \pi )^{1-a}}} \int\limits_{-\infty }^{\infty } f(x) e^{i b x \omega } \, dx\tag{1}$$

$$\mathcal{F}_x[f(x)](\omega )=\sqrt{\frac{1}{2 \pi }} \int\limits_{-\infty }^{\infty } f(x) e^{i x \omega } \, dx\ ,\quad\{a,b\}=\{0,1\}\tag{2}$$

$$\mathcal{F}_x[f(x)](\omega )=\int\limits_{-\infty }^{\infty } f(x) e^{-i x \omega } \, dx\ ,\quad\{a,b\}=\{1,-1\}\tag{3}$$


Matlab defines the Fourier transform as follows (see Matlab Fourier Transform) where the $fourier$ function uses the parameters $\{c,s\}=\{1,-1\}$.


$$\mathcal{F}_x[f(x)](\omega)=c \int\limits_{-\infty}^{\infty} f(x) e^{i s x \omega } \, dx\tag{4}$$


Therefore using the Fourier parameters $\{a,b\}=\{1,-1\}$ in Mathematica is equivalent to using the Fourier parameters $\{c,s\}=\{1,-1\}$ in Matlab.

Steven Clark
  • 7,363
  • 1
    @JeanMarie Thanks. I believe the last paragraph is correct as formula (3) is equivalent to formula (4) where ${c,s}={1,-1}$. I said perhaps because I'm not sure I fully understand your answer. I evaluated the Fourier transform you suggested and the result had both imaginary and real parts, but your answer didn't seem to account for the imaginary part of the result (see https://www.wolframalpha.com/input/?i=FourierTransform%5B1%2FSqrt%5Bt%5D+Exp%5BI+t%5D%2C+t%2C+w%5D). – Steven Clark Sep 02 '21 at 23:57
  • 1
    @JeanMarie I'll also note that I believe the Wolfram result defined in the formula for $H2(\omega)$ in the question above is strictly real for $\omega\in\mathbb{R}$, so it seems that removing what you refer to as the non-essential factor has the undesirable effect of introducing an imaginary component into the result. – Steven Clark Sep 03 '21 at 00:44
  • Thanks for this deep dive analysis of Wolfram's and Matlab's behavior. This is unveiling. –  Sep 03 '21 at 05:44