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
24 votes

Series sum approximation

Writing: NSum[(-1)^n/Sqrt[Log[n]], {n, 2, Infinity}, Method -> "AlternatingSigns"] I get: 0.690243 which is what you want. In particular, directly from ...
πρόσεχε's user avatar
16 votes

Chebyshev Approximation

Here's a way to leverage the Clenshaw-Curtis rule of NIntegrate and Anton Antonov's answer, Determining which rule NIntegrate selects automatically, to construct a ...
Michael E2's user avatar
  • 238k
16 votes

François Viète's approximation to π

You could use VietePiApprox[n_] := (Times @@ NestList[Sqrt[2 + #] &, Sqrt[2], n])/ 2^(n + 1) SetAttributes[VietePiApprox, Listable] which approximates Pi as ...
KennyColnago's user avatar
  • 15.3k
15 votes

How can I get samples of f(x) that are roughly evenly spaced?

f[x_] := 1 - 8 x^2 + 8 x^4; You can use the option MeshFunctions -> {ArcLength} and ... 1. Specify the number of equal-arc-...
kglr's user avatar
  • 398k
14 votes
Accepted

Approximating for $a \gg b$

How about this: Normal@Series[1/((a + b) b), {a, Infinity, 1}] (* ==> 1/(a b) *) Normal@Series[ArcTan[a + b], {a, Infinity, 1}] (* ==> -(1/a) + Pi/2 *) ...
Jens's user avatar
  • 97.5k
14 votes

Continued fraction approximation for $\pi$

1 + ContinuedFractionK[(2 n - 1)^2, 2, {n, 1, Infinity}] (* 4/π *) Pick a termination point less than Infinity to get an ...
Michael E2's user avatar
  • 238k
13 votes

How can I get samples of f(x) that are roughly evenly spaced?

If we want to the ArcLength approximately equal to the dist = 0.15;, we can define an arclength function ...
cvgmt's user avatar
  • 76.9k
12 votes

Approximation with radial basis functions

Introduction Radial basis function approximation has the form $$f(x) \approx \sum_{j=1}^N c_j \phi(\| x-x_j\|)$$ for some function $\phi(r)$ such as a Gaussian. Solving for the coefficients $c_j$ is ...
Michael E2's user avatar
  • 238k
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

Approximation with radial basis functions

Here is an answer with LinearModelFit using the data in the example referenced in the question. Data: ...
Anton Antonov's user avatar
11 votes
Accepted

Why this weird return value from `N`?

As @t-smart seems to suspect, the change in V11.3 to let machine underflows to underflow to 0. is at the root of this bug. In the OP's problem, Mathematica ...
Michael E2's user avatar
  • 238k
10 votes
Accepted

Calculating relative error of Ramanujan formula for ellipse perimeter

We have to express a parameter $h=(a-b)^2/(a+b)^2$ in terms of the eccentricity of the ellipse $e = \sqrt{1-b^2/a^2}$. Similarly we need comparing the second Ramanujan approximation for the ...
Artes's user avatar
  • 57.5k
9 votes

Analytical approximation of indefinite integral on a given interval to a given precision

One can construct a Chebyshev series approximation to the integrand for an interval, such as -5 <= x <=5 mentioned in the comments, and integrate it to get a ...
Michael E2's user avatar
  • 238k
9 votes

François Viète's approximation to π

Well, FoldList also can finish this job: 2/Times @@ (1/2 FoldList[Sqrt[2 + #] &, ConstantArray[Sqrt[2.], 10]]) By the way,...
Αλέξανδρος Ζεγγ's user avatar
9 votes
Accepted

How to find a numerical antiderivative with NIntegrate methods?

We construct an NDSolve method which can pass an NIntegrate method to NIntegrate to set up ...
Michael E2's user avatar
  • 238k
9 votes

Making algebraic substitutions with approximations

You could use Series[c/(a^2 - a*b), {a, Infinity, 4}] which yields
user293787's user avatar
  • 11.9k
8 votes

Series sum approximation

Using identity: $$\int_0^{\infty } \frac{2 n^{-t^2}}{\sqrt{\pi }} \, dt=\frac{1}{\sqrt{\log (n)}}$$ then I have: $$\sum _{n=2}^{\infty } \frac{(-1)^n}{\sqrt{\log (n)}}=\\\sum _{n=2}^{\infty } (-1)^n \...
Mariusz Iwaniuk's user avatar
8 votes
Accepted

Extracting a function from a Contour Plot

What you may not know is that the notebook interface is a bit like a web browser. Whatever complicated interface the web browser is showing, you can always just right-click and show the HTML source ...
C. E.'s user avatar
  • 70.8k
8 votes
Accepted

How to approximate $PV\int_0^\infty \frac{\tan x}{x}\text{d}x?$

The integral is Pi/2, a proof of which may be found on math.SE. Here's a numerical check, integrating $(\tan z)/z$ over parallel paths $z = x \pm a i$ and ...
Michael E2's user avatar
  • 238k
8 votes
Accepted

Suggest an irrational number from decimal one

Try WolframAlpha guess[x_]:=WolframAlpha["identify "<>ToString@x]
AsukaMinato's user avatar
  • 9,988
8 votes
Accepted

Approximation in LinePlot from NIntegrate

Exclude the poles. And do not need Quite anymore also. V 13.2 on windows. Basically you have an improper integral due to discontinuity at $x=1$ ...
Nasser's user avatar
  • 146k
8 votes

Better Stirling Approximation Error

...
Roman's user avatar
  • 48.3k
7 votes

Finding out the closest approximation of a decimal number by a ratio of two integers

Here is a brute-force version of bobby's answer: Table[First[MinimalBy[FareySequence[k], Abs[0.647437 - #] &]], {k, {5, 20, 1000}}] ...
J. M.'s missing motivation's user avatar
7 votes
Accepted

Fail to make good approximation with a Taylor Series

Perhaps this? PadeApproximant[-((-1 + m)^2/(-1 + 2 m - m^2 - 4 m Ne + 2 m^2 Ne)), {m, 0, {0, 1}}] (* 1/(1 + 4 m Ne) *) Note: A Taylor series is a power series, ...
Michael E2's user avatar
  • 238k
7 votes

Replace product of variables to zero

I would use an algebraic function for an algebraic operation, similar to what I did in the similar question, Replacement rules and algebra: ...
Michael E2's user avatar
  • 238k
7 votes

Continued fraction approximation for $\pi$

Michael's method of using ContinuedFractionK[] is the canonical way. If you want to look at the forward recursion method manually, you can use repeated matrix ...
J. M.'s missing motivation's user avatar
7 votes
Accepted

Series function not expanding an expression

V 12.1.1. Just add FullSimplify to help it ...
Nasser's user avatar
  • 146k
7 votes
Accepted

Solving symbolically a trascendental equation containing an exponential

It seems you have a Transcendental equation, so you will need to approximate, and that implies choices: Wich kind of approximation To which order Around what value? In this example ...
rhermans's user avatar
  • 36.8k

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