Perl Monk, Perl Meditation | |
PerlMonks |
Re: solve cubic equationsby vrk (Chaplain) |
on May 03, 2017 at 08:02 UTC ( [id://1189392]=note: print w/replies, xml ) | Need Help?? |
It's always fun to implement numerical algorithms, especially when a closed form solution exists. You're missing some roots, though... The fundamental theorem of algebra shows that a polynomial of degree n has exactly n roots, although some (or all) of them can be complex. Your cubic solver finds only the real roots. By the way, for finding the roots of polynomials of higher degree, there's an iterative solver on CPAN (Math::Polynomial::Solve). You'll need it if you go higher than degree 5.
In Section
Cool Uses for Perl
|
|