Skip to content

Wrong solution to cubic equation #6

@m2-farzan

Description

@m2-farzan

Hi again

The solution find_roots returns for x^3 + 36 * x^2 + 144 * x + 64 = 0 is wrong. If you run this code on rustnomial 0.3.2 (or older versions):

fn main() {
    let poly = Polynomial::<f64>::new(vec![1.0, 36.0, 144.0, 64.0]);
    let roots = poly.roots();
    match roots {
        rustnomial::Roots::ManyRealRoots(v) => {
            println!("roots() returned `Many Real Roots` with values:");
            for v_ in v {
                println!("{}", v_);
            }
        },
        _ => {
            println!("roots() returned some other type.");
        }
    }
}

it returns:

roots() returned `Many Real Roots` with values:
-31.053752658339498
1.4912025299402378
-6.43744987160074

but in reality the equation has different roots:

-4
-31.492
-0.50807

(See here for exact forms)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions