# How can I use the programming language to find the vertices of a quadratic equation?

How can I use the programming language to find the vertices of a quadratic equation? For example, I have an equation like this.

``````Y=3X**2-12X+4
``````

Although I can use the following way to find the minimum value of Y

``````x=np.arange(-100,101,1)
y=3*np.power(x,2)-12*x+4
print(np.min(y))
``````

But then I don't know how to use the program to find the X value, I can only solve the problem using mathematical equations, so please help, thank you.

``````import  matplotlib.pyplot as plt
import  numpy as np
x=np.arange(-100,101,1)
y=3*np.power(x,2)-12*x+4
print(np.min(y))
'''
-8=3x**2-12x+4
-12=3x**2-12x
-12=3(x**2-4x)
-4=x**2-4x
0=x**2-4x+4
0=x**2-2*2x+2**2
0=(x-2)**2
'''
plt.plot(x,y)
plt.grid()
plt.show()
``````

## 2 answers

• answered 2019-09-10 02:38

use argmin (link)

``````x[ y.argmin() ]
``````

• answered 2019-09-10 03:57

Sorry，I have other questions,but I can not post questions。 For the differential derivative of 2x^4-3x^2+2x-20, I can solve the problem in the way of programming language, but I can't do it in the next x=-1, please help, thank you. When x has a value of -1, what is the value of the derivative? Code：

``````from sympy import Symbol,Derivative
import numpy as np
x=Symbol('x')
y=2*np.power(x,4)-3*np.power(x,2)+2*x-20
y2=y.diff(x)
print(y2.__class__)
#When x has a value of -1, what is the value of the derivative?
f=Derivative((y,x,-1)).doit()
print(f)
``````