Rényi's Parking Constant

Author

Eric W. Weisstein
December 17, 2008

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Constants/RenyisParkingConstants.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/RenyisParkingConstants.html.

©2008 Wolfram Research, Inc. except for portions noted otherwise

Code

IntervalInsert[i_]:=Module[
{
ins,new,
s=Select[List@@i,-Subtract@@#>1&]
},
If[s=={},
i,
ins=s[[n=Random[Integer,{1,Length[s]}]]];
new={ins[[1]]{1,1}+{0,#},{ins[[1]]+#+1,ins[[2]]}}&[Random[Real,{0,-(1+Subtract@@ins)}]];IntervalUnion[Interval@@Complement[List@@i,{s[[n]]}],Interval@@new]
]
]

Figure

<<Combinatorica`

ParkingPlot[n_,opts___]:=Module[
{
l,i,
w=.2,h=.1,x=.1,
cars
},
l=First/@Partition[Take[Flatten[i=List@@FixedPoint[IntervalInsert,Interval[{0,n}]]],{2,-2}],2];
cars={
Black,Rectangle[{#+x,-h},{#+x+w,0}],Rectangle[{#+x,.4},{#+x+w,.4+h}],
Rectangle[{1+#-x,-h},{1+#-x-w,0}],Rectangle[{1+#-x,.4},{1+#-x-w,.4+h}],
Hue[Random[]],Rectangle[{#,0},{1+#,.4}]
}&/@l[[RandomPermutation[Length[l]]]];
MapIndexed[Show[Graphics[{
(*road*)
GrayLevel[.8],Rectangle[{0,-.4},{n,3.5}],
(*stripe*)
Yellow,Table[Rectangle[{i,1.5},{i+.3,1.6}],{i,0,n,.5}],
(*white lines*)
White,
Rectangle[{0,.5},{n,.55}],
Rectangle[{0,2.7},{n,2.75}],
(*curb*)
GrayLevel[.4],
Rectangle[{0,-.4},{n,-.2}],
Rectangle[{0,3.3},{n,3.5}],
(*text*)
Text[ToString[Round[100(#2[[1]]-1)/n]]<>"%",{n/2,4},
TextStyle->{FontFamily->"Times"}],
(*cars*)
#}],
opts,AspectRatio->Automatic,PlotRange->{{0,n},{-.4,4.5}}]&,
FoldList[Join,{},cars]
]
]

movie=ParkingPlot[20,ImageSize->500]

Animation

<<Utilities`GIF`

Export[gifs<>"renyi.gif",movie,ConversionOptions->{"AnimationDisplayTime"->1}]//Timing

Fraction

With[{n=1000},
r=FixedPoint[IntervalInsert,Interval[{0,n}]];
1+Plus@@(Subtract@@@List@@r)/n
]//Timing

Integral

(∫_0^x)((1-exp(-y))/y)dy

V5

int=Integrate[(1-Exp[-y])/y,{y,0,x},Assumptions->x>0]

Integrate[Exp[-2 int],{x,0,Infinity}]

V7

int=Integrate[(1-Exp[-y])/y,{y,0,x},Assumptions->x>0]

Integrate[Exp[-2 int],{x,0,Infinity}]

Integrate[Exp[-2 int],x]

V12

int=Integrate[(1-Exp[-y])/y,{y,0,x},Assumptions->x>0]

FullSimplify[%,x>0]

Integrate[Exp[-2 int],{x,0,Infinity}]

Numeric

NIntegrate[Exp[-2 int],{x,0,Infinity},WorkingPrecision->50,MaxRecursion->10]

exp(-2 ℽ) (∫_0^∞)((exp(2 (ExpIntegralEi[-x])))/(x^2))dx

V12

Exp[-2EulerGamma]Integrate[((Exp[2ExpIntegralEi[-x]])/(x^2)),{x,0,∞}]

Numeric

Exp[-2EulerGamma]NIntegrate[((Exp[2ExpIntegralEi[-x]])/(x^2)),{x,0,∞}]

Series

Series[(((E^(-2EulerGamma))(E^(2 ExpIntegralEi[-x])))/(x^2)),{x,0,10}]

SeriesCoefficient[(((E^(-2EulerGamma))(E^(2 ExpIntegralEi[-x])))/(x^2)),{x,0,n}]