Quartic function

From testwiki
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

Template:RoundBoxTop

  • 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.

Template:RoundBoxBottom

Lesson

Template:RoundBoxTop

Introduction

The quartic function is the sum of powers of x from 0 through 4:

y=f(x)=ax4+bx3+cx2+dx1+ex0

usually written as:

y=f(x)=ax4+bx3+cx2+dx+e.

If e==0 the function becomes x(ax3+bx2+cx+d).

Within this page we'll say that:

  • both coefficients a,e must be non-zero,
  • coefficient a 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:

ax4+bx3+cx2+dx+e=0.

Roots of the function are values of x that satisfy the quartic equation. Template:RoundBoxTop Because the function is "quartic" (maximum power of x is 4), the function contains exactly 4 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. Template:RoundBoxBottom Template:RoundBoxTop

File:0312quartic01a.png
Graph of typical quartic function showing minima and maximum.

The figure shows a typical quartic function.


The function crosses the X axis in 4 different places. The function has 4 roots: (2,0),(1,0),(5,0),(10,0).

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(x) is very large, f(x) is always positive.
  • If absolute minimum is above X axis, curve does not cross X axis and function contains only complex roots.
  • There is always at least one point where the curve is parallel to X axis.


The curve is never parallel to the Y axis. For any real value of x there is always a real value of y. Template:RoundBoxBottom Template:RoundBoxTop

File:0312quartic02.png
When coefficient d is missing, there is a stationary point at x = 0.

If coefficient d is missing, the quartic function becomes y=ax4+bx3+cx2+e, and

y=4ax3+3bx2+2cx=x(4ax2+3bx+2c).

For a stationary point y=x(4ax2+3bx+2c)=0.

When coefficient d is missing, there is always a stationary point at x=0. Template:RoundBoxBottom

Template:RoundBoxTop

File:0319quartic02.png
Graph of quartic function that is quadratic in x2.
Because coefficient d is missing, there is a stationary point where x=0.

If coefficients b,d are missing, the quartic function becomes a quadratic in x2.

The curve (red line) in diagram has equation: y=f(x)=x413x2+365

The quartic equation may be solved as: X213X+36=0 where X=x2 or x=X.

X=4 or X=9.

x=±2 or x=±3. Template:RoundBoxBottom

Template:RoundBoxTop

File:0312quartic03.png

The quartic function may be expressed as x=ay4+by3+cy2+dy+e.

Unless otherwise noted, references to "quartic function" on this page refer to function of form y=ax4+bx3+cx2+dx+e. Template:RoundBoxBottom

Template:RoundBoxTop

File:0318quartic01.png
Graph of quartic function with coefficient a negative.
There is no absolute minimum.

Coefficient a may be negative as shown in diagram.


As abs(x) increases, the value of f(x) is dominated by the term ax4.

When abs(x) is very large, f(x) is always negative.


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

Template:RoundBoxTop

File:0502quartic01.png
Graph of quartic function with coefficient b missing.
Sum of roots is 0.
Yaxis compressed for clarity.

When sum of roots is 0, coefficient b=0.


In the diagram, roots of f(x) are 5,4,2,7.

Sum of roots =0.

Therefore coefficient b=0. Template:RoundBoxBottom

Function as product of linear function and cubic

Template:RoundBoxTop

File:0313quartic01.png
Graphs of quartic function and associated cubic function.

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

(xp)(Ax3+Bx2+Cx+D) where

A=a; B=Ap+b; C=Bp+c; D=Cp+d.

When one real root p is known, the other three roots may be calculated as roots of the cubic function Ax3+Bx2+Cx+D.

In the diagram the quartic function has equation: y=x423x3+163x2393x+25248.

It is known that 3 is a root of this function.

The associated cubic has equation: y=x320x2+103x8448

The 2 curves coincide at points (1,0), (7,0), (12,0), the three points that are roots of both functions. Template:RoundBoxBottom

Function defined by 5 points

Template:RoundBoxTop

File:0313quartic02.png
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:

(5,0),(2,0),(1,0),(3,6),(6,2)

Rearrange the standard quartic function to prepare for the calculation of a,b,c,d,e:

x4a+x3b+x2c+xd+1ey=0.

For function solveMbyN see "Solving simultaneous equations" .

Template:RoundBoxTop

# 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)

Template:RoundBoxTop

[[ 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]]     #

Template:RoundBoxBottom

# python code

output = solveMbyN(L11)
print (output)

Template:RoundBoxTop

# 5 coefficients a, b, c, d, e:
(0.02651515151515152, 0.004545454545454542, -0.847727272727273, -0.728787878787879, 1.5454545454545459)

