program klok;Output (in radians):
function minimum(theta : double; teken : integer) : double; begin minimum := 2 - 2*cos(theta+teken*2*pi/3-12*theta) + 2 - 2*cos(theta-teken*2*pi/3-720*theta); end;
function normal(theta : double) : double; var OK : boolean; v : double; begin v := theta; OK := false; while not OK do begin OK := (0 <= v) and (v < 2*pi); v := v - 2*pi; end; normal := v + 2*pi; end;
procedure brute_force(teken : integer); var k : integer; M,min,p,w : double; begin min := 8; w := 0; for k := 0 to 43200-1 do begin p := k*2*pi/43200; M := minimum(p,teken); if min > M then begin w := p; min := M; end; end; Writeln('Minimum =',min); Writeln('H =',w,' <',w+2*pi/43200); Writeln('M =',normal(12*w),' =',w+teken*2*pi/3); Writeln('S =',normal(720*w),' =',w-teken*2*pi/3); Writeln; end;
begin brute_force(+1); brute_force(-1); end.
Minimum = 1.32888417836478E-0004 H = 3.04690854166910E+0000 < 3.04705398577343E+0000 M = 5.14697596413128E+0000 = 5.14130364406230E+0000 S = 9.42477796078314E-0001 = 9.52513439275905E-0001Differentiation of the minimum functions, resulting in two equations: $$ 11\sin(11\theta-2\pi/3) + 719\sin(719\theta+2\pi/3) = 0 \\ 11\sin(11\theta+2\pi/3) + 719\sin(719\theta-2\pi/3) = 0 $$ Solving these with MAPLE, resulting in numerical refinement of the above:
Minimum = 1.32888417839328E-0004 H = 3.23627676551049E+0000 < 3.23642220961482E+0000 M = 1.13620934304831E+0000 = 1.14188166311729E+0000 S = 5.34070751109978E+0000 = 5.33067186790368E+0000
Digits := 50; fsolve(11*sin(11*theta-2*Pi/3)+719*sin(719*theta+2*Pi/3)=0,theta=3.0469..3.0470); fsolve(11*sin(11*theta+2*Pi/3)+719*sin(719*theta-2*Pi/3)=0,theta=3.2362..3.2364);Giving (Hours hand in radians):
3.0469223755142191756046177765785671073381009266460 3.2362629316653673013206689899804386610562378721043Don't know which one of the two is the best. It looks like the minima are exactly the same, namely:
0.0000339325557414428099817512048046050292710528311