Skip to content

Hi. can I get some help with this math problem? #57

Answered by Axect
luxiant asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @luxiant,

The internal implementation of the Bisection method in Peroxide is outlined below:

I(a, b) => {
    let f_ad = ADFn::new(|x| self.f(x));
    let x = 0.5 * (a + b);
    let fa = f_ad.call_stable(a);
    let fx = f_ad.call_stable(x);
    let fb = f_ad.call_stable(b);
    if (a - b).abs() <= self.tol {
        self.find = RootBool::Find;
        self.root = x;
    } else {
        if fa * fx < 0f64 {
            self.curr = I(a, x);
        } else if fx * fb < 0f64 {
            self.curr = I(x, b);
        } else if fx == 0f64 {
            self.find = RootBool::Find;
            self.root = x;
        } else {
            self.find = RootBool::Error;
        }
    }
}

This alg…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@luxiant
Comment options

Answer selected by luxiant
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants