Question: I have a function w(x), and a) I need to calculate the derivative in each point within [-2,2]. b) I need to plot the derivatives.
I have a function w(x), and
a) I need to calculate the derivative in each point within [-2,2].
b) I need to plot the derivatives.
A solution for a, and b seperately please.
This is what I have currently.
a)

b)
![derivative in each point within [-2,2]. b) I need to plot the](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3e8b74e2bc_85466f3e8b6d5a66.jpg)
import matplotlib.pyplot as plt import numpy as np def w(x): sum e for i in range(3): sum += np.cos((7**i)*np-pi*x)/(2**i) return sum np.linspace(-2,2,20) dx = x[1]-x[@] y = list(map(W, x)) dydx = np-gradient(y, dx) print(dydx) 1 2 import matplotlib.pyplot as plt import numpy as np 3 4 5 6 7 8 def w(x): sum = 0 for i in range(3): sum += np.cos((7**i)*np.pi*x)/(2**i) return sum 9 10 11 12 1 X = np.linspace(-2,2,100) dx X[1]-x[@] list(map(w, x)) dydx np.gradient(y, dx) 13 = 14 15 O in 17 18 19 20 plt.plot(dydx) plt.ylim([-20,20]) plt.xlabel("X") plt.ylabel("Y") plt.show() import matplotlib.pyplot as plt import numpy as np def w(x): sum e for i in range(3): sum += np.cos((7**i)*np-pi*x)/(2**i) return sum np.linspace(-2,2,20) dx = x[1]-x[@] y = list(map(W, x)) dydx = np-gradient(y, dx) print(dydx) 1 2 import matplotlib.pyplot as plt import numpy as np 3 4 5 6 7 8 def w(x): sum = 0 for i in range(3): sum += np.cos((7**i)*np.pi*x)/(2**i) return sum 9 10 11 12 1 X = np.linspace(-2,2,100) dx X[1]-x[@] list(map(w, x)) dydx np.gradient(y, dx) 13 = 14 15 O in 17 18 19 20 plt.plot(dydx) plt.ylim([-20,20]) plt.xlabel("X") plt.ylabel("Y") plt.show()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
