mini challenge: find the smallest cosine of an integer
|
10-21-2021, 09:44 AM
(This post was last modified: 10-21-2021 09:45 AM by EdS2.)
Post: #6
|
|||
|
|||
RE: mini challenge: find the smallest cosine of an integer
Thanks both, that's two very different approaches!
Peter, I like the simplicity and directness of your program. It's a good trick, I think, to look for n close to odd multiples of pi/2, and leave the cosines out of the loop. But there's something curious about your result. You get 24462 as the first n to have a cos less than 0.0001. And yet cos(24462) ≈ 0.0112. I suppose that adding pi some twenty thousand times might have caused a precision problem, but it seems a bit early for that to have happened. (In fact, it's about right: five digits to the left of the point and looking for small values in five digits to the right.) I think your program might do somewhat better by adding (pi-3) instead of pi. The Online Encylopedia of Integer Sequences is quite handy. For this investigation, these two entries are of some use: A004112 Numbers k where |cos(k)| (or |cosec(k)| or |cot(k)|) decreases monotonically to 0; also |tan(k)|, |sec(k)|, |sin(k)| increases. A096456 Numerators of convergents to Pi/2. From the first, we find a link to this list of record-holders for small cos, and from that we see: cos(24129) ≈ 0.002375894172 cos(24484) ≈ -0.002345749902 which I think must only be coincidentally close to your 24462. But perhaps more notably we see cos(40459) ≈ 0.000989256 which ought to be the first one less than 0.001 Albert, I am not at all surprised that continued fractions and convergents would come into a mathematical solution! But your method for dealing with trailing zeros to find answers for calculators with limited precision is very nice. I wonder if the OEIS would like to add a series for the numerators of pi/2 convergents where the denominators are odd. I note also that Free 42 shows its strengths again, quite wonderfully. (I note also that wolfram alpha online needs to be given integers with lots of trailing zeros, to compute cosine with adequate precision: giving it those large inputs in floating form returns zero for cosine.) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)