add logn and error checking for invalue eps and epsilon values

Add new logn(x, n [,eps]) builtin to compute logarithms to base n.

Verify that eps arguments (error tolerance arguments that override
the default epsilon value) to builtin functions have proper values.
Previously the eps argument had little to no value checks for
many builtin functions.

Document in help files for builtin functions that take eps arguments,
the LIMIT range for such eps values.
This commit is contained in:
Landon Curt Noll
2023-08-31 22:33:41 -07:00
parent 4787199462
commit 1c839dfede
55 changed files with 1092 additions and 199 deletions

10
CHANGES
View File

@@ -89,6 +89,16 @@ The following are the changes from calc version 2.14.3.5 to date:
Setting an invalid epsilon via the epsilon(value) or confiv("epsilon", Setting an invalid epsilon via the epsilon(value) or confiv("epsilon",
value) triggers an error. The epsilon value must be: 0 < epsilon < 1. value) triggers an error. The epsilon value must be: 0 < epsilon < 1.
Add new logn(x, n [,eps]) builtin to compute logarithms to base n.
Verify that eps arguments (error tolerance arguments that override
the default epsilon value) to builtin functions have proper values.
Previously the eps argument had little to no value checks for
many builtin functions.
Document in help files for builtin functions that take eps arguments,
the LIMIT range for such eps values.
The following are the changes from calc version 2.14.3.4 to 2.14.3.5: The following are the changes from calc version 2.14.3.4 to 2.14.3.5:

View File

@@ -3007,8 +3007,6 @@ define test_2600()
strcat(str(tnum++), ': log2(2^500) == 500')); strcat(str(tnum++), ': log2(2^500) == 500'));
vrfy(log2(1/2^23209) == -23209, vrfy(log2(1/2^23209) == -23209,
strcat(str(tnum++), ': log2(1/2^23209) == -23209')); strcat(str(tnum++), ': log2(1/2^23209) == -23209'));
vrfy(isint(log2(1/2^23209)),
strcat(str(tnum++), ': isint(log2(1/2^23209))'));
vrfy(round(log2(127),10) == 6.9886846868, vrfy(round(log2(127),10) == 6.9886846868,
strcat(str(tnum++), strcat(str(tnum++),
': round(log2(127),10) == 6.9886846868')); ': round(log2(127),10) == 6.9886846868'));
@@ -3036,6 +3034,48 @@ define test_2600()
vrfy(round(log2(17+0.3i),10) == 4.0876874474+0.0254566819i, vrfy(round(log2(17+0.3i),10) == 4.0876874474+0.0254566819i,
strcat(str(tnum++), strcat(str(tnum++),
': round(log2(17+0.3i),10) == 4.0876874474+0.0254566819i')); ': round(log2(17+0.3i),10) == 4.0876874474+0.0254566819i'));
vrfy(logn(2, 2) == 1,
strcat(str(tnum++), ': logn(2, 2) == 1'));
vrfy(logn(4, 2) == 2,
strcat(str(tnum++), ': logn(4, 2) == 2'));
vrfy(logn(1024, 2) == 10,
strcat(str(tnum++), ': logn(1024, 2) == 10'));
vrfy(logn(2^500, 2) == 500,
strcat(str(tnum++), ': logn(2^500, 2) == 500'));
vrfy(logn(1/2^23209, 2) == -23209,
strcat(str(tnum++), ': logn(1/2^23209, 2) == -23209'));
vrfy(round(logn(127, 1/13),10) == -1.8886092516,
strcat(str(tnum++),
': round(logn(127, 1/13),10) == -1.8886092516'));
vrfy(round(logn(23209, sqrt(3)),10) == 18.299987206,
strcat(str(tnum++),
': round(logn(23209, sqrt(3)),10) == 18.299987206'));
vrfy(round(logn(2, 42),10) == 0.1854490234,
strcat(str(tnum++),
': round(logn(2, 42),10) == 0.1854490234'));
vrfy(round(logn(1024, 42),10) == 1.8544902342,
strcat(str(tnum++),
': round(logn(1024, 42),10) == 1.8544902342'));
vrfy(round(logn(2^500, 42),10) == 92.7245117077,
strcat(str(tnum++),
': round(logn(2^500, 42),10) == 92.7245117077'));
vrfy(round(logn(1/2^23209, 42),10) == -4304.0863844473,
strcat(str(tnum++),
': round(logn(1/2^23209, 42),10) == -4304.0863844473'));
vrfy(logn(-1, 1i) == 2,
strcat(str(tnum++), ': logn(-1, 1i) == 2'));
vrfy(round(logn(22+3i, 3i),10) == 0.984899142-1.2848465788i,
strcat(str(tnum++),
': round(logn(22+3i, 3i),10) == 0.984899142-1.2848465788i'));
vrfy(round(logn(22.2+3.3i, -4-3.3i),10) == 0.5456929478+0.9025545623i,
strcat(str(tnum++),
': round(logn(22.2+3.3i, -4-3.3i),10) == 0.5456929478+0.9025545623i'));
vrfy(round(logn(-127, 7),10) == 2.4894197139+1.6144592571i,
strcat(str(tnum++),
': round(logn(-127, 7),10) == 2.4894197139+1.6144592571i'));
vrfy(round(logn(-127, 7i),10) == 2.2963271277-0.2392040372i,
strcat(str(tnum++),
': round(logn(-127, 7i),10) == 2.2963271277-0.2392040372i'));
epsilon(i),; epsilon(i),;
print tnum++: ': epsilon(i),;'; print tnum++: ': epsilon(i),;';

View File

@@ -545,3 +545,8 @@ E_HM2H2 Invalid rounding arg 4 for hm2h
E_LOG2_1 Bad epsilon argument for log2 E_LOG2_1 Bad epsilon argument for log2
E_LOG2_2 Non-numeric first argument for log2 E_LOG2_2 Non-numeric first argument for log2
E_LOG2_3 Cannot calculate log2 for this value E_LOG2_3 Cannot calculate log2 for this value
E_LOGN_1 Bad epsilon argument for logn
E_LOGN_2 Non-numeric first argument for logn
E_LOGN_3 Cannot calculate logn for this value
E_LOGN_4 Cannot calculate logn for this log base
E_LOGN_5 Non-numeric second argument for logn

823
func.c

File diff suppressed because it is too large Load Diff

View File

@@ -36,7 +36,7 @@ EXAMPLE
5 6.40312 6.4031242374 5 6.40312 6.4031242374
LIMITS LIMITS
none when x is complex, eps != 0
LINK LIBRARY LINK LIBRARY
NUMBER *qqabs(NUMBER *x) NUMBER *qqabs(NUMBER *x)
@@ -44,7 +44,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
cmp, epsilon, hypot, norm, near, obj cmp, epsilon, hypot, norm, near, obj
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real, -1 <= x <= 1 x real, -1 <= x <= 1
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
1.0472 1.0471975512 1.047197551196598 1.04719755119659774615 1.0472 1.0471975512 1.047197551196598 1.04719755119659774615
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qacos(NUMBER *x, NUMBER *eps) NUMBER *qacos(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asin, atan, asec, acsc, acot, epsilon asin, atan, asec, acsc, acot, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real, x >= 1 x real, x >= 1
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return nonnegative real return nonnegative real
@@ -24,7 +24,7 @@ EXAMPLE
1.31696 1.3169578969 1.316957896924817 1.31695789692481670862 1.31696 1.3169578969 1.316957896924817 1.31695789692481670862
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qacosh(NUMBER *x, NUMBER *eps) NUMBER *qacosh(NUMBER *x, NUMBER *eps)
@@ -32,7 +32,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asinh, atanh, asech, acsch, acoth, epsilon asinh, atanh, asech, acsch, acoth, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
0.46365 0.463647609 0.463647609000806 0.46364760900080611621 0.46365 0.463647609 0.463647609000806 0.46364760900080611621
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qacot(NUMBER *x, NUMBER *eps) NUMBER *qacot(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asin, acos, atan, asec, acsc, epsilon asin, acos, atan, asec, acsc, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real, with abs(x) > 1 x real, with abs(x) > 1
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -23,7 +23,7 @@ EXAMPLE
0.54931 0.5493061443 0.549306144334055 0.5493061443340548457 0.54931 0.5493061443 0.549306144334055 0.5493061443340548457
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qacoth(NUMBER *x, NUMBER *eps) NUMBER *qacoth(NUMBER *x, NUMBER *eps)
@@ -31,7 +31,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asinh, acosh, atanh, asech, acsch, epsilon asinh, acosh, atanh, asech, acsch, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real, with absolute value >= 1 x real, with absolute value >= 1
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
0.5236 0.5235987756 0.523598775598299 0.52359877559829887308 0.5236 0.5235987756 0.523598775598299 0.52359877559829887308
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qacsc(NUMBER *x, NUMBER *eps) NUMBER *qacsc(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asin, acos, atan, asec, acot, epsilon asin, acos, atan, asec, acot, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real x nonzero real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -23,7 +23,7 @@ EXAMPLE
0.48121 0.4812118251 0.481211825059603 0.4812118250596034475 0.48121 0.4812118251 0.481211825059603 0.4812118250596034475
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qacsch(NUMBER *x, NUMBER *eps) NUMBER *qacsch(NUMBER *x, NUMBER *eps)
@@ -31,7 +31,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asinh, acosh, atanh, asech, acoth, epsilon asinh, acosh, atanh, asech, acoth, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -24,7 +24,7 @@ EXAMPLE
56.3099 135 -135 56.3099 135 -135
LIMITS LIMITS
none eps != 0
LINK LIBRARY LINK LIBRARY
none none

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real, with absolute value >= 1 x real, with absolute value >= 1
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
1.0472 1.0471975512 1.047197551196598 1.04719755119659774615 1.0472 1.0471975512 1.047197551196598 1.04719755119659774615
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qasec(NUMBER *x, NUMBER *eps) NUMBER *qasec(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asin, acos, atan, acsc, acot, epsilon asin, acos, atan, acsc, acot, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real, 0 < x <= 1 x real, 0 < x <= 1
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -23,7 +23,7 @@ EXAMPLE
1.31696 1.3169578969 1.316957896924817 1.31695789692481670862 1.31696 1.3169578969 1.316957896924817 1.31695789692481670862
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qasech(NUMBER *x, NUMBER *eps) NUMBER *qasech(NUMBER *x, NUMBER *eps)
@@ -31,7 +31,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asinh, acosh, atanh, acsch, acoth, epsilon asinh, acosh, atanh, acsch, acoth, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real, -1 <= x <= 1 x real, -1 <= x <= 1
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
0.5236 0.5235987756 0.523598775598299 0.52359877559829887308 0.5236 0.5235987756 0.523598775598299 0.52359877559829887308
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qasin(NUMBER *q, NUMBER *epsilon) NUMBER *qasin(NUMBER *q, NUMBER *epsilon)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
acos, atan, asec, acsc, acot, epsilon acos, atan, asec, acsc, acot, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -23,7 +23,7 @@ EXAMPLE
1.44363 1.4436354752 1.44363547517881 1.44363547517881034249 1.44363 1.4436354752 1.44363547517881 1.44363547517881034249
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qasinh(NUMBER *x, NUMBER *eps) NUMBER *qasinh(NUMBER *x, NUMBER *eps)
@@ -31,7 +31,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
acosh, atanh, asech, acsch, acoth, epsilon acosh, atanh, asech, acsch, acoth, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
1.10715 1.1071487178 1.107148717794091 1.10714871779409050302 1.10715 1.1071487178 1.107148717794091 1.10714871779409050302
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qatan(NUMBER *x, NUMBER *eps) NUMBER *qatan(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asin, acos, asec, acsc, acot, epsilon asin, acos, asec, acsc, acot, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -28,7 +28,7 @@ EXAMPLE
0 ~0.52359877559829887307 ~0.31038740713235146535 0 ~0.52359877559829887307 ~0.31038740713235146535
LIMITS LIMITS
none eps != 0
LINK LIBRARY LINK LIBRARY
NUMBER *qatan2(NUMBER *y, *x, *acc) NUMBER *qatan2(NUMBER *y, *x, *acc)
@@ -36,7 +36,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
acos, asin, atan, cos, epsilon, sin, tan acos, asin, atan, cos, epsilon, sin, tan
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -23,7 +23,7 @@ EXAMPLE
0.54931 0.5493061443 0.549306144334055 0.5493061443340548457 0.54931 0.5493061443 0.549306144334055 0.5493061443340548457
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qatanh(NUMBER *x, NUMBER *eps) NUMBER *qatanh(NUMBER *x, NUMBER *eps)
@@ -31,7 +31,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
asinh, acosh, asech, acsch, acoth, epsilon asinh, acosh, asech, acsch, acoth, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -1034,7 +1034,7 @@ EXAMPLE
3.141592653589793238462643383279502884197169399375105820974944592307816406 3.141592653589793238462643383279502884197169399375105820974944592307816406
LIMITS LIMITS
none 0 < epsilon < 1
LINK LIBRARY LINK LIBRARY
none none

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return number return number
@@ -26,7 +26,7 @@ EXAMPLE
0.5 0 -1 0.5 0 -1
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qcos(NUMBER *x, NUMBER *eps) NUMBER *qcos(NUMBER *x, NUMBER *eps)
@@ -35,7 +35,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sin, tan, sec, csc, cot, epsilon sin, tan, sec, csc, cot, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,13 +6,13 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
DESCRIPTION DESCRIPTION
Calculate the cosh of x to the nearest or next to nearest multiple of Calculate the cosh of x to the nearest or next to nearest multiple of
epsilon, with absolute error less than .75 * abs(eps). epsilon, with absolute error less than .75 * eps.
cosh(x) = (exp(x) + exp(-x))/2 cosh(x) = (exp(x) + exp(-x))/2
@@ -21,7 +21,7 @@ EXAMPLE
1.54308 1.5430806348 1.543080634815244 1.54308063481524377848 1.54308 1.5430806348 1.543080634815244 1.54308063481524377848
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qcosh(NUMBER *x, NUMBER *eps) NUMBER *qcosh(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sinh, tanh, sech, csch, coth, epsilon sinh, tanh, sech, csch, coth, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real x nonzero real
acc nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -19,7 +19,7 @@ EXAMPLE
0.64209 0.6420926159 0.642092615934331 0.64209261593433070301 0.64209 0.6420926159 0.642092615934331 0.64209261593433070301
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qcot(NUMBER *x, NUMBER *eps) NUMBER *qcot(NUMBER *x, NUMBER *eps)
@@ -27,7 +27,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sin, cos, tan, sec, csc, epsilon sin, cos, tan, sec, csc, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real x nonzero real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
1.31304 1.3130352855 1.313035285499331 1.31303528549933130364 1.31304 1.3130352855 1.313035285499331 1.31303528549933130364
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qcoth(NUMBER *x, NUMBER *eps) NUMBER *qcoth(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sinh, cosh, tanh, sech, csch, epsilon sinh, cosh, tanh, sech, csch, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -19,7 +19,7 @@ EXAMPLE
1.1884 1.1883951058 1.188395105778121 1.18839510577812121626 1.1884 1.1883951058 1.188395105778121 1.18839510577812121626
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qcsc(NUMBER *x, NUMBER *eps) NUMBER *qcsc(NUMBER *x, NUMBER *eps)
@@ -27,7 +27,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sin, cos, tan, sec, cot, epsilon sin, cos, tan, sec, cot, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real x nonzero real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -21,7 +21,7 @@ EXAMPLE
0.85092 0.8509181282 0.850918128239322 0.85091812823932154513 0.85092 0.8509181282 0.850918128239322 0.85091812823932154513
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qcsch(NUMBER *x, NUMBER *eps) NUMBER *qcsch(NUMBER *x, NUMBER *eps)
@@ -29,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sinh, cosh, tanh, sech, coth, epsilon sinh, cosh, tanh, sech, coth, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps eps value is ignored
return number return number
@@ -32,7 +32,7 @@ SEE ALSO
d2r, r2d, g2r, r2g, g2d, d2r, r2d, g2r, r2g, g2d,
sin, cos, tan, sec, csc, cot, epsilon sin, cos, tan, sec, csc, cot, epsilon
## Copyright (C) 2021 Landon Curt Noll ## Copyright (C) 2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return number return number
@@ -27,7 +27,7 @@ EXAMPLE
0.5 0.5 1 0.5 0.5 1
LIMITS LIMITS
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qpidiv180(NUMBER *eps) NUMBER *qpidiv180(NUMBER *eps)
@@ -36,7 +36,7 @@ SEE ALSO
r2d, g2r, r2g, d2g, g2d, r2d, g2r, r2g, d2g, g2d,
sin, cos, tan, sec, csc, cot, epsilon sin, cos, tan, sec, csc, cot, epsilon
## Copyright (C) 2021 Landon Curt Noll ## Copyright (C) 2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -5,7 +5,7 @@ SYNOPSIS
epsilon([eps]) epsilon([eps])
TYPES TYPES
eps real number greater than 0 and less than 1 eps 0 < real < 1, defaults to epsilon()
return real number greater than 0 and less than 1 return real number greater than 0 and less than 1
@@ -72,7 +72,7 @@ EXAMPLE
3.141592653589793238462643383279502884197169399375105820974944592307816406 3.141592653589793238462643383279502884197169399375105820974944592307816406
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
void setepsilon(NUMBER *eps) void setepsilon(NUMBER *eps)
@@ -81,7 +81,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
config, display, fprintf, printf, strprintf config, display, fprintf, printf, strprintf
## Copyright (C) 1999,2018,2021 Landon Curt Noll ## Copyright (C) 1999,2018,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real or complex x real or complex
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real or complex return real or complex
@@ -32,6 +32,7 @@ EXAMPLE
LIMITS LIMITS
x < 693093 x < 693093
0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qexp(NUMBER *x, NUMBER *eps) NUMBER *qexp(NUMBER *x, NUMBER *eps)
@@ -40,7 +41,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
ln, cosh, sinh, tanh ln, cosh, sinh, tanh
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps eps value is ignored
return number return number
@@ -32,7 +32,7 @@ SEE ALSO
d2r, r2d, g2r, r2g, d2g, d2r, r2d, g2r, r2g, d2g,
sin, cos, tan, sec, csc, cot, epsilon sin, cos, tan, sec, csc, cot, epsilon
## Copyright (C) 2021 Landon Curt Noll ## Copyright (C) 2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return number return number
@@ -27,7 +27,7 @@ EXAMPLE
0.5 0.5 1 0.5 0.5 1
LIMITS LIMITS
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qpidiv200(NUMBER *eps) NUMBER *qpidiv200(NUMBER *eps)
@@ -36,7 +36,7 @@ SEE ALSO
d2r, r2d, r2g, d2g, g2d, d2r, r2d, r2g, d2g, g2d,
sin, cos, tan, sec, csc, cot, epsilon sin, cos, tan, sec, csc, cot, epsilon
## Copyright (C) 2021 Landon Curt Noll ## Copyright (C) 2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
z number (real or complex) z number (real or complex)
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return number or "Log of zero or infinity" error value return number or "Log of zero or infinity" error value
@@ -42,7 +42,7 @@ EXAMPLE
1.42291+0.22751i 1.4229114625+0.2275106584i 1.42291+0.22751i 1.4229114625+0.2275106584i
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
COMPLEX *c_gd(COMPLEX *x, NUMBER *eps) COMPLEX *c_gd(COMPLEX *x, NUMBER *eps)
@@ -50,7 +50,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
agd, exp, ln, sin, sinh, etc. agd, exp, ln, sin, sinh, etc.
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x, y real x, y real
eps nonzero real eps nonzero real, defaults to epsilon()
return real return real
@@ -19,7 +19,7 @@ EXAMPLE
5 3.605551 5 3.605551
LIMITS LIMITS
none eps != 0
LINK LIBRARY LINK LIBRARY
NUMBER *qhypot(NUMBER *q1, *q2, *epsilon) NUMBER *qhypot(NUMBER *q1, *q2, *epsilon)
@@ -27,7 +27,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
ltol ltol
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real or complex x nonzero real or complex
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real or complex return real or complex
@@ -25,7 +25,7 @@ EXAMPLE
LIMITS LIMITS
x != 0 x != 0
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qln(NUMBER *x, NUMBER *eps) NUMBER *qln(NUMBER *x, NUMBER *eps)

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real or complex x nonzero real or complex
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real or complex return real or complex
@@ -29,7 +29,7 @@ EXAMPLE
LIMITS LIMITS
x != 0 x != 0
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qlog(NUMBER *x, NUMBER *eps) NUMBER *qlog(NUMBER *x, NUMBER *eps)
@@ -38,7 +38,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
ilog, ilogn, ilog10, ilog2, ln, log2, logn ilog, ilogn, ilog10, ilog2, ln, log2, logn
## Copyright (C) 2006 Landon Curt Noll ## Copyright (C) 2006,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real or complex x nonzero real or complex
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real or complex return real or complex
@@ -17,7 +17,7 @@ DESCRIPTION
When x is an integer power of 2, log2(x) will return an integer When x is an integer power of 2, log2(x) will return an integer
regardless of the value of eps or epsilon(). regardless of the value of eps or epsilon().
If y is a positive integer, log(x, 2^-y) will usually be correct If y is a positive integer, log2(x, 2^-y) will usually be correct
to the y-th decimal place. to the y-th decimal place.
EXAMPLE EXAMPLE
@@ -41,7 +41,7 @@ EXAMPLE
LIMITS LIMITS
x != 0 x != 0
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qlog2(NUMBER *x, NUMBER *eps) NUMBER *qlog2(NUMBER *x, NUMBER *eps)

View File

@@ -7,7 +7,7 @@ SYNOPSIS
TYPES TYPES
x nonzero real or complex x nonzero real or complex
n nonzero real or complex n nonzero real or complex
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real or complex return real or complex
@@ -17,26 +17,45 @@ DESCRIPTION
The base, n, must not be 0 nor 1. The base, n, must not be 0 nor 1.
If y is a positive integer, log(x, n^-y) will usually be correct When x = 2^a is an integer power of 2 and when n = 2^b is an
integer power of 2, then log2(x, n) will return a/b
regardless of the value of eps or epsilon().
If y is a positive integer, logn(x, n, m^-y) will usually be correct
to the y-th decimal place. to the y-th decimal place.
EXAMPLE EXAMPLE
; print logn(15.625, 2.5), logn(15.625, 2.5, 1e-25) ; print logn(2, 2), logn(4, 2), logn(1024, 2), logn(2^500, 2), logn(1/2^23209, 2)
~3.00000000000000000001 3 1 2 10 500 -23209
; print logn(127, 1/13), log(23209, sqrt(3)), logn(2^17-19, 17) ; print logn(2, 42), logn(1024, 42), logn(2^500, 42), logn(1/2^23209, 42)
~-1.88860925162778125111 6 ~4.15900804831225415076 0.18544902341536890054 1.85449023415368900542 92.72451170768445027095 -4304.08638444729681267682
; print logn(127, 1/13), logn(23209, sqrt(3)), logn(2^17-19, 17)
-1.88860925162778125111 18.29998720595030380546 4.15900804831225415076
; print logn(-1, 1i), logn(2+3i, 3i+2), logn(2+3i, 3i) ; print logn(-1, 1i), logn(2+3i, 3i+2), logn(2+3i, 3i)
2 1 ~0.80360095345990217753-~0.25441159318835790311i 2 1 0.80360095345990217753-0.25441159318835790311i
; print logn(22+3i, 3i, 1e-50) ; print logn(22+3i, 3i), logn(22+3i, 3i, 1e-50)
~0.98489914201047045408-~1.28484657882287682702i 0.98489914201047045409-1.28484657882287682702i 0.98489914201047045408-1.28484657882287682702i
; print logn(-127, 7), logn(-127i, 7i)
2.48941971386002223933+1.61445925708078115429i 1.11272593230445294959-1.70545496954177392315i
; print logn(2+3i, 4), logn(-2+3i, 4i)
0.92510992953527304010+0.70893581537286099830i 1.17764179178059522911+0.22287007593665359808i
; print logn(2-3i, 4), logn(-2-3i, 4i)
0.92510992953527304010-0.70893581537286099830i -0.36752510241663632776-1.14080522421220596732i
; print logn(17+0.3i, 17, 1e-75), logn(-17-0.3i, 17i, 1e-75)
1.00005495001021376506+0.00622799102938744640i 0.29734185630294053511-1.26746929577868497155i
LIMITS LIMITS
x != 0 x != 0
n != 0 && n != 1 n != 0 && n != 1
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qlogn(NUMBER *x, NUMBER *n, NUMBER *eps) NUMBER *qlogn(NUMBER *x, NUMBER *n, NUMBER *eps)

View File

@@ -7,7 +7,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real eps nonzero real, defaults to epsilon()
return real return real
@@ -21,6 +21,7 @@ EXAMPLE
LIMITS LIMITS
abs(x) <= 1 abs(x) <= 1
eps != 0
LINK LIBRARY LINK LIBRARY
NUMBER *qlegtoleg(NUMBER *q1, *epsilon, BOOL wantneg) NUMBER *qlegtoleg(NUMBER *q1, *epsilon, BOOL wantneg)
@@ -28,7 +29,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
hypot hypot
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -7,7 +7,7 @@ SYNOPSIS
TYPES TYPES
x real x real
y real y real
eps real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return -1, 0 or 1 return -1, 0 or 1
@@ -22,7 +22,7 @@ EXAMPLE
-1 1 -1 1
LIMITS LIMITS
eps >= 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
FLAG qnear(NUMBER *x, NUMBER *y, NUMBER *eps) FLAG qnear(NUMBER *x, NUMBER *y, NUMBER *eps)
@@ -30,7 +30,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
epsilon, abs epsilon, abs
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -5,7 +5,7 @@ SYNOPSIS
pi([eps]) pi([eps])
TYPES TYPES
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -18,7 +18,7 @@ EXAMPLE
3.14159 3.1415926536 3.141592653589793 3.14159265358979323846 3.14159 3.1415926536 3.141592653589793 3.14159265358979323846
LIMITS LIMITS
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qpi(NUMBER *eps) NUMBER *qpi(NUMBER *eps)
@@ -26,7 +26,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
atan2 atan2
## Copyright (C) 1999-2006 Landon Curt Noll ## Copyright (C) 1999-2006,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -26,7 +26,7 @@ EXAMPLE
1.41421+1.41421i 2i -1.414215+1.41421i 1.41421+1.41421i 2i -1.414215+1.41421i
LIMITS LIMITS
none eps != 0
LINK LIBRARY LINK LIBRARY
COMPLEX *c_polar(NUMBER *r, NUMBER *t, NUMBER *eps); COMPLEX *c_polar(NUMBER *r, NUMBER *t, NUMBER *eps);
@@ -34,7 +34,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
abs, arg, re, im abs, arg, re, im
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -45,7 +45,7 @@ LIMITS
except in the case of y = 0; power(0, 0, eps) is the multiple of except in the case of y = 0; power(0, 0, eps) is the multiple of
eps nearest 1. eps nearest 1.
eps > 0 eps != 0
LINK LIBRARY LINK LIBRARY
void powervalue(VALUE *x, VALUE *y, VALUE *eps, VALUE *result) void powervalue(VALUE *x, VALUE *y, VALUE *eps, VALUE *result)
@@ -55,7 +55,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
root root
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return number return number
@@ -25,7 +25,7 @@ EXAMPLE
180+~229.18311805232928350739i 60+180, 36+900i 180+~229.18311805232928350739i 60+180, 36+900i
LIMITS LIMITS
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qpidiv180(NUMBER *eps) NUMBER *qpidiv180(NUMBER *eps)
@@ -34,7 +34,7 @@ SEE ALSO
d2r, g2r, r2g, d2g, g2d, d2r, g2r, r2g, d2g, g2d,
sin, cos, tan, sec, csc, cot, epsilon sin, cos, tan, sec, csc, cot, epsilon
## Copyright (C) 2021 Landon Curt Noll ## Copyright (C) 2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return number return number
@@ -25,7 +25,7 @@ EXAMPLE
200+~254.64790894703253723043i 50+200i 40+1000i 200+~254.64790894703253723043i 50+200i 40+1000i
LIMITS LIMITS
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qpidiv200(NUMBER *eps) NUMBER *qpidiv200(NUMBER *eps)
@@ -34,7 +34,7 @@ SEE ALSO
d2r, r2d, g2r, d2g, g2d, d2r, r2d, g2r, d2g, g2d,
sin, cos, tan, sec, csc, cot, epsilon sin, cos, tan, sec, csc, cot, epsilon
## Copyright (C) 2021 Landon Curt Noll ## Copyright (C) 2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -42,7 +42,7 @@ EXAMPLE
LIMITS LIMITS
n >= 0 n >= 0
eps > 0 eps != 0
LINK LIBRARY LINK LIBRARY
void rootvalue(VALUE *x, VALUE *n, VALUE *eps, VALUE *result) void rootvalue(VALUE *x, VALUE *n, VALUE *eps, VALUE *result)
@@ -52,7 +52,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
power power
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -20,7 +20,7 @@ EXAMPLE
LIMITS LIMITS
unlike sin and cos, x must be real unlike sin and cos, x must be real
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qsec(NUMBER *x, NUMBER *eps) NUMBER *qsec(NUMBER *x, NUMBER *eps)
@@ -28,7 +28,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sin, cos, tan, csc, cot, epsilon sin, cos, tan, csc, cot, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -22,7 +22,7 @@ EXAMPLE
LIMITS LIMITS
unlike sin and cos, x must be real unlike sin and cos, x must be real
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qsech(NUMBER *x, NUMBER *eps) NUMBER *qsech(NUMBER *x, NUMBER *eps)
@@ -30,7 +30,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sinh, cosh, tanh, csch, coth, epsilon sinh, cosh, tanh, csch, coth, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x number (real or complex) x number (real or complex)
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return number return number
@@ -26,7 +26,7 @@ EXAMPLE
0.5 1 0 0.5 1 0
LIMITS LIMITS
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qsin(NUMBER *x, NUMBER *eps) NUMBER *qsin(NUMBER *x, NUMBER *eps)
@@ -35,7 +35,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
cos, tan, sec, csc, cot, epsilon cos, tan, sec, csc, cot, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -22,7 +22,7 @@ EXAMPLE
LIMITS LIMITS
unlike sin and cos, x must be real unlike sin and cos, x must be real
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qsinh(NUMBER *x, NUMBER *eps) NUMBER *qsinh(NUMBER *x, NUMBER *eps)
@@ -30,7 +30,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
cosh, tanh, sech, csch, coth, epsilon cosh, tanh, sech, csch, coth, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -15,7 +15,7 @@ TYPES
For other argument types: For other argument types:
x real or complex x real or complex
eps nonzero real eps 0 < real < 1, defaults to epsilon()
z integer z integer
return real or complex return real or complex
@@ -119,7 +119,7 @@ EXAMPLE
0 0.0002 0 0.0002
LIMITS LIMITS
none 0 < eps < 1
LINK LIBRARY LINK LIBRARY
COMPLEX *c_sqrt(COMPLEX *x, NUMBER *ep, long z) COMPLEX *c_sqrt(COMPLEX *x, NUMBER *ep, long z)
@@ -130,7 +130,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
appr, epsilon appr, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -20,7 +20,7 @@ EXAMPLE
LIMITS LIMITS
unlike sin and cos, x must be real unlike sin and cos, x must be real
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qtan(NUMBER *x, NUMBER *eps) NUMBER *qtan(NUMBER *x, NUMBER *eps)
@@ -28,7 +28,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sin, cos, sec, csc, cot, epsilon sin, cos, sec, csc, cot, epsilon
## Copyright (C) 1999 Landon Curt Noll ## Copyright (C) 1999,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES TYPES
x real x real
eps nonzero real, defaults to epsilon() eps 0 < real < 1, defaults to epsilon()
return real return real
@@ -22,7 +22,7 @@ EXAMPLE
LIMITS LIMITS
unlike sin and cos, x must be real unlike sin and cos, x must be real
eps > 0 0 < eps < 1
LINK LIBRARY LINK LIBRARY
NUMBER *qtanh(NUMBER *x, NUMBER *eps) NUMBER *qtanh(NUMBER *x, NUMBER *eps)
@@ -30,7 +30,7 @@ LINK LIBRARY
SEE ALSO SEE ALSO
sinh, cosh, sech, csch, coth, epsilon sinh, cosh, sech, csch, coth, epsilon
## Copyright (C) 1999,2021 Landon Curt Noll ## Copyright (C) 1999,2021,2023 Landon Curt Noll
## ##
## Calc is open software; you can redistribute it and/or modify it under ## 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 ## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -189,6 +189,7 @@ E_FUNC NUMBER *qexp(NUMBER *q, NUMBER *epsilon);
E_FUNC NUMBER *qln(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qln(NUMBER *q, NUMBER *epsilon);
E_FUNC NUMBER *qlog(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qlog(NUMBER *q, NUMBER *epsilon);
E_FUNC NUMBER *qlog2(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qlog2(NUMBER *q, NUMBER *epsilon);
E_FUNC NUMBER *qlogn(NUMBER *q, NUMBER *n, NUMBER *epsilon);
E_FUNC NUMBER *qtan(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qtan(NUMBER *q, NUMBER *epsilon);
E_FUNC NUMBER *qsec(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qsec(NUMBER *q, NUMBER *epsilon);
E_FUNC NUMBER *qcot(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qcot(NUMBER *q, NUMBER *epsilon);

105
qtrans.c
View File

@@ -49,6 +49,8 @@ STATIC NUMBER *ln_10 = NULL;
STATIC NUMBER *ln_10_epsilon = NULL; STATIC NUMBER *ln_10_epsilon = NULL;
STATIC NUMBER *ln_2 = NULL; STATIC NUMBER *ln_2 = NULL;
STATIC NUMBER *ln_2_epsilon = NULL; STATIC NUMBER *ln_2_epsilon = NULL;
STATIC NUMBER *ln_n = NULL;
STATIC NUMBER *ln_n_epsilon = NULL;
/* /*
* cache pi * cache pi
@@ -1049,10 +1051,14 @@ qln(NUMBER *q, NUMBER *epsilon)
NUMBER *qtmp, *res; NUMBER *qtmp, *res;
bool neg; bool neg;
if (qiszero(q) || qiszero(epsilon)) { if (qiszero(q)) {
math_error("logarithm of 0"); math_error("logarithm of 0");
not_reached(); not_reached();
} }
if (qiszero(epsilon)) {
math_error("Zero epsilon value for ln");
not_reached();
}
if (qisunit(q)) if (qisunit(q))
return qlink(&_qzero_); return qlink(&_qzero_);
q = qqabs(q); /* Ignore sign of q */ q = qqabs(q); /* Ignore sign of q */
@@ -1161,10 +1167,14 @@ qlog(NUMBER *q, NUMBER *epsilon)
NUMBER *ret; /* base 10 logarithm of x */ NUMBER *ret; /* base 10 logarithm of x */
/* firewall */ /* firewall */
if (qiszero(q) || qiszero(epsilon)) { if (qiszero(q)) {
math_error("logarithm of 0"); math_error("logarithm of 0");
not_reached(); not_reached();
} }
if (qiszero(epsilon)) {
math_error("Zero epsilon value for log");
not_reached();
}
/* /*
* shortcut for small integer powers of 10 * shortcut for small integer powers of 10
@@ -1238,10 +1248,14 @@ qlog2(NUMBER *q, NUMBER *epsilon)
NUMBER *ret; /* base 2 logarithm of x */ NUMBER *ret; /* base 2 logarithm of x */
/* firewall */ /* firewall */
if (qiszero(q) || qiszero(epsilon)) { if (qiszero(q)) {
math_error("logarithm of 0"); math_error("logarithm of 0");
not_reached(); not_reached();
} }
if (qiszero(epsilon)) {
math_error("Zero epsilon value for log2");
not_reached();
}
/* /*
* special case: q is integer power of 2 * special case: q is integer power of 2
@@ -1256,7 +1270,7 @@ qlog2(NUMBER *q, NUMBER *epsilon)
* compute ln(c) first * compute ln(c) first
*/ */
ln_q = qln(q, epsilon); ln_q = qln(q, epsilon);
/* quick return for log(1) == 0 */ /* quick return for ln(1) == 0 */
if (qiszero(ln_q)) { if (qiszero(ln_q)) {
return ln_q; return ln_q;
} }
@@ -1295,6 +1309,89 @@ qlog2(NUMBER *q, NUMBER *epsilon)
} }
/*
* Calculate the base n logarithm
*
* logn(q, n) = ln(q) / ln(n)
*/
NUMBER *
qlogn(NUMBER *q, NUMBER *n, NUMBER *epsilon)
{
int need_new_ln_n = true; /* false => use cached ln_n value */
NUMBER *ln_q; /* ln(x) */
NUMBER *ret; /* base 2 logarithm of x */
/* firewall */
if (qiszero(q)) {
math_error("logarithm of 0");
not_reached();
}
if (qiszero(epsilon)) {
math_error("Zero epsilon value for logn");
not_reached();
}
if (qiszero(n)) {
math_error("invalid logarithm base of 0 for logn");
not_reached();
}
if (qisone(n)) {
math_error("invalid logarithm base of 1 for logn");
not_reached();
}
/*
* special case: q is integer power of 2
*/
ret = qalloc();
if (qispowerof2(q, &ret)) {
return ret;
}
/* XXX - deal with n is integer power of 2 - XXX */
qfree(ret);
/*
* compute ln(q) first
*/
ln_q = qln(q, epsilon);
/* quick return for ln(1) == 0 */
if (qiszero(ln_q)) {
return ln_q;
}
/*
* save epsilon for ln(n) if needed
*/
if (ln_n_epsilon == NULL) {
/* first time call */
ln_n_epsilon = qcopy(epsilon);
} else if (qcmp(ln_n_epsilon, epsilon) == true) {
/* replaced cached value with epsilon arg */
qfree(ln_n_epsilon);
ln_n_epsilon = qcopy(epsilon);
} else if (ln_n != NULL) {
/* the previously computed ln(2) is OK to use */
need_new_ln_n = false;
}
/*
* compute ln(n) if needed
*/
if (need_new_ln_n == true) {
if (ln_n != NULL) {
qfree(ln_n);
}
ln_n = qln(&_qtwo_, ln_n_epsilon);
}
/*
* return ln(q) / ln(2)
*/
ret = qqdiv(ln_q, ln_n);
qfree(ln_q);
return ret;
}
/* /*
* Calculate the result of raising one number to the power of another. * Calculate the result of raising one number to the power of another.
* The result is calculated to the nearest or next to nearest multiple of * The result is calculated to the nearest or next to nearest multiple of