Your age as a continued fraction

Your age as a continued fraction is given by the function CFage. It computes the difference between a birth date and the current time. Then this period is measured in years and transformed into a continued fraction. One can also give dates as integer lists right down to minutes and seconds. The number of terms is optional.

CFage[birthdate:(_String|_DateObject|{_Integer,___}),terms_:11]:=
    Dynamic[
       Fold[#2+1/#1&,
         MapAt[
          ToString,
              Take[
                 ContinuedFraction[
                   DateDifference[birthdate,Now]/Quantity@"yr"],
              UpTo[terms]]/.{a__,b_,1}:>{a,b+1}//Reverse,1]]//OutputForm,
    UpdateInterval->.5]

Let’s take Einstein birthday as an example:

The function CFage will work with such DateObject or it’s String analog:

3245terhgrerw4q3tegra.gif

8 Likes

Hi Bill, funny clock. One comment about truncation: if there’s uncertainty on either of the dates, this sets a limit for the number of meaningful recursions. For Example, I don’t know the exact time of Einstein’s birthday to the hour, minute, second, etc.

I also don’t know if terms=11 is expected to lead to truncation at the precision of ~1day. That would be a desirable default for birthdays. A more tightly constrained function would replace the “terms” variable with a variable in terms of a precision goal.

A slight adaptation of this algorithm could also be used to compare experimental data, where the precision is well known. How far apart are two atomic spectral lines, and can you write that number in a continued fraction? Too impractical for me; none the less, some will find it interesting.