Lagrange Interpolation

I have this table with 90 elements, and i want to make a cicle that gives me de lagrange operators This are the elements, and i want to make a interpolation but i need to make it with lagrange interpolations and show the cicle to calculate the lagrange operators.

{{230.5, 622.}, {231.5, 622.}, {230.5, 613.}, {234., 605.}, {235., 594.}, {236., 584.}, {239.5, 574.}, {238., 564.}, {239.5, 549.}, {239.5, 538.}, {244., 531.}, {242.5, 516.}, {236., 510.}, {235., 501.}, {230.5, 491.}, {235., 490.}, {236., 481.}, {238., 469.}, {242.5, 459.}, {245., 449.}, {241.5, 443.}, {247., 433.}, {254., 424.}, {255., 417.}, {264., 408.}, {266., 399.}, {267., 401.}, {266., 395.}, {268.5, 389.}, {278.5, 383.}, {279.5, 370.}, {288.5, 356.}, {297.5, 340.}, {301.5, 331.}, {305., 327.}, {310.5, 324.}, {319.5, 315.}, {325., 306.}, {337.5, 296.}, {345., 292.}, {349.5, 276.}, {353., 258.}, {358.5, 245.}, {359.5, 235.}, {362., 232.}, {364., 224.}, {372., 208.}, {373., 195.}, {386.5, 185.}, {396.5, 183.}, {408.5, 176.}, {418.5, 171.}, {429., 162.}, {440., 156.}, {447.5, 154.}, {459., 144.}, {461., 144.}, {463.5, 140.}, {471., 142.}, {484.5, 134.}, {491., 129.}, {495.5, 123.}, {501., 125.}, {507., 121.}, {517., 110.}, {528., 108.}, {537., 103.}, {543.5, 99.}, {554.5, 97.}, {558., 91.}, {562.5,88.}, {571.5, 87.}, {578., 82.}, {587., 74.}, {597., 68.}, {605., 68.}, {607., 63.}, {611.5, 67.}, {617., 60.}, {622.5, 59.}, {627., 59.}, {640.5, 58.}, {647., 54.}, {650.5, 49.}, {652.5, 49.}, {657., 52.}, {667., 53.}, {676., 51.}, {681.5, 44.}, {683., 40.}}; Thank you

Interpolation of a eigenvector of a matrix and it’s derivative

I have a matrix with two variables and the condition is I can’t evaluate it’s Eigenvectors analytically. I want to interpolate its numerical eigenvectors and Most importantly get a derivative of them wrt to the variables. Somehow, my values from the interpolated function don’t seem to match with the actual one.

Below I have posted code with a random matrix which, of course, can be evaluated analytically and compared to the numerically interpolated result.

    Mat[x_, y_] = {{x + 2 y^2, 2 x - 3 y}, {\[Sqrt]y - x, 5 x + y}};(* Matrix 2 X 2*)     vec[x_, y_] := Eigensystem[Mat[x, y]][[2]] 

For interpolating complex eigenvectors, I usually separate Real and Imag and sum individual interpolation functions. But, here I did both together. Numeric Table (bigger data set to ensure best fit) for the first Eigenvector is below:

    Nvec = ParallelTable[{x, y, vec[x, y][[1]]}, {x, -4, 4, .01}, {y, -4, 4, .01}]; 

The interpolation is:

    Nintevec = Interpolation[Flatten[Nvec, 1], InterpolationOrder -> 2(*,Method-> "Spline"*)] 

The values and Derivative of the Interpolating function at any point say {x,y}->{1,2} is:

    Nintevec[1, 2]     (* {0.951926 + 0. I, 0.237982 - 0.192876 I}*)     D[Nintevec[x, y], x] /. {x -> 1, y -> 2}     (*{0.0854973 + 0. I, -0.335611 + 0.00790822 I}*) 

These Values don’t match with the actual analytical results of:

    vec[1, 2][[1]] // N     (* {2.41421 + 1.95664 I, 1.}*)     D[vec[x, y][[1]], x] /. {x -> 1, y -> 2} // N     (*{1. - 3.48988 I, 0.}*) 

