Prerequisite: You will be using utils.py from Python 2 Assignment Task 1) In utils.py, add a Python function called calculate_fourier_coefficients that calculates the coefficients
Prerequisite: You will be using "utils.py" from Python 2 Assignment Task 1) In "utils.py," add a Python function called "calculate_fourier_coefficients" that calculates the coefficients of a Fourier Series for a given periodic function f (x). The function should return a list of tuples, where each list element represents the nth harmonic coefficients (an, bn ) for n = = 0... N where N denotes the maximum harmonic. Task 2) In "utils.py," add a Python function called "approximate_fourier_series" that approximates the original function using a Fourier Series with a specified number of harmonics. The function should return a Numpy array with the resulting approximated signal. Task 3) Write a Python (.py) script called "fourier_series.py" that computes the Fourier Series approximation of a periodic square wave function using L = 1, 3, 5, 7 harmonics. The script should also plot (see example below) the original function and all approximations. Your submission should include the following files: A Python (.py) file called "utils.py" containing the implementation of the Fourier Series functions. A Python (.py) file called "fourier_series.py" containing the script demonstrating the usage of the Fourier Series functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Answer import numpy as np import matplotlibpyplot as plt from utils import calculatefour...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started