python draw quadratic equation code example
Example 1: quadratic equation plot in python
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,1,10)
eta1=0.05
eta2=0.1
lmd1= 2.8
y = 0.5*(-(1/3)*eta1*x**2 + np.sqrt( ((1/3)*eta1*x**2)**2-4*(3*x**2*2.8**2-1))
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.plot(x,y, 'r')
plt.show()
Example 2: quadratic equations in python
def square(n):
num=n
newnum=n*n
return newnum