cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A308879 a(n) is the n-digit integer m that maximizes sin(m).

This page as a plain text file.
%I A308879 #53 May 23 2021 02:48:36
%S A308879 8,33,699,9929,51819,573204,4846147,37362253,288632526,9251925681,
%T A308879 81129397337,881156436695
%N A308879 a(n) is the n-digit integer m that maximizes sin(m).
%C A308879 a(n) is also the n-digit integer that minimizes the mean square error of the approximation sin(x+m) for cos(x) over [0, 2*Pi].
%C A308879 Naturally, sin(a(n)) is the best approximation to 1 for an n-digit integer argument. a(n) is the closest integer to an n-digit number of the form (4k+1)*Pi/2. Often used to compute an approximated rotation matrix with just a few number of characters of code, as in M = sin(x+{0,699,-699,0}). It is not guaranteed that each term in the sequence produces a better approximation than the previous one, although numerical evidence suggests so. It is therefore also not guaranteed to be a subsequence of A046959.
%e A308879 For n=3, a(3)=699 since no other 3-digit integer m makes sin(x+m) closer to cos(x) than m=699 does. For example, cos(4.5) = -0.210795799... and sin(4.5+699) = -0.215061112... and no other value of m will make the latter closer to the former.
%o A308879 (C)
%o A308879   double e = 1.0;
%o A308879   int b = 0, d=1, c=10;
%o A308879   int a[10]; // print A to see the results
%o A308879   for( int i=0; d<10; i++ )
%o A308879   {
%o A308879       double y = double(i*4+1)*PI/2.0;
%o A308879       double z = round(y);
%o A308879       double f = abs(z-y);
%o A308879       int    w = int(z);
%o A308879       if( w>=c ) { a[d]=b; c*=10; e=1.0; b=0; d++; }
%o A308879       if( f< e ) { e=f; b=w; }
%o A308879   }
%Y A308879 Cf. A046959.
%K A308879 nonn,base,more
%O A308879 1,1
%A A308879 _Inigo Quilez_, Feb 12 2020