cmlabs.differentiate.test_lagrange_derivative
- cmlabs.differentiate.test_lagrange_derivative()[source]
Lagrange derivative.
\[\begin{split}\begin{aligned} L_4(x) = \sum_{i=0}^{4} l_i(x) f(x_i) \\ l_i(x) = \prod_{j=0, j \neq i}^{4} \frac{x - x_j}{x_i - x_j} \end{aligned}\end{split}\]\(k=2, \quad m=0, \quad n=4\)
\[\begin{split}\begin{gather} l_0''(x_0) = \frac{35}{12h^2}, \quad l_1''(x_0) = -\frac{26}{3h^2}, \quad l_2''(x_0) = \frac{19}{2h^2} \\ l_3''(x_0) = -\frac{14}{3h^2}, \quad l_4''(x_0) = \frac{11}{12h^2} \\ L_4''(x_0) = \frac{1}{h^2} \left( \frac{35}{12} f(x_0) - \frac{26}{3} f(x_1) + \frac{19}{2} f(x_2) - \frac{14}{3} f(x_3) + \frac{11}{12} f(x_4) \right)\\ R_{4,2}''(x_0) = \frac{f^{(5)}(\xi_1)}{5!}\omega_{5}''(x_0) + 2 \frac{f^{(6)}(\xi_2)}{6!}\omega_{5}'(x_0) \\ R_{4,2}''(x_0) = \frac{f^{(5)}}{5!} \cdot (-100h^3) + \frac{f^{(6)}}{6!} \cdot 48h^4 \\ \left(x - \lg(x+2)\right)'' = \frac{1}{(x + 2)^2 \cdot \ln(10)} \\ \left(x - \lg(x+2)\right)^{(5)} = -\frac{24}{(x + 2)^5 \cdot \ln(10)} \\ \left(x - \lg(x+2)\right)^{(6)} = \frac{120}{(x + 2)^6 \cdot \ln(10)} \\ min(R_{4,2}) = \left(-\frac{24}{(x_n + 2)^5 \cdot \ln(10)}\right) \cdot \frac{1}{5!} \cdot (-100h^3) + \\ + \left(\frac{120}{(x_n + 2)^6 \cdot \ln(10)}\right) \cdot \frac{1}{6!} \cdot 48h^4 \\ max(R_{4,2}) = \left(-\frac{24}{(x_0 + 2)^5 \cdot \ln(10)}\right) \cdot \frac{1}{5!} \cdot (-100h^3) + \\ + \left(\frac{120}{(x_0 + 2)^6 \cdot \ln(10)}\right) \cdot \frac{1}{6!} \cdot 48h^4 \\ |min(R_{4,2})| \leq |R_{4,2}''(x)| \leq |max(R_{4,2})| \end{gather}\end{split}\]Notes
Examples
>>> # Test 1: Lagrange Derivative >>> # - X: [0.5 0.556 0.611 ... 0.889 0.944 1. ] >>> # - x_0 = 0.5 >>> # - h = 0.05555555555555558 >>> # - Y: [0.102 0.148 0.194 ... 0.428 0.475 0.523] >>> # L_4_2(x_0) = 0.06947426144114938 >>> # OR WE CAN USE CUSTOM lagrange_derivative FUNCTION >>> lagrange_derivative([0.5 ... 0.722], [0.102 ... 0.287], 0.5, k=2) >>> # L_4_2(x_0) = 0.06947426144084545 >>> # R_4_2_min = 6.1744127485294504e-06 >>> # R_4_2_max = 1.5386508722671422e-05 >>> # f''(x_0) = 0.06948711710452028 >>> # R_4_2 = 1.2855663370905934e-05 >>> 6.1744127485294504e-06 <= 1.2855663370905934e-05 <= 1.5386508722671422e-05 >>> # True