#%% Import of packages import matplotlib.pyplot as plt import numpy as np #%% Function f(x) def fun_f(x): f = (x + 1)*(x - 1) return f #%% Generating x_array x_low = -2 x_high = 2 dx = 0.1 x_array = np.arange(x_low, x_high+dx, dx) #%% Function values f_array = fun_f(x_array) #%% Plotting plt.close('all') plt.figure(1) plt.plot(x_array, f_array, 'b', label='f(x)') plt.plot(-1, 0, 'ro') plt.plot(1, 0, 'ro') plt.legend() plt.grid() plt.xlabel('x') plt.ylabel('f(x)') plt.savefig('plot_f_secorder.pdf') # pdf of plot plt.show()