@@ -14,7 +14,7 @@ pub fn linear_interpolation(x: f64, point0: (f64, f64), point1: (f64, f64)) -> f
14
14
/// Source: https://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html
15
15
/// x is the point we wish to interpolate
16
16
/// defined points are a vector of tuples containing known x and y values of our function
17
- pub fn langrange_polynomial_interpolation ( x : f64 , defined_points : & Vec < ( f64 , f64 ) > ) -> f64 {
17
+ pub fn lagrange_polynomial_interpolation ( x : f64 , defined_points : & Vec < ( f64 , f64 ) > ) -> f64 {
18
18
let mut defined_x_values: Vec < f64 > = Vec :: new ( ) ;
19
19
let mut defined_y_values: Vec < f64 > = Vec :: new ( ) ;
20
20
@@ -74,25 +74,25 @@ mod tests {
74
74
75
75
// check for equality
76
76
assert_eq ! (
77
- langrange_polynomial_interpolation ( 1.0 , & defined_points) ,
77
+ lagrange_polynomial_interpolation ( 1.0 , & defined_points) ,
78
78
1.0
79
79
) ;
80
80
assert_eq ! (
81
- langrange_polynomial_interpolation ( 2.0 , & defined_points) ,
81
+ lagrange_polynomial_interpolation ( 2.0 , & defined_points) ,
82
82
4.0
83
83
) ;
84
84
assert_eq ! (
85
- langrange_polynomial_interpolation ( 3.0 , & defined_points) ,
85
+ lagrange_polynomial_interpolation ( 3.0 , & defined_points) ,
86
86
9.0
87
87
) ;
88
88
89
89
//other
90
90
assert_eq ! (
91
- langrange_polynomial_interpolation ( 0.5 , & defined_points) ,
91
+ lagrange_polynomial_interpolation ( 0.5 , & defined_points) ,
92
92
0.25
93
93
) ;
94
94
assert_eq ! (
95
- langrange_polynomial_interpolation ( 2.5 , & defined_points) ,
95
+ lagrange_polynomial_interpolation ( 2.5 , & defined_points) ,
96
96
6.25
97
97
) ;
98
98
}
0 commit comments