Skip to content

Instantly share code, notes, and snippets.

@theoparis
Created March 16, 2022 22:55
Show Gist options
  • Save theoparis/aaa73d3af5b829b74228259eb090607b to your computer and use it in GitHub Desktop.
Save theoparis/aaa73d3af5b829b74228259eb090607b to your computer and use it in GitHub Desktop.
Python quadratic equation solver test 1
import math
print("format is ax^2+bx+c")
a = float(input("a="))
b = float(input("b="))
c = float(input("c="))
# fomrula is -b^2-4ac
# ((b) - ((b) * (2))) * (b)= -b^2
X = (b**2) - (4 * a * c)
# formula should be (-b(+ or -)sqrtx)/2a
Q = (-b + math.sqrt(X)) / (2 * a)
q = (-b - math.sqrt(X)) / (2 * a)
print("format is X=-b^2-4ac")
# This needs to have a comma to seperate the arguments!
print("x=", str(X))
print("format is x=-b+(sqrt-b^2-4ac)/2a")
print("x=", str(Q))
print("format is x=-b-(sqrt-b^2-4ac)/2a")
print("x=", str(q))
o = (b) * (2)
v = (b) - (o)
e = (a) * (2)
x = (v) / (e)
print("axis of symetry=", str(x))
f = (x) * (x)
h = (a) * (f) + (b) * (x) + (c)
print("vert 1 =")
print(x, h)
x = (x) + (1)
f = (x) * (x)
h = (a) * (f) + ((b) * (x)) + (c)
print("vert 2 =")
print(x, h)
x = (x) + (1)
f = (x) * (x)
h = (a) * (f) + ((b) * (x)) + (c)
print("vert 3 =")
print(x, h)
x = (x) - (3)
f = (x) * (x)
h = (a) * (f) + ((b) * (x)) + (c)
print("vert -2 =")
print(x, h)
x = (x) - (1)
f = (x) * (x)
h = (a) * (f) + ((b) * (x)) + (c)
print("vert -3 =")
print(x, h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment