Post Reply 
About the continuous Fourier Transform
12-14-2020, 06:02 AM (This post was last modified: 12-14-2020 11:20 AM by Stevetuc.)
Post: #21
RE: About the continuous Fourier Transform
(12-13-2020 08:33 AM)Aries Wrote:  
(12-10-2020 06:51 AM)dah145 Wrote:  That'll be nice yeah. Thank you.

Hey dah145,
I'm back, here is a simple app:

[Image: fapp1.jpg]

[Image: fapp2.jpg]

First off you define the piecewise function (in an interval equal to a period) like this (say for rect(t) function):

[Image: rect.jpg]

Then you "describe" the function as a matrix (and store it to ff, as requested by the app), like this:

[Image: matrix.jpg]

Lastly, you can apply fourier(ff):

[Image: fourier.jpg]

The graph:

[Image: rect-plot.jpg]

For every row in the matrix (cycle "for"), the program runs the integration and then the results (stored in "s") are counted together.
I hope this can be a valid "starting point", eventually you could do so much more.
Happy XMas to you and everyone here,

Aries Smile

Ive had a stab at translating this for the prime.

Code:

#cas
fourier(ff):=
BEGIN
LOCAL i,n,s,t,fff,a,b,ggg;
0▶s;
rowDim(ff)▶n;
e^(−*w*x)▶ggg;
FOR i from 1 to n
DO
ff[i,1]▶fff;ff[i,2]▶a;ff[i,3]▶b;
s*int(fff*ggg,x,a,b|assumi)▶s
END;
s
END;
#end

The undefined symbol after e^(- in the listing is the imaginary symbol i from the shift keyboard.

Im getting an undefined result from the integration:
[Image: 20201214-054545.jpg]

Edit: I corrected a mistake in the code
s*int(fff*ggg,x,a,b|assumi)▶s should be
s+int(fff*ggg,x,a,b|assumi)▶s
The result is now [x,0,±∞,±∞] in cas and [10.2581355196,0,+Inf,+Inf] in home
Without the assume the result is 1
Needs more work!

After clearing cas vars, I get this result:
Code:
((−i)*e^(i*w*τ/2)+i*e^((−i)*w*τ/2))/w

After applying exp2trig()
[Image: 20201214-111312.jpg]

Updated code with exp2trig included in returned value:
Code:
#cas
fourier(ff):=
BEGIN
LOCAL i,n,s,t,fff,a,b,ggg;
0▶s;
rowDim(ff)▶n;
e^(−*w*x)▶ggg;
FOR i from 1 to n
DO
ff[i,1]▶fff;ff[i,2]▶a;ff[i,3]▶b;
s+int(fff*ggg,x,a,b)▶s
END;
RETURN exp2trig(s)
END;
#end
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: About the continuous Fourier Transform - Stevetuc - 12-14-2020 06:02 AM



User(s) browsing this thread: 3 Guest(s)