Quartic function

From Wikiversity
Jump to navigation Jump to search

The quartic function is the bridge between the cubic function and more advanced functions such as the quintic and sextic.

Objective[edit | edit source]

  • Present quartic function and quartic equation.
  • Introduce the concept of roots of equal absolute value.
  • Show how to predict and calculate equal roots, techniques that will be useful when applied to higher order functions.
  • Simplify the depressed quartic.
  • Show that the quartic equation is effectively solved when at least one root is known.
  • Present the "resolvent" cubic function.
  • Show how to derive and use the quartic formula.

Lesson[edit | edit source]

Introduction[edit | edit source]

The quartic function is the sum of powers of from through :

usually written as:

If the function becomes

Within this page we'll say that:

  • both coefficients must be non-zero,
  • coefficient must be positive (simply for our convenience),
  • all coefficients must be real numbers, accepting that the function may contain complex roots.

The quartic equation is the quartic function equated to zero:

.

Roots of the function are values of that satisfy the quartic equation.

Because the function is "quartic" (maximum power of is ), the function contains exactly roots, an even number of complex roots and an even number of real roots.

Other combinations of real and complex roots are possible, but they produce complex coefficients.

Graph of typical quartic function showing minima and maximum.

The figure shows a typical quartic function.


The function crosses the axis in 4 different places. The function has 4 roots:

This function contains one local minimum, one local maximum and one absolute minimum. There is no absolute maximum.


Because the function contains one absolute minimum:

  • If abs() is very large, is always positive.
  • If absolute minimum is above axis, curve does not cross axis and function contains only complex roots.
  • There is always at least one point where the curve is parallel to axis.


The curve is never parallel to the axis. For any real value of there is always a real value of

When coefficient d is missing, there is a stationary point at x = 0.

If coefficient is missing, the quartic function becomes and

For a stationary point

When coefficient is missing, there is always a stationary point at

Graph of quartic function that is quadratic in .
Because coefficient is missing, there is a stationary point where

If coefficients are missing, the quartic function becomes a quadratic in

The curve (red line) in diagram has equation:

The quartic equation may be solved as: where or

or

or

The quartic function may be expressed as

Unless otherwise noted, references to "quartic function" on this page refer to function of form

Graph of quartic function with coefficient a negative.
There is no absolute minimum.

Coefficient may be negative as shown in diagram.


As abs increases, the value of is dominated by the term

When abs is very large, is always negative.


Unless stated otherwise, any reference to "quartic function" on this page will assume coefficient positive.

Graph of quartic function with coefficient b missing.
Sum of roots is
axis compressed for clarity.

When sum of roots is coefficient


In the diagram, roots of are

Sum of roots

Therefore coefficient

Function as product of linear function and cubic[edit | edit source]

Graphs of quartic function and associated cubic function.

When is a root of the function, the function may be expressed as:

where

When one real root is known, the other three roots may be calculated as roots of the cubic function

In the diagram the quartic function has equation:

It is known that is a root of this function.

The associated cubic has equation:

The 2 curves coincide at points the three points that are roots of both functions.

Function defined by 5 points[edit | edit source]

Figure 1. Quartic function defined by 5 points
Any 5 points on the curve may be used to define the function.

Because the quartic function contains 5 coefficients, 5 simultaneous equations are needed to define the function.

See Figure 1. The quartic function may be defined by any 5 unique points on the curve.

For example, let us choose the five points:

Rearrange the standard quartic function to prepare for the calculation of

For function solveMbyN see "Solving simultaneous equations" .

# python code

points = (-5,0), (-2,0), (1,0), (3,-6), (6,2)

L11 = []

for point in points :
    x,y = point
    L11 += [[x*x*x*x, x*x*x, x*x, x, 1, -y]]

print (L11)
[[ 625.0, -125.0, 25.0, -5.0, 1.0,  0.0],     #
 [  16.0,   -8.0,  4.0, -2.0, 1.0,  0.0],     #
 [   1.0,    1.0,  1.0,  1.0, 1.0,  0.0],     # matrix supplied to function solveMbyN() below.
 [  81.0,   27.0,  9.0,  3.0, 1.0,  6.0],     # 5 rows by 6 columns.
 [1296.0,  216.0, 36.0,  6.0, 1.0, -2.0]]     #

# python code

output = solveMbyN(L11)
print (output)
# 5 coefficients a, b, c, d, e:
(0.02651515151515152, 0.004545454545454542, -0.847727272727273, -0.728787878787879, 1.5454545454545459)

Quartic function defined by the 5 points is

Function defined by 3 points and 2 slopes[edit | edit source]

Figure 1. Quartic function defined by 3 points and 2 slopes.
Any 3 points on the curve and the slopes at any 2 of these points may be used to define the function.

Slope at slope at

Because the quartic function contains 5 coefficients, 5 simultaneous equations are needed to define the function.

See Figure 1. The quartic function may be defined by any 3 unique points on the curve and the slopes at any 2 of these points.

For example, let us choose the three points:

At point slope is

At point slope is


Rearrange the standard quartic function to prepare for the calculation of

Rearrange the standard cubic function of slope to prepare for the calculation of

For function solveMbyN see "Solving simultaneous equations" .

# python code

def makeEntry(input) :
    x,y,s = ( tuple(input) + (None,) )[:3]
    L1 = []
    if s != None :
        L2 = [ float(v) for v in [4*x*x*x, 3*x*x, 2*x, 1, 0, -s] ]
        L1 += [ L2 ]

    L2 = [ float(v) for v in [x*x*x*x, x*x*x, x*x, x, 1, -y]]
    L1 += [ L2 ]
    return L1

