fix historical trigonometric functions for values of 0

Fixed how the historical trigonometric functions call
the underlying trigonometric functions.  This fixes a
number of issues where the function for values of 0.

Updated cal/regress.cal to test historical trigonometric functions
at the  0 value.
This commit is contained in:
Landon Curt Noll
2023-09-06 18:02:46 -07:00
parent c153ac08b9
commit b67e20881a
2 changed files with 32 additions and 58 deletions

View File

@@ -1995,9 +1995,8 @@ qacoth(NUMBER *q, NUMBER *epsilon)
NUMBER *
qversin(NUMBER *q, NUMBER *epsilon)
{
NUMBER *sin, *cos, *res;
NUMBER *versin;
long n;
NUMBER *res;
NUMBER *cos;
/*
* firewall
@@ -2014,18 +2013,10 @@ qversin(NUMBER *q, NUMBER *epsilon)
/*
* calculate trig function value
*/
n = -qilog2(epsilon);
qsincos(q, n + 2, &sin, &cos);
qfree(sin);
versin = qsub(&_qone_, cos);
cos = qcos(q, epsilon);
res = qsub(&_qone_, cos);
qfree(cos);
/*
* round value to nearest epsilon
*/
res = qmappr(versin, epsilon, 24);
qfree(versin);
/*
* return 1 - cos(x)
*/
@@ -2151,9 +2142,7 @@ qaversin(NUMBER *q, NUMBER *epsilon)
NUMBER *
qcoversin(NUMBER *q, NUMBER *epsilon)
{
NUMBER *sin, *cos, *res;
NUMBER *coversin;
long n;
NUMBER *sin, *res;
/*
* firewall
@@ -2170,20 +2159,10 @@ qcoversin(NUMBER *q, NUMBER *epsilon)
/*
* calculate trig function value
*/
n = -qilog2(epsilon);
if (qiszero(q) || n < 0)
return qlink(&_qzero_);
qsincos(q, n + 2, &sin, &cos);
qfree(cos);
coversin = qsub(&_qone_, sin);
sin = qsin(q, epsilon);
res = qsub(&_qone_, sin);
qfree(sin);
/*
* round value to nearest epsilon
*/
res = qmappr(coversin, epsilon, 24);
qfree(coversin);
/*
* return 1 - sin(x)
*/
@@ -2312,9 +2291,7 @@ qacoversin(NUMBER *q, NUMBER *epsilon)
NUMBER *
qvercos(NUMBER *q, NUMBER *epsilon)
{
NUMBER *sin, *cos, *res;
NUMBER *vercos;
long n;
NUMBER *cos, *res;
/*
* firewall
@@ -2331,18 +2308,10 @@ qvercos(NUMBER *q, NUMBER *epsilon)
/*
* calculate trig function value
*/
n = -qilog2(epsilon);
qsincos(q, n + 2, &sin, &cos);
qfree(sin);
vercos = qqadd(&_qone_, cos);
cos = qcos(q, epsilon);
res = qqadd(&_qone_, cos);
qfree(cos);
/*
* round value to nearest epsilon
*/
res = qmappr(vercos, epsilon, 24);
qfree(vercos);
/*
* return 1 + cos(x)
*/
@@ -2468,9 +2437,7 @@ qavercos(NUMBER *q, NUMBER *epsilon)
NUMBER *
qcovercos(NUMBER *q, NUMBER *epsilon)
{
NUMBER *sin, *cos, *res;
NUMBER *covercos;
long n;
NUMBER *sin, *res;
/*
* firewall
@@ -2487,20 +2454,10 @@ qcovercos(NUMBER *q, NUMBER *epsilon)
/*
* calculate trig function value
*/
n = -qilog2(epsilon);
if (qiszero(q) || n < 0)
return qlink(&_qzero_);
qsincos(q, n + 2, &sin, &cos);
qfree(cos);
covercos = qqadd(&_qone_, sin);
sin = qsin(q, epsilon);
res = qqadd(&_qone_, sin);
qfree(sin);
/*
* round value to nearest epsilon
*/
res = qmappr(covercos, epsilon, 24);
qfree(covercos);
/*
* return 1 + sin(x)
*/