Optimizing Volume of a Box
Author: Elisha Petersen

A nice visualization of the maxize the volume of a box problem by Elisha Petersen. Pick the dimension of the sheet of metal to start with (a by b). Then slide the value of 's' which is the size of the square cut out of the corners. FInd the value that maximizes the Volume of the box.

s = 2.5 (slider from 0 to 5, step 0.1)
a = 11.8 (slider from 0 to 20, step 0.1)
b = 6.2 (slider from 0 to 20, step 0.1)
P, c, d, e, f, g, h, i, j, k, l, m, n = Polygon((s, 0), (a - s, 0), (a - s, s), (a, s), (a, b - s), (a - s, b - s), (a - s, b), (s, b), (s, b - s), (0, b - s), (0, s), (s, s))
V: s * (a - 2 s) * (b - 2 s)
T2: "Volume=" + V
Volume: (s, V / 10)
P1 = (4.266666666666666, -5.833333333333329)
P2 = Point(P1, Vector[Vector[(0, 0), (a - 2 s, 0)]])
P3 = Point(P1, Vector[Vector[(0, 0), (-1, -1) / sqrt(2) * (b - 2 s)]])
P4 = Point(P1, Vector[Vector[(0, 0), (0, s)]])
Q, p, q, r, t = Polygon(P1, P2, P2 + Vector[P1, P4], P4)
R, p1_1, p4_1, q, p3 = Polygon(P1, P4, P3 + Vector[P1, P4], P3)
S, p1, p2, a_1, p3_1 = Polygon(P1, P2, P2 + Vector[P1, P3], P3)
T, p3_2, b_1, c_1, d_1 = Polygon(P3, P3 + Vector[P1, P2], P3 + Vector[P1, P2] + Vector[P1, P4], P3 + Vector[P1, P4])
U, e_1, f_1, g_1, p2_1 = Polygon(P3 + Vector[P1, P2], P3 + Vector[P1, P2] + Vector[P1, P4], P2 + Vector[P1, P4], P2)
B = Intersect(j, k)
C = Intersect(g, h)
a1 = Segment(B, C)
D = Intersect(d, e)
b1 = Segment(C, D)
E = Intersect(m, n)
c1 = Segment(D, E)
d1 = Segment(E, B)