t1 = (
(-2,-2, 0),  # point (-2, -2) with slope 0.
(6,-4, 0),   # point (6, -4) with slope 0.
(4,1),       # point (4, 1)
    )

L1 = []
for v in t1 : L1 += makeEntry ( v )
print (L1)
[[ -32.0,  12.0, -4.0,  1.0, 0.0,  0.0],      #
 [  16.0,  -8.0,  4.0, -2.0, 1.0,  2.0],      #
 [ 864.0, 108.0, 12.0,  1.0, 0.0,  0.0],      # matrix supplied to function solveMbyN() below.
 [1296.0, 216.0, 36.0,  6.0, 1.0,  4.0],      # 5 rows by 6 columns.
 [ 256.0,  64.0, 16.0,  4.0, 1.0, -1.0]].     #

# python code

output = solveMbyN(L1)
print (output)
# 5 coefficients a, b, c, d, e:
(0.03255208333333339, -0.2526041666666665, -0.3072916666666667, 2.84375, 2.375)

Quartic function defined by three points and two slopes is:

Associated cubic functions[edit | edit source]

When p == -2[edit | edit source]

Figure 1. Quartic function and associated cubic function when
p = -2.

In this case roots of associated cubic include x = p.

Quartic function is:


When associated cubic function is :


Three blue vertical lines show 3 values of where and

In this case roots of include

When p == 5[edit | edit source]

Figure 1. Quartic function and associated cubic function when
p = 5.

In this case the one root of associated cubic excludes x = p.

Quartic function is:


When associated cubic function is :


Two blue vertical lines show 2 values of where

In this case the one root of excludes

When p == 6[edit | edit source]

Figure 1. Quartic function and associated cubic function when
p = 6.

In this case the one root of associated cubic includes x = p.

Quartic function is:


When associated cubic function is:


One blue vertical line shows 1 value of where

In this case the one root of includes

Examples[edit | edit source]

Quartic with 2 stationary points[edit | edit source]

Graph of quartic function with 2 stationary points.

In the diagram the red line represents quartic function

The grey line is the first derivative of

The 2 roots of and show that has stationary points at and

Quartic with 1 stationary point[edit | edit source]

Graph of quartic function with 1 stationary point.

In the diagram the red line represents quartic function

The grey line is the first derivative of

The 1 root of (approx.), shows that has 1 stationary point where

First and second derivatives[edit | edit source]

Points of inflection[edit | edit source]

Graphs of quartic function and first two derivatives.
Dotted portion of black line shows where f(x) is always concave down.
Dotted portion of red line shows where g(x) is decreasing.
Dotted portion of blue line shows where h(x) is negative.
When h(x) is negative, f(x) is concave down.
When h(x) is positive, f(x) is concave up.

In the diagram the black line has equation:

The first derivative, the red line, has equation:

The second derivative, the blue line, has equation:


When

  • is increasing.
  • is positive.
  • is always concave up.


When

  • is at a local maximum.
  • Concavity of is between up and down.


When

  • is decreasing.
  • is negative.
  • is always concave down.


When

  • is at a local minimum.
  • Concavity of is between down and up.


When

  • is increasing.
  • is positive.
  • is always concave up.


The roots of

Let point on have coordinates

Let point on have coordinates

At point concavity of changes from up to down.

At point concavity of changes from down to up.

The points (the coordinates of which are roots of ) are the points of inflection of

Maxima and minima[edit | edit source]

Graphs of quartic function and first two derivatives showing maximum and minima.
Point on is a stationary point. at point is concave down. Point is local maximum.
Point on is a stationary point. at point is concave up. Point is local minimum.
Similarly, point is local minimum.

In the diagram the black line has equation:

The first derivative, the red line, has equation:

The second derivative, the blue line, has equation:


Roots of


Let point on have coordinates

At is positive. Point is a stationary point and at is concave up. Point is a local minimum.


Let point on have coordinates

At is negative. Point is a stationary point and at is concave down. Point is a local maximum.


Let point on have coordinates

At is positive. Point is a stationary point and at is concave up. Point is a local minimum.

Quartic with 2 stationary points[edit | edit source]

Graph of quartic function with 2 stationary points and first 2 derivatives.
Black line:
Red line:

Blue line:
Dotted portion of black line shows where is concave down.

In the diagram, point on has coordinates

Similarly, points have coordinates


has roots:

Points are stationary points.


has roots:

Points are points of inflection.


At point is positive. at is concave up. Point is local minimum.

Summary:

  • Point is both stationary point and point of inflection.
  • Point is point of inflection.
  • Point is both stationary point and local minimum.

The simplest quartic function[edit | edit source]

Graph of simplest quartic function.
Point is a root of
Point is a root of
Point is intercept of

The simplest quartic function has coefficients

Red line in diagram has equation:

First derivative (not shown) of

When There is a stationary point on when point

Second derivative (not shown) of

When There is a point of inflection on when

For every non-zero value of is positive. To left and right of point is always concave up. Point is both local minimum and absolute minimum.


  • Point is stationary point and point of inflection and absolute minimum.


Curve is useful for finding the fourth root of a real number.

Solve:

This is equivalent to finding a root of function

If you use Newton's method to find a root of this would be more efficient than solving

Roots of equal absolute value[edit | edit source]

The standard quartic function:

For in substitute Call this

For in substitute Call this

Combine and to eliminate and produce an equation in


We are interested in coefficient of

If is a solution and function has 2 roots of form where


An example:

