Updated by Andrey Kamaev almost 13 years ago

I have tested the simplest case for a quadratic equation could not generate meaningful results. The equation is @2(x-3)(x+5)=0@, 2(x-3)(x+5)=0, in other representation it is @2x^2+4x-30=0@ 2x^2+4x-30=0
Clearly the roots are @x=3@ x=3 and @x=-5@ x=-5

Here is the code to demonstrate the case:
<pre><code class="cpp">
<pre>
// Coefficients of 2(x-3)(x+5) = 0

Mat coefs = (Mat_<float>(1,3) << -30.0f, 4.0f, 2.0f);

std::cout << "Coefs: " << coefs << std::endl;

Mat r;



solvePoly(coefs, r);

std::cout << "roots after 300 iterations: " << r << std::endl;



solvePoly(coefs, r, 9999);

std::cout << "roots after 9999 iterations: " << r << std::endl;
</code></pre> </pre>

The output is:
<pre>
Coefs: [-30, 4, 2]
roots after 300 iterations: [-48.41674, -190.29749; 1.1712749, 1.5136811]
roots after 9999 iterations: [255.0712, 1078.2856; 1.1929021, 1.6043143]
</pre>

Back