This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ahojnnes
Recipients ahojnnes, georg.brandl, mark.dickinson, rhettinger
Date 2010-01-24.13:46:11
SpamBayes Score 0.00035218368
Marked as misclassified No
Message-id <1264340773.12.0.694119702517.issue7770@psf.upfronthosting.co.za>
In-reply-to
Content
This is the version I would suggest and which is quite accurate unless the numbers get extremely large.

def sin(x):
    """Return the sine of x as measured in radians.

    >>> print sin(Decimal('0.5'))
    0.4794255386042030002732879352
    >>> print sin(0.5)
    0.479425538604
    >>> print sin(0.5+0j)
    (0.479425538604+0j)

    """
    x = x - pi()*int(x / pi())
    getcontext().prec += 2
    i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1
    while s != lasts:
        lasts = s
        i += 2
        fact *= i * (i-1)
        num *= x * x
        sign *= -1
        s += num / fact * sign
    getcontext().prec -= 2
    return +s
History
Date User Action Args
2010-01-24 13:46:13ahojnnessetrecipients: + ahojnnes, georg.brandl, rhettinger, mark.dickinson
2010-01-24 13:46:13ahojnnessetmessageid: <1264340773.12.0.694119702517.issue7770@psf.upfronthosting.co.za>
2010-01-24 13:46:11ahojnneslinkissue7770 messages
2010-01-24 13:46:11ahojnnescreate