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:
- This REAL WORLD FORMULA is very very long AND REPETITIVE.
-
ABBREVIATIONS (macros) are CRUCIAL for MANAGING COMPLEXITY.
-
Managing complexity is what computer science is about!
-
Expand:
Let a = cd in
Let b = dc in
Let c = fg in
Let d = gf in
abba
-
Contract:
aabaabbbaaabaabbbabbabbaaab