Question: how to use python do this question? Problem 1 (5 points) Write a function called sum_sine_plot which takes input parameters a, b, N and num
how to use python do this question?
Problem 1 (5 points) Write a function called sum_sine_plot which takes input parameters a, b, N and num and plots the function fx)A+ over the interval [a, b] using num equally spaced points from a to b.(In other words, use np.linspace(a,b,num) for the x values.) The function also returns the x and y values of the plot in a matrix with 2 columns with x values in the first column and y values in the second In [1]: import numpy as np import matplotlib.pyplot as plt # YOUR SOLUTION GOES HERE def sum_sine_plot (a,b,N,num) x np.linspace(a,b,num) y 1/2[(1-(-1)**k)/(k*np.pi)*np.sin(kx) for k in range(1,N+1)] plt.plot(x,y) plt.show) In [2): "Check sum_sine_plot returns the correct datatype." assert type(sum_sine_plot(0,2,5,5)) print("Problem 1 Test 1: Success!") type(np.array([O])), "Return value should be a NumPy array." Traceback (most recent call last) NameError cipython-input-2-777c34acaaf4> in
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