Template:RoundBoxBottom Template:RoundBoxBottom Quartic function defined by the 5 points (5,0),(2,0),(1,0),(3,6),(6,2) is y=0.875x4+0.15x327.975x224.05x+5133. Template:RoundBoxBottom

Function defined by 3 points and 2 slopes

Template:RoundBoxTop

File:0314quartic03.png
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 (2,2) = slope at (6,4) = 0.

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:

(2,2),(6,4),(4,1)

At point (2,2) slope is 0.

At point (6,4) slope is 0.


Rearrange the standard quartic function to prepare for the calculation of a,b,c,d,e:

x4a+x3b+x2c+xd+1ey=0.

Rearrange the standard cubic function of slope to prepare for the calculation of a,b,c,d,e:

4x3a+3x2b+2xc+1d+0es=0.

For function solveMbyN see "Solving simultaneous equations" .

Template:RoundBoxTop

# 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)

Template:RoundBoxTop

[[ -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]].     #

Template:RoundBoxBottom

# python code

output = solveMbyN(L1)
print (output)

Template:RoundBoxTop

# 5 coefficients a, b, c, d, e:
(0.03255208333333339, -0.2526041666666665, -0.3072916666666667, 2.84375, 2.375)

Template:RoundBoxBottom Template:RoundBoxBottom Quartic function defined by three points and two slopes is: y=1.5625x412.125x314.75x2+136.5x+114.048.

Associated cubic functions

Template:RoundBoxTop

When p == -2

Template:RoundBoxTop

File:0314 2curves01.png
Figure 1. Quartic function and associated cubic function when
p = -2.

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

Quartic function is: y=f(x)=1.5625x412.125x314.75x2+136.5x+114.048.


When p==2, associated cubic function is : y=g(x)=1.5625x315.25x2+15.75x+10548.


Three blue vertical lines show 3 values of x where g(x)=0 and f(x)=f(2)

In this case roots of g(x) include x=p. Template:RoundBoxBottom

When p == 5

Template:RoundBoxTop

File:0314 2curves02.png
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: y=f(x)=1.5625x412.125x314.75x2+136.5x+114.048.


When p==5, associated cubic function is : y=g(x)=1.5625x34.3125x236.3125x45.062548.


Two blue vertical lines show 2 values of x where f(x)=f(5)

In this case the one root of g(x) excludes x=p. Template:RoundBoxBottom

When p == 6

Template:RoundBoxTop

File:0315 2curves01.png
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: y=f(x)=1.5625x412.125x314.75x2+136.5x+114.048.


When p==6, associated cubic function is: y=g(x)=1.5625x32.75x231.25x5148.


One blue vertical line shows 1 value of x where f(x)=f(6)

In this case the one root of g(x) includes x=p. Template:RoundBoxBottom Template:RoundBoxBottom Template:RoundBoxBottom

Examples

Template:RoundBoxTop

Quartic with 2 stationary points

Template:RoundBoxTop

File:0315 2statPoints02.png
Graph of quartic function with 2 stationary points.

In the diagram the red line represents quartic function y=f(x)=4(x4+3x3+3x2+x)1.

The grey line g(x) is the first derivative of f(x).

The 2 roots of g(x), 1 and 14 show that f(x) has stationary points at x=1 and x=0.25. Template:RoundBoxBottom

Quartic with 1 stationary point

Template:RoundBoxTop

File:0315 1statPoint.png
Graph of quartic function with 1 stationary point.

In the diagram the red line represents quartic function y=f(x)=x4+3x3+3x2+3x2

The grey line g(x) is the first derivative of f(x).

The 1 root of g(x), 1.607 (approx.), shows that f(x) has 1 stationary point where g(x)=0. Template:RoundBoxBottom Template:RoundBoxBottom Template:RoundBoxBottom

First and second derivatives

Template:RoundBoxTop

Points of inflection

Template:RoundBoxTop

File:0317 3curves01.png
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: y=f(x)=x416x3+42x2+12x+4144.

The first derivative, the red line, has equation: y=g(x)=x312x2+21x+336.

The second derivative, the blue line, has equation: y=h(x)=x28x+712.


When x<x1:

  • y is increasing.
  • y is positive.
  • f(x) is always concave up.


When x==x1:

  • y is at a local maximum.
  • y=0.
  • Concavity of f(x) is between up and down.


When x1<x<x2:

  • y is decreasing.
  • y is negative.
  • f(x) is always concave down.


When x==x2:

  • y is at a local minimum.
  • y=0.
  • Concavity of f(x) is between down and up.


When x2<x:

  • y is increasing.
  • y is positive.
  • f(x) is always concave up.


Template:RoundBoxTop The roots of h(x):x1=1,x2=7.

Let point p1 on f(x) have coordinates (x1,f(x1)).

Let point p2 on f(x) have coordinates (x2,f(x2)).

At point p1 concavity of f(x) changes from up to down.

At point p2 concavity of f(x) changes from down to up.

The points p1,p2 (the X coordinates of which are roots of h(x)) are the points of inflection of f(x). Template:RoundBoxBottom Template:RoundBoxBottom

Maxima and minima

Template:RoundBoxTop

File:0317 3curves03.png
Graphs of quartic function and first two derivatives showing maximum and minima.
Point p2 on f(x) is a stationary point. f(x) at point p2 is concave down. Point p2 is local maximum.
Point p1 on f(x) is a stationary point. f(x) at point p1 is concave up. Point p1 is local minimum.
Similarly, point p3 is local minimum.

In the diagram the black line has equation: y=f(x)=1.5625x412.125x314.75x2+136.5x+11448.

The first derivative, the red line, has equation: y=g(x)=6.25x336.375x229.5x+136.548.

The second derivative, the blue line, has equation: y=h(x)=18.75x272.75x29.548.


Roots of g(x): x1=2; x2=1.82; x3=6.


Let point p1 on f(x) have coordinates (x1,f(x1)).

At x1 h(x1) is positive. Point p1 is a stationary point and f(x) at p1 is concave up. Point p1 is a local minimum.


Let point p2 on f(x) have coordinates (x2,f(x2)).

At x2 h(x2) is negative. Point p2 is a stationary point and f(x) at p2 is concave down. Point p2 is a local maximum.


Let point p3 on f(x) have coordinates (x3,f(x3)).

At x3 h(x3) is positive. Point p3 is a stationary point and f(x) at p3 is concave up. Point p3 is a local minimum. Template:RoundBoxBottom

Quartic with 2 stationary points

Template:RoundBoxTop

File:0318 3curves01.png
Graph of quartic function with 2 stationary points and first 2 derivatives.
Black line: y=f(x)=4(x4+3x3+3x2+x)1.
Red line: y=g(x)=4(4x3+9x2+6x+1).
y=h(x)=4(12x2+18x+6)
Blue line: y=4(2x2+3x+1)=h(x)6.
Dotted portion of black line shows where f(x) is concave down.

In the diagram, point p1 on f(x) has coordinates (x1,f(x1)).

Similarly, points p2,p3 have coordinates (x2,f(x2)), (x3,f(x3)).


y has roots: x1=1; x3=0.25.

Points p1,p3 are stationary points.


y has roots: x1=1; x2=0.5.

Points p1,p2 are points of inflection.


At point p3 y is positive. f(x) at p3 is concave up. Point p3 is local minimum. Template:RoundBoxTop Summary:

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

Template:RoundBoxBottom Template:RoundBoxBottom Template:RoundBoxBottom

The simplest quartic function

Template:RoundBoxTop

File:0320quartic01.png
Graph of simplest quartic function.
Point p1 (1.1,0) is a root of f(x).
Point p2 (1.1,0) is a root of f(x).
Point p0 (0,1.14) is Y intercept of f(x).

The simplest quartic function has coefficients b=c=d=0.

Red line in diagram has equation: y=f(x)=x41.14

First derivative (not shown) of f(x): y=g(x)=4x3.

When x==0, g(x)=0. There is a stationary point on f(x) when x==0, point p0.

Second derivative (not shown) of f(x): y=h(x)=12x2.

When x==0, h(x)=0. There is a point of inflection on f(x) when x==0.

For every non-zero value of x, h(x) is positive. To left and right of point p0, f(x) is always concave up. Point p0 is both local minimum and absolute minimum.


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


Curve f(x) is useful for finding the fourth root of a real number.

Solve: x=N14.

x4=N.

x4N=0.

This is equivalent to finding a root of function y=j(x)=x4N.

If you use Newton's method to find a root of j(x), this would be more efficient than solving x=N. Template:RoundBoxBottom

Roots of equal absolute value

Template:RoundBoxTop The standard quartic function: y=ax4+bx3+cx2+dx+e  (1)

For x in (1) substitute (p+q). Call this (2).

For x in (1) substitute (pq). Call this (3).

Combine (2) and (3) to eliminate q and produce an equation in p:

(64aaa)pppppp+

(96aab)ppppp+

(32aac48abb)pppp+

(32abc8bbb)ppp+

(+16aae4abd4acc8bbc)pp+

