I am trying to write a function to plot a sine graph. The function takes three sine arguments: amplitude being A, frequency being B, horizontal shift being C (see below)
A sin(B(x-C))
This is my code:
import numpy as np
import matplotlib.pylab as plt
x = np.linspace(-np.pi, np.pi, 201)
def sine(amplitude, frequency, horizontal_shift) -> object:
si = np.sin(x - sine)
si = si * frequency
si = amplitude * si
return si
test = sine(4, 1, 2)
print(test)
plt.plot(x, test)
plt.show()
However, I keep getting this error:
TypeError: unsupported operand type(s) for -: 'float' and 'function'
I have tried to
- input ints only
- input numbers as strings
- defining my function as this:
def sine(amplitude, frequency, horizontal_shift) -> object
but I get the same error.

x - sinesupposed to be doing?sineis the function that you just defined. Math isn't defined for functions!