Context: The "Classic" riddle here: https://fivethirtyeight.com/features/can-you-crack-the-safe/
Input code. There's quite a bit going on here, but the asterisks mark the most important lines. B C D
are angles in radians, b c d
are the corresponding complex coordinates on the unit circle (A=0
and a=1
), W X Y Z
are areas in square units. I've left out declarations and some definitions/equations to focus on the main issue.
**** tri(l,m,n) = abs((I/4)*(l*conjugate(m) - m*conjugate(l) + m*conjugate(n) \
- n*conjugate(m) + n*conjugate(l) - l*conjugate(n)))
**** aslice(r,s,t,u,v) = (1/2)*(s-r) - tri(t,u,0) + tri(t,u,v)
**** eq5 = W == aslice(A,B,a,b,p)
eq6 = X == aslice(B,C,b,c,p)
eq7 = Y == aslice(C,D,c,d,p)
eq8 = Z == aslice(D,2*pi,d,a,p)
eq9 = X == 2*W
eq10 = Y == 3*W
eq11 = Z == 4*W
Out = solve([$eqs], $vars, solution_dict=True)
**** print(CC(W.subs(Out[0])))
**** print(CC(aslice(A,B,a,b,p).subs(Out[0])))
**** print(CC(((1/2)*(B-A) + tri(a,b,p) - tri(a,b,0)).subs(Out[0])))
And the output is this:
0.314159265358979
0.132523633357639
0.132523633357639
Now, based on eq5
, the three outputs at the bottom ought to be equal. But the solved-for W
(first line) appears to be the area of the circular sector, where aslice()
(second line) and its definition (third line) correctly output the area of the actual slice (based on the solved-for variables).
Unfortunately, this means the program is comparing the wrong things in eq6, eq7, eq8
, so the solution is not much of a solution at all. I'm not sure what could be causing this issue, though. Any thoughts?