(+8abe2bbd2bcc)p+

(+add+bbebcd) = 0  (4).


We are interested in coefficient 0 of (4): c0=add+bbebcd.

If c0==0, p=0 is a solution and function (1) has 2 roots of form 0±q where q=db.


An example: Template:RoundBoxTop

File:0320quartic02.png
Graph of quartic function with 2 roots of equal absolute value.

In the diagram the red line has equation: y=f(x)=x412x3+31x2+48x14045.


a,b,c,d,e=1,12,31,48,140

c0=add+bbebcd=1(48)(48)+(12)(12)(140)(12)(31)(48)=0.


f(x) has roots of equal absolute value.

q=db=4812=4=±2.

The 2 roots of equal absolute value are: 2,2. Template:RoundBoxBottom The method works with complex roots of equal absolute value: Template:RoundBoxTop

File:0320quartic03.png
Graph of quartic function with 2 complex roots of equal absolute value.

In the diagram the red line has equation: y=f(x)=x43x3x227x9050.


a,b,c,d,e=1,3,1,27,90

c0=0.


f(x) has roots of equal absolute value.

q=db=(27)3=9=±3i.

The 2 roots of equal absolute value are: 3i,3i. Template:RoundBoxBottom Template:RoundBoxBottom

Equal roots

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

ax4+bx3+cx2+dx+e=0  (1)

4ax3+3bx2+2cx+d=0  (2)


Begin the process of reducing (1), (2) to linear functions.


Combine (1), (2) to produce 2 cubic functions:

Fx3+Gx2+Hx+J  (1a) where:

F=ad; G=bd4ae; H=cd3be; J=dd2ce.

fx3+gx2+hx+j  (2a) where:

f=4a; g=3b; h=2c; j=d.


Combine (1a), (2a) to produce 2 quadratic functions:

Kx2+Lx+M  (1b) where:

K=GfFg; L=HfFh; M=JfFj.

kx2+lx+m  (2b) where:

k=FjJf; l=GjJg; m=HjJh.


Combine (1b), (2b) to produce 2 linear functions:

Rx+S  (1c) where:

R=LkKl; S=MkKm.

rx+s  (2c) where:

r=KmMk; s=LmMl.


From (1c): x1=SR

From (2c): x2=sr


If x1==x2:

SR=sr

Rs=rS

RsSr=0.


