login
A308879
a(n) is the n-digit integer m that maximizes sin(m).
0
8, 33, 699, 9929, 51819, 573204, 4846147, 37362253, 288632526, 9251925681, 81129397337, 881156436695
OFFSET
1,1
COMMENTS
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].
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.
EXAMPLE
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.
PROG
(C)
double e = 1.0;
int b = 0, d=1, c=10;
int a[10]; // print A to see the results
for( int i=0; d<10; i++ )
{
double y = double(i*4+1)*PI/2.0;
double z = round(y);
double f = abs(z-y);
int w = int(z);
if( w>=c ) { a[d]=b; c*=10; e=1.0; b=0; d++; }
if( f< e ) { e=f; b=w; }
}
CROSSREFS
Cf. A046959.
Sequence in context: A069509 A204191 A041118 * A297904 A298498 A091720
KEYWORD
nonn,base,more
AUTHOR
Inigo Quilez, Feb 12 2020
STATUS
approved