Run an example 'Interpolation: Lagrange'.
()
| 248 | |
| 249 | @print_docstring |
| 250 | def example_interpolation_lagrange(): |
| 251 | """Run an example 'Interpolation: Lagrange'.""" |
| 252 | x = np.array([2, 11 / 4, 4]) |
| 253 | y = np.array([1 / 2, 4 / 11, 1 / 4]) |
| 254 | x_int = 3 |
| 255 | |
| 256 | print("Inputs:") |
| 257 | print(f"x = {x}") |
| 258 | print(f"y = {y}") |
| 259 | print(f"x_int = {x_int}") |
| 260 | |
| 261 | y_int = interpolation.lagrange(x, y, x_int) |
| 262 | |
| 263 | print("Output:") |
| 264 | print(f"y_int = {y_int:.5f}") |
| 265 | |
| 266 | |
| 267 | @print_docstring |