Second post dedicated to the Fourier series [Link] with several examples of classical periodic functions.

1- Triangle wave

The formula is:

$f\left(x\right)=\frac{4}{\pi}(\frac{1}{9}\mathrm{cos(3x)}+\frac{1}{25}\mathrm{cos(5x)}+...+\frac{1}{{n}^{2}}\mathrm{cos(}nx))$Or can be written like this...

$f\left(x\right)=\frac{4}{\pi}\sum _{k=1}^{\mathrm{\infty}}\frac{\mathrm{cos(2k+1)}.x}{{\mathrm{(2k+1)}}^{2}}$

and the corresponding macro...

+++ IJ snippet: Triangle_wave_fourier_series.ijm +++

+++ End of IJ snippet +++

To create the triangle wave, select the whole image (Ctrl+A) then compute the profile (

`Analyze > Plot Profile`

or Ctrl +K).Fig. 1: Triangle wave obtained from the sum of each row of the Fourier Series. |

##### 2- Sawtooth wave

Another function defined by ...$f\left(x\right)=\frac{2}{\pi}(\mathrm{sinx}-\frac{1}{2}\mathrm{sin(}2x)+\frac{1}{3}\mathrm{sin(3x)}-\frac{1}{4}\mathrm{sin(}4x)+...+{\left(-1\right)}^{n+1}\frac{1}{n}\mathrm{sin(}nx))$

The following video shows the evolution of the resulting curve when we add more components.

#### 3- JavaScript

Here is a small script containing all the various functions previously described. For sake of convenience, this script is written in JavaScript but uses exactly the same function`Process > Math > Macro...`

+++ IJ JavaScript snippet +++
+++ End of IJ JavaScript snippet +++

#### 4- Links

Square wave image [Link]

## No comments:

## Post a Comment