Skip to content

Instantly share code, notes, and snippets.

@albanie
Created February 25, 2015 08:42
Show Gist options
  • Save albanie/4ebfa62880fd2492f2c1 to your computer and use it in GitHub Desktop.
Save albanie/4ebfa62880fd2492f2c1 to your computer and use it in GitHub Desktop.
Show that the result of summing two periodic signals is periodic
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np, math
"""Define the periodic function"""
def f(t):
return math.cos(2 * math.pi * t) + 0.5 * math.cos( 4 * math.pi * t)
"""Define inputs, find outputs and plot graph"""
inputs = np.linspace(-2, 2, 100)
outputs = [f(input) for input in inputs]
plt.plot(inputs, outputs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment