Sure! Here is the code in Python using matplotlib library to plot the graph of the function y=3x^3-x+2:
import matplotlib.pyplot as plt import numpy as np def f(x): return 3*x**3 - x + 2 x = np.linspace(-2, 2, 100) # Range for x values y = f(x) # Calculate y values using the function plt.plot(x, y) plt.xlabel('x') plt.ylabel('y') plt.title('Graph of y=3x^3-x+2') plt.grid(True) plt.show()
This code will generate a graph of the function y=3x^3-x+2 with x values ranging from -2 to 2. You can adjust the range of x values by changing the values in np.linspace(-2, 2, 100).
Sure! Here is the code in Python using matplotlib library to plot the graph of the function y=3x^3-x+2:
import matplotlib.pyplot as pltimport numpy as np
def f(x):
return 3*x**3 - x + 2
x = np.linspace(-2, 2, 100) # Range for x values
y = f(x) # Calculate y values using the function
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.title('Graph of y=3x^3-x+2')
plt.grid(True)
plt.show()
This code will generate a graph of the function y=3x^3-x+2 with x values ranging from -2 to 2. You can adjust the range of x values by changing the values in np.linspace(-2, 2, 100).