Cubic function

From Wikiversity
Jump to navigation Jump to search

It is not the purpose of this page to repeat good information available elsewhere. However, it seems to the author that other descriptions of the cubic function are more complicated than they need to be. This page attempts to demystify elementary but essential information concerning the cubic function.

Objective[edit]

Books-aj.svg aj ashton 01f.png
  • Present cubic function and cubic 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 cubic.
  • Simplify Vieta's substitution.
  • Review complex numbers as they apply to a complex cube root.
  • Show that the cubic equation is effectively solved when at least one real root is known.
  • Use Newton's Method to calculate one real root.
  • Show that the cubic equation can be solved with high-school math.

Lesson[edit]

Introduction[edit]

The cubic 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 cubic equation is the cubic function equated to zero:

.

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

Function as product of 3 linear functions[edit]

The function may be expressed as:

where are roots of the function, in which case

where:

Solving the cubic equation means that, given , at least one of must be calculated.

Given , I found that can be calculated as:

This approach was not helpful.

Function as product of linear function and quadratic[edit]

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

where

When one real root is known, the other two roots may be calculated as roots of the quadratic function .

The simplest cubic function[edit]

Figure 1.

The simplest cubic function has coefficients

The simplest cubic function has coefficients , for example:

.

To solve the equation:

The function also contains two complex roots that may be found as solutions of the associated quadratic:

Roots of equal absolute value[edit]

The cubic function

Let one value of be and another be .

Substitute these values into the original function in and expand.

Reduce and and substitute for :

Combine and to eliminate and produce a function in :

From

If is a solution and function becomes:

and two roots of are .

An example[edit]

Figure 2.

The roots of equal absolute value are

See Figure 2.


The function has roots of equal absolute value.

The roots of equal absolute value are .

Equal Roots[edit]

Combine and from above to eliminate and produce a function in :



From above:


If , then is a solution , and become:

If because , there is a stationary point where .


Note that is the discriminant of the cubic formula. If because the discriminant is , function contains at least 2 roots equal to when both functions are .

Note that are functions of the curve and the slope of the curve. In other words, equal roots occur where the curve and the slope of the curve are both zero.


and can be combined to produce:


and can be combined to produce:


If the original function contains 3 unique roots, then are numerically different.


If the original function contains exactly 2 equal roots, then are numerically identical, and the 2 roots have the value in .


If the original function contains 3 equal roots, then are both null, are numerically identical and .


From equations (4g) and (5g):

Examples[edit]

No equal roots[edit]

Figure 3a.

Cubic function with 3 unique, real roots at .

Consider function

from

from

are numerically different.

Exactly 2 equal roots[edit]

Figure 3b.

Cubic function with 2 equal, real roots at .

Consider function

from

from

There are 2 equal roots at

3 equal roots[edit]

Figure 3c.

Cubic function with 3 equal, real roots at .

Consider function

from

from

from

are numerically identical, the discriminant of each is and

Depressed cubic[edit]

The depressed cubic may be used to solve the cubic equation.

In the cubic function: let , substitute for and expand:

In the depressed function the coefficient of is and the coefficient of is .

When the function is equated to , the depressed equation is:

where

and

Be prepared for the possibility that one or both of may be zero.

When A = 0[edit]

Figure 4a.

Cubic function with slope 0 at point of inflection .

This condition occurs when the cubic function in has exactly one stationary point or when slope at point of inflection is zero.

The other roots may be derived from the associated quadratic:

When B = 0[edit]

Figure 4b.

Cubic function with point of inflection on axis.

This condition occurs when the cubic function in is of format or when point of inflection is on the axis.

When A = B = 0[edit]

Figure 4c (same as 3c above).

Cubic function with:
* point of inflection on axis,
* slope at point of inflection.

This condition occurs when:

  • slope at point of inflection is , and
  • point of inflection is on axis.


Consider function

Vieta's substitution[edit]

Let the depressed cubic be written as: where and

Let

Substitute for in the depressed function:

where and .

From the quadratic formula:

The discriminant . Substitute for and expand:

This discriminant =

The factor is a factor of above.

Discriminant [edit]

Figure 5a.

Cubic function with 2 equal, real roots at .

If discriminant , the function contains at least 2 equal, real roots.

Consider function

Associated quadratic

The 2 equal roots are: .


Discriminant positive[edit]

Figure 5b.

Cubic function with discriminant positive
and 1 real root at .

If discriminant is positive, the function contains exactly 1 real root.

Consider function

discriminant

or:


The associated quadratic is:

and the two complex roots are:

Discriminant negative[edit]

If discriminant is negative, the function contains 3 real roots and becomes the complex number .


Let be the modulus of .

Let be the real part of .

Let be the imaginary part of .

Then

Let be the phase of .

Then and .

. Therefore:

An example[edit]

Figure 5c.

Cubic function with 3 unique, real roots at .

in which

radians.

radians.

Review of complex math[edit]

Figure 6a: Components of complex number Z.

Origin at point .
parallel to axis.
parallel to axis.
= modulus of
Angle is the phase of


Figure 6b: Complex numbers and .

Origin at point .
(off image to left.)


A complex number contains a real part and an imaginary part, eg:

In theoretical math the value is usually written as . In the field of electrical engineering and computer language Python it is usually written as .


