Skip to content

Incorrect result of multiplication #6

@Xendergo

Description

@Xendergo

I found a situation where the library returns an incorrect result of multiplication...

use algebraics::prelude::*;
use algebraics::RealAlgebraicNumber as N;

fn main() {
    let v = N::from(5).pow((1, 2)) / N::from(4) - N::from(1) / N::from(4);

    println!("{v:?}");
    // RealAlgebraicNumber { minimal_polynomial: -1 + 2*X + 4*X^2, interval: DyadicFractionInterval { lower_bound_numer: -1, upper_bound_numer: 3, log2_denom: 1 } }
    // This polynomial has a root at 0.30901.. which is the correct answer

    println!("{:?}", &v * &v);
    // RealAlgebraicNumber { minimal_polynomial: 1 + 4*X, interval: DyadicFractionInterval { lower_bound_numer: -1, upper_bound_numer: 0, log2_denom: 0 } }
    // This polynomial has only one root at -0.25 which is the wrong answer
}

This happens on the latest commit as well as on the crates.io version

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