Use the solve method of sympy to derive analytical solutions for the quadratic equation $ ax ^ 2 + bx + c = 0 $ and the cubic equation $ ax ^ 3 + bx ^ 2 + cx + d = 0 $.
(1)Quadratic equation
from sympy import *
x=Symbol('x') #letter'x'Is defined as the variable x
"""
Derivation of solution formula
"""
a=Symbol('a')
b=Symbol('b')
c=Symbol('c')
d=Symbol('d')
#Quadratic equation
solve(a*x**2+b*x+c,x)
(2)Cubic equation
from sympy import *
x=Symbol('x') #letter'x'Is defined as the variable x
"""
Derivation of solution formula
"""
a=Symbol('a')
b=Symbol('b')
c=Symbol('c')
d=Symbol('d')
solve(a*x**3+b*x**2+c*x+d, x)
Similarly, the formula for the solution of the quartic equation can be derived.