I thought of interpolating to tackle this, if there are other ways I am willing to try it on. Any help is greatly appreciated? Thank you

System of delay differential equations: using first interpolation as second initial condition

I am trying to solve numerically the following system of two coupled delay differential equations:

$ $ \dot x(t)=-\gamma x(t)-\frac{\gamma}{4}e^{i\omega_0\tau_1}y(t-\tau_1)\theta(t-\tau_1)+\frac{\gamma}{4}e^{i\omega_0\tau_2}y(t-\tau_2)\theta(t-\tau_2)+\frac{\gamma}{2}e^{i\omega_0\tau_3}x(t-\tau_3)\theta(t-\tau_3),$ $ $ $ \dot y(t)= -\frac{\gamma}{2}y(t)-\frac{\gamma}{4}e^{i\omega_0\tau_1}x(t-\tau_1)\theta(t-\tau_1)+\frac{\gamma}{4}e^{i\omega_0\tau_2}x(t-\tau_2)\theta(t-\tau_2).$ $ where $ \tau_1<\tau_2<\tau_3$ . The parameters $ \gamma, \omega_0$ are constants, and $ \theta(t)$ is the Heaviside step function. The history of the system is known for $ 0\leq t\leq\tau_1$ : $ $ x(t)=e^{-\gamma t}, y(t)=e^{-\gamma t/2}.$ $ Here what I tried:

I first solved the system for $ 0\leq t\leq\tau_2$ using the aforementioned initial history using NDSolve:

\[Gamma] = 1.0; \[Omega]0 = 2 Pi; \[Tau]1 = 1.0; \[Tau]2 = 2.0; \[Tau]3 = 3.0;  sol1 = NDSolve[{x'[   t] == - \[Gamma] x[t] - (\[Gamma]/4) E^(I \[Tau]1 \[Omega]0)     y[t - \[Tau]1],  y'[t] == - 0.5 \[Gamma] y[t] - (\[Gamma]/4) E^(    I \[Tau]1 \[Omega]0) x[t - \[Tau]1],  x[t /; t <= \[Tau]1] == (1.0/Sqrt[2.0]) Exp[-\[Gamma] t],  y[t /; t <= \[Tau]1] == (1.0/Sqrt[2.0]) Exp[-0.5 \[Gamma] t]}, {x,  y}, {t, 0, \[Tau]2}]; 

I get the following solution for $ |x(t)|^2$ and $ |y(t)|^2$ : abs[x]^2,abs[y]^2

The problem arises when I use this first interpolated solution as the initial history to solve for the next interval of time:

sol2 = NDSolve[{x'[   t] == - \[Gamma] x[t] - (\[Gamma]/4) E^(I \[Tau]1 \[Omega]0)     y[t - \[Tau]1] + (\[Gamma]/4) E^(I \[Tau]2 \[Omega]0)     y[t - \[Tau]2],  y'[t] == - 0.5 \[Gamma] y[t] - (\[Gamma]/4) E^(    I \[Tau]1 \[Omega]0) x[t - \[Tau]1] + (\[Gamma]/4) E^(    I \[Tau]2 \[Omega]0) x[t - \[Tau]2],  x[t /; t <= \[Tau]2] == Evaluate[x[t] /. sol1],  y[t /; t <= \[Tau]2] == Evaluate[y[t] /. sol1]}, {x, y}, {t,  0, \[Tau]3}];  

This time I get the following messages: enter image description here enter image description here

It seems that the second NDSolve (sol2) does not allow the interpolation of the first result as initial history. Any suggestion? Thank you in advance.

Interpolation of render with fixed physics update

In Fix Your Timestep, they briefly address the remainder time in relation to rendering. Saying that remainder can be used to generate an interpolated rendering.

We can use this remainder value to get a blending factor between the previous and current physics state simply by dividing by dt. This gives an alpha value in the range [0,1] which is used to perform a linear interpolation between the two physics states to get the current state to render.

http://web.archive.org/web/20190506030345/https://gafferongames.com/post/fix_your_timestep/

So let’s say your last two physics updates we’ll call A and B are from 00:10.033 and 00:10.066, and it is now 00:10.070 when we want to perform a render. We have a remainder of .004.

I take “interpolation between the two physics states” to mean we compare all the objects in update A and B and slide them back from B towards A by 88% (.033-.004)/.033). This would mean I’m actually rendering the physical state at 00:10.037, correct? So my physics updates A and B are really more like “previous” and “next” and my interpolation is between the previous and the next, correct?

Interpolation Inequality’s Proof

Let $ \Omega \subseteq R^{n}$ bounded domain. I need to prove that for $ u\in H^{2}(\Omega)\cap H^{1}_{0}(\Omega)$ : \begin{equation} \|\nabla u\|_{L^{2}(\Omega)}^{2}\leq \|u\|_{L^{2}(\Omega)}\|\Delta u\|_{L^{2}(\Omega)} \end{equation} I know that I should prove it for a $ u\in C^{2}_{0}(\Omega)$ and then use the Global Approximation Theorem with smooth functions to extend $ u\in C^{2}_{0}(\Omega)$ to $ u\in H^{2}(\Omega)\cap H^{1}_{0}(\Omega)$ . Also, I know the following expression could be useful: \begin{equation} \Delta(\frac{u^{2}}{2})=|\nabla u|^{2}+u\Delta u \end{equation}

Python multidimensional Lookup interpolation

To interpolate within a dataset, I want to create a multidimensional Lookup table in python. In this case, the tree input arrays x,y and z are given together with the output quantity a.

I was able to visualize the impact of x and y with a 2D heatmap:

xi = np.linspace(np.amin(x),np.amax(x),100) yi = np.linspace(np.amin(y),np.amax(y),100)  zi = griddata((x, y), a, (xi[None,:], yi[:,None]), method='linear')  CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k') CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.bwr_r) plt.colorbar() 

2D heatmap

However, my goal is not visualization. In the end I want to pass some x,y and z values to the Lookup and get an interpolated value of a.

I’ve allready found something related here, but the proposed function did not work. Is there any library I’ve missed so far or a suitable way to perform a multidimensional interpolation?

Lagrange interpolation formula


Give the formula of the $ 1$ st degree Lagrange polynomial $ L(x)$ interpolating a function $ f$ at the points $ 0$ and $ 1$ . Give the formula for the error $ L – f$ . Finally, show that

$ $ \sup_{x \in [0, 1]} |L(x) – f(x)| \leq \frac{1}{8} \sup_{[0, 1]} |f”|. $ $

To do this problem, I used the formula

$ $ L(x) = \sum_{i=0}^{n} l_{i}(x) y_{i},$ $

where $ $ l_{i}(x) = \prod_{0 \leq j \leq n \text{ and } j \neq i} \frac{x – x_{j}}{x_{i} – x_{j}}$ $

with $ x_{0} = 0, x_{1} = 1$ and $ y_{0} = f(x_{0}), y_{1} = f(x_{1})$ .

So first,

$ $ l_{0}(x) = \frac{x – x_{1}}{x_{0} – x_{1}} = \frac{x – 1}{-1} = 1 – x. $ $

Also,

$ $ \ell_{1}(x) = \frac{x – x_{0}}{x_{1} – x_{0}} = x .$ $

So I got $ L(x) = (1 – x)y_{0} + xy_{1}$ as my answer. Is this correct? I’m new to Lagrange interpolation and just wanna make I’m doing everything right.


Assuming this is right, I have the error formula provided in my book:

$ $ |L(x) – f(x)| \leq \frac{M_{n + 1}}{(n + 1)!} |\pi_{n + 1}(x)|,$ $

where $ M_{n + 1} = \max_{\xi \in [a, b]} |f^{(n + 1)}(\xi)|$ and $ \pi_{n + 1}(x) = \prod_{i=0}^{n} (x-x_{i})$ .

This looks really similar to what I need to do next, but I would like some guidance on how to do the next two parts.