The value RsSr 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 aa,dd (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 status==0, there are at least 2 equal roots which may be calculated as shown below. Template:RoundBoxTop If coefficient d is non-zero, it is not necessary to calculate status.

If coefficient d==0, verify that status=0 before proceeding. Template:RoundBoxBottom

No equal roots

Template:RoundBoxTop

File:0320quartic03.png
Graph of quartic function with no equal roots.

Red line in diagram is of function: y=f(x)=x43x3x227x9050


a,b,c,d,e=1,3,1,27,90

R,S=15269148,35977608

x1=SR=3597760815269148=2.3562289133617


r,s=35977608,60634332

x2=sr=6063433235977608=1.685335278543253


x1!=x2. There are no equal roots. Template:RoundBoxBottom

Exactly 2 equal roots

Template:RoundBoxTop

File:0329quartic04.png
Graph of quartic function with exactly 2 equal roots.

Red line in diagram is of function: y=f(x)=x4+6x348x2182x+735100


a,b,c,d,e=1,6,48,182,735

R,S=1027353600,7191475200

x1=SR=71914752001027353600=7


r,s=7191475200,50340326400

x2=sr=503403264007191475200=7


x1=x2=7. There are 2 equal roots at x=7.

Template:RoundBoxTop The following 3 graphs show the steps that lead to calculation of equal roots at point (7,0).

In all graphs, all curves have a common root at point (7,0). Template:RoundBoxBottom

Template:RoundBoxTop 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 g(x)=x28x+15 are 3,5.

All roots of f(x) are 7,7,3,5. Template:RoundBoxBottom Template:RoundBoxBottom

Exactly 3 equal roots

Template:RoundBoxTop

File:0320 2curves01.png
Graph of quartic function with exactly 3 equal roots and corresponding quadratic.

Red line in diagram is of function: y=f(x)=x42x336x2+162x189100


a,b,c,d,e=1,2,36,162,189

R,S=0,0  (1c)

r,s=0,0  (2c)

In this case the calculation of x1,x2 is not appropriate because there are more than 2 equal roots. Try equations (1b),(2b). Both of these are equivalent to: y=g(x)=x26x+9, blue line in diagram.

Discriminant of g(x)=(6)24(1)(9)=0. g(x) has two equal roots at x=(6)2(1)=3. Therefore f(x) has 3 equal roots at x=3. Template:RoundBoxBottom

Four equal roots

Template:RoundBoxTop

File:0321 2curves01.png
Graph of quartic function with 4 equal roots and corresponding cubic.
g(x)=f(x)4.

Red line in diagram is of function: y=f(x)=x420x3+150x2500x+625.


a,b,c,d,e=1,20,150,500,625

R,S=0,0

r,s=0,0

K,L,M=0,0,0

k,l,m=0,0,0

In this case (1b),(2b),(1c),(2c) are all null.

This is the only case in which (1b),(2b) are null.

(1a),(2a) are both equivalent to: y=g(x)=x315x2+75x125, blue line in diagram.

g(x) has one root at x=5. Therefore f(x) has 4 equal roots at x=5. Template:RoundBoxBottom

Two pairs of equal roots

Template:RoundBoxTop

File:0321 2curves02.png
Graph of quartic function with 2 pairs of equal roots and corresponding quadratic.

Red line in diagram is of function: y=f(x)=x46x311x2+60x+10020.


a,b,c,d,e=1,6,11,60,100

R,S=0,0

r,s=0,0

In this case (1c),(2c) are both null.

(1b),(2b) are both equivalent to: y=g(x)=x23x1020, blue line in diagram.

g(x) has one root at x=2 and one root at x=5. Therefore f(x) has 2 equal roots at x=2 and 2 equal roots at x=5. Template:RoundBoxTop

File:0408 2curves02.png
Graph of quartic function with 2 pairs of equal, complex roots and corresponding quadratic.
g(x)=(x(32i))(x(3+2i))=x26x+13.
f(x)=(g(x))2.

This method is valid for complex roots.

For example: y=f(x)=x412x3+62x2156x+169.

a,b,c,d,e=1,12,62,156,169.

In this case (1c), (2c) are both null.

(1b), (2b) are both equivalent to: y=g(x)=x26x+13, blue line in diagram.

Roots of g(x) are 3±2i.

f(x) has 2 roots equal to 3+2i and 2 roots equal to 32i. Template:RoundBoxBottom Template:RoundBoxBottom

Summmary

Template:RoundBoxTop

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

Template:RoundBoxBottom

Caution

Template:RoundBoxTop

File:0915quartic02.png
Calculation of false equal roots.
In this example, method calculates 2 legitimate equal roots at (4,0) and 2 false equal roots at (7.543296089385474,0).

Black line in diagram has equation: y=f(x)=0.012684240362811794x4  0.19522392290249435x3 + 0.7654478458049887x2+0x3.


f(x) is a quartic function with exactly 2 equal roots and coefficient d missing.


Calculation of equal roots of f(x) gives linear functions (1c),(2c) null and quadratic functions (1b),(2b) with equal roots of (4,0),(7.543296089385474,0).


Usually, this indicates that f(x) should have 2 equal roots at (4,0) and 2 equal roots at (7.543296089385474,0).


It is obvious that 7.543296089385474 is not a root of f(x).


When x=7.543296089385474, slope of derivative g(x)=0. Value of f(x) !=0.


This example indicates that it would be wise to verify that calculated equal roots are in fact valid roots of f(x). Template:RoundBoxBottom Template:RoundBoxBottom

Depressed quartic

Template:RoundBoxTop A depressed quartic is any quartic function with any one or more of coefficients b,c,d missing. Within this section a depressed quartic has coefficient b missing.

To produce the depressed quartic:

y=ax4+bx3+cx2+dx+e  (1)

y=(44a3)(ax4+bx3+cx2+dx+e)44a3  (2)

Let x=b+t4a. Substitute in (2), expand and simplify:

y=t4+At2+Bt+C44a3  (3)

where:

A=16ac6b2

B=64a2d32abc+8b3

C=256a3e64a2bd+16ab2c3b4


When equated to 0, (3) becomes the depressed equation:

t4+At2+Bt+C=0  (4).

Be prepared for the possibility that any 1 or more of A,B,C may be zero.

Coefficient B missing

Template:RoundBoxTop

File:0322 3curves01.png
Graph of quartic function that resembles a quadratic.

If coefficient B==0, (4) becomes a quadratic in t2:

t4+At2+C=0.


(1) has the appearance of a quadratic.


The black line: y=f(x)=x44x3+9x210x+510

B=64a2d32abc+8b3 =8(8(10)4(4)(9)+64) =8(80+14464) =8(0)=0.


The red line: y=g(x)=4x312x2+18x1010

y=g(x)=0 where x=1.


The grey line: y=h(x)=12x224x+1810


  • Absolute minima of f(x) and of h(x) and point of inflection of g(x) occur where x=b4=1.
  • y is always positive. f(x) is always concave up.
  • f(1+p)=f(1p).

Template:RoundBoxTop If (1) contains 2 pairs of equal roots, coefficient B=0.

The converse is not necessarily true.


If (1) contains 4 equal roots, coefficients A=B=C=0. Template:RoundBoxBottom Template:RoundBoxBottom

Coefficient C missing

Template:RoundBoxTop

File:0501quartic01.png
Graph of quartic function with coefficient C of depressed function missing.
Y axis compressed for clarity.

If coefficient C==0, (4) becomes:

t4+At2+Bt=t(t3+At+B)=0

in which case t=0 is a solution and x=b4a is a root of (1).


Curve (red line) in example has equation: y=f(x)=8x4+16x3+24x2+89x+40.

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 C of depressed function is missing. t=0 is a solution.

Using x=b+t4a,

one root of f(x)=16+04(8)=0.5. Template:RoundBoxBottom

Resolvent cubic

Template:RoundBoxTop 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: t4+At2+Bt+C  (1)

For t substitute (u+v)  (2)

For t substitute (uv)  (3)

(2)+(3): 2Auu+2Avv+2Bu+2C+2uuuu+12uuvv+2vvvv  (4)

Simplify (4): Auu+AV+Bu+C+uuuu+6uuV+VV  (4a)

(2)(3): 4Auv+2Bv+8uuuv+8uvvv  (5)

Simplify (5): 2Au+B+4uuu+4uV  (5a)

From (5a): 4uV=(2Au+B+4uuu)  (5b)

(4a)*4u4u: 4u4uAuu+A4u(4uV)+4u4uBu+4u4uC+4u4uuuuu+6uu4u(4uV)+(4uV)(4uV)  (6)

In (6) replace 4uV with ((2Au+B+4uuu)), expand, simplify, gather like terms and result is:

Pu6+Qu4+Ru2+S or Template:RoundBoxTop PU3+QU2+RU+S  (7) where:

U=u2

P=64

Q=32A

R=4A216C

S=B2 Template:RoundBoxBottom Template:RoundBoxTop From (5b): V=v2=(2Au+B+4uuu)4u=(A2+U)B4u  (8) Template:RoundBoxBottom Template:RoundBoxTop Some simple changes reduce the number of calculations and also the sizes of coefficients P,Q,R,S.

A2=8ac3b2 where A2=A2

B4=16a2d8abc+2b3 where B4=B4

C=256a3e64a2bd+16ab2c3b4


Then:

P=64

Q=32(A2)(2)=64A2

R=4(A2)(2)(A2)(2)16C=16A2216C

S=(B4)(4)(B4)(4)=16B42


Divide all 4 coefficients by 16:

P=4

Q=4A2

R=A22C

S=B42

V=v2=(A2+U)B4u.


A close examination of coefficients R,S shows that both coefficients are always exactly divisible by 4.

Therefore, all four coefficients may be defined as follows:

P=1

Q=A2

R=A22C4

S=B424 Template:RoundBoxBottom Template:RoundBoxBottom Template:RoundBoxBottom

Solving quartic equation

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

Template:RoundBoxTop

File:0323 2curves01.png
Graphs of quartic function with 4 real roots and associated resolvent cubic.
Resolvent cubic contains 3 real, positive roots.

Calculate roots of: y=f(x)=x4x319x211x+30 Template:RoundBoxBottom

Calculate coefficients of depressed quartic:

Template:RoundBoxTop

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

Template:RoundBoxBottom Calculate coefficients of resolvent cubic:

Template:RoundBoxTop

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

Template:RoundBoxBottom Calculate roots of cubic function: y=g(x)=64x39920x2+277696x1742400.

There are 3 real, positive roots: 9,25,121.

Using 3 roots of g(x), calculate 4 roots of f(x):

Template:RoundBoxTop

# 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 f(x) are: 5,1,2,3. Template:RoundBoxBottom All 3 values of U 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

Example 1

Template:RoundBoxTop

File:0323 2curves02.png
Graphs of quartic function with 2 real and 2 complex roots and associated resolvent cubic.

Calculate roots of: y=f(x)=x4+2x3+18x270x87 Template:RoundBoxBottom

Template:RoundBoxTop Calculate coefficients of depressed quartic:

Template:RoundBoxTop

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

Template:RoundBoxBottom Calculate coefficients of resolvent cubic:

Template:RoundBoxTop

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

Template:RoundBoxBottom Calculate one real root of cubic function: y=g(x)=64x3+8448x2+474112x31002624.

36 is one real root. Choose U=36.

Calculate roots of f(x):

Template:RoundBoxTop

# 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

Template:RoundBoxBottom Template:RoundBoxBottom

Example 2

Template:RoundBoxTop

File:0321 2curves00.png
Coefficient d of g(x)=0.

Calculate roots of: y=f(x) =3x46x341x2+44x189 Template:RoundBoxBottom Calculate coefficients of depressed quartic:

Template:RoundBoxTop

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 B=0. Template:RoundBoxBottom Calculate coefficients of resolvent cubic:

Template:RoundBoxTop

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 S=0. Template:RoundBoxBottom Calculate roots of cubic function: y=g(x)=x31092x2+605376x+0.

Roots are 0,546±554.3103823671355j.

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

Calculate roots of f(x):

Template:RoundBoxTop

# 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 x are: 3.7883225218763052,4.788322521876306,0.5±1.795283650280614j Template:RoundBoxBottom

Depressed quartic as quadratic

In this example coefficient B of depressed quartic =0.

Therefore, resolvent cubic can be ignored and depressed quartic processed as quadratic in T=t2.

t42184t2+(0)t1229040

T22184T1229040 where T=t2.

Solutions of this quadratic are: T1,T2=2648.1182474349434,464.11824743494344

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 x are same as those shown above.

When roots of quartic function are of form p ± q, p ± r, coefficient B of depressed function =0.

Four complex roots

Template:RoundBoxTop

File:0323 2curves03.png
Graphs of quartic function with 4 complex roots and associated resolvent cubic.

Calculate roots of: y=f(x)=x420x3+408x2+2296x+18020 Template:RoundBoxBottom

Calculate coefficients of depressed quartic:

Template:RoundBoxTop

4128 344064 9683200

Template:RoundBoxBottom Calculate coefficients of resolvent cubic:

Template:RoundBoxTop

64 132096 -86769664 -118380036096

Template:RoundBoxBottom Calculate one root of cubic function: y=g(x)=64x3+132096x286769664x118380036096.

There are 3 real roots: 2304,784,1024. Choose U=784.

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

Calculate roots of f(x):

Template:RoundBoxTop

# 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

Template:RoundBoxBottom

Quartic formula

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." Template:RoundBoxTop Both links above point to formula for equation x4+ax3+bx2+cx+d=0. Template:RoundBoxBottom Given quartic equation: ax4+bx3+cx2+dx+e=0, calculate the 4 values of x.


x=b+t4a where:

Template:RoundBoxTop Coefficients of depressed quartic:

A=16ac6b2

B=64a2d32abc+8b3

C=256a3e64a2bd+16ab2c3b4 Template:RoundBoxBottom

Template:RoundBoxTop Coefficients of resolvent cubic:

a1=P=64

b1=Q=32A

c1=R=4A216C

d1=S=B2 Template:RoundBoxBottom

Template:RoundBoxTop Coefficients of depressed cubic:

A1=9a1c13b12

B1=27a12d19a1b1c1+2b13 Template:RoundBoxBottom Template:RoundBoxTop One root of resolvent cubic:


C1=A13=b123a1c1

Δ=B124C13  Δ may be negative.

δ=Δ

W=B1+δ2

w=W3

t1=w+C1w

U=b1+t13a1 Template:RoundBoxBottom

Template:RoundBoxTop One root of quartic:

u=U  u may be positive or negative.

V=(A2+U)B4u

v=V  v may be positive or negative.

t=u+v Template:RoundBoxBottom Formula above produces one value of x. Python code below utilizes ±U and ±V to produce 4 values of t and then, four values of x.

An example:

Template:RoundBoxTop

File:0330quartic01.png
Graph of quartic function with 2 real roots.
Y axis compressed for clarity.

Calculate roots of f(x)=4x4+4x375x2776x1869.

# 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)

Template:RoundBoxTop

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

Because f(t) is a depressed quartic function, sum of four values_of_t =1164436(2)=0. Template:RoundBoxBottom

# 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 j instead of i.

If A==B==C==0, f(x) contains 4 equal roots and x=b4a.

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

Before using this formula, check for equal roots as in "Exactly 3 equal roots" above. Template:RoundBoxTop 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)]

Template:RoundBoxBottom Template:RoundBoxBottom

In practice

Template:RoundBoxTop 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 T=t2. This ensures that execution of formula does not fail with error Divide by zero at statement for V in ( v1 - B4/u,). Template:RoundBoxTop

# 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. Template:RoundBoxBottom

Examples

Template:RoundBoxTop 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 B4=0, depressed quartic was processed as quadratic in t2. Template:RoundBoxBottom Template:RoundBoxBottom

Two Conic Sections

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 ABCDEF have equation Ax2+By2+Cxy+Dx+Ey+F=0.

Let other section with name abcdef have equation ax2+by2+cxy+dx+ey+f=0.

Because there can be as many as 4 points of intersection, a special "resolvent" quartic function is used to calculate the x 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

Template:RoundBoxTop

File:0308 2conic sections06.png
Two conic sections with no common point.
Resolvent quartic function (black curve) has no real roots.
y axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:1.89x2+1.61y2+0.96xy36.3x11.6y+130.25=0.

Let circle (blue curve) have equation:x2+y26.8x17.6y+80=0.

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

y=f(x)=x416.4x3432.98x2+6850.532x22836.7009.

f(x) has no real roots. Therefore, there is no point of intersection. Template:RoundBoxBottom

With one common point

Template:RoundBoxTop

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

Let ellipse (red curve) have equation:1.89x2+1.61y2+0.96xy36.3x11.6y+130.25=0.

Let circle (blue curve) have equation:x2+y26.8x17.6y+73=0.

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

y=f(x)=x416.4x3432.84x2+7456.48x24355.36.

Roots of f(x) are: (1422.978250586152114j),(14+22.978250586152114j),5.8,5.8.

f(x) has 2 equal, real roots at x=5.8, effectively 1 real root where x=5.8

Therefore, there is one point of intersection where x=5.8. Template:RoundBoxBottom

With two common points

Example 1

Template:RoundBoxTop

File:0308 2conic sections04.png
Two conic sections with two common points.
Resolvent quartic function (black curve) has two unique, real roots.
y axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:1.89x2+1.61y2+0.96xy36.3x11.6y+130.25=0.

Let circle (blue curve) have equation:x2+y26.8x17.6y+64=0.

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

y=f(x)=x416.4x3432.66x2+8235.556x26681.1841.

Roots of f(x) are: (14.36157882589224123.341853011785357j), (14.361578825892241+23.341853011785357j), 4.59885619413921,7.72430145764527.

f(x) has 2 unique, real roots at x=4.59885619413921,7.72430145764527.

Therefore, there are two points of intersections where x=4.59885619413921,7.72430145764527. Template:RoundBoxBottom

Example 2

Template:RoundBoxTop

File:0308 2conic sections01.png
Two conic sections with two common points.
Resolvent quartic function (black curve) has two pairs of equal roots.
y axis of quartic function is compressed to illustrate shape of curve.

Let ellipse (red curve) have equation:1.89x2+1.61y2+0.96xy36.3x11.6y+130.25=0.

Let circle (blue curve) have equation:x2+y218.8x1.6y+53=0.

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

y=f(x)=x4+37.6x3504.24x2+2835.04x5685.16.

Roots of f(x) are:5.8,5.8,13,13.

f(x) has 2 pairs of equal roots at x=5.8,13, effectively 2 real roots.

Therefore, there are two points of intersection where x=5.8,13. Template:RoundBoxBottom


With 3 common points

Template:RoundBoxTop

File:0308 2conic sections03.png
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:1.89x2+1.61y2+0.96xy36.3x11.6y+130.25=0.

Let circle (blue curve) have equation:x2+y217.6x3.2y+55=0.

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

y=f(x)=x432.2x3+366.69x21784.428x+3165.1876.

Roots of f(x) are:5.8,5.8,6.83589838486224,13.7641016151377.

f(x) has 1 pair of equal roots at x=5.8 and 2 unique, real roots at x=6.83589838486224,13.7641016151377, effectively 3 real roots.

Therefore, there are three points of intersection where x=5.8,6.83589838486224,13.7641016151377. Template:RoundBoxBottom

With 4 common points

Template:RoundBoxTop

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

Let ellipse (red curve) have equation:1.89x2+1.61y2+0.96xy36.3x11.6y+130.25=0.

Let circle (blue curve) have equation:x2+y218.8x1.6y+62.99=0.

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

y=f(x)=x4+37.6x3504.4398x2+2838.79624x5544.61147921.

Roots of f(x) are:4.36661032156283,8.77936456353008,10.0206354364699,14.4333896784371.

f(x) has 4 real roots as shown above.

Therefore, there are four points of intersection where x=4.36661032156283,8.77936456353008,10.0206354364699,14.4333896784371. Template:RoundBoxBottom

Links to related topics

Template:RoundBoxTop "Cubic formula"

"Complex square root" Template:RoundBoxBottom