Graph of quartic function with 2 roots of equal absolute value.

In the diagram the red line has equation:



has roots of equal absolute value.

The 2 roots of equal absolute value are:

The method works with complex roots of equal absolute value:

Graph of quartic function with 2 complex roots of equal absolute value.

In the diagram the red line has equation:



has roots of equal absolute value.

The 2 roots of equal absolute value are:

Equal roots[edit | edit source]

Equal roots occur when the function and the slope of the function both equal zero.


Begin the process of reducing to linear functions.


Combine to produce 2 cubic functions:

where:

where:


Combine to produce 2 quadratic functions:

where:

where:


Combine to produce 2 linear functions:

where:

where:


From

From


If


The value is in fact:

+ 2048aaaaacddeeee - 768aaaaaddddeee - 1536aaaabcdddeee + 576aaaabdddddee 
- 1024aaaacccddeee + 1536aaaaccddddee - 648aaaacdddddde + 81aaaadddddddd 
+ 1152aaabbccddeee - 480aaabbcddddee + 18aaabbdddddde - 640aaabcccdddee 
+ 384aaabccddddde - 54aaabcddddddd + 128aaacccccddee - 80aaaccccdddde 
+ 12aaacccdddddd - 216aabbbbcddeee + 81aabbbbddddee + 144aabbbccdddee 
- 86aabbbcddddde + 12aabbbddddddd - 32aabbccccddee + 20aabbcccdddde 
- 3aabbccdddddd

which, by removing values (common to all values), may be reduced to:

status = (
+ 2048aaaceeee - 768aaaddeee - 1536aabcdeee + 576aabdddee 
- 1024aaccceee + 1536aaccddee - 648aacdddde + 81aadddddd 
+ 1152abbcceee - 480abbcddee + 18abbdddde - 640abcccdee 
+ 384abccddde - 54abcddddd + 128acccccee - 80accccdde 
+ 12acccdddd - 216bbbbceee + 81bbbbddee + 144bbbccdee 
- 86bbbcddde + 12bbbddddd - 32bbccccee + 20bbcccdde 
- 3bbccdddd
)

If there are at least 2 equal roots which may be calculated as shown below.

If coefficient is non-zero, it is not necessary to calculate

If coefficient verify that before proceeding.

No equal roots[edit | edit source]

Graph of quartic function with no equal roots.

Red line in diagram is of function:




There are no equal roots.

Exactly 2 equal roots[edit | edit source]

Graph of quartic function with exactly 2 equal roots.

Red line in diagram is of function:




There are 2 equal roots at

The following 3 graphs show the steps that lead to calculation of equal roots at point

In all graphs, all curves have a common root at point

See "Function as product of linear function and cubic" above.

To calculate all roots:

# python code.
a,b,c,d,e = 1,6,-48,-182,735

# The associated cubic:
p = -7
A = a
B = A*p + b
C = B*p + c
D = C*P + d

# The associated quadratic:
a1 = A
b1 = a1*p + B
c1 = b1*p + C

a1,b1,c1
(1, -8, 15)

Roots of quadratic function are

All roots of are

Exactly 3 equal roots[edit | edit source]

Graph of quartic function with exactly 3 equal roots and corresponding quadratic.

Red line in diagram is of function:


In this case the calculation of is not appropriate because there are more than 2 equal roots. Try equations Both of these are equivalent to: blue line in diagram.

Discriminant of has two equal roots at Therefore has 3 equal roots at

Four equal roots[edit | edit source]

Graph of quartic function with 4 equal roots and corresponding cubic.

Red line in diagram is of function:


In this case are all null.

This is the only case in which are null.

are both equivalent to: blue line in diagram.

has one root at Therefore has 4 equal roots at

Two pairs of equal roots[edit | edit source]

Graph of quartic function with 2 pairs of equal roots and corresponding quadratic.

Red line in diagram is of function:


In this case are both null.

are both equivalent to: blue line in diagram.

has one root at and one root at Therefore has 2 equal roots at and 2 equal roots at

Graph of quartic function with 2 pairs of equal, complex roots and corresponding quadratic.

This method is valid for complex roots.

For example:

In this case are both null.

are both equivalent to: blue line in diagram.

Roots of are

has 2 roots equal to and 2 roots equal to

Summmary[edit | edit source]

No equal roots 2 equal roots 3 equal roots 4 equal roots 2 pairs of equal roots
Cubic: 1(a), 2(a) different different different same different
Quadratic: 1(b), 2(b) different different same, 1root null same, 2roots
Linear: 1(c), 2(c) different same null null null

Caution[edit | edit source]

Calculation of false equal roots.
In this example, method calculates 2 legitimate equal roots at and 2 false equal roots at

Black line in diagram has equation:


is a quartic function with exactly 2 equal roots and coefficient missing.


Calculation of equal roots of gives linear functions null and quadratic functions with equal roots of


Usually, this indicates that should have 2 equal roots at and 2 equal roots at


It is obvious that is not a root of


When slope of derivative Value of


This example indicates that it would be wise to verify that calculated equal roots are in fact valid roots of

Depressed quartic[edit | edit source]

A depressed quartic is any quartic function with any one or more of coefficients missing. Within this section a depressed quartic has coefficient missing.

To produce the depressed quartic:

Let Substitute in expand and simplify:

where:


When equated to becomes the depressed equation:

Be prepared for the possibility that any 1 or more of may be zero.

Coefficient B missing[edit | edit source]

Graph of quartic function that resembles a quadratic.

If coefficient becomes a quadratic in


has the appearance of a quadratic.


