4
$\begingroup$

How can I compute the average distance from the base of a rectangular pyramid to its apex? For example, if the base of the pyramid is 30 feet by 8 feet, and the height of the pyramid is 12 feet, then what is the average distance from the base to the apex, meaning if we measured the distance from every point in the base to the apex, what would be the average distance? Assume that the pyramid is symmetric.

I had originally thought there would be some simple formula for this computation, but mathematicians have informed me it is a complex integral. How can I set that up in Mathematica?

$\endgroup$
4
  • $\begingroup$ Is it easier for square pyramids? What does the integral look like in the plane w/ triangles? $\endgroup$ Oct 29, 2014 at 16:43
  • 3
    $\begingroup$ NIntegrate[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, -15, 15}, {y, -4, 4}]/(30 8) $\endgroup$
    – user484
    Oct 29, 2014 at 16:44
  • $\begingroup$ @alancalvitti Since a square pyramid is symmetric across the diagonal, the answer will be the same for a half pyramid divided that way. $\endgroup$ Oct 29, 2014 at 20:29
  • $\begingroup$ @TylerDurden, by the 2nd part of my q, I meant, what does the integral look like of the average distance from the base of a triangle to the apex, in the plane. $\endgroup$ Oct 29, 2014 at 20:41

2 Answers 2

4
$\begingroup$
dist = UniformDistribution[{{-15, 15}, {-4, 4}}];
avgdist = NExpectation[Norm[{x, y, 12}], {x, y} \[Distributed] dist]

14.8171

You can also use

 NExpectation[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, y} \[Distributed] dist] 

to get the same result.

Update: You can obtain the average distance symbolically using

Integrate[Sqrt[c^2 + x^2 + y^2] Boole[-a < x < a && -b < y < b], 
          {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, 
          Assumptions -> {a > 0, b > 0, c > 0}]/(4 a b)

enter image description here

$\endgroup$
2
$\begingroup$
DensityPlot[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, -15, 15}, {y, -4, 4}, 
            AspectRatio -> Automatic]

Mathematica graphics

NIntegrate[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, -15, 15}, {y, -4, 4}]/(30 8)

(* 14.8171 *)

{a, b, c, d, e} = {{0, 0, 12}, {-15, -4, 0}, {-15, 4, 0}, {15, 4, 0}, {15, -4, 0}};
coords = {{b, c, d, e}, {a, b, c}, {a, c, d}, {a, d, e}, {a, e, b}};
text = DensityPlot[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, -15, 15}, {y, -4, 4}, 
                  AspectRatio -> Automatic, Frame -> None,  PlotRangePadding -> None]; 
Graphics3D[{Texture[Rasterize@text], 
  Polygon[coords[[1]], VertexTextureCoordinates -> {{1, 1}, {1, 0}, {0, 0}, {0, 1}}], 
  FaceForm[Opacity[.3]], Polygon /@ Rest@coords}, Lighting -> "Neutral"]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.