Skip to content

Instantly share code, notes, and snippets.

@Axect
Created December 11, 2023 04:39
Show Gist options
  • Save Axect/f1c08de0656731f608e5db1c67c96921 to your computer and use it in GitHub Desktop.
Save Axect/f1c08de0656731f608e5db1c67c96921 to your computer and use it in GitHub Desktop.
Bisection test with Peroxide
use peroxide::fuga::*;
fn main() {
let h = |x: AD| -> AD {
let y = if x.x() < 5.0 { -5.0 } else { 5.0 };
println!("y = {:>2}", y);
AD0(y)
};
let sol = bisection(h, (0.0, 10.0), 5, 0.0001);
match sol {
Ok(x) => println!("{}", x),
Err(_) => println!("No solution found"),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment