cmlabs.interpolate.test_lagrange_remainder_1

cmlabs.interpolate.test_lagrange_remainder_1()[source]

Estimate the derivative and remainder degree 1.

\[\begin{split}\begin{gather} R_1(x) = f(x) - L_1(x) \\ \\ f(x) = x - \log_{10}(x + 2) \\ f''(x) = \frac{1}{(x + 2)^2 \cdot \ln(10)} \\ \min{f''_{[x_i, x_{i+1}]}} = \min_{x \in [x_i, x_{i+1}]} |f''(x)| = \frac{1}{(x_{i+1} + 2)^2 \cdot \ln(10)} \\ \max{f''_{[x_i, x_{i+1}]}} = \max_{x \in [x_i, x_{i+1}]} |f''(x)| = \frac{1}{(x_i + 2)^2 \cdot \ln(10)} \\ \\ \left|\frac{\min{f''(x)}}{2} \cdot \omega_2(x)\right| \leq |R_1(x)| \leq \left|\frac{\max{f''(x)}}{2} \cdot \omega_2(x)\right|, \quad x \in [x_i, x_{i+1}] \\ \end{gather}\end{split}\]

Results

>>> # Test 2: Estimating Remainder Degree 1 In Lagrange Interpolation Formula
>>> # - X:  [0.5   0.556 0.611 ... 0.889 0.944 1.   ]
>>> # - x* =  0.77
>>> # Nearest points: [0.722 0.778]
>>> # Nearest f(x) values: [0.287 0.334]
>>> # f''(x) min: 0.056284564854661434
>>> # f''(x) max: 0.05860533616686946
>>> f(0.77) - lagrange([0.722 0.778], [0.287 0.334], 0.77)
>>> # 1.0619234786568565e-05
>>> # R_min: 1.0457811124230303e-05
>>> # R_max: 1.0889016164338089e-05
>>> |1.0457811124230303e-05| <= |1.0619234786568565e-05| <= |1.0889016164338089e-05|
>>> # True
>>> abs(1.0889016164338089e-05) <= 1e-4
>>> # True

See also

lagrange_remainder