How to plot parabola in Python
Code for python user friendly
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-50,50,100)
y = x**2
plt.plot(x,y)
plt.show()
#plt.axis('equal')
code for matlab user friendly
from matplotlib.pyplot import *
from numpy import *
x = linspace(-50,50,100)
y = x**2
plot(x,y)
show()
first two lines are just modules whose work are graph plotting and math calculation
linspace (-50,50,100) it means counting start from -50 then next no. is -49 and so on till 50
or just type print(x) after linspace line. The reason counting start from -50 so that it start from negative x axis and move to y axis
x**2 here ** means raise to the power
plot(x,y) as it name suggest it plots the graph
show() for non jupyter user they need to add this line to show the grah
0 Comments
if you are not getting it then ask i am glad to help