diff --git a/CHANGES b/CHANGES index 0cce4d2..9df9f1a 100644 --- a/CHANGES +++ b/CHANGES @@ -99,7 +99,7 @@ The following are the changes from calc version 2.14.3.5 to date: Document in help files for builtin functions that take eps arguments, the LIMIT range for such eps values. - Added new versin(x, [,eps]) for versed sine and vercos(x, [,eps]) + Added new versin(x, [,eps]) for versed sine and coversin(x, [,eps]) for versed cosine. diff --git a/cal/regress.cal b/cal/regress.cal index 8044520..83bfa6e 100644 --- a/cal/regress.cal +++ b/cal/regress.cal @@ -3533,31 +3533,31 @@ define test_trig() strcat(str(tnum++), ': round(versin(2 + 3i, 1e-10), 10) == 5.189625691+9.1092278938i')); - /* test versed cosine */ + /* test coversed sine */ pi = pi(1e-20); - vrfy(round(vercos(0.2, 1e-10), 10) == 0.8013306692, + vrfy(round(coversin(0.2, 1e-10), 10) == 0.8013306692, strcat(str(tnum++), - ': round(vercos(0.2, 1e-10), 10) == 0.8013306692')); - vrfy(round(vercos(3/7, 1e-10), 10) == 0.584428145, + ': round(coversin(0.2, 1e-10), 10) == 0.8013306692')); + vrfy(round(coversin(3/7, 1e-10), 10) == 0.584428145, strcat(str(tnum++), - ': round(vercos(3/7, 1e-10), 10) == 0.584428145')); - vrfy(round(vercos(-31, 1e-10), 10) == 0.5959623547, + ': round(coversin(3/7, 1e-10), 10) == 0.584428145')); + vrfy(round(coversin(-31, 1e-10), 10) == 0.5959623547, strcat(str(tnum++), - ': round(vercos(-31, 1e-10), 10) == 0.5959623547')); - vrfy(vercos(pi/6, 1e-10) == 0.5, - strcat(str(tnum++), ': vercos(pi/6, 1e-10) == 0.5')); - vrfy(vercos(pi/2, 1e-10) == 0, - strcat(str(tnum++), ': vercos(pi/2, 1e-10) == 0')); - vrfy(vercos(pi, 1e-10) == 1, - strcat(str(tnum++), ': vercos(pi, 1e-10) == 1')); - vrfy(vercos(3*pi/2, 1e-10) == 2, - strcat(str(tnum++), ': vercos(3*pi/2, 1e-10) == 2')); - vrfy(round(vercos(1, 1e-10), 10) == 0.1585290152, + ': round(coversin(-31, 1e-10), 10) == 0.5959623547')); + vrfy(coversin(pi/6, 1e-10) == 0.5, + strcat(str(tnum++), ': coversin(pi/6, 1e-10) == 0.5')); + vrfy(coversin(pi/2, 1e-10) == 0, + strcat(str(tnum++), ': coversin(pi/2, 1e-10) == 0')); + vrfy(coversin(pi, 1e-10) == 1, + strcat(str(tnum++), ': coversin(pi, 1e-10) == 1')); + vrfy(coversin(3*pi/2, 1e-10) == 2, + strcat(str(tnum++), ': coversin(3*pi/2, 1e-10) == 2')); + vrfy(round(coversin(1, 1e-10), 10) == 0.1585290152, strcat(str(tnum++), - ': round(vercos(1, 1e-10), 10) == 0.1585290152')); - vrfy(round(vercos(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i, + ': round(coversin(1, 1e-10), 10) == 0.1585290152')); + vrfy(round(coversin(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i, strcat(str(tnum++), - ': round(vercos(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i')); + ': round(coversin(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i')); print strcat(str(tnum++), ': Ending test_trig'); } diff --git a/calcerr.tbl b/calcerr.tbl index d5c1560..0680dd2 100644 --- a/calcerr.tbl +++ b/calcerr.tbl @@ -553,6 +553,6 @@ E_LOGN_5 Non-numeric second argument for logn E_VERSIN1 Bad epsilon for versin E_VERSIN2 Bad first argument for versin E_VERSIN3 Too-large im(argument) for versin -E_VERCOS1 Bad epsilon for vercos -E_VERCOS2 Bad first argument for vercos -E_VERCOS3 Too-large im(argument) for vercos +E_COVERSIN1 Bad epsilon for coversin +E_COVERSIN2 Bad first argument for coversin +E_COVERSIN3 Too-large im(argument) for coversin diff --git a/cmath.h b/cmath.h index 2abeefc..8fcc752 100644 --- a/cmath.h +++ b/cmath.h @@ -119,7 +119,7 @@ E_FUNC COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_versin(COMPLEX *c, NUMBER *epsilon); -E_FUNC COMPLEX *c_vercos(COMPLEX *c, NUMBER *epsilon); +E_FUNC COMPLEX *c_coversin(COMPLEX *c, NUMBER *epsilon); diff --git a/comfunc.c b/comfunc.c index 50dec9a..a7ff572 100644 --- a/comfunc.c +++ b/comfunc.c @@ -1371,10 +1371,10 @@ c_versin(COMPLEX *c, NUMBER *epsilon) * * This uses the formula: * - * vercos(x) = 1 - sin(x) + * coversin(x) = 1 - sin(x) */ COMPLEX * -c_vercos(COMPLEX *c, NUMBER *epsilon) +c_coversin(COMPLEX *c, NUMBER *epsilon) { COMPLEX *r; /* return COMPLEX value */ COMPLEX *ctmp; /* complex sin(c) */ @@ -1387,7 +1387,7 @@ c_vercos(COMPLEX *c, NUMBER *epsilon) not_reached(); } if (check_epsilon(epsilon) == false) { - math_error("Invalid epsilon value for complex vercos"); + math_error("Invalid epsilon value for complex coversin"); not_reached(); } @@ -1396,7 +1396,7 @@ c_vercos(COMPLEX *c, NUMBER *epsilon) */ ctmp = c_sin(c, epsilon); if (ctmp == NULL) { - math_error("Failed to compute complex sin for complex vercos"); + math_error("Failed to compute complex sin for complex coversin"); not_reached(); } r = c_sub(&_cone_, ctmp); diff --git a/func.c b/func.c index 2f8a990..5fda13f 100644 --- a/func.c +++ b/func.c @@ -3538,7 +3538,7 @@ f_versin(int count, VALUE **vals) S_FUNC VALUE -f_vercos(int count, VALUE **vals) +f_coversin(int count, VALUE **vals) { VALUE result; COMPLEX *c; @@ -3555,7 +3555,7 @@ f_vercos(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_VERCOS1); + return error_value(E_COVERSIN1); } eps = vals[1]->v_num; } @@ -3565,13 +3565,13 @@ f_vercos(int count, VALUE **vals) */ switch (vals[0]->v_type) { case V_NUM: - result.v_num = qvercos(vals[0]->v_num, eps); + result.v_num = qcoversin(vals[0]->v_num, eps); result.v_type = V_NUM; break; case V_COM: - c = c_vercos(vals[0]->v_com, eps); + c = c_coversin(vals[0]->v_com, eps); if (c == NULL) { - return error_value(E_VERCOS3); + return error_value(E_COVERSIN3); } result.v_com = c; result.v_type = V_COM; @@ -3582,7 +3582,7 @@ f_vercos(int count, VALUE **vals) } break; default: - return error_value(E_VERCOS2); + return error_value(E_COVERSIN2); } return result; } @@ -10859,6 +10859,8 @@ STATIC CONST struct builtin builtins[] = { "hyperbolic cotangent of a within accuracy b"}, {"count", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_count}, "count listr/matrix elements satisfying some condition"}, + {"coversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_coversin}, + "coversed sine of value a within accuracy b"}, {"cp", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_cp}, "cross product of two vectors"}, {"csc", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_csc}, @@ -11416,8 +11418,6 @@ STATIC CONST struct builtin builtins[] = { "unget char read from file"}, {"usertime", 0, 0, 0, OP_NOP, {.numfunc_0 = f_usertime}, {.null = NULL}, "user mode CPU time in seconds"}, - {"vercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_vercos}, - "versed cosine of value a within accuracy b"}, {"versin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_versin}, "versed sine of value a within accuracy b"}, {"version", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_version}, diff --git a/help/Makefile b/help/Makefile index d9d6e93..9d0f913 100644 --- a/help/Makefile +++ b/help/Makefile @@ -203,33 +203,33 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \ append appr arg argv arrow asec asech asin asinh assign atan atan2 \ atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \ btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \ - cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \ - d2dms d2g d2r delete den dereference det digit digits display dms2d dp \ - epsilon errcount errmax errno error estr euler eval exp fact factor \ - fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \ - fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \ - fputstr frac free freebernoulli freeeuler freeglobals freeredc \ - freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \ - g2r gcd gcdrem gd getenv gms2g h2hm h2hms hash head highbit hmean \ - hms2h hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \ - inverse iroot isalnum isalpha isassoc isatty isblk iscntrl isconfig \ - isdefined isdigit iserror iseven isfile isgraph ishash isident isint \ - islist islower ismat ismult isnull isnum isobj isobjtype isodd isprime \ - isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \ - isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \ - lfactor ln log log2 logn lowbit ltol makelist matdim matfill matmax \ - matmin matsum mattrace mattrans max memsize meq min minv mmin mne mod \ - modify name near newerror nextcand nextprime norm null num oldvalue \ - ord param perm pfact pi pix places pmod polar poly pop popcnt pound \ - power prevcand prevprime printf prompt protect ptest push putenv quo \ - quomod r2d r2g rand randbit random randombit randperm rcin rcmul rcout \ - rcpow rcsq re remove reverse rewind rm root round rsearch runtime \ - saveval scale scan scanf search sec sech seed segment select sgn sha1 \ - sin sinh size sizeof sleep sort sqrt srand srandom ssq stoponerror str \ - strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \ - strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \ - sum swap system systime tail tan tanh test time trunc usertime vercos \ - versin version xor + cmdbuf cmp comb conj cos cosh cot coth count coversin cp csc csch \ + ctime d2dm d2dms d2g d2r delete den dereference det digit digits \ + display dms2d dp epsilon errcount errmax errno error estr euler eval \ + exp fact factor fclose fcnt feof ferror fflush fgetc fgetfield \ + fgetfile fgetline fgets fgetstr fib files floor fopen forall fpathopen \ + fprintf fputc fputs fputstr frac free freebernoulli freeeuler \ + freeglobals freeredc freestatics frem freopen fscan fscanf fseek fsize \ + ftell g2d g2gm g2gms g2r gcd gcdrem gd getenv gms2g h2hm h2hms hash \ + head highbit hmean hms2h hnrmod hypot ilog ilog10 ilog2 im indices \ + inputlevel insert int inverse iroot isalnum isalpha isassoc isatty \ + isblk iscntrl isconfig isdefined isdigit iserror iseven isfile isgraph \ + ishash isident isint islist islower ismat ismult isnull isnum isobj \ + isobjtype isodd isprime isprint isptr ispunct isqrt isrand israndom \ + isreal isrel issimple isspace issq isstr istype isupper isxdigit \ + jacobi join lcm lcmfact lfactor ln log log2 logn lowbit ltol makelist \ + matdim matfill matmax matmin matsum mattrace mattrans max memsize meq \ + min minv mmin mne mod modify name near newerror nextcand nextprime \ + norm null num oldvalue ord param perm pfact pi pix places pmod polar \ + poly pop popcnt pound power prevcand prevprime printf prompt protect \ + ptest push putenv quo quomod r2d r2g rand randbit random randombit \ + randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \ + round rsearch runtime saveval scale scan scanf search sec sech seed \ + segment select sgn sha1 sin sinh size sizeof sleep sort sqrt srand \ + srandom ssq stoponerror str strcasecmp strcat strcmp strcpy strerror \ + strlen strncasecmp strncmp strncpy strpos strprintf strscan strscanf \ + strtolower strtoupper substr sum swap system systime tail tan tanh \ + test time trunc usertime versin version xor # This list is of files that are clones of DETAIL_HELP files. They are # built from DETAIL_HELP files. diff --git a/help/cos b/help/cos index 6a7c921..34dc27f 100644 --- a/help/cos +++ b/help/cos @@ -34,7 +34,7 @@ LINK LIBRARY SEE ALSO sin, tan, sec, csc, cot, epsilon - versin, vercos + versin, coversin ## Copyright (C) 1999,2021,2023 Landon Curt Noll ## diff --git a/help/cot b/help/cot index 414d758..2863916 100644 --- a/help/cot +++ b/help/cot @@ -27,7 +27,7 @@ LINK LIBRARY SEE ALSO sin, cos, tan, sec, csc, epsilon - versin, vercos + versin, coversin ## Copyright (C) 1999,2021,2023 Landon Curt Noll ## diff --git a/help/vercos b/help/coversin similarity index 74% rename from help/vercos rename to help/coversin index 4cac2e2..7870d3e 100644 --- a/help/vercos +++ b/help/coversin @@ -1,8 +1,8 @@ NAME - vercos - versed cosine + coversin - coversed sine SYNOPSIS - vercos(x [,eps]) + coversin(x [,eps]) TYPES x number (real or complex) @@ -14,31 +14,31 @@ DESCRIPTION Calculate the versed cosine of x to a multiple of eps with error less in absolute value than .75 * eps. - The versed cosine function is sometimes called coversin, sometimes called cvs, + The coversed sine function is sometimes called covers, or cosiv, or cvs, may be defined as: - vercos(x) = 1 - sin(x) + coversin(x) = 1 - sin(x) EXAMPLE - ; print vercos(0.2), vercos(3/7), vercos(-31) + ; print coversin(0.2), coversin(3/7), coversin(-31) 0.80133066920493878454 0.58442814500694799193 0.59596235467693499395 - ; print vercos(1, 1e-5), vercos(1, 1e-10), vercos(1, 1e-15), vercos(1, 1e-20) + ; print coversin(1, 1e-5), coversin(1, 1e-10), coversin(1, 1e-15), coversin(1, 1e-20) 0.15853 0.1585290152 0.158529015192104 0.15852901519210349335 - ; print vercos(2 + 3i, 1e-5), vercos(2 + 3i, 1e-10) + ; print coversin(2 + 3i, 1e-5), coversin(2 + 3i, 1e-10) -8.1545+4.16891i -8.1544991469+4.16890696i ; pi = pi(1e-20) - ; print vercos(pi/6, 1e-10), vercos(pi/2, 1e-10), vercos(pi, 1e-10), vercos(3*pi/2, 1e-10) + ; print coversin(pi/6, 1e-10), coversin(pi/2, 1e-10), coversin(pi, 1e-10), coversin(3*pi/2, 1e-10) 0.5 0 1 2 LIMITS 0 < eps < 1 LINK LIBRARY - NUMBER *qvercos(NUMBER *x, NUMBER *eps) - COMPLEX *c_vercos(COMPLEX *x, NUMBER *eps) + NUMBER *qcoversin(NUMBER *x, NUMBER *eps) + COMPLEX *c_coversin(COMPLEX *x, NUMBER *eps) SEE ALSO sin, cos, tan, sec, csc, cot, epsilon diff --git a/help/csc b/help/csc index 4b95241..f277ac0 100644 --- a/help/csc +++ b/help/csc @@ -26,7 +26,7 @@ LINK LIBRARY SEE ALSO sin, cos, tan, sec, cot, epsilon - versin, vercos + versin, coversin ## Copyright (C) 1999,2023 Landon Curt Noll ## diff --git a/help/sec b/help/sec index b563824..afdc317 100644 --- a/help/sec +++ b/help/sec @@ -27,7 +27,7 @@ LINK LIBRARY SEE ALSO sin, cos, tan, csc, cot, epsilon - versin, vercos + versin, coversin ## Copyright (C) 1999,2023 Landon Curt Noll ## diff --git a/help/sin b/help/sin index e8bfade..8272bdb 100644 --- a/help/sin +++ b/help/sin @@ -34,7 +34,7 @@ LINK LIBRARY SEE ALSO cos, tan, sec, csc, cot, epsilon - versin, vercos + versin, coversin ## Copyright (C) 1999,2021,2023 Landon Curt Noll ## diff --git a/help/tan b/help/tan index 5b17f82..ba7dd9e 100644 --- a/help/tan +++ b/help/tan @@ -28,7 +28,7 @@ LINK LIBRARY SEE ALSO sin, cos, sec, csc, cot, epsilon - versin, vercos + versin, coversin ## Copyright (C) 1999,2023 Landon Curt Noll ## diff --git a/help/versin b/help/versin index 9ae00d6..e6410e2 100644 --- a/help/versin +++ b/help/versin @@ -17,7 +17,7 @@ DESCRIPTION The versed sine function is sometimes called vers, sometimes called ver, may be defined as: - versin(x) = 1 - cos(x) + versin(x) = 1 - cos(x) EXAMPLE ; print versin(0.2), versin(3/7), versin(-31) @@ -42,7 +42,7 @@ LINK LIBRARY SEE ALSO sin, cos, tan, sec, csc, cot, epsilon - vercos + coversin ## Copyright (C) 2023 Landon Curt Noll ## diff --git a/qmath.h b/qmath.h index 21f9532..793a0e3 100644 --- a/qmath.h +++ b/qmath.h @@ -223,7 +223,7 @@ E_FUNC void qfreebern(void); E_FUNC NUMBER *qeuler(ZVALUE z); E_FUNC void qfreeeuler(void); E_FUNC NUMBER *qversin(NUMBER *q, NUMBER *epsilon); -E_FUNC NUMBER *qvercos(NUMBER *q, NUMBER *epsilon); +E_FUNC NUMBER *qcoversin(NUMBER *q, NUMBER *epsilon); /* diff --git a/qtrans.c b/qtrans.c index 179a164..4621de6 100644 --- a/qtrans.c +++ b/qtrans.c @@ -1977,7 +1977,9 @@ qacoth(NUMBER *q, NUMBER *epsilon) /* * versed sine - this calls qsincos() and discards the value of sin. * - * This uses the formula: versin(x) = 1 - cos(x). + * This uses the formula: + * + * versin(x) = 1 - cos(x) */ NUMBER * qversin(NUMBER *q, NUMBER *epsilon) @@ -2006,13 +2008,15 @@ qversin(NUMBER *q, NUMBER *epsilon) /* * versed cosine - this calls qsincos() and discards the value of cos. * - * This uses the formula: vercos(x) = 1 - sin(x). + * This uses the formula: + * + * coversin(x) = 1 - sin(x) */ NUMBER * -qvercos(NUMBER *q, NUMBER *epsilon) +qcoversin(NUMBER *q, NUMBER *epsilon) { NUMBER *sin, *cos, *res; - NUMBER *vercos; + NUMBER *coversin; long n; if (qiszero(epsilon)) { @@ -2024,9 +2028,9 @@ qvercos(NUMBER *q, NUMBER *epsilon) return qlink(&_qzero_); qsincos(q, n + 2, &sin, &cos); qfree(cos); - vercos = qsub(&_qone_, sin); + coversin = qsub(&_qone_, sin); qfree(sin); - res = qmappr(vercos, epsilon, 24); - qfree(vercos); + res = qmappr(coversin, epsilon, 24); + qfree(coversin); return res; }