mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
add trigonometric chord of a unit circle functions
Improve builtin function strings, as printed by help builtin, that use an optional accuracy (epsilon) arg by adding a comma. Added the following new trigonometric functions: crd(x [,eps]) trigonometric chord of a unit circle acrd(x [,eps]) inverse trigonometric chord of a unit circle
This commit is contained in:
51
CHANGES
51
CHANGES
@@ -1,5 +1,30 @@
|
||||
The following are the changes from calc version 2.14.3.5 to date:
|
||||
|
||||
Added the following new trigonometric functions:
|
||||
|
||||
versin(x [,eps]) versed trigonometric sine
|
||||
coversin(x [,eps]) coversed trigonometric sine
|
||||
vercos(x [,eps]) versed trigonometric cosine
|
||||
covercos(x [,eps]) coversed trigonometric cosine
|
||||
aversin(x [,eps]) inverse versed trigonometric sine
|
||||
acoversin(x [,eps]) inverse coversed trigonometric sine
|
||||
avercos(x [,eps]) inverse versed trigonometric cosine
|
||||
acovercos(x [,eps]) inverse coversed trigonometric cosine
|
||||
haversin(x [,eps]) half versed trigonometric sine
|
||||
hacoversin(x [,eps]) half coversed trigonometric sine
|
||||
havercos(x [,eps]) half versed trigonometric cosine
|
||||
hacovercos(x [,eps]) half coversed trigonometric cosine
|
||||
ahaversin(x [,eps]) inverse half versed trigonometric sine
|
||||
ahacoversin(x [,eps]) inverse half coversed trigonometric sine
|
||||
ahavercos(x [,eps]) inverse half versed trigonometric cosine
|
||||
ahacovercos(x [,eps]) inverse half coversed trigonometric cosine
|
||||
exsec(x [,eps]) exterior trigonometric secant
|
||||
aexsec(x [,eps]) inverse exterior trigonometric secant
|
||||
excsc(x [,eps]) exterior trigonometric cosecant
|
||||
aexcsc(x [,eps]) inverse exterior trigonometric cosecant
|
||||
crd(x [,eps]) trigonometric chord of a unit circle
|
||||
acrd(x [,eps]) inverse trigonometric chord of a unit circle
|
||||
|
||||
As Msys2 is a fork of Cygwin, if the OSNAME is Msys, the Cygwin
|
||||
target will be used. Thanks to GitHub user @iahung2 for the
|
||||
pull request.
|
||||
@@ -336,29 +361,6 @@ The following are the changes from calc version 2.14.3.5 to date:
|
||||
|
||||
Fixed SEE ALSO typo in help randperm.
|
||||
|
||||
Added the following new trigonometric functions:
|
||||
|
||||
versin(x [,eps]) versed trigonometric sine
|
||||
coversin(x [,eps]) coversed trigonometric sine
|
||||
vercos(x [,eps]) versed trigonometric cosine
|
||||
covercos(x [,eps]) coversed trigonometric cosine
|
||||
aversin(x [,eps]) inverse versed trigonometric sine
|
||||
acoversin(x [,eps]) inverse coversed trigonometric sine
|
||||
avercos(x [,eps]) inverse versed trigonometric cosine
|
||||
acovercos(x [,eps]) inverse coversed trigonometric cosine
|
||||
haversin(x [,eps]) half versed trigonometric sine
|
||||
hacoversin(x [,eps]) half coversed trigonometric sine
|
||||
havercos(x [,eps]) half versed trigonometric cosine
|
||||
hacovercos(x [,eps]) half coversed trigonometric cosine
|
||||
ahaversin(x [,eps]) inverse half versed trigonometric sine
|
||||
ahacoversin(x [,eps]) inverse half coversed trigonometric sine
|
||||
ahavercos(x [,eps]) inverse half versed trigonometric cosine
|
||||
ahacovercos(x [,eps]) inverse half coversed trigonometric cosine
|
||||
exsec(x [,eps]) exterior trigonometric secant
|
||||
aexsec(x [,eps]) inverse exterior trigonometric secant
|
||||
excsc(x [,eps]) exterior trigonometric cosecant
|
||||
aexcsc(x [,eps]) inverse exterior trigonometric cosecant
|
||||
|
||||
Fixed calc regression test 42dd to set the display value back to 20.
|
||||
|
||||
Added to test 95dd and test9500.trigeq.cal to the calc regression test
|
||||
@@ -366,6 +368,9 @@ The following are the changes from calc version 2.14.3.5 to date:
|
||||
|
||||
Added to test 34dd, some if the missing inverse trigonometric tests.
|
||||
|
||||
Improve builtin function strings, as printed by help builtin,
|
||||
that use an optional accuracy (epsilon) arg by adding a comma.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.14.3.4 to 2.14.3.5:
|
||||
|
||||
|
@@ -4138,6 +4138,50 @@ define test_trig()
|
||||
strcat(str(tnum++),
|
||||
': round(aexcsc(2 + 3i, 1e-10), 10) == 0.1650861985-0.1681700706i'));
|
||||
|
||||
/* test trigonometric chord of a unit circle */
|
||||
vrfy(crd(0, 1e-10) == 0,
|
||||
strcat(str(tnum++), ': crd(0, 1e-10) == 0'));
|
||||
vrfy(round(crd(0.2, 1e-10), 10) == 0.1996668332,
|
||||
strcat(str(tnum++),
|
||||
': round(crd(0.2, 1e-10), 10) == 0.1996668332'));
|
||||
vrfy(round(crd(3/7, 1e-10), 10) == 0.4252990674,
|
||||
strcat(str(tnum++),
|
||||
': round(crd(3/7, 1e-10), 10) == 0.4252990674'));
|
||||
vrfy(round(crd(-31, 1e-10), 10) == -0.4129349638,
|
||||
strcat(str(tnum++),
|
||||
': round(crd(-31, 1e-10), 10) == -0.4129349638'));
|
||||
vrfy(crd(pi/3, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': crd(pi/3, 1e-10) == 1'));
|
||||
vrfy(crd(pi, 1e-10) == 2,
|
||||
strcat(str(tnum++), ': crd(pi, 1e-10) == 2'));
|
||||
vrfy(crd(5*pi/3, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': crd(5*pi/3, 1e-10) == 1'));
|
||||
vrfy(round(crd(1, 1e-10), 10) == 0.9588510772,
|
||||
strcat(str(tnum++),
|
||||
': round(crd(1, 1e-10), 10) == 0.9588510772'));
|
||||
vrfy(round(crd(2 + 3i, 1e-10), 10) == 3.9589688712+2.3009091988i,
|
||||
strcat(str(tnum++),
|
||||
': round(crd(2 + 3i, 1e-10), 10) == 3.9589688712+2.3009091988i'));
|
||||
|
||||
/* test inverse trigonometric chord of a unit circle */
|
||||
vrfy(acrd(0, 1e-10) == 0,
|
||||
strcat(str(tnum++), ': acrd(0, 1e-10) == 0'));
|
||||
vrfy(round(acrd(0.2, 1e-10), 10) == 0.2003348424,
|
||||
strcat(str(tnum++),
|
||||
': round(acrd(0.2, 1e-10), 10) == 0.2003348424'));
|
||||
vrfy(round(acrd(3/7, 1e-10), 10) == 0.4319209974,
|
||||
strcat(str(tnum++),
|
||||
': round(acrd(3/7, 1e-10), 10) == 0.4319209974'));
|
||||
vrfy(round(acrd(-31, 1e-10), 10) == -3.1415926536+6.8658899902i,
|
||||
strcat(str(tnum++),
|
||||
': round(acrd(-31, 1e-10), 10) == -3.1415926536+6.8658899902i'));
|
||||
vrfy(round(acrd(1, 1e-10), 10) == 1.0471975512,
|
||||
strcat(str(tnum++),
|
||||
': round(acrd(1, 1e-10), 10) == 1.0471975512'));
|
||||
vrfy(round(acrd(2 + 3i, 1e-10), 10) == 1.0471975512+2.6339157938i,
|
||||
strcat(str(tnum++),
|
||||
': round(acrd(2 + 3i, 1e-10), 10) == 1.0471975512+2.6339157938i'));
|
||||
|
||||
print strcat(str(tnum++), ': Ending test_trig');
|
||||
}
|
||||
print '051: parsed test_trig()';
|
||||
@@ -9835,8 +9879,9 @@ vrfy(verify_havercos(9513) == 0, '9513: verify_havercos(9513) == 0');
|
||||
vrfy(verify_hacovercos(9514) == 0, '9514: verify_hacovercos(9514) == 0');
|
||||
vrfy(verify_exsec(9515) == 0, '9515: verify_exsec(9515) == 0');
|
||||
vrfy(verify_excsc(9516) == 0, '9516: verify_excsc(9516) == 0');
|
||||
vrfy(verify_crd(9517) == 0, '9516: verify_excsc(9517) == 0');
|
||||
|
||||
print '9517: Ending trigonometric identities test set';
|
||||
print '9518: Ending trigonometric identities test set';
|
||||
|
||||
|
||||
/*
|
||||
@@ -10839,6 +10884,12 @@ vrfy_errsym(10590, 10590, "E_EXCSC_4");
|
||||
vrfy_errsym(10591, 10591, "E_AEXCSC_1");
|
||||
vrfy_errsym(10592, 10592, "E_AEXCSC_2");
|
||||
vrfy_errsym(10593, 10593, "E_AEXCSC_3");
|
||||
vrfy_errsym(10594, 10594, "E_CRD_1");
|
||||
vrfy_errsym(10595, 10595, "E_CRD_2");
|
||||
vrfy_errsym(10596, 10596, "E_CRD_3");
|
||||
vrfy_errsym(10597, 10597, "E_ACRD_1");
|
||||
vrfy_errsym(10598, 10598, "E_ACRD_2");
|
||||
vrfy_errsym(10599, 10599, "E_ACRD_3");
|
||||
|
||||
/* ************************************************************** */
|
||||
/* NOTE: Reserve thru test 10998 for calc computation error codes */
|
||||
|
@@ -364,6 +364,16 @@ define compare(ident_val, trig_val, name, index, testnum)
|
||||
{
|
||||
local abs_diff; /* absolute difference between ident_val and trig_val */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (!isnum(trig_val)) {
|
||||
printf("**** trig test %d-%d failed: %s(tval[%d]): ",
|
||||
testnum, index, name, index);
|
||||
printf("%d returned a non-numeric value\n", trig_val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute absolute difference
|
||||
*/
|
||||
@@ -1244,3 +1254,61 @@ define verify_excsc(testnum)
|
||||
}
|
||||
return error_count;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* verify_crd - verify trigonometric chord of a unit circle
|
||||
*
|
||||
* We use the following trigonometric identity:
|
||||
*
|
||||
* crd(x) = 2 * sin(x / 2)
|
||||
*
|
||||
* given:
|
||||
* testnum regression test number being performed
|
||||
*
|
||||
* returns:
|
||||
* number of tests that failed
|
||||
*/
|
||||
define verify_crd(testnum)
|
||||
{
|
||||
local tval_len; /* current length of the tval[] array */
|
||||
local ident_val; /* computed trig value trigonometric identity */
|
||||
local trig_val; /* computed value from the trigonometric function */
|
||||
local error_count; /* number of compare errors detected */
|
||||
local i;
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (size(sin_tval) <= 0) {
|
||||
precompute_trig();
|
||||
}
|
||||
|
||||
/*
|
||||
* for each test value, verify the trigonometric identity within epsilon
|
||||
*/
|
||||
tval_len = size(tval);
|
||||
for (i=0; i < tval_len; ++i) {
|
||||
|
||||
/* NOTE: We actually check the identity: crd(x*2) = 2 * sin(x) */
|
||||
|
||||
/* compute trigonometric identity */
|
||||
ident_val = 2 * sin_tval[i];
|
||||
|
||||
/* compute trigonometric function */
|
||||
trig_val = crd(tval[i] * 2);
|
||||
|
||||
/* compare trigonometric identity with trigonometric function value */
|
||||
if (compare(ident_val, trig_val, "crd", i, testnum)) {
|
||||
++error_count;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* report test results
|
||||
*/
|
||||
if (error_count != 0) {
|
||||
print '**** test', testnum : ': crd test failure count:', error_count;
|
||||
}
|
||||
return error_count;
|
||||
}
|
||||
|
2
cmath.h
2
cmath.h
@@ -148,6 +148,8 @@ E_FUNC COMPLEX *c_exsec(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_aexsec(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_excsc(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_aexcsc(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_crd(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acrd(COMPLEX *c, NUMBER *epsilon);
|
||||
|
||||
|
||||
|
||||
|
142
comfunc.c
142
comfunc.c
@@ -1655,7 +1655,7 @@ c_ilog(COMPLEX *c, ZVALUE base)
|
||||
* versin(x) = 1 - cos(x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -1705,7 +1705,7 @@ c_versin(COMPLEX *c, NUMBER *epsilon)
|
||||
* aversin(x) = acos(1 - x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -1751,7 +1751,7 @@ c_aversin(COMPLEX *c, NUMBER *epsilon)
|
||||
* coversin(x) = 1 - cos(x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -1801,7 +1801,7 @@ c_coversin(COMPLEX *c, NUMBER *epsilon)
|
||||
* acoversin(x) = asin(1 - x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -1847,7 +1847,7 @@ c_acoversin(COMPLEX *c, NUMBER *epsilon)
|
||||
* vercos(x) = 1 + cos(x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -1897,7 +1897,7 @@ c_vercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* avercos(x) = acos(x - 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -1943,7 +1943,7 @@ c_avercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* covercos(x) = 1 + sin(x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -1993,7 +1993,7 @@ c_covercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* acovercos(x) = asin(x - 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2039,7 +2039,7 @@ c_acovercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* haversin(x) = versin(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2089,7 +2089,7 @@ c_haversin(COMPLEX *c, NUMBER *epsilon)
|
||||
* ahaversin(x) = acos(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2138,7 +2138,7 @@ c_ahaversin(COMPLEX *c, NUMBER *epsilon)
|
||||
* hacoversin(x) = coversin(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2188,7 +2188,7 @@ c_hacoversin(COMPLEX *c, NUMBER *epsilon)
|
||||
* ahacoversin(x) = asin(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2237,7 +2237,7 @@ c_ahacoversin(COMPLEX *c, NUMBER *epsilon)
|
||||
* havercos(x) = vercos(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2287,7 +2287,7 @@ c_havercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* ahavercos(x) = acos(2*x - 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2336,7 +2336,7 @@ c_ahavercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* hacovercos(x) = covercos(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2386,7 +2386,7 @@ c_hacovercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* ahacovercos(x) = asin(2*x - 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2435,7 +2435,7 @@ c_ahacovercos(COMPLEX *c, NUMBER *epsilon)
|
||||
* exsec(x) = sec(x) - 1
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2485,7 +2485,7 @@ c_exsec(COMPLEX *c, NUMBER *epsilon)
|
||||
* aexsec(x) = asec(x + 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2531,7 +2531,7 @@ c_aexsec(COMPLEX *c, NUMBER *epsilon)
|
||||
* excsc(x) = csc(x) - 1
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2581,7 +2581,7 @@ c_excsc(COMPLEX *c, NUMBER *epsilon)
|
||||
* aexcsc(x) = acsc(x + 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
@@ -2617,3 +2617,105 @@ c_aexcsc(COMPLEX *c, NUMBER *epsilon)
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_crd - COMPLEX valued trigonometric chord of a unit circle
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* crd(x) = 2 * sin(x / 2)
|
||||
*
|
||||
* given:
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_crd(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* return COMPLEX value */
|
||||
COMPLEX *cdiv2; /* complex c/2 */
|
||||
COMPLEX *ctmp; /* complex sin(c/2) */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex trig function value
|
||||
*/
|
||||
cdiv2 = c_divq(c, &_qtwo_);
|
||||
ctmp = c_sin(cdiv2, epsilon);
|
||||
comfree(cdiv2);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex sine for complex crd");
|
||||
not_reached();
|
||||
}
|
||||
r = c_mulq(ctmp, &_qtwo_);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_acrd - COMPLEX valued inverse trigonometric chord of a unit circle
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* acrd(x) = 2 * asin(x / 2)
|
||||
*
|
||||
* given:
|
||||
* c complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_acrd(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *cdiv2; /* complex c/2 */
|
||||
COMPLEX *ctmp; /* complex asin(c/2) */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
cdiv2 = c_divq(c, &_qtwo_);
|
||||
ctmp = c_asin(cdiv2, epsilon);
|
||||
comfree(cdiv2);
|
||||
r = c_mulq(ctmp, &_qtwo_);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
9
errtbl.c
9
errtbl.c
@@ -145,7 +145,8 @@
|
||||
* Do not remove such computation error codes, nor change their errnum values,
|
||||
* not change their E_STRING errsym codes.
|
||||
*/
|
||||
CONST struct errtbl error_table[] = {
|
||||
CONST struct errtbl error_table[] =
|
||||
{
|
||||
|
||||
/* The E__BASE entry below must start with 10000 and must be first!! */
|
||||
{ 10000, "E__BASE", "No error" },
|
||||
@@ -742,6 +743,12 @@ CONST struct errtbl error_table[] = {
|
||||
{ 10591, "E_AEXCSC_1", "Bad epsilon for aexcsc" },
|
||||
{ 10592, "E_AEXCSC_2", "Bad argument for aexcsc" },
|
||||
{ 10593, "E_AEXCSC_3", "Invalid value for calculating aexcsc" },
|
||||
{ 10594, "E_CRD_1", "Bad epsilon for crd" },
|
||||
{ 10595, "E_CRD_2", "Bad argument for crd" },
|
||||
{ 10596, "E_CRD_3", "Invalid complex argument for crd" },
|
||||
{ 10597, "E_ACRD_1", "Bad epsilon for acrd" },
|
||||
{ 10598, "E_ACRD_2", "Bad argument for acrd" },
|
||||
{ 10599, "E_ACRD_3", "Invalid value for calculating acrd" },
|
||||
/* IMPORTANT NOTE: add new entries above here and be sure their errnum numeric value is consecutive! */
|
||||
|
||||
/* The next NULL entry must be last */
|
||||
|
252
func.c
252
func.c
@@ -12219,6 +12219,142 @@ f_aexcsc(int count, VALUE **vals)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_crd - exterior trigonometric cosecant
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_crd(int count, VALUE **vals)
|
||||
{
|
||||
VALUE result;
|
||||
COMPLEX *c;
|
||||
NUMBER *err;
|
||||
|
||||
/* initialize VALUEs */
|
||||
result.v_subtype = V_NOSUBTYPE;
|
||||
|
||||
/*
|
||||
* set error tolerance for builtin function
|
||||
*
|
||||
* Use err VALUE arg if given and value is in a valid range.
|
||||
*/
|
||||
err = conf->epsilon;
|
||||
if (count == 2) {
|
||||
if (verify_eps(vals[1]) == false) {
|
||||
return error_value(E_CRD_1);
|
||||
}
|
||||
err = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute cosecant to a given error tolerance
|
||||
*/
|
||||
switch (vals[0]->v_type) {
|
||||
case V_NUM:
|
||||
result.v_num = qcrd(vals[0]->v_num, err);
|
||||
result.v_type = V_NUM;
|
||||
break;
|
||||
case V_COM:
|
||||
c = c_crd(vals[0]->v_com, err);
|
||||
if (c == NULL) {
|
||||
return error_value(E_CRD_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return error_value(E_CRD_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_acrd - exterior trigonometric cosecant
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_acrd(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
|
||||
/* initialize VALUE */
|
||||
result.v_subtype = V_NOSUBTYPE;
|
||||
|
||||
/*
|
||||
* set error tolerance for builtin function
|
||||
*
|
||||
* Use eps VALUE arg if given and value is in a valid range.
|
||||
*/
|
||||
eps = conf->epsilon;
|
||||
if (count == 2) {
|
||||
if (verify_eps(vals[1]) == false) {
|
||||
return error_value(E_ACRD_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute inverse trig function to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qacrd_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
*/
|
||||
if (result.v_num != NULL) {
|
||||
result.v_type = V_NUM;
|
||||
|
||||
/*
|
||||
* case: trig function returned NULL - need to try COMPLEX trig function
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_acrd(arg1.v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_ACRD_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
*/
|
||||
return error_value(E_ACRD_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif /* !FUNCLIST */
|
||||
|
||||
|
||||
@@ -12260,39 +12396,41 @@ f_aexcsc(int count, VALUE **vals)
|
||||
*/
|
||||
STATIC CONST struct builtin builtins[] = {
|
||||
{"abs", 1, 2, 0, OP_ABS, {.null = NULL}, {.null = NULL},
|
||||
"absolute value within accuracy b"},
|
||||
"absolute value, within accuracy b"},
|
||||
{"access", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_access},
|
||||
"determine accessibility of file a for mode b"},
|
||||
{"acos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acos},
|
||||
"inverse cosine of a within accuracy b"},
|
||||
"inverse cosine of a, within accuracy b"},
|
||||
{"acosh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acosh},
|
||||
"inverse hyperbolic cosine of a within accuracy b"},
|
||||
"inverse hyperbolic cosine of a, within accuracy b"},
|
||||
{"acot", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acot},
|
||||
"inverse cotangent of a within accuracy b"},
|
||||
"inverse cotangent of a, within accuracy b"},
|
||||
{"acoth", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acoth},
|
||||
"inverse hyperbolic cotangent of a within accuracy b"},
|
||||
"inverse hyperbolic cotangent of a, within accuracy b"},
|
||||
{"acovercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acovercos},
|
||||
"inverse coversed cosine of a within accuracy b"},
|
||||
"inverse coversed cosine of a, within accuracy b"},
|
||||
{"acoversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acoversin},
|
||||
"inverse coversed sine of a within accuracy b"},
|
||||
"inverse coversed sine of a, within accuracy b"},
|
||||
{"acrd", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acrd},
|
||||
"angle of unit circle chord with length a, within accuracy b"},
|
||||
{"acsc", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acsc},
|
||||
"inverse cosecant of a within accuracy b"},
|
||||
"inverse cosecant of a, within accuracy b"},
|
||||
{"acsch", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acsch},
|
||||
"inverse csch of a within accuracy b"},
|
||||
"inverse csch of a, within accuracy b"},
|
||||
{"aexcsc", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_aexcsc},
|
||||
"inverse exterior cosecant of a within accuracy b"},
|
||||
"inverse exterior cosecant of a, within accuracy b"},
|
||||
{"aexsec", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_aexsec},
|
||||
"inverse exterior secant of a within accuracy b"},
|
||||
"inverse exterior secant of a, within accuracy b"},
|
||||
{"agd", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_agd},
|
||||
"inverse Gudermannian function"},
|
||||
{"ahacovercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahacovercos},
|
||||
"inverse half coversed cosine of a within accuracy b"},
|
||||
"inverse half coversed cosine of a, within accuracy b"},
|
||||
{"ahacoversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahacoversin},
|
||||
"inverse half coversed sine of a within accuracy b"},
|
||||
"inverse half coversed sine of a, within accuracy b"},
|
||||
{"ahavercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahavercos},
|
||||
"inverse half versed cosine of a within accuracy b"},
|
||||
"inverse half versed cosine of a, within accuracy b"},
|
||||
{"ahaversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahaversin},
|
||||
"inverse half versed sine of a within accuracy b"},
|
||||
"inverse half versed sine of a, within accuracy b"},
|
||||
{"append", 1, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_listappend},
|
||||
"append values to end of list"},
|
||||
{"appr", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_appr},
|
||||
@@ -12302,25 +12440,25 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"argv", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_argv},
|
||||
"calc argc or argv string"},
|
||||
{"asec", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asec},
|
||||
"inverse secant of a within accuracy b"},
|
||||
"inverse secant of a, within accuracy b"},
|
||||
{"asech", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asech},
|
||||
"inverse hyperbolic secant of a within accuracy b"},
|
||||
"inverse hyperbolic secant of a, within accuracy b"},
|
||||
{"asin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asin},
|
||||
"inverse sine of a within accuracy b"},
|
||||
"inverse sine of a, within accuracy b"},
|
||||
{"asinh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asinh},
|
||||
"inverse hyperbolic sine of a within accuracy b"},
|
||||
"inverse hyperbolic sine of a, within accuracy b"},
|
||||
{"assoc", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_assoc},
|
||||
"create new association array"},
|
||||
{"atan", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_atan},
|
||||
"inverse tangent of a within accuracy b"},
|
||||
"inverse tangent of a, within accuracy b"},
|
||||
{"atan2", 2, 3, FE, OP_NOP, {.numfunc_3 = qatan2}, {.null = NULL},
|
||||
"angle to point (b,a) within accuracy c"},
|
||||
{"atanh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_atanh},
|
||||
"inverse hyperbolic tangent of a within accuracy b"},
|
||||
"inverse hyperbolic tangent of a, within accuracy b"},
|
||||
{"avercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_avercos},
|
||||
"inverse versed cosine of a within accuracy b"},
|
||||
"inverse versed cosine of a, within accuracy b"},
|
||||
{"aversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_aversin},
|
||||
"inverse versed sine of a within accuracy b"},
|
||||
"inverse versed sine of a, within accuracy b"},
|
||||
{"avg", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_avg},
|
||||
"arithmetic mean of values"},
|
||||
{"base", 0, 1, 0, OP_NOP, {.numfunc_cnt = f_base}, {.null = NULL},
|
||||
@@ -12354,7 +12492,7 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"ceil", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ceil},
|
||||
"smallest integer greater than or equal to number"},
|
||||
{"cfappr", 1, 3, 0, OP_NOP, {.numfunc_cnt = f_cfappr}, {.null = NULL},
|
||||
"approximate a within accuracy b using\n"
|
||||
"approximate a, within accuracy b using\n"
|
||||
"\t\t\tcontinued fractions"},
|
||||
{"cfsim", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_cfsim}, {.null = NULL},
|
||||
"simplify number using continued fractions"},
|
||||
@@ -12373,25 +12511,27 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"copy", 2, 5, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_copy},
|
||||
"copy value to/from a block: copy(s,d,len,si,di)"},
|
||||
{"cos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_cos},
|
||||
"cosine of value a within accuracy b"},
|
||||
"cosine of value a, within accuracy b"},
|
||||
{"cosh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_cosh},
|
||||
"hyperbolic cosine of a within accuracy b"},
|
||||
"hyperbolic cosine of a, within accuracy b"},
|
||||
{"cot", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_cot},
|
||||
"cotangent of a within accuracy b"},
|
||||
"cotangent of a, within accuracy b"},
|
||||
{"coth", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_coth},
|
||||
"hyperbolic cotangent of a within accuracy b"},
|
||||
"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"},
|
||||
{"covercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_covercos},
|
||||
"coversed cosine of value a within accuracy b"},
|
||||
"coversed cosine of value a, within accuracy b"},
|
||||
{"coversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_coversin},
|
||||
"coversed sine of value a within accuracy b"},
|
||||
"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"},
|
||||
{"crd", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_crd},
|
||||
"length of unit circle chord with angle a, within accuracy b"},
|
||||
{"csc", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_csc},
|
||||
"cosecant of a within accuracy b"},
|
||||
"cosecant of a, within accuracy b"},
|
||||
{"csch", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_csch},
|
||||
"hyperbolic cosecant of a within accuracy b"},
|
||||
"hyperbolic cosecant of a, within accuracy b"},
|
||||
{"ctime", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_ctime},
|
||||
"date and time as string"},
|
||||
{"custom", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_custom},
|
||||
@@ -12441,11 +12581,11 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"eval", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_eval},
|
||||
"evaluate expression from string to value"},
|
||||
{"excsc", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_excsc},
|
||||
"exterior cosecant of a within accuracy b"},
|
||||
"exterior cosecant of a, within accuracy b"},
|
||||
{"exp", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_exp},
|
||||
"exponential of value a within accuracy b"},
|
||||
"exponential of value a, within accuracy b"},
|
||||
{"exsec", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_exsec},
|
||||
"exterior secant of a within accuracy b"},
|
||||
"exterior secant of a, within accuracy b"},
|
||||
{"fact", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fact},
|
||||
"factorial"},
|
||||
{"factor", 1, 3, 0, OP_NOP, {.numfunc_cnt = f_factor}, {.null = NULL},
|
||||
@@ -12549,16 +12689,16 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"h2hms", 4, 5, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_h2hms},
|
||||
"convert a to b hours, c min, d sec, rounding type e\n"},
|
||||
{"hacovercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hacovercos},
|
||||
"half coversed cosine of value a within accuracy b"},
|
||||
"half coversed cosine of value a, within accuracy b"},
|
||||
{"hacoversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hacoversin},
|
||||
"half coversed sine of value a within accuracy b"},
|
||||
"half coversed sine of value a, within accuracy b"},
|
||||
{"hash", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hash},
|
||||
"return non-negative hash value for one or\n"
|
||||
"\t\t\tmore values"},
|
||||
{"havercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_havercos},
|
||||
"half versed cosine of value a within accuracy b"},
|
||||
"half versed cosine of value a, within accuracy b"},
|
||||
{"haversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_haversin},
|
||||
"half versed sine of value a within accuracy b"},
|
||||
"half versed sine of value a, within accuracy b"},
|
||||
{"head", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_head},
|
||||
"return list of specified number at head of a list"},
|
||||
{"highbit", 1, 1, 0, OP_HIGHBIT, {.null = NULL}, {.null = NULL},
|
||||
@@ -12572,7 +12712,7 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"hnrmod", 4, 4, 0, OP_NOP, {.numfunc_4 = f_hnrmod}, {.null = NULL},
|
||||
"v mod h*2^n+r, h>0, n>0, r = -1, 0 or 1"},
|
||||
{"hypot", 2, 3, FE, OP_NOP, {.numfunc_3 = qhypot}, {.null = NULL},
|
||||
"hypotenuse of right triangle within accuracy c"},
|
||||
"hypotenuse of right triangle, within accuracy c"},
|
||||
{"ilog", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_ilog},
|
||||
"integral log of a to integral base b"},
|
||||
{"ilog10", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ilog10},
|
||||
@@ -12695,13 +12835,13 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"list", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_list},
|
||||
"create list of specified values"},
|
||||
{"ln", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ln},
|
||||
"natural logarithm of value a within accuracy b"},
|
||||
"natural logarithm of value a, within accuracy b"},
|
||||
{"log", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_log},
|
||||
"base 10 logarithm of value a within accuracy b"},
|
||||
"base 10 logarithm of value a, within accuracy b"},
|
||||
{"log2", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_log2},
|
||||
"base 2 logarithm of value a within accuracy b"},
|
||||
"base 2 logarithm of value a, within accuracy b"},
|
||||
{"logn", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_logn},
|
||||
"base b logarithm of value a within accuracy c"},
|
||||
"base b logarithm of value a, within accuracy c"},
|
||||
{"lowbit", 1, 1, 0, OP_LOWBIT, {.null = NULL}, {.null = NULL},
|
||||
"low bit number in base 2 representation"},
|
||||
{"ltol", 1, 2, FE, OP_NOP, {.numfunc_2 = f_legtoleg}, {.null = NULL},
|
||||
@@ -12766,7 +12906,7 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"pfact", 1, 1, 0, OP_NOP, {.numfunc_1 = qpfact}, {.null = NULL},
|
||||
"product of primes up till number"},
|
||||
{"pi", 0, 1, FE, OP_NOP, {.numfunc_1 = qpi}, {.null = NULL},
|
||||
"value of pi accurate to within epsilon"},
|
||||
"value of pi, within accuracy a"},
|
||||
{"pix", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_pix}, {.null = NULL},
|
||||
"number of primes < = a < 2^32, return b if error"},
|
||||
{"places", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_places},
|
||||
@@ -12783,7 +12923,7 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"popcnt", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_popcnt}, {.null = NULL},
|
||||
"number of bits in a that match b (or 1)"},
|
||||
{"power", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_power},
|
||||
"value a raised to the power b within accuracy c"},
|
||||
"value a raised to the power b, within accuracy c"},
|
||||
{"prevcand", 1, 5, 0, OP_NOP, {.numfunc_cnt = f_prevcand}, {.null = NULL},
|
||||
"largest value = = d mod e < a, ptest(a,b,c) true"},
|
||||
{"prevprime", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_pprime}, {.null = NULL},
|
||||
@@ -12840,7 +12980,7 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"rm", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_rm},
|
||||
"remove file(s), -f turns off no-such-file errors"},
|
||||
{"root", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_root},
|
||||
"value a taken to the b'th root within accuracy c"},
|
||||
"value a taken to the b'th root, within accuracy c"},
|
||||
{"round", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_round},
|
||||
"round value a to b number of decimal places"},
|
||||
{"rsearch", 2, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_rsearch},
|
||||
@@ -12862,9 +13002,9 @@ STATIC CONST struct builtin builtins[] = {
|
||||
"search matrix or list for value b starting\n"
|
||||
"\t\t\tat index c"},
|
||||
{"sec", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sec},
|
||||
"secant of a within accuracy b"},
|
||||
"secant of a, within accuracy b"},
|
||||
{"sech", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sech},
|
||||
"hyperbolic secant of a within accuracy b"},
|
||||
"hyperbolic secant of a, within accuracy b"},
|
||||
{"seed", 0, 0, 0, OP_NOP, {.numfunc_0 = f_seed}, {.null = NULL},
|
||||
"return a 64 bit seed for a pseudo-random generator"},
|
||||
{"segment", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_segment},
|
||||
@@ -12878,9 +13018,9 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"sha1", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sha1},
|
||||
"Secure Hash Algorithm (SHS-1 FIPS Pub 180-1)"},
|
||||
{"sin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sin},
|
||||
"sine of value a within accuracy b"},
|
||||
"sine of value a, within accuracy b"},
|
||||
{"sinh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sinh},
|
||||
"hyperbolic sine of a within accuracy b"},
|
||||
"hyperbolic sine of a, within accuracy b"},
|
||||
{"size", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_size},
|
||||
"total number of elements in value"},
|
||||
{"sizeof", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_sizeof},
|
||||
@@ -12890,7 +13030,7 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"sort", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_sort},
|
||||
"sort a copy of a matrix or list"},
|
||||
{"sqrt", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sqrt},
|
||||
"square root of value a within accuracy b"},
|
||||
"square root of value a, within accuracy b"},
|
||||
{"srand", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_srand},
|
||||
"seed the rand() function"},
|
||||
{"srandom", 0, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_srandom},
|
||||
@@ -12944,9 +13084,9 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"tail", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_tail},
|
||||
"retain list of specified number at tail of list"},
|
||||
{"tan", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_tan},
|
||||
"tangent of a within accuracy b"},
|
||||
"tangent of a, within accuracy b"},
|
||||
{"tanh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_tanh},
|
||||
"hyperbolic tangent of a within accuracy b"},
|
||||
"hyperbolic tangent of a, within accuracy b"},
|
||||
{"test", 1, 1, 0, OP_TEST, {.null = NULL}, {.null = NULL},
|
||||
"test that value is nonzero"},
|
||||
{"time", 0, 0, 0, OP_NOP, {.numfunc_0 = f_time}, {.null = NULL},
|
||||
@@ -12958,9 +13098,9 @@ STATIC CONST struct builtin builtins[] = {
|
||||
{"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"},
|
||||
"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"},
|
||||
"versed sine of value a, within accuracy b"},
|
||||
{"version", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_version},
|
||||
"calc version string"},
|
||||
{"xor", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_xor},
|
||||
|
@@ -200,23 +200,24 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
# to keep this list in nice sorted order.
|
||||
#
|
||||
DETAIL_HELP= abs access acos acosh acot acoth acovercos acoversin \
|
||||
acsc acsch address agd ahacovercos ahacoversin ahavercos ahaversin \
|
||||
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
|
||||
atanh avercos aversin 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 covercos \
|
||||
coversin cp csc csch ctime d2dm d2dms d2g d2r delete den dereference \
|
||||
det digit digits display dms2d dp epsilon errcount errmax errno error \
|
||||
errsym 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 hacovercos hacoversin hash havercos haversin 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 \
|
||||
acrd acsc acsch address aexcsc aexsec agd ahacovercos ahacoversin \
|
||||
ahavercos ahaversin append appr arg argv arrow asec asech asin asinh \
|
||||
assign atan atan2 atanh avercos aversin 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 covercos coversin cp crd csc csch ctime d2dm d2dms d2g d2r \
|
||||
delete den dereference det digit digits display dms2d dp epsilon \
|
||||
errcount errmax errno error errsym estr euler eval excsc exp exsec \
|
||||
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 hacovercos \
|
||||
hacoversin hash havercos haversin 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 \
|
||||
|
13
help/acos
13
help/acos
@@ -54,8 +54,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/acot
13
help/acot
@@ -54,8 +54,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -53,8 +53,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -53,8 +53,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
88
help/acrd
Normal file
88
help/acrd
Normal file
@@ -0,0 +1,88 @@
|
||||
NAME
|
||||
acrd - inverse trigonometric chord of a unit circle
|
||||
|
||||
SYNOPSIS
|
||||
acrd(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Calculate angle of unit circle chord of length x to a multiple of eps with error less in
|
||||
absolute value than .75 * eps.
|
||||
|
||||
A chord of a circle is a straight line segment whose endpoints lie on a arc of a circle.
|
||||
A chord extended infinitely on both directions into a line would produce a secant line.
|
||||
|
||||
This function is sometimes called chord, is equivalent to:
|
||||
|
||||
acrd(x) = 2 * asin(x / 2)
|
||||
|
||||
EXAMPLE
|
||||
; print acrd(1/2), acrd(5/7), acrd(42/7)
|
||||
0.50536051028415730696 0.73041444258073348124 3.14159265358979323846-3.52549434807817210092i
|
||||
|
||||
; print acrd(1, 1e-5), acrd(1, 1e-10), acrd(1, 1e-15), acrd(1, 1e-20)
|
||||
1.0472 1.0471975512 1.047197551196598 1.04719755119659774616
|
||||
|
||||
; print acrd(2 + 3i, 1e-5), acrd(2 + 3i, 1e-10)
|
||||
1.0472+2.63392i 1.0471975512+2.6339157938i
|
||||
|
||||
; pi = pi(1e-20)
|
||||
; print acrd(pi/6), acrd(pi/2), acrd(pi)
|
||||
0.52977229404847186194 1.80667822153302569472 3.14159265358979323846-2.04645495709510115864i
|
||||
|
||||
LIMITS
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qacrd(NUMBER *x, NUMBER *eps)
|
||||
COMPLEX *c_acrd(COMPLEX *x, NUMBER *eps)
|
||||
|
||||
SEE ALSO
|
||||
sin, cos, tan, cot, sec, csc
|
||||
asin, acos, atan, acot, asec, acsc
|
||||
coversin, vercos, covercos
|
||||
aversin, acoversin, avercos, acovercos
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2023/10/02 16:49:42
|
||||
## File existed as early as: 2023
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
13
help/acsc
13
help/acsc
@@ -57,8 +57,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/aexcsc
13
help/aexcsc
@@ -59,8 +59,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/aexsec
13
help/aexsec
@@ -56,8 +56,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -56,8 +56,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -56,8 +56,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -57,8 +57,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -57,8 +57,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/asec
13
help/asec
@@ -54,8 +54,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/asin
13
help/asin
@@ -54,8 +54,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/atan
13
help/atan
@@ -54,8 +54,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/avercos
13
help/avercos
@@ -54,8 +54,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/aversin
13
help/aversin
@@ -54,8 +54,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/cos
13
help/cos
@@ -43,8 +43,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/cot
13
help/cot
@@ -49,8 +49,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -47,8 +47,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -47,8 +47,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
88
help/crd
Normal file
88
help/crd
Normal file
@@ -0,0 +1,88 @@
|
||||
NAME
|
||||
crd - trigonometric chord of a unit circle
|
||||
|
||||
SYNOPSIS
|
||||
crd(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Calculate length of unit circle chord with angle x to a multiple of eps with error less in
|
||||
absolute value than .75 * eps.
|
||||
|
||||
A chord of a circle is a straight line segment whose endpoints lie on a arc of a circle.
|
||||
A chord extended infinitely on both directions into a line would produce a secant line.
|
||||
|
||||
This function is sometimes called chord, is equivalent to:
|
||||
|
||||
crd(x) = 2 * sin(x / 2)
|
||||
|
||||
EXAMPLE
|
||||
; print crd(1/2), crd(5/7), crd(42/7)
|
||||
0.4948079185090458592 0.6991976162706840944 0.2822400161197344442
|
||||
|
||||
; print crd(1, 1e-5), crd(1, 1e-10), crd(1, 1e-15), crd(1, 1e-20)
|
||||
0.95886 0.9588510772 0.958851077208406 0.95885107720840600054
|
||||
|
||||
; print crd(2 + 3i, 1e-5), crd(2 + 3i, 1e-10)
|
||||
3.95896+2.3009i 3.9589688712+2.3009091988i
|
||||
|
||||
; pi = pi(1e-20)
|
||||
; print crd(pi/6), crd(pi/2), crd(pi)
|
||||
0.5176380902050415247 1.4142135623730950488 2
|
||||
|
||||
LIMITS
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcrd(NUMBER *x, NUMBER *eps)
|
||||
COMPLEX *c_crd(COMPLEX *x, NUMBER *eps)
|
||||
|
||||
SEE ALSO
|
||||
sin, cos, tan, cot, sec, csc
|
||||
asin, acos, atan, acot, asec, acsc
|
||||
coversin, vercos, covercos
|
||||
aversin, acoversin, avercos, acovercos
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2023/10/02 16:49:42
|
||||
## File existed as early as: 2023
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
13
help/csc
13
help/csc
@@ -49,8 +49,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/excsc
13
help/excsc
@@ -49,8 +49,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/exsec
13
help/exsec
@@ -49,8 +49,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -47,8 +47,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -47,8 +47,21 @@ SEE ALSO
|
||||
haversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -47,8 +47,21 @@ SEE ALSO
|
||||
haversin, hacoversin, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
@@ -47,8 +47,21 @@ SEE ALSO
|
||||
hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/sec
13
help/sec
@@ -49,8 +49,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/sin
13
help/sin
@@ -43,8 +43,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/tan
13
help/tan
@@ -49,8 +49,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 1999,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
14
help/vercos
14
help/vercos
@@ -47,8 +47,22 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
13
help/versin
13
help/versin
@@ -47,8 +47,21 @@ SEE ALSO
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
epsilon
|
||||
|
||||
EXTERNAL RESOURCES
|
||||
For general information on trigonometric functions, see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
|
||||
https://en.wikipedia.org/wiki/Versine
|
||||
https://en.wikipedia.org/wiki/Exsecant
|
||||
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||
https://en.wikipedia.org/wiki/Chord_(geometry)
|
||||
https://en.wikipedia.org/wiki/Secant_line
|
||||
https://en.wikipedia.org/wiki/Hartley_transform#cas
|
||||
https://en.wikipedia.org/wiki/Cis_(mathematics)
|
||||
|
||||
## Copyright (C) 2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
3
qmath.h
3
qmath.h
@@ -256,6 +256,9 @@ E_FUNC NUMBER *qaexsec(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qexcsc(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qaexcsc_or_NULL(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qaexcsc(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcrd(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacrd_or_NULL(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacrd(NUMBER *q, NUMBER *epsilon);
|
||||
|
||||
/*
|
||||
* pseudo-seed generator
|
||||
|
156
qtrans.c
156
qtrans.c
@@ -3467,3 +3467,159 @@ qaexcsc(NUMBER *q, NUMBER *epsilon)
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qcrd - trigonometric chord of a unit circle
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* crd(x) = 2 * sin(x / 2)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qcrd(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qdiv2; /* q/2 */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
qdiv2 = qdivi(q, 2);
|
||||
qtmp = qsin(qdiv2, epsilon);
|
||||
qfree(qdiv2);
|
||||
res = qmuli(qtmp, 2);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qacrd_or_NULL - return NULL or non-complex inverse trigonometric chord of a unit circle
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* acrd(x) = 2 * asin(x / 2)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*
|
||||
* returns:
|
||||
* != NULL ==> real value result of trig function on q with error epsilon,
|
||||
* NULL ==> trig function value cannot be expressed as a NUMBER
|
||||
*
|
||||
* NOTE: If this function returns NULL, consider calling the equivalent
|
||||
* COMPLEX function from comfunc.c. See the help file for the
|
||||
* related builtin for details.
|
||||
*/
|
||||
NUMBER *
|
||||
qacrd_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qdiv2; /* q/2 */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
qdiv2 = qdivi(q, 2);
|
||||
qtmp = qasin(qdiv2, epsilon);
|
||||
qfree(qdiv2);
|
||||
if (qtmp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
res = qmuli(qtmp, 2);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qacrd - non-complex inverse trigonometric chord of a unit circle
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* acrd(x) = 2 * asin(x / 2)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qacrd(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
res = qacrd_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse sine for acrd");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user