The black line:


The red line:

where


The grey line:


  • Absolute minima of and of and point of inflection of occur where
  • is always positive. is always concave up.

If contains 2 pairs of equal roots, coefficient

The converse is not necessarily true.


If contains 4 equal roots, coefficients

Coefficient C missing[edit | edit source]

Graph of quartic function with coefficient C of depressed function missing.
axis compressed for clarity.

If coefficient becomes:

in which case is a solution and is a root of


Curve (red line) in example has equation:

Coefficients of depressed function are:

# python code
a,b,c,d,e = 8, 16, 24, 89, 40

A = 16*a*c - 6*b*b
B = 64*a*a*d - 32*a*b*c + 8*b*b*b
C = 256*a*a*a*e - 64*a*a*b*d + 16*a*b*b*c - 3*b*b*b*b

A,B,C
(1536, 299008, 0)

Coefficient of depressed function is missing. is a solution.

Using

one root of

Resolvent cubic[edit | edit source]

This section introduces a special cubic function called "resolvent" because it helps to resolve a requirement, the calculation of the roots of the quartic.

The depressed quartic:

For substitute

For substitute

Simplify

Simplify

From

In replace with expand, simplify, gather like terms and result is:

or

where:

From

Some simple changes reduce the number of calculations and also the sizes of coefficients

where

where


Then:


Divide all 4 coefficients by


A close examination of coefficients shows that both coefficients are always exactly divisible by

Therefore, all four coefficients may be defined as follows:

Solving quartic equation[edit | edit source]

This section presents 4 examples that show how to use the depressed quartic and the resolvent cubic to solve the quartic equation.

Four real roots[edit | edit source]

Graphs of quartic function with 4 real roots and associated resolvent cubic.
Resolvent cubic contains 3 real, positive roots.

Calculate roots of:

Calculate coefficients of depressed quartic:

a,b,c,d,e = 1,-1,-19,-11,30
A = 16*a*c - 6*b*b
B = 64*a*a*d - 32*a*b*c + 8*b*b*b
C = 256*a*a*a*e - 64*a*a*b*d + 16*a*b*b*c - 3*b*b*b*b
print (A,B,C)
-310 -1320 6669

Calculate coefficients of resolvent cubic:

P = 64
Q = 32*A
R = 4*A*A - 16*C
S = -B*B
print (P,Q,R,S)
64 -9920 277696 -1742400

Calculate roots of cubic function:

There are 3 real, positive roots:

Using 3 roots of calculate 4 roots of

# python code

for U in (9, 25, 121) :
    print ('\nU =', U)
    sqrtU = U ** 0.5
    for u in (sqrtU, -sqrtU) :
        V = -(A/2 + U) - B/(4*u)
        v = V ** .5
        for t in (u+v, u-v) :
            x = (-b+t) / (4*a)
            y = a*x**4 + b*x**3 + c*x**2 + d*x + e
            print ('x:',x, '; y:',y)
U = 9
x: 5.0 ; y: 0.0
x: -3.0 ; y: 0.0
x: 1.0 ; y: 0.0
x: -2.0 ; y: 0.0

U = 25
x: 5.0 ; y: 0.0
x: -2.0 ; y: 0.0
x: 1.0 ; y: 0.0
x: -3.0 ; y: 0.0

U = 121
x: 5.0 ; y: 0.0
x: 1.0 ; y: 0.0
x: -2.0 ; y: 0.0
x: -3.0 ; y: 0.0

Roots of are:

All 3 values of produce the same results, but not in same sequence.

It is not necessary to calculate all 3 roots of resolvent cubic. Any one non-zero root is sufficient to do the job.

Two real and two complex roots[edit | edit source]

Example 1[edit | edit source]

Graphs of quartic function with 2 real and 2 complex roots and associated resolvent cubic.

Calculate roots of:

Calculate coefficients of depressed quartic:

a,b,c,d,e = 1,2,18,-70,-87
A = 16*a*c - 6*b*b
B = 64*a*a*d - 32*a*b*c + 8*b*b*b
C = 256*a*a*a*e - 64*a*a*b*d + 16*a*b*b*c - 3*b*b*b*b
print (A,B,C)
264 -5568 -12208

Calculate coefficients of resolvent cubic:

P = 64
Q = 32*A
R = 4*A*A - 16*C
S = -B*B
print (P,Q,R,S)
64 8448 474112 -31002624

Calculate one real root of cubic function:

is one real root. Choose

Calculate roots of

# python code

U = 36
u1 = U**.5
for u in (u1, -u1) :
    V = -(A/2 + U) - B/(4*u)
    if V >= 0 : v = V**.5
    else : v = 1j * (-V)**.5
    for t in (u+v, u-v) :
      	x = (-b+t)/(4*a)
        # Check result. Expecting sum = 0.
      	sum = a*x**4 + b*x**3 + c*x**2 + d*x + e
        print ('x =',x, '; sum =',sum   )
x = 3.0     ; sum = 0.0
x = -1.0    ; sum = 0.0
x = (-2+5j) ; sum = 0j
x = (-2-5j) ; sum = 0j

Example 2[edit | edit source]

Coefficient of

Calculate roots of:

Calculate coefficients of depressed quartic:

a,b,c,d,e = 3, -6, -41, 44, -189
A = 16*a*c - 6*b*b
B = 64*a*a*d - 32*a*b*c + 8*b*b*b
C = 256*a*a*a*e - 64*a*a*b*d + 16*a*b*b*c - 3*b*b*b*b
print (A,B,C)
-2184, 0, -1229040

