# -*- coding: utf-8 -*- """ Created on Fri Nov 20 17:31:39 2020 @author: user """ # Solve the quartic function import numpy as np def SolveQuartic(a,b,c,d,e) : #Quartic if a != 0 : x1,x2,x3,x4 = np.roots([a,b,c,d,e]) print("\nThe four roots are:" "\n\tx1 = ",np.round(x1,3), "\n\tx2 = ",np.round(x2,3), "\n\tx3 = ",np.round(x3,3), "\n\tx4 = ",np.round(x4,3)) else : #Cubic if b != 0 : x1,x2,x3 = np.roots([b,c,d,e]) print("\nThe three roots are:" "\n\tx1 = ",np.round(x1,3), "\n\tx2 = ",np.round(x2,3), "\n\tx3 = ",np.round(x3,3)) else : #Quardric if c != 0 : x1,x2 = np.roots([c,d,e]) print("\nThe two roots are:" "\n\tx1 = ",np.round(x1,3), "\n\tx2 = ",np.round(x2,3)) else : #Linear if d != 0 : x1 = np.roots([d,e]) print("\nThe toot is:" "\n\tx1 = ",np.round(x1,3)) else : print("\nIt is not a function!") def main () : print("""Welcome! I will help you solve the quartic equation: ax^4 + bx^3 + cx^2 + dx + e = 0 """) a = int(input("Enter a: ")) b = int(input("Enter b: ")) c = int(input("Enter c: ")) d = int(input("Enter d: ")) e = int(input("Enter e: ")) SolveQuartic(a,b,c,d,e) main()