Numerical approximation of Lamé curve perimeter for $n >2$

206 Views Asked by At

What is the numerical approximation for a Lamé Curve?

This question: Arc length of the squircle seems to be related, but doesn't provide an answer to the case where $a \neq b$, nor the limit that $n > 2$.

Mainly as I'm trying to figure out how the calculator here might work (i.e. it doesn't need to be exactly how they work, but should be a close enough approximation).

I've looked at What is the circumference (arc length) of $x^4 + x^2 + y^4 + y^2 = 2$? and tried to plot a superellipse then once I am sure the formula is correct I could get Wolfram Alpha to do the heavy lifting of integrating it, but the website seems to hang.

How can I approximate this?

2

There are 2 best solutions below

3
On BEST ANSWER

Here is precisely how the website's calculator works: $\newcommand{\peri}{\bbox[#E4E6E8,1px]{\textsf{Perimeter}}} \newcommand{\ans}{\bbox[#E4E6E8]{\textsf{anss}}}$

Discovery

If you View Source and search for the button label Calculate you will find <td align="center" rowspan="3"><input type="button" onclick="lame(this.form)" value="Calculate" style="margin-top:2px"><br>. Where is this lame(...) defined? After poking around I discovered that this is hidden in drop-ads.js. (Aside: is this file for advertisements? why is user-code here...?) enter image description here

The full code for lame(...) is

function lame(form) {
a=eval(form.a.value);b=eval(form.b.value);n=eval(form.n.value);
var d=eval(Math.PI/1000000);
var sum=eval(0);
var i=eval(0);
while (i<250000) {
sum=sum
    +Math.sin(i*Math.PI/500000+d)
    *Math.cos(i*Math.PI/500000+d)
    *Math.sqrt(a*a*Math.pow(Math.cos(i*Math.PI/500000+d),4/n)
               /Math.pow(Math.cos(i*Math.PI/500000+d),4)
    +b*b*Math.pow(Math.sin(i*Math.PI/500000+d),4/n)
               /Math.pow(Math.sin(i*Math.PI/500000+d),4));
i=i+1; 
}
function adj(x) {
if (x<3) {c=1;}
if (x>=3&&x<4) {c=1.00007;}
if (x>=4&&x<5) {c=1.0005;}
if (x>=5) {c=1.002;}
return c;}
var zum=eval(0);
var j=eval(0);
while (j<250000) {
zum=zum+Math.pow(1-Math.pow(j/250000+1/500000,n),(1/n));
j=j+1;}
ansss=4*a*b*zum/250000;
anss=adj(n)*sum*Math.PI*4/(250000*n);
form.quote.value="Area = "+Math.round(1000*ansss)/1000+"\n"+"Perimeter = "+Math.ceil(1000*anss)/1000;}

Translating from javascript to $math$

The relevant part of the output is given by Math.ceil(1000*anss)/1000;}, i.e. $\frac1{1000}{\lceil 1000\, \ans \rceil}$. This is a rounding up to 4 decimal points of anss=adj(n)*sum*Math.PI*4/(250000*n). What exactly though is anss?

adj(n) is a small fudge factor that was probably empirically determined. But the remaining bit, expressed in mathematical notation is as follows: set $N=250000$. Then \begin{align} &\ans =\\& \frac{4\pi}{Nn}\sum_{i=0}^{N-1}\sin\left(\tfrac{\pi}2\tfrac iN+\tfrac\pi{4N}\right)\cos\left(\tfrac{\pi}2\tfrac iN+\tfrac\pi{4N}\right) \sqrt{a^2\cos\left(\tfrac{\pi}2\tfrac iN+\tfrac\pi{4N}\right)^{\frac4n-4} + b^2\sin\left(\tfrac{\pi}2\tfrac iN+\tfrac\pi{4N}\right)^{\frac4n-4} } \end{align}

This is a Riemann sum (with tags $\pi i/2N + \pi/4N$ and uniform mesh size $\pi/2N$) for the integral \begin{align} &\frac{4\pi}n \int_0^1 \sin(\pi x/2) \cos(\pi x/2) \sqrt{a^2\sin^{4/n-4}(\pi x/2) + b^2\cos^{4/n-4}(\pi x/2)} dx \\&= 4\int_0^{\pi/2} \frac2n\sin t \cos t \sqrt{a^2 \sin^{4/n-4}t+b^2\cos^{4/n-4}t } \ dt \end{align} which is precisely the arc-length integral (using symmetry across both axes to absorb the $4$) $$ \int_0^{2\pi} |\gamma'(t)|\ dt, \quad \gamma(t) = \binom{a \lvert\sin t|^{2/n-1}\sin t}{b\lvert \cos t|^{2/n-1}\cos t},$$ where $\big|\binom{v_1}{v_2}\big|=\sqrt{v_1^2+v_2^2}$ denotes the Euclidean norm, and for $t\in[0,\pi/2]$, $$\gamma'(t) = \frac2n\sin t\cos t\binom{a \sin^{2/n-2}t}{-b\cos^{2/n-2}t} . $$

Visualisation of arclength integrand and Riemann sums

