update major trigonometric help files and regression tests

Improved help files for sin, cos, tan, cot, sec, csc.  In case
of tan, cot, sec, csc corrected help file was corrected to
indicate that complex arguments are allowed.  This was a help
file oversight from long ago when those trigonometric functions

Expanded the calc regression test suite test 34dd to test various
real and complex values for sin, cos, tan, cot, sec, csc.
This commit is contained in:
Landon Curt Noll
2023-09-10 16:33:31 -07:00
parent 78d536140f
commit a722b5cca7
8 changed files with 214 additions and 8 deletions

View File

@@ -176,6 +176,15 @@ The following are the changes from calc version 2.14.3.5 to date:
number generator in place of the additive 55 generator for a number generator in place of the additive 55 generator for a
while now. while now.
Improved help files for sin, cos, tan, cot, sec, csc. In case
of tan, cot, sec, csc corrected help file was corrected to
indicate that complex arguments are allowed. This was a help
file oversight from long ago when those trigonometric functions
were expanded to include complex arguments.
Expanded the calc regression test suite test 34dd to test various
real and complex values for sin, cos, tan, cot, sec, csc.
The following are the changes from calc version 2.14.3.4 to 2.14.3.5: The following are the changes from calc version 2.14.3.4 to 2.14.3.5:

View File

