Skip to main content
37 votes

How can I adaptively simplify a curved shape?

We can use the Ramer-Douglas-Peucker algorithm to reduce the number of points. This algorithm was originally devised for processing map data. ...
Szabolcs's user avatar
  • 236k
29 votes
Accepted

Inflection point and curvature

Let's rename things slightly to make it more consistent g = Fit[newdata, {1, x, x^2, x^3, x^4}, x]; To find inflection points, you can just put (blue) points ...
wxffles's user avatar
  • 14.2k
25 votes
Accepted

Easy way to plot ODE solutions from NDSolve?

I wanted to share some undocumented techniques that give quick rough plots of NDSolve solutions. The keys points are this, the second one being quite handy at ...
Michael E2's user avatar
  • 237k
24 votes

My Girlfriend is going to prison...Save her with Math

Similar to previous answers, only I don't make the instantaneous absorption assumption since it isn't really necessary. The equation can be found here on page three, where ka and ke are the rates of ...
bobthechemist's user avatar
23 votes
Accepted

Data extraction from a picture of a graph

This is not a complete solution, but might get you on the way. With a little bit of trial and error you can identify the coordinates of the blocks and the key in the image: ...
Simon Woods's user avatar
  • 85.1k
19 votes
Accepted

How to Take Derivative of Interpolating Function?

Use Derivative. If your interpolating function is called if, then its derivative is computed by ...
Szabolcs's user avatar
  • 236k
19 votes

Make an offset curve (parallel curve)

...
ubpdqn's user avatar
  • 61.9k
18 votes

Extracting the function from InterpolatingFunction object

In M11+ you can use the "GetPolynomial" method of an interpolating function to obtain the corresponding piecewise expression (but only when using the default "Hermite" method): ...
Carl Woll's user avatar
  • 131k
18 votes
Accepted

Morphing between two functions

You might be interested in the approach with optimal transport. Let $F(x)=\int_{-\infty}^x f(y)\,dy$ and $G(x)=\int_{-\infty}^x g(y)\,dy$ be the repartition functions. Then $T(x)=G^{-1}\bigl(F(x)\...
Federico's user avatar
  • 2,553
16 votes

How do you calculate the 2d area between list points?

Assuming you want the area of the polygon made of the points. At first we'll order the points: orderedPoints=points[[FindShortestTour[points][[2]]]]; Then lets ...
Julien Kluge's user avatar
  • 5,385
14 votes

2D smoothing spline interpolation

Update Since version 12, this functionality in integrated in Mathematica via the Option FitRegularization Following on @Ajasja's answer in the spirit of this answer one can in fact provide ...
chris's user avatar
  • 23k
14 votes

My Girlfriend is going to prison...Save her with Math

Assuming the simplest kinetic model for elimination (and making the simplifying assumption of "instant absorption" to peak concentration): ...
ubpdqn's user avatar
  • 61.9k
14 votes
Accepted

FindMaximum of Interpolated data set

NMaximize is good for finding global maxima: NMaximize[{f[x], 26 < x < 6908}, x] (* {28.9179, {x -> 177.957}} *) For <...
aardvark2012's user avatar
  • 5,424
14 votes
Accepted

Interpolating noisy data

Using Quantile regression might produce results you want -- you have to experiment with the number of knots or the knots locations. Get data: ...
Anton Antonov's user avatar
14 votes
Accepted

Meaning of InterpolationOrder -> All for multidimensional interpolation

This is code that has been written many moons ago... here is an example: ...
user21's user avatar
  • 40k
14 votes
Accepted

Integration of Interpolated function take an unacceptable amount of time

The code in the question takes about 40 seconds on my computer. Turning off SymbolicProcessing, as suggested by Tim Laska in a comment, reduces the run time to ...
bbgodfrey's user avatar
  • 61.7k
14 votes
Accepted

Interpolation[] gives negative values when all the initial data is positive

One good way to interpolate a function of this nature is to take its Log, interpolate, and take Exp of the result. ...
John Doty's user avatar
  • 13.8k
14 votes

Plotting a directed contour with self-intersections

Something to get you started: ...
Lukas Lang's user avatar
  • 34.1k
13 votes

Extracting the function from InterpolatingFunction object

You could use Series. What's necessary is to know which abscissa values were used for the interpolation. Let's generate some fake data. ...
LLlAMnYP's user avatar
  • 11.5k
13 votes
Accepted

How to speed up integration of interpolation function?

The way to deal with this is to use the special setting Method -> "InterpolationPointsSubdivision" of NIntegrate[], which ...
J. M.'s missing motivation's user avatar
13 votes
Accepted

How to calculate the control points of a Bézier curve?

Here is my approach: ...
xyz's user avatar
  • 625
13 votes

How can I find the inverse of an interpolating function?

...
Bob Hanlon's user avatar
  • 160k
12 votes

Extracting the function from InterpolatingFunction object

Here is a (mostly) general routine that (tries to) convert a one-dimensional InterpolatingFunction[] into an equivalent ...
J. M.'s missing motivation's user avatar
12 votes
Accepted

Complex continuation of an interpolated function

There are limitations to extending polynomial interpolation on a real interval to the complex plane. The limitations are related to the Bernstein ellipse (see also Trefethen, Approximation Theory and ...
Michael E2's user avatar
  • 237k
12 votes
Accepted

How do you interpolate outside the range of data?

You can use the undocumented argument "ExtrapolationHandler", which I learned about here, together with ConditionalExpression as ...
C. E.'s user avatar
  • 70.8k
12 votes
Accepted

Interpolation on an unstructured mesh

Here is how to do it, just let ToElementMesh create the mesh: ...
user21's user avatar
  • 40k
11 votes

The only usage for the option InterpolationOrder in NDSolve is to be set to All?

First, InterpolationOrder can be set to integer and make a difference, but there are limitations. Whether the settings other than ...
Michael E2's user avatar
  • 237k
11 votes

How can I adaptively simplify a curved shape?

Here is my attempt to use ParametricPlot for obtaining an adaptive approximation of the shape. It is based on the code of glyph to ...
Alexey Popkov's user avatar
11 votes

How can I adaptively simplify a curved shape?

Here I present a very simple angle-based polygon reduction algorithm as described in the chapter "A Simple Algorithm" of David Eberly's "Polyline Reduction". The only addition is ...
Alexey Popkov's user avatar
11 votes
Accepted

Make an offset curve (parallel curve)

This involves an algebraic curve so it can be done in closed form (one approach already shown does this, in the parametric form). We'll do the interpolation below at high precision in order to make ...
Daniel Lichtblau's user avatar

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