# How can I calculate the perimeter of an equation-defined curve？

This is how the curve looks like:

img = ContourPlot[
1/x + 3/4 (((y - 1/Sqrt[3])/x)^2 + 1) Exp[
ArcTan[(y - 1/Sqrt[3])/x] - Pi/6] == 0,
{x, -3, 1},
{y, -(1/5), 4},
PlotPoints -> 70 ]


@xzczd comes up with a (kinka hacky!) solution, which extract the coordinates forming that curve:

Total[EuclideanDistance @@@
Partition[First@Cases[Normal@img,
Line[a_] :> a, Infinity], 2, 1]
]

(* 9.85614 *)


Is there any better way to do this?

-
"kinka hacky" is nice as it is more generic? –  chris Jul 27 '13 at 17:07
@chris maybe :D –  mm.Jang Jul 27 '13 at 17:17
@chris The fatal defect of this method is, it can't control the Precision. The result is always MachinePrecision, and the influence from PlotPoints is also big: PlotPoints -> 70 gives 9.92371, -> 200 gives 9.85703, -> 300 gives 9.84398, -> 400 gives 9.84211 –  xzczd Jul 28 '13 at 6:10
@xzczd sure; on the other hand its not always trivial to find a parametrization as you did below?? –  chris Jul 28 '13 at 7:57
@chris So I'm still looking forward to a general numeric solution though b.gatessucks had solved it analytically :) –  xzczd Jul 28 '13 at 9:44

You can get a parametric representation for your curve :

eqn = 1/x +  3/4 (((y - 1/Sqrt[3])/x)^2 + 1) Exp[ArcTan[(y - 1/Sqrt[3])/x] - Pi/6] ;

aux = First@Solve[(eqn /. {y -> 1/Sqrt[3] + t x}) == 0, x]
(* {x -> -((4 E^(\[Pi]/6 - ArcTan[t]))/(3 (1 + t^2)))} *)

solx = aux[[1, 2]]
(* -((4 E^(\[Pi]/6 - ArcTan[t]))/(3 (1 + t^2))) *)

soly = 1/Sqrt[3] + t x /. aux
(* 1/Sqrt[3] - (4 E^(\[Pi]/6 - ArcTan[t]) t)/(3 (1 + t^2)) *)

Plot[{solx, soly}, {t, -50, 50}, PlotRange -> All]


It looks like you get the curve with t in [-500,500] - you might need to improve on the interval.

ParametricPlot[{solx, soly}, {t, -500, 500}, PlotRange -> All, PlotPoints -> 200]


The last step is just the usual definition of arclength (thanks to @MichaelE2):

NIntegrate[ Sqrt[Simplify[(D[solx, t])^2 + (D[soly, t])^2 ]], {t, -Infinity, Infinity}]
(* 9.83926 *)

-
Very nice, but I think the limits should be {t, -Infinity, Infinity}, at least on the integral. –  Michael E2 Jul 27 '13 at 18:35
Oh, parametric representation… I should have not given up the effort for getting analytic solution so easily… –  xzczd Jul 28 '13 at 6:24
@MichaelE2 You're right, thanks. –  b.gatessucks Jul 28 '13 at 7:48