Saturday, July 2, 2022

Casio fx-CG50: Discrete Fourier Transform

Casio fx-CG50: Discrete Fourier Transform



Making the Discrete Transforms and Back Again


Given a set of numbers, either real or complex:


{x_0, x_1, x_2, x_3, ... , x_n-1}  (small X)


can be transformed using a discrete transform by the sum:


X_k = Σ( x_m * e^(-2 * π * k * m * i ÷ n), m = 0, n - 1)

with i = √(-1)  (big X)


We can do the reverse:


x_k = 1 ÷ n * Σ( X_m * e^(2 * π * k * m * i ÷ n), m = 0, n - 1)


On the Casio fx-CG50, lists start with marker 1 instead of 0, so a slight adjustment in the programs below are needed.


On the programs:

List 25 = small x

List 26 = big X


Casio fx-CG50 Program:  DFT  (Discrete Fourier Transform)


Menu "FORMAT","a+bi",1,"r∠θ",2

Lbl 1:a+bi:Goto 3

Lbl 2:r∠θ:Goto 3

Lbl 3

"DFT"

"E. SHORE, 2022"

"SMALL X (List 25)"?→List 25

Dim List 25→N

List 25→List 26

For 1→K To N

0→S

For 1→J To N

List 25[J]→A

S+A×e^(-2×π×i×(K-1)×(J-1)÷N)→S

Next

S→List 26[K]

Next

"BIG X (List 26)"⊿

List 26


Note:  i = √(-1), [SHIFT] [ 0 ]


Casio fx-CG50 Program:  IDFT  (Inverse Discrete Fourier Transform)


Menu "FORMAT","a+bi",1,"r∠θ",2

Lbl 1:a+bi:Goto 3

Lbl 2:r∠θ:Goto 3

Lbl 3

"INVERSE DFT"

"E. SHORE, 2022"

"BIG X (List 26)"?→List 26

Dim List 26→N

List 26→List 25

For 1→K To N

0→S

For 1→J To N

List 26[J]→A

S+A×e^(2×π×i×(K-1)×(J-1)÷N)→S

Next

S÷N→List 25[K]

Next

"SMALL X (List 25)"⊿

List 25


Note:  i = √(-1), [SHIFT] [ 0 ]


Example Transforms


List 25 (small x):  {2, 4, 6, 8}

List 26 (big X):  {20, -4+4i, -4, -4-4i}


List 25 (small x): {5 + i, 6 + 2i, 7 + 3i, 8 + 4i, 9 + 5i}

List 26 (big X), approximate: 

{35 + 15i, -5.941 + 0.941i, -3.3123 -1.6877i, -1.6877 - 3.3123i, 0.941 - 5.941i}


Source:


Discrete Fourier Transform. Brilliant.org. Retrieved May 7, 2022, from https://brilliant.org/wiki/discrete-fourier-transform/


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.