Fcube = @(x,y,z) 8*sqrt(x.^2+y.^2+z.^2).*(1-x).*(1-y).*(1-z)

delta = integral3(Fcube,0,1,0,1,0,1)

which comes out to about 0.6617

How could you simplify the problem if the unit squares were not touching each other? Say one unit square was had a corner at the origin, while the other had the corresponding corner at (3,4)?

]]>The integral you are computing is also known as a box integral. It gives the expectation of the distance between a fixed point in a hypercube and a point in the cube chosen at random. The case of two random points in the cube is a special case of the box integral and is also known as hypercube line picking.

The wolfram page on the topic lists numerical values for cubes from dimension one to eight. For the unit cube in three dimensions, the constant even has its own name: the Robbins constant. Its value is approximately 0.6617.

A 1976 paper by Anderssen and coauthors gives upper and lower bounds for the line picking constant for hypercubes of arbitrary dimension.

A quick search reveals that there are many other similar problems, such as cube triangle picking (average area of a triangle inside a hypercube), ball triangle picking, cube tetrahedron picking, octahedron tetrahedron picking etc. A recent paper by Borwein at al. even extends the classical theory of box integrals to fractals embedded in unit hypercubes!

Best

Pieterjan

You should create a new category “Riddles” or “Puzzles” (Better yet, both) and add this one in it.

]]>— Cleve ]]>

I managed to downloaded Cleve’s Laboratory, and tried C^5. It is found out that it is based on the newest version of Matlab. Even with my Matlab 2016b, it fails. After I fixed the errors cased by the string definition with “”, I see the window of C^5. But the “web” button does not work. A lot of errors are reported.

Maybe the compatibility of the program should be paid attention to.

–Wenjian Yu

]]>In regards to your article on quadruple precision, on which the comments are now closed, a much better approach is to represent an extended precision number as an unevaluated sum of two or more double precision numbers. This permits the use of existing fast code for double precision math, including vectorisation. A fairly comprehensive implementation (though somewhat sparsely documented!) is available here: https://github.com/tholden/DoubleDouble

Hope this is of some interest.

Best regards,

Tom ]]>