For $n>2$, the integrand near $t=0$ behaves like $t^{-1+2/n}$, from $\sin t\sim t$. Near $t=\pi/2$ the same happens using $\cos t \sim \pi/2-t$. This is not a bounded function (which explains why the tags cannot be the left or right endpoints of the mesh), so the Riemann sum (which approximates using a bounded step function) is likely not so accurate. See the behavior near $x=0,\pi/2$: enter image description here Intuitively the error from the tails should be like the bound from Speed of convergence of a Riemann sum, i.e. $$ \int_0^{2\pi} |\gamma'(t)|\ dt = \ans + O(N^{-2/n})$$ Which might explain why some sort of fudge-factor was used; even with the huge $N=250000$, $N^{-2/10} \approx 0.083,$ so this probably isn't enough for 4 decimal points.

4
On

If we have the parametrisation $$x=a \cos ^{\frac{2}{n}}(t) \qquad \text{and} \qquad y=b \sin ^{\frac{2}{n}}(t)$$ the arc length is given,before any simplification by $$L_n=4\int_{0}^{\frac \pi 2}\sqrt{\frac{4 a^2 \sin ^2(t) \cos ^{\frac{4}{n}-2}(t)+4 b^2 \cos ^2(t) \sin ^{\frac{4}{n}-2}(t)}{n^2}} \,dt$$ To simplify it; let $b^2=k a^2$ $$L_n=\frac {8a}n\int_{0}^{\frac \pi 2}\csc (t) \sec (t) \sqrt{\sin ^4(t) \cos^{\frac{4}{n}}(t)+k \cos ^4(t) \sin ^{\frac{4}{n}}(t)}\,dt$$

I do not think that, for $k \neq 1$, we could have closed forms for $K_n=\frac{n L_n}{8a}$.

For $k=1$, we have already very nasty expressions in terms of Meijer G-functions. So, I shall just give the numerical values for $\frac {L_n}a$ $$\left( \begin{array}{cc} n & \frac {L_n}a \\ 2 & 6.283185307 \\ 3 & 6.744993140 \\ 4 & 7.017697944 \\ 5 & 7.194443066 \\ 6 & 7.317726359 \\ 7 & 7.408459373 \\ 8 & 7.477973847 \\ 9 & 7.532910247 \\ 10 & 7.577407935 \\ 11 & 7.614177499 \\ 12 & 7.645065791 \\ 13 & 7.671372121 \\ 14 & 7.694034284 \\ 15 & 7.713742831 \\ 16 & 7.731014058 \\ 17 & 7.746238338 \\ 18 & 7.759713239 \\ 19 & 7.771666925 \\ 20 & 7.782275154 \end{array} \right)$$

For $n \gt 20$, I start having numerical problems.

Now, for $k\neq 1$, only numerical results. I shall give the results for a few values of $n$ and $k$

$$\left( \begin{array}{cccccc} n & k=0.50 & k=0.75 & k=1.00 & k=1.25 & k=1.50 \\ 2 & 5.40258 & 5.86985 & 6.28319 & 6.65917 & 7.00709 \\ 3 & 5.78312 & 6.29811 & 6.74499 & 7.14644 & 7.51462 \\ 4 & 6.00926 & 6.55128 & 7.01770 & 7.43438 & 7.81498 \\ 5 & 6.15621 & 6.71544 & 7.19444 & 7.62104 & 8.00982 \\ 6 & 6.25884 & 6.82996 & 7.31772 & 7.75125 & 8.14578 \\ 7 & 6.33436 & 6.91418 & 7.40837 & 7.84702 & 8.24580 \\ 8 & 6.39206 & 6.97851 & 7.47762 & 7.92019 & 8.32224 \\ 9 & 6.43724 & 7.02892 & 7.53191 & 7.97759 & 8.38223 \\ 10 & 6.47308 & 7.06899 & 7.57512 & 8.02331 & 8.43005 \\ 11 & 6.50154 & 7.10094 & 7.60967 & 8.05994 & 8.46842 \\ 12 & 6.52390 & 7.12622 & 7.63714 & 8.08915 & 8.49909 \\ 13 & 6.54100 & 7.14581 & 7.65858 & 8.11209 & 8.52328 \\ 14 & 6.55345 & 7.16041 & 7.67477 & 8.12956 & 8.54183 \\ 15 & 6.56171 & 7.17053 & 7.68629 & 8.14220 & 8.55540 \\ 16 & 6.56616 & 7.17662 & 7.69360 & 8.15049 & 8.56452 \\ 17 & 6.56713 & 7.17903 & 7.69710 & 8.15486 & 8.56962 \\ 18 & 6.56491 & 7.17811 & 7.69714 & 8.15568 & 8.57109 \\ 19 & 6.55978 & 7.17414 & 7.69404 & 8.15328 & 8.56927 \\ 20 & 6.55200 & 7.16740 & 7.68808 & 8.14795 & 8.56447 \end{array} \right)$$

Edit

To give you an idea of the complexity of the formulae for the simplest case $$L_4=2 a\, \int_{0}^{\frac \pi 2} \sqrt{\sin (t) \tan (t)+\cos (t) \cot (t)}\,dt$$ $$L_4=a\frac{\sqrt[4]{3}}{16 \sqrt{2} \pi ^{7/2} \Gamma \left(\frac{5}{4}\right)}\,G_{5,5}^{5,5}\left(1\left| \begin{array}{c} \frac{1}{3},\frac{2}{3},\frac{5}{6},1,\frac{4}{3} \\ \frac{1}{12},\frac{5}{12},\frac{7}{12},\frac{3}{4},\frac{13}{12} \end{array} \right.\right)$$