add cmappr() and missing complex tan, cot, sec, csc in liblcac

Added complex multiple approximation function to commath.c so
that users of libcalc may directly round complex number to
nearest multiple of a given real number:

    E_FUNC COMPLEX *cmappr(COMPLEX *c, NUMBER *e, long rnd, bool cfree);

For example:

    COMPLEX *c;             /* complex number to round to nearest epsilon */
    NUMBER *eps;            /* epsilon rounding precision */
    COMPLEX *res;           /* c rounded to nearest epsilon */
    long rnd = 24L;         /* a common rounding mode */
    bool ok_to_free;        /* true ==> free c, false ==> do not free c */

    ...

    res = cmappr(c, eps, ok_to_free);

The complex trigonometric functions tan, cot, sec, csc were implemented
in func.c as calls to complex sin and complex cos.  We added the
direct calls to comfunc.c so that users of libcalc may
call them directly:

    E_FUNC COMPLEX *c_tan(COMPLEX *c, NUMBER *eps);
    E_FUNC COMPLEX *c_cot(COMPLEX *c, NUMBER *eps);
    E_FUNC COMPLEX *c_sec(COMPLEX *c, NUMBER *eps);
    E_FUNC COMPLEX *c_cot(COMPLEX *c, NUMBER *eps);
This commit is contained in:
Landon Curt Noll
2023-09-10 22:54:50 -07:00
parent a722b5cca7
commit bf730f5518
11 changed files with 559 additions and 106 deletions

View File

@@ -14,6 +14,10 @@ DESCRIPTION
Calculate the cotangent of x to a multiple of eps, with error less
in absolute value than .75 * eps.
This function is equivalent to:
cot(x) = cos(x) / sin(x)
EXAMPLE
; print cot(1, 1e-5), cot(1, 1e-10), cot(1, 1e-15), cot(1, 1e-20)
0.64209 0.6420926159 0.642092615934331 0.64209261593433070301
@@ -33,6 +37,7 @@ LIMITS
LINK LIBRARY
NUMBER *qcot(NUMBER *x, NUMBER *eps)
COMPLEX *c_cot(COMPLEX *c, NUMBER *eps)
SEE ALSO
sin, cos, tan, sec, csc

View File

@@ -14,6 +14,10 @@ DESCRIPTION
Calculate the cosecant of x to a multiple of eps, with error less
in absolute value than .75 * eps.
This function is equivalent to:
csc(x) = 1 / sin(x)
EXAMPLE
; print csc(1, 1e-5), csc(1, 1e-10), csc(1, 1e-15), csc(1, 1e-20)
1.1884 1.1883951058 1.188395105778121 1.18839510577812121626
@@ -33,6 +37,7 @@ LIMITS
LINK LIBRARY
NUMBER *qcsc(NUMBER *x, NUMBER *eps)
COMPLEX *c_csc(COMPLEX *c, NUMBER *eps)
SEE ALSO
sin, cos, tan, cot, sec

View File

@@ -14,6 +14,10 @@ DESCRIPTION
Calculate the secant of x to a multiple of eps, with error less
in absolute value than .75 * eps.
This function is equivalent to:
sec(x) = 1 / cos(x)
EXAMPLE
; print sec(1, 1e-5), sec(1, 1e-10), sec(1, 1e-15), sec(1, 1e-20)
1.85082 1.8508157177 1.850815717680926 1.85081571768092561791
@@ -33,6 +37,7 @@ LIMITS
LINK LIBRARY
NUMBER *qsec(NUMBER *x, NUMBER *eps)
COMPLEX *c_sec(COMPLEX *c, NUMBER *eps)
SEE ALSO
sin, cos, tan, cot, csc

View File

@@ -14,6 +14,10 @@ DESCRIPTION
Calculate the tangent of x to a multiple of eps, with error less
in absolute value than .75 * eps.
This function is equivalent to:
tan(x) = sin(x) / cos(x)
EXAMPLE
; print tan(1, 1e-5), tan(1, 1e-10), tan(1, 1e-15), tan(1, 1e-20)
1.55741 1.5574077247 1.557407724654902 1.55740772465490223051
@@ -33,6 +37,7 @@ LIMITS
LINK LIBRARY
NUMBER *qtan(NUMBER *x, NUMBER *eps)
COMPLEX *c_tan(COMPLEX *c, NUMBER *eps)
SEE ALSO
sin, cos, cot, sec, csc