previous | top | next

The cubic formula macros.


The cubic formula is an equation which can be used to find where a curve with the general formula "y = ax ^ 3 + bx ^ 2 + cx + d" intersects the x axis.

Let p = -b / (3a) in

Let q = p ^ 3 + (bc - 3ad) / (6 a^2) in

Let r = c / (3a) in

Let s = q ^ 2 + (r - p ^ 2) ^ 3 in

x = (q + s ^ 1/2) ^ 1/3 + (q - s ^ 1/2) ^ 1/3 + p

With all the abbreviations expanded, it looks like this: