# A fun and unusual absolute value example

Last week I wrote about some of the fun we were having with our new 3D printer:

https://mikesmathpage.wordpress.com/2014/03/12/learning-from-3d-printing/

The main example I used was our print of the shape for “Prince Rupert Cube” problem.  We’d learned how to make simple shapes like this one from playing around on Laura Taalman’s outrageously amazing 3D printing blog and from watching  a Wolfram 3D printing video (both linked in the blog post above).  Here’s a picture of a cube passing through another cube that is (or was!) exactly the same size:

I wanted the original blog post to include the Mathematica code we’d used to construct this Prince Rupert cube shape, but I just couldn’t find the right way to talk through it.    Since the main purpose of the post was to talk about some of the things we were learning, the details of the code seemed secondary anyway and I just left it out.

BUT, a few pieces of the code were actually pretty neat and writing about it was still kicking around in the back of my mind this week.  Then a new blog post on absolute value from Fawn Nguyen today brought it right back to the front of my mind!

http://fawnnguyen.com/2014/03/18/20140316.aspx

So, here’s one of the pieces of the code that was really neat.

In order to create the Prince Rupert cube in Mathematica  the first thing we needed to do was to draw a solid cube.   Honestly I wasn’t sure how to do that (in no way am I a Mathematica expert), but luckily drawing a cube was one of the examples in the Wolfram 3D printing video from post I linked above.  Lucky break for us!

Here’s how the Wolfram folks made a cube in just two lines.  The first line defines the cube, the second line makes the 3D plot:

cube[{x_, y_, z_}, r_] := (Abs[x] < r && Abs[y] < r && Abs[z] < r)

RegionPlot3D[(cube[{x, y, z}, 1], {x, -1.5, 1.5}, {y, -1.5, 1.5}, {z, -1.5, 1.5}, Mesh -> None, PlotPoints -> 50]

That code draws this nice little picture:

I thought the definition of the cube in the first line was neat example for math students because of the interesting (and unexpected to me at least) use of absolute value.  The function “cube[]” takes two inputs.  The first is a point (x,y,z) in 3 space, and the second is a distance r.  The function tells you that if the point (x,y,z) satisfies all  three of these conditions:

1. the absolute value of the x coordinate is less than the distance r,
2. the absolute value of the y coordinate is less than the distance r, and
3. the absolute value of the z coordinate is less than the distance,

then the point (x,y,z) is in the cube.  If any of the conditions are not satisfied, then it tells you that the point (x,y,z) is not in the cube.

I think this function naturally leads to a lot of interesting absolute value questions.  Such as:

Why do these three conditions define a cube in the first place?

Where is the center of this cube?

What are the coordinates for the corners of this cube?

What if I wanted to make a box whose width and height were equal, but whose length was twice as big, how would I do that?

How could i have defined this cube without using absolute value?

There are probably many other natural questions, too.  Definitely a fun and non-standard example for absolute value and one of the neat ways that 3D printing makes you think through some interesting math.