Post Reply 
smallest |cos(x)| ?
10-07-2021, 12:14 PM
Post: #1
smallest |cos(x)| ?
Last month, I had proposed a better complex tan(z) for Free42

We considered HP71B math-rom implementation.
Quote:tan((x,y)) = ( sin(x)*cos(x)/d , sinh(y)*cosh(y)/d )
d is sinh(y)^2+cos(x)^2

Does d ever goes to zero ?
What is smallest cos(x)^2 ? (numerically)

To make cos(x)^2 small, x must be close to (2k+1) * pi/2
This is Python script for searching smallest |cos(x)|, for IEEE double

Code:
from gmpy2 import *
def eps(x, f=next_above):
    'find smallest |cos(x)|, x should be close to (2k+1)*pi/2'
    x2 = f(x); y = cos(x); y2 = cos(x2)
    if abs(y) < abs(y2): x,y, x2,y2, f = x2,y2, x,y, next_below
    while y*y2 > 0:
        x, x2 = x2, f(x2)
        y, y2 = y2, cos(x2)
    if abs(y) < abs(y2): return x, y
    return x2, y2

Looping (2k+1)*pi/2, for k = 1 to 1000000 step 2, k = 29 give tiniest |cos(x)|

>>> eps(const_pi()/2 * 29)
(mpfr('45.553093477052002'), mpfr('-6.1898063658835771e-19'))

Others had search for this too. From Accurate trigonometric functions for large arguments

>>> eps(mpfr('0x1.6ac5b262ca1ffp+849'))
(mpfr('5.3193726483265414e+255'), mpfr('-4.6871659242546277e-19'))

---

How to setup a Free42 program to search for this ?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
smallest |cos(x)| ? - Albert Chan - 10-07-2021 12:14 PM
RE: smallest |cos(x)| ? - Werner - 10-07-2021, 03:40 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-07-2021, 06:40 PM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 07:02 AM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 08:17 PM
RE: smallest |cos(x)| ? - ijabbott - 10-09-2021, 01:15 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 02:09 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 05:01 PM
RE: smallest |cos(x)| ? - EdS2 - 10-08-2021, 08:24 AM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 02:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 07:54 PM
RE: smallest |cos(x)| ? - Werner - 10-11-2021, 01:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 04:22 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-10-2021, 01:36 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 10:05 PM



User(s) browsing this thread: 1 Guest(s)