Cube Point Picking

Author

Eric W. Weisstein
February 26, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/ComputationalGeometry/CubePointPicking.nb.

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

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

Initialization

<<Utilities`Simplify`

Mean Distance from Random Point to Center

Numeric

NIntegrate[Sqrt[x^2+y^2+z^2],{x,-1/2,1/2},{y,-1/2,1/2},{z,-1/2,1/2}]

8NIntegrate[Sqrt[x^2+y^2+z^2],{x,0,1/2},{y,0,1/2},{z,0,1/2}]

Exact

8Integrate[Sqrt[x^2+y^2+z^2],{x,0,1/2},{y,0,1/2},{z,0,1/2}]

(1/144) (18 (Sqrt[3])-3 π+24 ArcCsch[(Sqrt[2])]-2 Log[4096]+48 Log[1+(Sqrt[3])])//LogExpand//Simplify//LogExpand//Expand

N[%,10]

Mean Distance from Random Point to Corner

Numeric

NIntegrate[Sqrt[(x-1/2)^2+(y-1/2)^2+(z-1/2)^2],{x,-1/2,1/2},{y,-1/2,1/2},{z,-1/2,1/2}]

NIntegrate[Sqrt[x^2+y^2+z^2],{x,0,1},{y,0,1},{z,0,1},WorkingPrecision->10]

v5.2

Integrate[Sqrt[x^2+y^2+z^2],{x,0,1},{y,0,1},{z,0,1}]

(1/144) (-20+36 (Sqrt[3])-3 π+48 ArcCsch[(Sqrt[2])]-6 Log[4]-4 Log[64]+96 Log[1+(Sqrt[3])])//N

...wrong...

Integrals one at a time

Integrate[Integrate[Integrate[Sqrt[x^2+y^2+z^2],{z,0,1},GenerateConditions->False],{y,0,1},GenerateConditions->False],{x,0,1}]

N[%]

(1/72) (18 (Sqrt[3])-3 π+24 ArcSinh[(1/(Sqrt[2]))]-2 Log[4096]+48 Log[1+(Sqrt[3])])//TrigToExp//LogExpand//FullSimplify

-(π/24)+(1/4) ((Sqrt[3])+2Log[2+ (Sqrt[3])])//Expand

N[%]

v6

(i=Integrate[Sqrt[x^2+y^2+z^2],{x,0,1},{y,0,1},{z,0,1}])//Timing

(1/72) (18 (Sqrt[3])-3 π+24 ArcCsch[(Sqrt[2])]-2 Log[4096]+48 Log[1+(Sqrt[3])])//LogExpand//Simplify

N[%,10]

Mean Distance from Center to a Face

Numerical

NIntegrate[(Sqrt[(x^2)+(y^2)+(1/4)]),{x,-1/2,1/2},{y,-1/2,1/2}]

8NIntegrate[(Sqrt[(x^2)+(y^2)+(1/4)]),{y,0,1/2},{x,0,y}]

Mean[Sqrt[#.#+1/4]&/@(Table[Random[],{10^6},{2}]/2)]//Timing

Analytical

Integrate[(Sqrt[(x^2)+(y^2)+(1/4)]),{x,-1/2,1/2},{y,-1/2,1/2}]

FullSimplify[TrigToExp[%]]

Log[2+(Sqrt[3]),18817+10864 (Sqrt[3])]//N

Expand[(1/72) (-2 π+3 (4 (Sqrt[3])+8Log[2+(Sqrt[3])]))]

N[(1/72) (-2 π+3 (4 (Sqrt[3])+8Log[2+(Sqrt[3])])),20]