The value is a complex number expressed in rectangular format.

The value is a complex number expressed in polar format where is the modulus of or and is the phase of or

Multiplication of complex numbers[edit]

To multiply complex numbers, multiply the moduli and add the phases.

Complex number cubed[edit]

Cube root of complex number W[edit]

Let and

If then:

and

Complex number [edit]

Let where

If

In the case of 3 real roots,

cos [edit]

The method above for calculating depends upon calculating the value of angle

However, may be calculated from because

Generally, when is known, there are 3 possible values of the third angle because

This suggests that there is a cubic relationship between and

Expansion of [edit]

Figure 7a.

Graph of

The well known identity for is:

The derivation of this identity may help understanding and interpreting the curve of

Let

and

Therefore the point is on the curve and

A 3A cos A cos 3A
0 0 1 1
180 180*3 -l -1
60 180 0.5 -1

Three simultaneous equations may be created from the above table:

Therefore

and

When is known,

Newton's Method[edit]

Figure 7b.

Newton's Method used to calculate when

Newton's method is a simple and fast root finding method that can be applied effectively to the calculation of when is known because:

  • the function is continuous in the area under search.
  • the derivative of the function is continuous in the area under search.
  • the method avoids proximity to stationary points.
  • a suitable starting point is easily chosen.

See Figure 7b.

Perl code used to calculate when is:

$cos3A = 0.1;

$x = 1; # starting point.
$y = 4*$x*$x*$x - 3*$x - $cos3A;

while(abs($y) > 0.00000000000001){
    $s = 12*$x*$x - 3; # slope of curve at x.
    $delta_x = $y/$s;
    $x -= $delta_x;
    $y = 4*$x*$x*$x - 3*$x - $cos3A;

    print "                                                                                   
x=$x                                                                                              
y=$y                                                                                              
";
}

print "                                                                                           
cos(A) = $x                                                                                       
";
x=0.9
y=0.116

x=0.882738095238095
y=0.00319753789412588

x=0.882234602936352
y=2.68482638085543e-06

x=0.882234179465815
y=1.89812054962601e-12

x=0.882234179465516
y=-3.60822483003176e-16

cos(A) = 0.882234179465516

When is positive[edit]

Figure 7c.

Newton's Method used to calculate when

When output of the above code is:

x=0.933333333333333
y=0.0521481481481486

x=0.926336712383224
y=0.000546900278781126

x=0.926261765753783
y=6.24370847246425e-08

x=0.926261757195518
y=7.7715611723761e-16

cos(A) = 0.926261757195518

If all 3 values of are required, the other 2 values can be calculated as roots of the associated quadratic function with coefficients

x1 = -0.136742508909433
x2 = -0.789519248286085

When is negative[edit]

Figure 7d.

Newton's Method used to calculate when

When is negative, the starting value of

When output of the above code is:

x=-0.911111111111111
y=-0.0920054869684496

x=-0.89789474513884
y=-0.00190051666894692

x=-0.897610005610658
y=-8.73486682706481e-07

x=-0.89760987462259
y=-1.8446355554147e-13

x=-0.897609874622562
y=-1.66533453693773e-16

cos(A) = -0.897609874622562

An example[edit]

Figure 7e.

Cubic function with 3 unique, real roots at .

in which

Use the code beside Figure 7b above with initial conditions:

$cosWphi = -0.338086344651354;

$cos3A = $cosWphi;

$x = -1; # starting point.

Point of Inflection[edit]

The Point of Inflection is the point at which the slope of the curve is minimum.

After taking the first and second derivatives value at point of inflection is:

The slope at point of inflection is:

Value at point of inflection is:

Depressed cubic[edit]

Recall from "Depressed cubic" above:

Therefore:

If 1 of is zero, the cubic equation may be solved as under "Depressed cubic" above.

Newton's Method[edit]

If both of the depressed function are non-zero, Newton's method may be applied to the original cubic function, and the Point of Inflection offers a convenient starting point.

slope at PoI positive[edit]

Figure 8a.


Cubic function with positive slope at Point of Inflection

slope at PoI negative[edit]

PoI above X axis[edit]

Figure 8b.


Cubic function with negative slope at Point of Inflection
and PoI above axis.

When the other 2 intercepts may be calculated as roots of the associated quadratic with coefficients:

($a,$b,$c,$d) = (0.1,0.9,0.2,-2.8);
($x,$y) = ($x1a,$ypoi);

while(abs($y) > 1e-14){
    $s = 3*$a*$x*$x + 2*$b*$x + $c;
    $delta_x = $y/$s;
    $x -= $delta_x ;
    $y = $a*$x*$x*$x + $b*$x*$x + $c*$x + $d;
    print "
x=$x,y=$y
";
}

print "
x=$x
";
x=-8.4,y=-0.246400000000004

x=-8.36056338028169,y=-0.00251336673084257

x=-8.36015274586958,y=-2.7116352896428e-07

x=-8.36015270155726,y=-8.88178419700125e-16

x=-8.36015270155726

PoI below X axis[edit]

Figure 8c.


Cubic function with negative slope at Point of Inflection
and PoI below axis.

When the other 2 intercepts may be calculated as roots of the associated quadratic with coefficients: