note bduggan I prefer the solution involving radicals.<br><br> What's cool is that you can use square roots to solve quadratics, third roots to solve cubics, fourth roots to solve quartics, but you can't use just radicals from 5 and up.<br><br> Perl 6's built-in <a href="https://docs.perl6.org/routine/roots">roots</a> function comes in handy.<br> <br> This equation comes right from the <a href="https://en.wikipedia.org/wiki/Cubic_function#Algebraic_solution">wikipedia</a> entry, and uses the names of the variables there. <pre> #!/usr/bin/env perl6 sub cubic(\a,\b,\c,\d) { my \&#916;0 = b² - 3 × a × c; # note: special case when &#916;0 == 0 my \&#916;1 = 2 * b³ - 9 × a × b × c + 27 × a² × d; my \C = ( ( &#916;1 + sqrt( &#916;1² - 4 × &#916;0³ + 0i) ) / 2 ).roots(3); my \&#962; = 1.roots(3); # cubic roots of unity return &#91;0,1,2].map: -> \k { ( -1 / ( 3 × a ) ) × ( b + &#962;&#91;k] × C + &#916;0 / ( C × &#962;&#91;k] ) ) } } my @vals = cubic(1,10,10,-10); # test use Test; plan 3; my \$f = -> \x { x³ + 10 * x² + 10 * x - 10 }; is-approx \$f( @vals&#91;0] ), 0, 'first value'; is-approx \$f( @vals&#91;1] ), 0, 'second value'; is-approx \$f( @vals&#91;2] ), 0, 'third value'; </pre> I had a hard time doing this with a code block on perlmonks, so I made a <a href="https://git.io/v9aHt">gist</a> instead. 1189383 1189383