Notice that coefficient

Calculate coefficients of resolvent cubic:

P = 64
Q = 32*A
R = 4*A*A - 16*C
S = -B*B
print (P,Q,R,S)
1, -1092, 605376, 0

Notice that coefficient

Calculate roots of cubic function:

Roots are

Value cannot be used because it will cause error Divide by zero at statement V = -(A/2 + U) - B/(4*u).

Calculate roots of

# python code
U = 546+554.3103823671355j
print ('\nU =',U)
sqrtU = U ** 0.5
for u in (sqrtU, -sqrtU) :
    V = -(A/2 + U) - B/(4*u)
    v = V ** 0.5
    s1 = '\nu,v'
    print (s1,eval(s1))
    for t in (u+v, u-v) :
        x = (-b+t)/(4*a)
        # Check result. Expecting sum = 0.
        sum = a*x**4 + b*x**3 + c*x**2 + d*x + e
        print ('x =', x,'; sum =',sum)
U = (546+554.3103823671355j)

u,v ((25.729935131257832+10.771701901683684j), (25.729935131257832-10.771701901683684j))
x = (4.788322521876306 + 0j)   ; sum = (1.9895196601282805e-13 + 0j)
x = (0.5 + 1.795283650280614j) ; sum = (5.684341886080802e-14 + 0j)

u,v ((-25.729935131257832-10.771701901683684j), (25.729935131257832-10.771701901683684j))
x = (0.5 - 1.795283650280614j) ; sum = (5.684341886080802e-14 + 0j)
x = (-3.7883225218763052 + 0j) ; sum = (1.7053025658242404e-13 + 0j)

Values of are:

Depressed quartic as quadratic[edit | edit source]

In this example coefficient of depressed quartic

Therefore, resolvent cubic can be ignored and depressed quartic processed as quadratic in

where

Solutions of this quadratic are:

T1,T2 = 2648.1182474349434, -464.11824743494344

t1 = T1 ** 0.5; t2 = ((-T2) ** 0.5) * 1j

for t in (t1,-t1,t2,-t2) :
    x = (-b+t)/(4*a)
    # Check result. Expecting sum = 0.
    sum = a*x**4 + b*x**3 + c*x**2 + d*x + e
    print ('x =', x,'; sum =',sum)
x =  4.788322521876305          ; sum = -1.7053025658242404e-13
x = -3.788322521876305          ; sum = -1.7053025658242404e-13
x = (0.5 + 1.7952836502806138j) ; sum = (-2.842170943040401e-14 + 0j)
x = (0.5 - 1.7952836502806138j) ; sum = (-2.842170943040401e-14 + 0j)

or

x = 0.5 ± 4.288322521876305, 0.5 ± 1.7952836502806138j

With precision of 15, values of are same as those shown above.

When roots of quartic function are of form p ± q, p ± r, coefficient of depressed function

Four complex roots[edit | edit source]

Graphs of quartic function with 4 complex roots and associated resolvent cubic.

Calculate roots of:

Calculate coefficients of depressed quartic:

4128 344064 9683200

Calculate coefficients of resolvent cubic:

64 132096 -86769664 -118380036096

Calculate one root of cubic function:

There are 3 real roots: Choose

Negative is chosen here to show that any 1 of the roots produces the correct result.

Calculate roots of

# python code

U = -784
u1 = 1j * (-U)**.5
for u in (u1, -u1) :
    V = -(A/2 + U) - B/(4*u)
    v = V**.5
    for t in (u+v, u-v) :
        x = (-b+t)/(4*a)
        # Check result. Expecting sum = 0.
        sum = a*x**4 + b*x**3 + c*x**2 + d*x + e
        print ('x =', x,'; sum =',sum)
# python expresses complex numbers with 'j'.
x = (13+19j) ; sum = 0j
x = (-3-5j)  ; sum = 0j
x = (13-19j) ; sum = 0j
x = (-3+5j)  ; sum = 0j

Quartic formula[edit | edit source]

The substitutions made above can be used to produce a formula for the solution of the quartic equation.

See main articles "The general case" or "General formula for roots."

Both links above point to formula for equation

Given quartic equation: calculate the 4 values of


where:

Coefficients of depressed quartic:

Coefficients of resolvent cubic:

Coefficients of depressed cubic:

One root of resolvent cubic:


may be negative.

One root of quartic:

may be positive or negative.

may be positive or negative.

Formula above produces one value of Python code below utilizes and to produce 4 values of and then, four values of

An example:[edit | edit source]

Graph of quartic function with 2 real roots.
axis compressed for clarity.

Calculate roots of

# Python code.

a,b,c,d,e = 4, 4, -75, -776, -1869

values_of_t = [
    t
# Coefficients of depressed quartic:
    for A in (16*a*c - 6*b*b,)
    for B in (64*a*a*d -32*a*b*c + 8*b*b*b,)
    for C in (256*a*a*a*e - 64*a*a*b*d + 16*a*b*b*c - 3*b*b*b*b,)

# Coefficients of resolvent cubic:
    for a1 in (64,)
    for b1 in (32*A,)
    for c1 in (4*A*A - 16*C,)
    for d1 in (-B*B,)

    for U in [
        # The resolvent cubic:
        (-b1+t1)/(3*a1)

        # Coefficients of depressed resolvent cubic:
        for A1 in (9*a1*c1 - 3*b1*b1,)
        for B1 in (27*a1*a1*d1 - 9*a1*b1*c1 + 2*b1*b1*b1,)

        # One root of resolvent cubic:
        for C1 in (-A1/3,)
        for Δ in (B1*B1 - 4*C1*C1*C1,)
        for δ in (Δ**0.5,)
        for W in ((-B1 + δ)/2,)
        for w in (W**(1/3),)
        for t1 in (w + C1/w,)  # See note below.
    ]

# Prepare to calculate 4 values of t.
    for u1 in (U**.5,)
    for v1 in ( -(A/2 + U) ,)

# Calculate 4 values of t.
    for u in (u1, -u1,)
        for V in ( v1 - B/(4*u),)
        for v in (V**.5,)
        for t in (u+v, u-v)
]

