#!python
# Solves for basic information from a standard form quadratic equation
# Copyright Bradley Sadowsky, 10/3/2016; MIT License
# qinf (Q)uadratic (IN)formation (F)inder
import cmath
import sys

def main():
    # Take (floating point) input into form y = ax^2 + bx + c
    a = float(input("A: "))
    b = float(input("B: "))
    c = float(input("C: "))
    
    # Check if input is that of a quadratic
    if a == 0:
      sys.exit("InputError: Not a quadratic")
    
    # Put equation into standard form display
    standform = "y = " + str(a) + "x^2 + " + str(b) + "x + " + str(c)
    
    # Solves for Y Intercept; y = c
    yint = str(c)
    
    # Solves for X Intercept(s); (-b {+|-} sqrt(b^2 - 4ac))/2a; See quad.py
    # Solve discriminant
    discriminant = cmath.sqrt((b**2)-(4*a*c))
    # Solve solutions
    psol = (-b + discriminant)/2*a #Positive Solution
    nsol = (-b - discriminant)/2*a #Negative Solution
    
    # Determines Vertex
    # x = -b/2a; y = a(-b/2a)^2 + b(-b/2a) + c
    vx = -b/2*a               # X of Vertex
    vy = a*(vx**2) + b*vx + c # Y of Vertex
    vert = "(" + str(vx) + ", " + str(vy) + ")"
    
    # Display Information
    print "\nYou have inputted the following equation: " + standform
    print "The Vertex is: " + vert
    print "The Y Intercept is: " + yint
    print "The Positive Solution [X Intercept] is: " + str(psol)
    print "The Negative Solution [X Intercept] is: " + str(nsol)


print "QInF [Quadratic INformation Finder] by Bradley Sadowsky, 10/3/2016; MIT License"
main()
