Skip to content

u5ele55/fourier_series_visualize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fourier_series_visualize

This small project shows how partial sums of fourier series approximate given function.
Also this project provides Function class, which presents intuitive and easy way to handle functions.

sin = Function( math.sin, label = 'sin' )
cos = Function( math.cos, label = 'cos' )
x = Function( lambda t: t, label = 'x' )

f = sin(cos(x*x)) + sin(x) + 3 # f(x) = sin(cos(x^2)) + sin(x) + 3
print(f(2))                    # sin(cos(2*2)) + sin(2) + 3 ≈ sin(-0.654) + 0.909 + 3 ≈ 3.3012144171849163
# also it has __str__ method, it uses "label" field as function name
print( f )                     # sin(cos(x*x)) + sin(x) + 3

Some samples

f(x) = x

For N = 4
x_4
For N = 20
x_20

f(x) = x + sin(x^2)

For N = 4
x_sinxx_4
For N = 20
x_sinxx_20

f(x) = |x| ^ sin(x)

abs(x)^sinx

Interaction

On start, there is a list of functions to work with. You can extend this list by adding functions to funcs list in cli/function_catalogue.py file.
By providing N - top bound of partial fourier sum, you'll get graphs of initial function and partial fourier sum on top of it. By closing graph you'll be able to enter N again.
image

About

How Fourier series approximate a function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages