Skip to content

find_roots_sturm misses a root of a quartic #35

Description

@sgtatham

This test program runs find_roots_sturm to determine the real roots of the quartic polynomial x^4 - 7x^3 + 7x - 1.

fn main() {
    println!(
        "{:?}",
        roots::find_roots_sturm(&[-7.0, 0.0, 7.0, -1.0], &mut 1.0e-12)
    );
}

As of roots v0.0.8, this is its output, which is incorrect:

[Ok(-1.0000000000000007), Ok(0.145898033750315), Ok(1.0000000000000009)]

This quartic happens to factorise as (x - 1) (x + 1) (x^2 - 7x + 1), and therefore its roots are +1, -1, and by the quadratic formula (7 ± √45) / 2, i.e. about 0.145898 and 6.854102. So find_roots_sturm has missed the large root 6.854102, and returned only the other three.

More generally, no real quartic has three real roots! If it has complex roots, then they appear in conjugate pairs, so there can be 0, 2 or 4 real roots, but not 1 or 3. So even without being able to factorise this quartic, it's clear that an answer of length 3 is wrong.

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