print ('values_of_t =', values_of_t)
values_of_t = [116, -44, (-36+64j), (-36-64j)]

Because is a depressed quartic function, sum of four values_of_t

# Python code.

# Calculate 4 separate roots.
values_of_x = [
    (-b + t)/(4*a)
    for t in values_of_t
]

print ('values_of_x =', values_of_x)
values_of_x = [7, -3, (-2.5 + 4j), (-2.5 - 4j)]

In python the imaginary part of a complex number is shown with instead of

If contains 4 equal roots and

If contains 3 or more equal roots, statement for t1 in (w + C1/w,) fails with divisor

Before using this formula, check for equal roots as in "Exactly 3 equal roots" above.

Values displayed above have been edited slightly. Actual calculated values were:

values_of_x = [7.000000000000001, 
               -3.0000000000000044, 
               (-2.499999999999998+4.000000000000001j), 
               (-2.4999999999999987-4.000000000000001j)]

In practice[edit | edit source]

The following Python code implements the quartic formula. However, under statement if B4 == 0 : there is code that processes the depressed quartic as a quadratic in This ensures that execution of formula does not fail with error Divide by zero at statement for V in ( v1 - B4/u,).

# python code

import cmath
cxSqrt = cmath.sqrt # Square root of complex number.

def rootsOfQuartic (abcde) :
    '''
x1,x2,x3,x4 = rootsOfQuartic ((a,b,c,d,e))
Each member of input must be int or float or Decimal object.
Int or Decimal object in input is quietly converted to float.
Output may be None.
'''
    def formatResults (x1x2x3x4) :
        '''
This function improves appearance of results.
(8 + 0j) becomes 8.0
'''
        values_of_x = list (x1x2x3x4)

        for p in (0,1,2,3) :
            v = values_of_x[p]
            if isinstance (v, complex) and (v.imag == 0) : values_of_x[p] = v.real

        return values_of_x

    status = 0
    try : a,b,c,d,e = [ float(v) for v in abcde ]
    except : status = 1
    if status :    
        print ('rootsOfQuartic () 1: Error creating coefficients a,b,c,d,e.')
        return None

    if a == 0 :
        print ('rootsOfQuartic () 2: Coefficient a must be non-zero.')
        return None

    # Coefficients of depressed quartic, modified.
#    A = 16*a*c - 6*b*b
    A2 = 8*a*c - 3*b*b
#    B = 64*a*a*d - 32*a*b*c + 8*b*b*b
    B4 = 16*a*a*d - 8*a*b*c + 2*b*b*b
    C = 256*a*a*a*e - 64*a*a*b*d + 16*a*b*b*c - 3*b*b*b*b


    if B4 == 0 :
        # B = 0.
        # Result returned from this section is type tuple, indicating that coefficient B4 = 0.
        if A2==C==0 :
            # 4 equal roots.
            root = -b/(4*a)
            return tuple(formatResults((root,root,root,root)))

        # t**4 + At**2 + (0)t + C
        # Depressed quartic is quadratic in T:
        # T**2 + AT + C where T = t**2
        # T**2 + 2(A2)T + C where A = 2(A2)
        #     -2(A2) +/- (4(A2)(A2) - 4C)**0.5
        # T = -------------------------------- = -A2 +/- ((A2)(A2) - C)**0.5
        #                     2
        disc = A2*A2 - C
        if disc >= 0 : root = disc ** 0.5
        else : root = ((-disc) ** 0.5) * 1j
        T1 = -A2 - root ; T2 = -A2 + root
        t1 = cxSqrt(T1) ; t2 = cxSqrt(T2)
        values_of_t = (t1,-t1,t2,-t2)
        values_of_x = [ (-b + t)/(4*a) for t in values_of_t ]
        return tuple(formatResults(values_of_x))


    # B4 is non-zero. Therefore, all of (S, U, u) are non-zero.
    P,Q,R,S = 1, A2, (A2*A2 - C)/4, -B4*B4/4
#    str1 = 'P,Q,R,S' ; print (str1, eval(str1))
    U = oneRootOfCubic((P,Q,R,S)) # Resolvent cubic.
    if U > 0 : sqrtU = U ** 0.5
    elif U == 0 :
        # This should not happen.
        print ('rootsOfQuartic () 3: Internal error.')
        return None
    else : sqrtU = ((-U) ** 0.5) * 1j
    v1 = -(A2+U)

    values_of_t = [
        t
        for u in (sqrtU, -sqrtU)
            for V in ( v1 - B4/u, )
            for v in ( cxSqrt(V), )
            for t in (u+v, u-v)
    ]
    
    values_of_x = [
        (-b + t)/(4*a)
        for t in values_of_t
    ]
    # Result returned from this section is type list, indicating that coefficient B4 != 0.
    return formatResults(values_of_x)

For function oneRootOfCubic() see Cubic_function: In_practice.

Examples[edit | edit source]

Python function equalRoots() below implements status as presented under Equal roots above.

# python code

def equalRoots(abcde) :
    '''
This function returns True if quartic function contains at least 2 equal roots.
    '''
    a,b,c,d,e = abcde
    
    aa = a*a ; aaa = aa*a
    bb = b*b ; bbb = bb*b ; bbbb = bb*bb
    cc = c*c ; ccc = cc*c ; cccc = cc*cc ; ccccc = cc*ccc
    dd = d*d ; ddd = dd*d ; dddd = dd*dd ; ddddd = dd*ddd ; dddddd = ddd*ddd
    ee = e*e ; eee = ee*e ; eeee = ee*ee
    
    v1 = (
            +2048*aaa*c*eeee +576*aa*b*ddd*ee +1536*aa*cc*dd*ee +81*aa*dddddd
            +1152*a*bb*cc*eee +18*a*bb*dddd*e +384*a*b*cc*ddd*e +128*a*ccccc*ee
            +12*a*ccc*dddd +81*bbbb*dd*ee +144*bbb*cc*d*ee +12*bbb*ddddd
            +20*bb*ccc*dd*e
         )
    v2 = (
            -768*aaa*dd*eee -1536*aa*b*c*d*eee -1024*aa*ccc*eee -648*aa*c*dddd*e
            -480*a*bb*c*dd*ee -640*a*b*ccc*d*ee -54*a*b*c*ddddd -80*a*cccc*dd*e
            -216*bbbb*c*eee -86*bbb*c*ddd*e -32*bb*cccc*ee -3*bb*cc*dddd
         )
    return (v1+v2) == 0

t1 = (
    ((1, -1, -19, -11,   30),  '4 unique, real roots.'),
    ((4,  4,-119, -60,  675),  '4 unique, real roots, B4 = 0.'),
    ((1,  6, -48,-182,  735),  '2 equal roots.'),
    ((1,-12,  50, -84,   45),  '2 equal roots. B4 = 0.'),
    ((1,-20, 146,-476,  637),  '2 equal roots, 2 complex roots.'),
    ((1,-12,  58,-132,  117),  '2 equal roots, 2 complex roots.  B4 = 0.'),
    ((1, -2, -36, 162, -189),  '3 equal roots.'),
    ((1,-20, 150,-500,  625),  '4 equal roots. B4 = 0.'),
    ((1, -6, -11,  60,  100),  '2 pairs of equal roots, B4 = 0.'),
    ((4,  4, -75,-776,-1869),  '2 complex roots.'),
    ((1,-12,  33,  18, -208),  '2 complex roots, B4 = 0.'), 
    ((1,-20, 408,2296,18020),  '4 complex roots.'),
    ((1,-12,  83, -282, 442),  '4 complex roots, B4 = 0.'),
    ((1,-12,  62,-156,  169),  '2 pairs of equal complex roots, B4 = 0.'),
)

for (abcde, comment) in t1 :
    print ()
    fourRoots = rootsOfQuartic (abcde)
    print (comment)
    print ('    Coefficients =', abcde)
    print ('    Four roots =', fourRoots)
    print ('    Equal roots detected:', equalRoots(abcde))
    # Check results.
    a,b,c,d,e = abcde
    for x in fourRoots :
        # To be exact, a*x**4 + b*x**3 + c*x**2 + d*x + e = 0
        sum = (a*x**4 + b*x**3 + c*x**2 + d*x + e)
        if sum :
            # Create exception.
            1/0
4 unique, real roots.
    Coefficients = (1, -1, -19, -11, 30)
    Four roots = [5.0, 1.0, -2.0, -3.0]
    Equal roots detected: False

4 unique, real roots, B4 = 0.
    Coefficients = (4, 4, -119, -60, 675)
    Four roots = (2.5, -3.0, 4.5, -5.0)
    Equal roots detected: False

2 equal roots.
    Coefficients = (1, 6, -48, -182, 735)
    Four roots = [5.0, 3.0, -7.0, -7.0]
    Equal roots detected: True

2 equal roots. B4 = 0.
    Coefficients = (1, -12, 50, -84, 45)
    Four roots = (3.0, 3.0, 5.0, 1.0)
    Equal roots detected: True

2 equal roots, 2 complex roots.
    Coefficients = (1, -20, 146, -476, 637)
    Four roots = [7.0, 7.0, (3+2j), (3-2j)]
    Equal roots detected: True

2 equal roots, 2 complex roots.  B4 = 0.
    Coefficients = (1, -12, 58, -132, 117)
    Four roots = ((3+2j), (3-2j), 3.0, 3.0)
    Equal roots detected: True

3 equal roots.
    Coefficients = (1, -2, -36, 162, -189)
    Four roots = [3.0, 3.0, 3.0, -7.0]
    Equal roots detected: True

4 equal roots. B4 = 0.
    Coefficients = (1, -20, 150, -500, 625)
    Four roots = (5.0, 5.0, 5.0, 5.0)
    Equal roots detected: True

2 pairs of equal roots, B4 = 0.
    Coefficients = (1, -6, -11, 60, 100)
    Four roots = (5.0, -2.0, 5.0, -2.0)
    Equal roots detected: True

2 complex roots.
    Coefficients = (4, 4, -75, -776, -1869)
    Four roots = [7.0, -3.0, (-2.5+4j), (-2.5-4j)]
    Equal roots detected: False

2 complex roots, B4 = 0.
    Coefficients = (1, -12, 33, 18, -208)
    Four roots = ((3+2j), (3-2j), 8.0, -2.0)
    Equal roots detected: False

4 complex roots.
    Coefficients = (1, -20, 408, 2296, 18020)
    Four roots = [(13+19j), (13-19j), (-3+5j), (-3-5j)]
    Equal roots detected: False

4 complex roots, B4 = 0.
    Coefficients = (1, -12, 83, -282, 442)
    Four roots = ((3+5j), (3-5j), (3+2j), (3-2j))
    Equal roots detected: False

2 pairs of equal complex roots, B4 = 0.
    Coefficients = (1, -12, 62, -156, 169)
    Four roots = ((3+2j), (3-2j), (3+2j), (3-2j))
    Equal roots detected: True

When description contains note depressed quartic was processed as quadratic in

Two Conic Sections[edit | edit source]

Examples of conic sections include: ellipse, circle, parabola and hyperbola.

This section presents examples of two conic sections, circle and ellipse, and how to calculate the coordinates of the point/s of intersection, if any, of the two sections.

Let one section with name have equation

Let other section with name have equation

Because there can be as many as 4 points of intersection, a special "resolvent" quartic function is used to calculate the coordinates of the point/s of intersection.

Coefficients of associated "resolvent" quartic are calculated as follows:

# python code

def intersection_of_2_conic_sections (abcdef, ABCDEF) :
    '''
A_,B_,C_,D_,E_ = intersection_of_2_conic_sections (abcdef, ABCDEF)
where A_,B_,C_,D_,E_ are coefficients of associated resolvent quartic function:
y = f(x) = A_*x**4 + B_*x**3 + C_*x**2 + D_*x + E_
    '''
    A,B,C,D,E,F = ABCDEF
    a,b,c,d,e,f = abcdef
    
    G = ((-1)*(B)*(a) + (1)*(A)*(b))
    H = ((-1)*(B)*(d) + (1)*(D)*(b))
    I = ((-1)*(B)*(f) + (1)*(F)*(b))
    J = ((-1)*(C)*(a) + (1)*(A)*(c))
    K = ((-1)*(C)*(d) + (-1)*(E)*(a) + (1)*(A)*(e) + (1)*(D)*(c))
    L = ((-1)*(C)*(f) + (-1)*(E)*(d) + (1)*(D)*(e) + (1)*(F)*(c))
    M = ((-1)*(E)*(f) + (1)*(F)*(e))
    g = ((-1)*(C)*(b) + (1)*(B)*(c))
    h = ((-1)*(E)*(b) + (1)*(B)*(e))
    i = ((-1)*(A)*(b) + (1)*(B)*(a))
    j = ((-1)*(D)*(b) + (1)*(B)*(d))
    k = ((-1)*(F)*(b) + (1)*(B)*(f))

    A_ =   ((-1)*(J)*(g) + (1)*(G)*(i))
    B_ =   ((-1)*(J)*(h) + (-1)*(K)*(g) + (1)*(G)*(j) + (1)*(H)*(i))
    C_ =   ((-1)*(K)*(h) + (-1)*(L)*(g) + (1)*(G)*(k) + (1)*(H)*(j) + (1)*(I)*(i))
    D_ =   ((-1)*(L)*(h) + (-1)*(M)*(g) + (1)*(H)*(k) + (1)*(I)*(j))
    E_ =   ((-1)*(M)*(h) + (1)*(I)*(k))

    str1 = 'y = ({})x^4 + ({})x^3 + ({})x^2 + ({})x + ({}) '.format(A_,B_,C_,D_,E_)
    print (str1)
    
    return A_,B_,C_,D_,E_

With no common point[edit | edit source]

Two conic sections with no common point.
Resolvent quartic function (black curve) has no real roots.
axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:

Let circle (blue curve) have equation:

Then, resolvent quartic function (black curve) has equation:

has no real roots. Therefore, there is no point of intersection.

With one common point[edit | edit source]

Two conic sections with one common point.
Resolvent quartic function (black curve) has two equal, real roots.
axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:

Let circle (blue curve) have equation:

Then, resolvent quartic function (black curve) has equation:

Roots of are:

has 2 equal, real roots at effectively 1 real root where

Therefore, there is one point of intersection where

With two common points[edit | edit source]

Example 1[edit | edit source]

Two conic sections with two common points.
Resolvent quartic function (black curve) has two unique, real roots.
axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:

Let circle (blue curve) have equation:

Then, resolvent quartic function (black curve) has equation:

Roots of are:

has 2 unique, real roots at

Therefore, there are two points of intersections where

Example 2[edit | edit source]

Two conic sections with two common points.
Resolvent quartic function (black curve) has two pairs of equal roots.
axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:

Let circle (blue curve) have equation:

Then, resolvent quartic function (black curve) has equation:

Roots of are:

has 2 pairs of equal roots at effectively 2 real roots.

Therefore, there are two points of intersection where


With 3 common points[edit | edit source]

Two conic sections with three common points.
Resolvent quartic function (black curve) has one pair of equal roots and 2 unique, real roots.

Let ellipse (red curve) have equation:

Let circle (blue curve) have equation:

Then, resolvent quartic function (black curve) has equation:

Roots of are:

has 1 pair of equal roots at and 2 unique, real roots at effectively 3 real roots.

Therefore, there are three points of intersection where

With 4 common points[edit | edit source]

Two conic sections with four common points.
Resolvent quartic function (black curve) has 4 unique, real roots.
axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:

Let circle (blue curve) have equation:

Then, resolvent quartic function (black curve) has equation:

Roots of are:

has 4 real roots as shown above.

Therefore, there are four points of intersection where

Links to related topics[edit | edit source]

"Cubic formula"

"Complex square root"