MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: solving a periodic function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114005] Re: solving a periodic function
  • From: Fred Klingener <gigabitbucket at BrockEng.com>
  • Date: Sat, 20 Nov 2010 06:14:36 -0500 (EST)
  • References: <ic34rb$5s7$1@smc.vnet.net>

On Nov 18, 7:06 am, Michael Stern <nycst... at gmail.com> wrote:
> I have a fun little puzzle that I solved via other methods, but would
> like to know if there might have been a more elegant method via
> Mathematica.
>
> I wanted to figure out the times during the day at which the hour hand
> and minute hand of a clock line up perfectly. I worked in terms of "unit
> time", in which the 12 hours of the clock are represented as ranging
> from 0 to 1. It is then easy to arrive at

To get a grip on what was going on (and maybe because DateList takes
seconds at the end to cast the answer in {HH,MM,SS}), I started by
calculating the hand positions in radians clockwise from 12 as a
function of seconds past midnight:

hourHandPosition[t_] := (2 Pi/12) t/( 60 60)

minuteHandPosition[t_] := (2 Pi/60) Mod[t/60, 60]

Plot[{hourHandPosition[t], minuteHandPosition[t]}, {t, 0, 12 60 60}]

Solve can handle this in the following form, getting times when hour
and minute hand are coincident, trying first for a solution in the
Rationals:

sols = Solve[hourHandPosition[t] == minuteHandPosition[t], t,
Rationals];

and it gives answers in the form 43200 (n - 1) / 11, {n, 0, 11}

The {HH, MM, SS} form can be constructed as follows (using now NSolve
to generate forms that fit DateList):

Drop[#, 3] & /@
  DateList /@ (t /.
     NSolve[hourHandPosition[t] == minuteHandPosition[t], t,
      Reals]) // TableForm

0	0	0.
1	5	27.2727
2	10	54.5455
3	16	21.8182
4	21	49.0909
5	27	16.3636
6	32	43.6364
7	38	10.9091
8	43	38.1818
9	49	5.45455
10	54	32.7273

The case where the hands are opposed is

Drop[#, 3] & /@
  DateList /@ (t /.
     NSolve[hourHandPosition[t] == minuteHandPosition[t] + Pi, t,
      Reals]) // TableForm

6	0	0.
7	5	27.2727
8	10	54.5455
9	16	21.8182
10	21	49.0909
11	27	16.3636
12	32	43.6364
13	38	10.9091
14	43	38.1818
15	49	5.45455
16	54	32.7273

, which would match your array if I Mod[]ed the hours and sorted.

>
> p.s. the solutions are evenly spaced at the following times
> {
>  {"12:32:43.6364"},
>  {"1:38:10.9091"},
>  {"2:43:38.1818"},
>  {"3:49:5.45455"},
>  {"4:54:32.7273"},
>  {"6:00:00."},
>  {"7:5:27.2727"},
>  {"8:10:54.5455"},
>  {"9:16:21.8182"},
>  {"10:21:49.0909"},
>  {"11:27:16.3636"}
>
> }

I frankly don't know why the ___Solves don't work on
unstraightness[t]==0, but maybe there's a clue in the fact that
something like this works:

Drop[#,3]&/@
DateList/@
(12 3600 t/.
Table[
FindRoot[
unstraightness[t]==0
,{t, j/12}
]
,{j,1,11}
]
)//TableForm

Fred Klingener


  • Prev by Date: Re: transform Matrix and List elements toreplacement Rules
  • Next by Date: Re: Mathematica 8: first impressions
  • Previous by thread: solving a periodic function
  • Next by thread: A beginner with a problem