@@ -2959,6 +2959,14 @@ define test_2600()
local tnum; /* test number */ local tnum; /* test number */
local i; local i;
/*
* NOTE: The various functions test in this are often accurate to
* eps (epsilon) or better, which defaults to about 20 decimal
* digits. We test a number of functions to 10 digits using
* round(..., 10) because we do not want to have to put lots
* of digits in the verify identities.
*/
print '2600: Beginning extensive numeric function test'; print '2600: Beginning extensive numeric function test';
i = config("sqrt"); i = config("sqrt");
@@ -3529,6 +3537,7 @@ print '049: parsed test_det()';
/* /*
* test 050-051: define test_trig and read test3400.trig for test 34dd * test 050-051: define test_trig and read test3400.trig for test 34dd
* *
*
* This function tests common trig functions. * This function tests common trig functions.
*/ */
read -once "test3400.trig"; read -once "test3400.trig";
@@ -3540,6 +3549,14 @@ define test_trig()
local pi; /* pi to 1e-20 precision */ local pi; /* pi to 1e-20 precision */
local i; local i;
/*
* NOTE: The various functions test in this are often accurate to
* eps (epsilon) or better, which defaults to about 20 decimal
* digits. We test a number of functions to 10 digits using
* round(..., 10) because we do not want to have to put lots
* of digits in the verify identities.
*/
print '3400: Beginning test_trig'; print '3400: Beginning test_trig';
/* test 3401-3407 */ /* test 3401-3407 */
@@ -3550,8 +3567,146 @@ define test_trig()
/* test trigonometric sine */ /* test trigonometric sine */
vrfy(sin(0, 1e-10) == 0, vrfy(sin(0, 1e-10) == 0,
strcat(str(tnum++), ': sin(0, 1e-10) == 0')); strcat(str(tnum++), ': sin(0, 1e-10) == 0'));
vrfy(round(sin(1, 1e-10), 10) == 0.8414709848,
strcat(str(tnum++),
': round(sin(1, 1e-10), 10) == 0.8414709848'));
vrfy(round(sin(2 + 3i, 1e-10), 10) == 9.1544991469-4.16890696i,
strcat(str(tnum++),
': round(sin(2 + 3i, 1e-10), 10) == 9.1544991469-4.16890696i'));
vrfy(sin(pi/6, 1e-10) == 0.5, vrfy(sin(pi/6, 1e-10) == 0.5,
strcat(str(tnum++), ': sin(pi/6, 1e-10) == 0.5')); strcat(str(tnum++), ': sin(pi/6, 1e-10) == 0.5'));
vrfy(sin(pi/2, 1e-10) == 1,
strcat(str(tnum++), ': sin(pi/2, 1e-10) == 1'));
vrfy(sin(pi, 1e-10) == 0,
strcat(str(tnum++), ': sin(pi, 1e-10) == 1'));
vrfy(round(sin(1/2, 1e-10), 10) == 0.4794255386,
strcat(str(tnum++),
': round(sin(1/2, 1e-10), 10) == 0.4794255386'));
vrfy(round(sin(5/7, 1e-10), 10) == 0.6550778972,
strcat(str(tnum++),
': round(sin(5/7, 1e-10), 10) == 0.6550778972'));
vrfy(round(sin(42/7, 1e-10), 10) == -0.2794154982,
strcat(str(tnum++),
': round(sin(42/7, 1e-10), 10) == -0.2794154982'));
/* test trigonometric cosine */
vrfy(cos(0, 1e-10) == 1,
strcat(str(tnum++), ': cos(0, 1e-10) == 1'));
vrfy(round(cos(1, 1e-10), 10) == 0.5403023059,
strcat(str(tnum++),
': round(cos(0.2, 1e-10), 10) == 0.5403023059'));
vrfy(cos(pi/3, 1e-10) == 0.5,
strcat(str(tnum++), ': cos(pi/3, 1e-10) == 0.5'));
vrfy(cos(pi/2, 1e-10) == 0,
strcat(str(tnum++), ': cos(pi/2, 1e-10) == 0'));
vrfy(cos(pi, 1e-10) == -1,
strcat(str(tnum++), ': cos(pi, 1e-10) == -1'));
vrfy(round(cos(2 + 3i, 1e-10), 10) == -4.189625691-9.1092278938i,
strcat(str(tnum++),
': round(cos(2 + 3i, 1e-10), 10) == -4.189625691-9.1092278938i'));
vrfy(round(cos(1/2, 1e-10), 10) == 0.8775825619,
strcat(str(tnum++),
': round(cos(1/2, 1e-10), 10) == 0.8775825619'));
vrfy(round(cos(5/7, 1e-10), 10) == 0.7555613467,
strcat(str(tnum++),
': round(cos(5/7, 1e-10), 10) == 0.7555613467'));
vrfy(round(cos(42/7, 1e-10), 10) == 0.9601702866,
strcat(str(tnum++),
': round(cos(42/7, 1e-10), 10) == 0.9601702866'));
/* test trigonometric tangent */
vrfy(tan(0, 1e-10) == 0,
strcat(str(tnum++), ': tan(0, 1e-10) == 0'));
vrfy(round(tan(1, 1e-10), 10) == 1.5574077247,
strcat(str(tnum++),
': round(tan(0.2, 1e-10), 10) == 1.5574077247'));
vrfy(round(tan(pi/6, 1e-10), 10) == 0.5773502692,
strcat(str(tnum++),
': round(tan(pi/6, 1e-10), 10) == 0.5773502692'));
vrfy(round(tan(pi/3, 1e-10), 10) == 1.7320508076,
strcat(str(tnum++),
': round(tan(pi/3, 1e-10), 10) == 1.7320508076'));
vrfy(tan(pi, 1e-10) == 0,
strcat(str(tnum++), ': tan(pi, 1e-10) == 0'));
vrfy(round(tan(1/2, 1e-10), 10) == 0.5463024898,
strcat(str(tnum++),
': round(tan(1/2, 1e-10), 10) == 0.5463024898'));
vrfy(round(tan(5/7, 1e-10), 10) == 0.8670082185,
strcat(str(tnum++),
': round(tan(5/7, 1e-10), 10) == 0.8670082185'));
vrfy(round(tan(42/7, 1e-10), 10) == -0.2910061914,
strcat(str(tnum++),
': round(tan(42/7, 1e-10), 10) == -0.2910061914'));
/* test trigonometric cotangent */
vrfy(round(cot(1, 1e-10), 10) == 0.6420926159,
strcat(str(tnum++),
': round(cot(0.2, 1e-10), 10) == 0.6420926159'));
vrfy(round(cot(pi/12, 1e-10), 10) == 3.7320508076,
strcat(str(tnum++),
': round(cot(pi/12, 1e-10), 10) == 3.7320508076'));
vrfy(round(cot(pi/6, 1e-10), 10) == 1.7320508076,
strcat(str(tnum++),
': round(cot(pi/6, 1e-10), 10) == 1.7320508076'));
vrfy(round(cot(pi/3, 1e-10), 10) == 0.5773502692,
strcat(str(tnum++),
': round(cot(pi/3, 1e-10), 10) == 0.5773502692'));
vrfy(cot(pi/2, 1e-10) == 0,
strcat(str(tnum++), ': cot(pi/2, 1e-10) == 0'));
vrfy(round(cot(1/2, 1e-10), 10) == 1.8304877217,
strcat(str(tnum++),
': round(cot(1/2, 1e-10), 10) == 1.8304877217'));
vrfy(round(cot(5/7, 1e-10), 10) == 1.1533916042,
strcat(str(tnum++),
': round(cot(5/7, 1e-10), 10) == 1.1533916042'));
vrfy(round(cot(42/7, 1e-10), 10) == -3.4363530042,
strcat(str(tnum++),
': round(cot(42/7, 1e-10), 10) == -3.4363530042'));
/* test trigonometric cosecant */
vrfy(round(csc(1, 1e-10), 10) == 1.1883951058,
strcat(str(tnum++),
': round(csc(0.2, 1e-10), 10) == 1.1883951058'));
vrfy(csc(pi/6, 1e-10) == 2,
strcat(str(tnum++), ': csc(pi/6, 1e-10) == 2'));
vrfy(round(csc(pi/3, 1e-10), 10) == 1.1547005384,
strcat(str(tnum++),
': round(csc(pi/3, 1e-10), 10) == 1.1547005384'));
vrfy(round(csc(4*pi/3, 1e-10), 10) == -1.1547005384,
strcat(str(tnum++),
': round(csc(4*pi/3, 1e-10), 10) == -1.1547005384'));
vrfy(round(csc(1/2, 1e-10), 10) == 2.0858296429,
strcat(str(tnum++),
': round(csc(1/2, 1e-10), 10) == 2.0858296429'));
vrfy(round(csc(5/7, 1e-10), 10) == 1.5265360109,
strcat(str(tnum++),
': round(csc(5/7, 1e-10), 10) == 1.5265360109'));
vrfy(round(csc(42/7, 1e-10), 10) == -3.5788995473,
strcat(str(tnum++),
': round(csc(42/7, 1e-10), 10) == -3.5788995473'));
/* test trigonometric secant */
vrfy(sec(0, 1e-10) == 1,
strcat(str(tnum++), ': sec(0, 1e-10) == 1'));
vrfy(round(sec(1, 1e-10), 10) == 1.8508157177,
strcat(str(tnum++),
': round(sec(0.2, 1e-10), 10) == 1.8508157177'));
vrfy(round(sec(pi/6, 1e-10), 10) == 1.1547005384,
strcat(str(tnum++),
': round(sec(pi/6, 1e-10), 10) == 1.1547005384'));
vrfy(sec(pi/3, 1e-10) == 2,
strcat(str(tnum++), ': sec(pi/2, 1e-10) == 2'));
vrfy(sec(pi, 1e-10) == -1,
strcat(str(tnum++), ': sec(pi, 1e-10) == -1'));
vrfy(round(sec(1/2, 1e-10), 10) == 1.1394939273,
strcat(str(tnum++),
': round(sec(1/2, 1e-10), 10) == 1.1394939273'));
vrfy(round(sec(5/7, 1e-10), 10) == 1.3235192673,
strcat(str(tnum++),
': round(sec(5/7, 1e-10), 10) == 1.3235192673'));
vrfy(round(sec(42/7, 1e-10), 10) == 1.0414819266,
strcat(str(tnum++),
': round(sec(42/7, 1e-10), 10) == 1.0414819266'));
/* test versed trigonometric sine */ /* test versed trigonometric sine */
vrfy(versin(0, 1e-10) == 0, vrfy(versin(0, 1e-10) == 0,

View File

@@ -25,6 +25,9 @@ EXAMPLE
; print cos(pi/3, 1e-10), cos(pi/2, 1e-10), cos(pi, 1e-10) ; print cos(pi/3, 1e-10), cos(pi/2, 1e-10), cos(pi, 1e-10)
0.5 0 -1 0.5 0 -1
; print cos(1/2), cos(5/7), cos(42/7)
0.87758256189037271612 0.75556134670069659847 0.96017028665036602055
LIMITS LIMITS
0 < eps < 1 0 < eps < 1

View File

@@ -5,7 +5,7 @@ SYNOPSIS
cot(x [,eps]) cot(x [,eps])
TYPES TYPES
x nonzero real x number (real or complex)
eps 0 < real < 1, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -18,12 +18,21 @@ EXAMPLE
; print cot(1, 1e-5), cot(1, 1e-10), cot(1, 1e-15), cot(1, 1e-20) ; print cot(1, 1e-5), cot(1, 1e-10), cot(1, 1e-15), cot(1, 1e-20)
0.64209 0.6420926159 0.642092615934331 0.64209261593433070301 0.64209 0.6420926159 0.642092615934331 0.64209261593433070301
; print cot(2 + 3i, 1e-5), cot(2 + 3i, 1e-10)
~-0.00373977357605613583-~0.99675796378381737782i ~-0.00373971037383300017-~0.99675779657435500069i
; pi = pi(1e-20)
; print cot(pi/12, 1e-10), cot(pi/6, 1e-10), cot(pi/3, 1e-10), cot(pi/2, 1e-10)
3.7320508076 1.7320508076 0.5773502692 0
; print cot(1/2), cot(5/7), cot(42/7)
1.83048772171245191927 1.15339160419695060142 -3.43635300418012783207
LIMITS LIMITS
0 < eps < 1 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qcot(NUMBER *x, NUMBER *eps) NUMBER *qcot(NUMBER *x, NUMBER *eps)
COMPLEX *c_acot(COMPLEX *c, NUMBER *eps);
SEE ALSO SEE ALSO
sin, cos, tan, sec, csc sin, cos, tan, sec, csc

View File

@@ -5,7 +5,7 @@ SYNOPSIS
csc(x [,eps]) csc(x [,eps])
TYPES TYPES
x real x number (real or complex)
eps 0 < real < 1, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -18,6 +18,16 @@ EXAMPLE
; print csc(1, 1e-5), csc(1, 1e-10), csc(1, 1e-15), csc(1, 1e-20) ; print csc(1, 1e-5), csc(1, 1e-10), csc(1, 1e-15), csc(1, 1e-20)
1.1884 1.1883951058 1.188395105778121 1.18839510577812121626 1.1884 1.1883951058 1.188395105778121 1.18839510577812121626
; print csc(2 + 3i, 1e-5), csc(2 + 3i, 1e-10)
~0.09047318155450436310+~0.04120099965201690801i ~0.09047320975303232503+~0.04120098628887626238i
; pi = pi(1e-20)
; print csc(pi/6, 1e-10), csc(pi/3, 1e-10), csc(4*pi/3, 1e-10)
2 1.1547005384 -1.1547005384
; print csc(1/2), csc(5/7), csc(42/7)
2.08582964293348818577 1.52653601091884339347 -3.57889954725440563736
LIMITS LIMITS
0 < eps < 1 0 < eps < 1

View File

@@ -5,7 +5,7 @@ SYNOPSIS
sec(x [,eps]) sec(x [,eps])
TYPES TYPES
x real x number (real or complex)
eps 0 < real < 1, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -18,8 +18,17 @@ EXAMPLE
; print sec(1, 1e-5), sec(1, 1e-10), sec(1, 1e-15), sec(1, 1e-20) ; print sec(1, 1e-5), sec(1, 1e-10), sec(1, 1e-15), sec(1, 1e-20)
1.85082 1.8508157177 1.850815717680926 1.85081571768092561791 1.85082 1.8508157177 1.850815717680926 1.85081571768092561791
; print sec(2 + 3i, 1e-5), sec(2 + 3i, 1e-10)
~-0.04167497639869547021+~0.09061109101765280898i ~-0.04167496441100888150+~0.09061113719571288336i
; pi = pi(1e-20)
; print 1e-10), sec(pi/6, 1e-10), sec(pi/3, 1e-10), sec(pi, 1e-10)
1.1547005384 2 -1
; print sec(1/2), sec(5/7), sec(42/7)
1.13949392732454912231 1.3235192673191814545 1.04148192659510767648
LIMITS LIMITS
unlike sin and cos, x must be real
0 < eps < 1 0 < eps < 1
LINK LIBRARY LINK LIBRARY

View File

@@ -25,6 +25,9 @@ EXAMPLE
; print sin(pi/6, 1e-10), sin(pi/2, 1e-10), sin(pi, 1e-10) ; print sin(pi/6, 1e-10), sin(pi/2, 1e-10), sin(pi, 1e-10)
0.5 1 0 0.5 1 0
; print sin(1/2), sin(5/7), sin(42/7)
0.47942553860420300027 0.6550778971785185742 -0.27941549819892587281
LIMITS LIMITS
0 < eps < 1 0 < eps < 1

View File

@@ -5,7 +5,7 @@ SYNOPSIS
tan(x [,eps]) tan(x [,eps])
TYPES TYPES
x real x number (real or complex)
eps 0 < real < 1, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -18,13 +18,21 @@ EXAMPLE
; print tan(1, 1e-5), tan(1, 1e-10), tan(1, 1e-15), tan(1, 1e-20) ; print tan(1, 1e-5), tan(1, 1e-10), tan(1, 1e-15), tan(1, 1e-20)
1.55741 1.5574077247 1.557407724654902 1.55740772465490223051 1.55741 1.5574077247 1.557407724654902 1.55740772465490223051
; print tan(2 + 3i, 1e-5), tan(2 + 3i, 1e-10)
~-0.00376408798745471014+~1.00323845857938817252i ~-0.00376402563894634508+~1.00323862734859967572i
; pi = pi(1e-20)
; print tan(0, 1e-10), tan(pi/6, 1e-10), tan(pi/3, 1e-10), tan(pi, 1e-10)
0 0.5773502692 1.7320508076 0
; print tan(1/2), tan(5/7), tan(42/7)
0.54630248984379051326 0.8670082185107029875 -0.29100619138474915705
LIMITS LIMITS
unlike sin and cos, x must be real
0 < eps < 1 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qtan(NUMBER *x, NUMBER *eps) NUMBER *qtan(NUMBER *x, NUMBER *eps)
COMPLEX *c_atan(COMPLEX *c, NUMBER *eps);
SEE ALSO SEE ALSO
sin, cos, cot, sec, csc sin, cos, cot, sec, csc