# Tag Info

## Hot answers tagged interpolation

9

In this case, the data are very unlike a polynomial, thus ill-suited for polynomial interpolation. On the other hand, the inverse data represent a polynomial, so interpolate them: invdata = Transpose@{points, 1/hyper}; invinterp = Interpolation[invdata] Plot[1/invinterp[x], {x, 1, 10}] In general, the art of polynomial approximation and interpolation ...

8

Not sure how useful will this be. Usually Standardize-d data is giving better results. We can also cut off parts of the surface which are distant from our data. rf = Nearest[Standardize@data] sr = ListSurfacePlot3D[Standardize @ data, BoxRatios -> 1, MaxPlotPoints -> 100, RegionFunction -> Function[{x, y, z}, Norm[{x, y, z} - rf[{x, ...

6

This is due to the interpolation. If you turn off the interpolation by InterpolationOrder -> 0 you will see symmetric plot. data = Flatten[Table[{x, y, If[x == y, 1, 0]}, {x, 0, 1, 1/10}, {y, 0, 1, 1/10}], 1]; dataR = data; dataL = data /. {x_, y_, z_} :> {-x, y, z}; data0 = Join[dataL,dataR] ListDensityPlot[data0, ...

6

I think your best bet is to generate a triangualted polygon surface. Here is an initial stab at it: p2d = b[[All, 1 ;; 2]]; tri1[i_, j_] := If[EvenQ[j], {{i, j}, {i + 1, j}, {i + 1/2, j + 1}} .05, {{i + 1/2, j}, {i + 1 + 1/2, j}, {i + 1, j + 1}} .05] tri2[i_, j_] := If[EvenQ[j], {{i, j}, {i + 1, j}, {i + 1/2, j - 1}} .05, {{i + 1/2, j}, {i + ...

5

Interpolation sometimes does not handle endpoints well, and this appears to be exacerbated in the present case, because the upper endpoint is far removed from the rest of the points. One workaround is to provide more, but very closely spaced, points of identical value (so that there is no need to know the form of the original function there) near the upper ...

4

This is an irritating bug that was introduced in V8 and has not been fixed even in the latest version (10.4.1) of Mathematica. Both f = FunctionInterpolation[N[1, 20] x, {x, 0, 1}] and g = FunctionInterpolation[N[1, 2] x, {x, 0, 1}] give a spate of error messages similar to ones you encountered. In both cases the functions returned appear to behave ...

4

I'll just treat the simplest case of interpolating across four noncoplanar points. The extension to general grids is straightforward (one just joins multiple pieces appropriately). Consider the following bivariate interpolating polynomial: ip[x_, y_] = InterpolatingPolynomial[{{{0, 0}, 1}, {{0, 1}, -1/2}, {{2, 0}, 1/2},...

4

ListDensityPlot interpolated by constructing a Delaunay triangulation of the data points and interpolating linearly on each triangle. For a perfectly rectangular point grid, there are two ways to break each rectangle into triangles. If we distort the grid slightly and make each rectangle a parallelogram, then there will only be one way to construct the ...

3

You could try using numerical differentiation from the Numerical Calculus package: Clear[r, fun] Needs["NumericalCalculus"] r = NDSolve[ {I k'[s] == 20 (s k[s] - (1 - s) (1 - k[s]) (1 + k[s])), k[0] == 1/2}, k, {s, 0, 1} ]; fun[s_] := Abs[(k /. r[[1]])[s]]; Plot[ {10 fun[t], ND[fun[s], s, t, Terms -> 20]}, {t, 0, 1}, PlotLegends -&...

3

You have many superfluous sets of {} that generate unexpected output in your code. In particular, the Interpolation functions generated by NDSolve were not returning a scalar value, but instead a unidimensional vector, i.e. a list containing a single value instead. That was probably an unintended consequence of the extra sets of braces in the definitions of ...

3

Clear["Global*"] yy = 10^-4; rr = 0.999; xx = 10^-15; zz = 10^-4; mm = 10^-4; yy + rr + xx^2 + zz - mm^2 - zz^2/24 ic = -17.5 s = NDSolve[{D[y[t], t] == (3 y[t])/5 - (12 m[t]^2 y[t])/5 + (2 r[t] y[t])/ 5 - (6 x[t]^2 y[t])/5 + (3 y[t]^2)/5 + (7 y[t] z[t])/ 5 - (y[t] z[t]^2)/10, D[r[t], t] == -((2 r[t])/5) - (12 m[t]^2 r[t])/5 + (2 r[...

3

If the function's derivative is easy to obtain, then the default piecewise interpolation works fairly well when the derivative values are specified. One can also use FunctionInterpolation. With FunctionInterpolation you can adjust the options to achieve a desired accuracy. f = x^-5; df = D[f, x]; data = Table[{{x}, f, df}, {x, 1., 100.}]; ifn1 = ...

3

A couple of points: You have some duplicate coordinates in your data, these need to be removed before you can interpolate A couple of the points in your list are outside the range you've specified. Therefore you need to extrapolate, not interpolate, and the results at these points can't be trusted. data0 = DeleteDuplicatesBy[data0, #[[;; 2]] &]; ...

3

This is not a full answer, but it seems to me that you may have a use for code that allows you to group the points by the orbit they belong to, as Jason also mentioned. It seems to me that, with this in hand, the problem may be reduced to the one @JasonB solved in your previous question. Here's a start in that direction: paths = FindClusters[data0, 15, ...

3

You can make an interpolating function for both px and py from the data you have: data = Import["Downloads/lyap_4d.dat", "Table"]; d00 = data[[All, {1, 2}]]; pyfunc = Interpolation[{{#1, #2}, #4} & @@@ data, InterpolationOrder -> 1]; pxfunc = Interpolation[{{#1, #2}, #3} & @@@ data, InterpolationOrder -> 1]; That answers the question ...

3

As I mentioned in a comment this blog post, "Find Fit for Non-linear data", discusses a similar problem. Quantile Regression (QR) can produce a good enough interpolation of order two: Import["https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/QuantileRegression.m"] qfunc = First@ QuantileRegression[dat, dat[[All, 1]], {0.5}, ...

3

One could try to find a solution with FindFormula. dat = {#, Exp[-#]} & /@ Append[Range[0, 3, .5], 10]; Plot[Evaluate@FindFormula[dat, x], {x, 0, 10}, PlotRange -> All, Epilog -> {Red, PointSize@Medium, Point@dat}] Addendum For the 2nd try to solve the problem I use BSplines. I insert a point until the curve is smooth. We don't know the ...

2

In such situations some sort of preprocessing of the data might be very useful: Clear[int, x] int[x_] = With[{data = {#1, Log@#2} & @@@ dat}, Exp[Interpolation[data, InterpolationOrder -> #, Method -> "Spline"][x]]] & /@ Range[2, 7]; Show[Plot[Evaluate@int[x], {x, 0, 10}, PlotRange -> All], ListPlot[dat], PlotRange ->...

2

Here is a function for multiplying InterpolatingFunctions generated from a single NDSolve (so that the coordinate grids are the same, as well as one-dimensional). This yields a single InterpolatingFunction that interpolates the product. It carries over derivative information, too. (I've done this before on the site, I think.) Anyway, Integrate on an ...

2

Alternatively, you could do a little complex number algebra for the purpose: kf = NDSolveValue[{I k'[s] == 20 (s k[s] - (1 - s) (1 - k[s]) (1 + k[s])), k[0] == 1/2}, k, {s, 0, 1}]; Plot[{10 Abs[kf[t]], Re[kf[t] Conjugate[kf'[t]]]/Abs[kf[t]]}, {t, 0, 1}, PlotLegends -> {"scaled function", "numerical derivative"}]

2

Import takes all sheets, which nests the data. First@ takes the first sheet formatting the data you need for the subsequent expressions. test = First@Import["Velocidade Angular.xls"]; time = test[[All, 1]]; x = test[[All, 2]]; f = Interpolation[Transpose[{time, x}], InterpolationOrder -> 3]; Show[ ListPlot[test[[All, 1 ;; 2]], PlotStyle -> Red], ...

1

Fit your data to a CDF using NonlinearModelFit data = {{406.833, 0.05}, {423.458, 0.1}, {436.375, 0.15}, {448.042, 0.2}, {459.583, 0.25}, {467.75, 0.3}, {479.083, 0.35}, {489.917, 0.4}, {500.875, 0.45}, {508.542, 0.5}, {521.792, 0.55}, {536.75, 0.6}, {547.458, 0.65}, {560.667, 0.7}, {584.208, 0.75}, {598.583, 0.8}, {632.875, 0.85}, {672....

1

You can just sample your function on a finer grid. Using grid spacing of 1, like you are, leads to horrible interpolation, whereas a grid spacing of 0.1 works out perfectly. (data = Table[{x, x^-5}, {x, 1, 100, #}]; Show[ Plot[Interpolation[data, InterpolationOrder -> 3][x], {x, 1, 10}, PlotRange -> All, ImageSize -> 400], ListPlot[...

Only top voted, non community-wiki answers of a minimum length are eligible