Generate dataset or return evenly spaced numbers using linspace

In this topic, we will discuss how to generate the numerical dataset for the implementation of any mathematical algorithm. The Numpy library provides the linspace function for generating the number of the numeric set of data. Here we have decided the range of numbers or between two numbers starting point to the ending point which generates the random number between two numbers. The linspace is very powerful because it accepts negative numbers.

import matplotlib.pyplot as plt
import numpy as np
def myfunction(x):
    return x**2+x+1
x_data=np.linspace(start=-3, stop=3, num=10)
plt.xlabel('X',fontsize=12)
plt.ylabel('F(x)',fontsize=12)
plt.plot(x_data,myfunction(x_data))
plt.show()