demo/
demo.rs

1use exp_root_log::approx_exp_root_log;
2
3fn main() {
4    // Sample data: x values and corresponding y values
5    let x: Vec<f64> = (0..100).map(|i| i as f64 / 100.0).collect();
6    let y: Vec<f64> = x.iter().map(|&x| (2.0 * std::f64::consts::PI * x).sin()).collect();
7
8    // Create the approximation function using ExpRoot+Log
9    let approx_fn = approx_exp_root_log(
10        &x,
11        &y,
12        &[0.5, 2.0, 5.0, 10.0, 20.0],    //  b_i
13        5,                                  //  x^5
14        &[1.0, 5.0, 10.0, 20.0],           // log params
15    );
16
17    // Evaluate the approximation
18    let y_pred: Vec<f64> = x.iter().map(|&xi| approx_fn(xi)).collect();
19    
20    // Print the result
21    println!("Approximated values: {:?}", y_pred);
22}