mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
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:
10
CHANGES
10
CHANGES
@@ -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",
|
||||
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:
|
||||
|
||||
|
@@ -3007,8 +3007,6 @@ define test_2600()
|
||||
strcat(str(tnum++), ': log2(2^500) == 500'));
|
||||
vrfy(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,
|
||||
strcat(str(tnum++),
|
||||
': round(log2(127),10) == 6.9886846868'));
|
||||
@@ -3036,6 +3034,48 @@ define test_2600()
|
||||
vrfy(round(log2(17+0.3i),10) == 4.0876874474+0.0254566819i,
|
||||
strcat(str(tnum++),
|
||||
': 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),;
|
||||
print tnum++: ': epsilon(i),;';
|
||||
|
||||
|
@@ -545,3 +545,8 @@ E_HM2H2 Invalid rounding arg 4 for hm2h
|
||||
E_LOG2_1 Bad epsilon argument for log2
|
||||
E_LOG2_2 Non-numeric first argument for log2
|
||||
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
|
||||
|
4
help/abs
4
help/abs
@@ -36,7 +36,7 @@ EXAMPLE
|
||||
5 6.40312 6.4031242374
|
||||
|
||||
LIMITS
|
||||
none
|
||||
when x is complex, eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qqabs(NUMBER *x)
|
||||
@@ -44,7 +44,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real, -1 <= x <= 1
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
1.0472 1.0471975512 1.047197551196598 1.04719755119659774615
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qacos(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real, x >= 1
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return nonnegative real
|
||||
|
||||
@@ -24,7 +24,7 @@ EXAMPLE
|
||||
1.31696 1.3169578969 1.316957896924817 1.31695789692481670862
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qacosh(NUMBER *x, NUMBER *eps)
|
||||
@@ -32,7 +32,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
0.46365 0.463647609 0.463647609000806 0.46364760900080611621
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qacot(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real, with abs(x) > 1
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -23,7 +23,7 @@ EXAMPLE
|
||||
0.54931 0.5493061443 0.549306144334055 0.5493061443340548457
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qacoth(NUMBER *x, NUMBER *eps)
|
||||
@@ -31,7 +31,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real, with absolute value >= 1
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
0.5236 0.5235987756 0.523598775598299 0.52359877559829887308
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qacsc(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x nonzero real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -23,7 +23,7 @@ EXAMPLE
|
||||
0.48121 0.4812118251 0.481211825059603 0.4812118250596034475
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qacsch(NUMBER *x, NUMBER *eps)
|
||||
@@ -31,7 +31,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
2
help/arg
2
help/arg
@@ -24,7 +24,7 @@ EXAMPLE
|
||||
56.3099 135 -135
|
||||
|
||||
LIMITS
|
||||
none
|
||||
eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real, with absolute value >= 1
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
1.0472 1.0471975512 1.047197551196598 1.04719755119659774615
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qasec(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real, 0 < x <= 1
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -23,7 +23,7 @@ EXAMPLE
|
||||
1.31696 1.3169578969 1.316957896924817 1.31695789692481670862
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qasech(NUMBER *x, NUMBER *eps)
|
||||
@@ -31,7 +31,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real, -1 <= x <= 1
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
0.5236 0.5235987756 0.523598775598299 0.52359877559829887308
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qasin(NUMBER *q, NUMBER *epsilon)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -23,7 +23,7 @@ EXAMPLE
|
||||
1.44363 1.4436354752 1.44363547517881 1.44363547517881034249
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qasinh(NUMBER *x, NUMBER *eps)
|
||||
@@ -31,7 +31,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
1.10715 1.1071487178 1.107148717794091 1.10714871779409050302
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qatan(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -28,7 +28,7 @@ EXAMPLE
|
||||
0 ~0.52359877559829887307 ~0.31038740713235146535
|
||||
|
||||
LIMITS
|
||||
none
|
||||
eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qatan2(NUMBER *y, *x, *acc)
|
||||
@@ -36,7 +36,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -23,7 +23,7 @@ EXAMPLE
|
||||
0.54931 0.5493061443 0.549306144334055 0.5493061443340548457
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qatanh(NUMBER *x, NUMBER *eps)
|
||||
@@ -31,7 +31,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -1034,7 +1034,7 @@ EXAMPLE
|
||||
3.141592653589793238462643383279502884197169399375105820974944592307816406
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < epsilon < 1
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
6
help/cos
6
help/cos
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
@@ -26,7 +26,7 @@ EXAMPLE
|
||||
0.5 0 -1
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcos(NUMBER *x, NUMBER *eps)
|
||||
@@ -35,7 +35,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,13 +6,13 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
DESCRIPTION
|
||||
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
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
1.54308 1.5430806348 1.543080634815244 1.54308063481524377848
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcosh(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/cot
6
help/cot
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x nonzero real
|
||||
acc nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -19,7 +19,7 @@ EXAMPLE
|
||||
0.64209 0.6420926159 0.642092615934331 0.64209261593433070301
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcot(NUMBER *x, NUMBER *eps)
|
||||
@@ -27,7 +27,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x nonzero real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
1.31304 1.3130352855 1.313035285499331 1.31303528549933130364
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcoth(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/csc
6
help/csc
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -19,7 +19,7 @@ EXAMPLE
|
||||
1.1884 1.1883951058 1.188395105778121 1.18839510577812121626
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcsc(NUMBER *x, NUMBER *eps)
|
||||
@@ -27,7 +27,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x nonzero real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,7 +21,7 @@ EXAMPLE
|
||||
0.85092 0.8509181282 0.850918128239322 0.85091812823932154513
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcsch(NUMBER *x, NUMBER *eps)
|
||||
@@ -29,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
4
help/d2g
4
help/d2g
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps eps value is ignored
|
||||
|
||||
return number
|
||||
|
||||
@@ -32,7 +32,7 @@ SEE ALSO
|
||||
d2r, r2d, g2r, r2g, g2d,
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/d2r
6
help/d2r
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
@@ -27,7 +27,7 @@ EXAMPLE
|
||||
0.5 0.5 1
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv180(NUMBER *eps)
|
||||
@@ -36,7 +36,7 @@ SEE ALSO
|
||||
r2d, g2r, r2g, d2g, g2d,
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -5,7 +5,7 @@ SYNOPSIS
|
||||
epsilon([eps])
|
||||
|
||||
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
|
||||
|
||||
@@ -72,7 +72,7 @@ EXAMPLE
|
||||
3.141592653589793238462643383279502884197169399375105820974944592307816406
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
void setepsilon(NUMBER *eps)
|
||||
@@ -81,7 +81,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
5
help/exp
5
help/exp
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real or complex
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real or complex
|
||||
|
||||
@@ -32,6 +32,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
x < 693093
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qexp(NUMBER *x, NUMBER *eps)
|
||||
@@ -40,7 +41,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
4
help/g2d
4
help/g2d
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps eps value is ignored
|
||||
|
||||
return number
|
||||
|
||||
@@ -32,7 +32,7 @@ SEE ALSO
|
||||
d2r, r2d, g2r, r2g, d2g,
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/g2r
6
help/g2r
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
@@ -27,7 +27,7 @@ EXAMPLE
|
||||
0.5 0.5 1
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv200(NUMBER *eps)
|
||||
@@ -36,7 +36,7 @@ SEE ALSO
|
||||
d2r, r2d, r2g, d2g, g2d,
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/gd
6
help/gd
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
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
|
||||
|
||||
@@ -42,7 +42,7 @@ EXAMPLE
|
||||
1.42291+0.22751i 1.4229114625+0.2275106584i
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
COMPLEX *c_gd(COMPLEX *x, NUMBER *eps)
|
||||
@@ -50,7 +50,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x, y real
|
||||
eps nonzero real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -19,7 +19,7 @@ EXAMPLE
|
||||
5 3.605551
|
||||
|
||||
LIMITS
|
||||
none
|
||||
eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qhypot(NUMBER *q1, *q2, *epsilon)
|
||||
@@ -27,7 +27,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
4
help/ln
4
help/ln
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x nonzero real or complex
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real or complex
|
||||
|
||||
@@ -25,7 +25,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
x != 0
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qln(NUMBER *x, NUMBER *eps)
|
||||
|
6
help/log
6
help/log
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x nonzero real or complex
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real or complex
|
||||
|
||||
@@ -29,7 +29,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
x != 0
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qlog(NUMBER *x, NUMBER *eps)
|
||||
@@ -38,7 +38,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x nonzero real or complex
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real or complex
|
||||
|
||||
@@ -17,7 +17,7 @@ DESCRIPTION
|
||||
When x is an integer power of 2, log2(x) will return an integer
|
||||
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.
|
||||
|
||||
EXAMPLE
|
||||
@@ -41,7 +41,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
x != 0
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qlog2(NUMBER *x, NUMBER *eps)
|
||||
|
39
help/logn
39
help/logn
@@ -7,7 +7,7 @@ SYNOPSIS
|
||||
TYPES
|
||||
x 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
|
||||
|
||||
@@ -17,26 +17,45 @@ DESCRIPTION
|
||||
|
||||
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.
|
||||
|
||||
EXAMPLE
|
||||
; print logn(15.625, 2.5), logn(15.625, 2.5, 1e-25)
|
||||
~3.00000000000000000001 3
|
||||
; print logn(2, 2), logn(4, 2), logn(1024, 2), logn(2^500, 2), logn(1/2^23209, 2)
|
||||
1 2 10 500 -23209
|
||||
|
||||
; print logn(127, 1/13), log(23209, sqrt(3)), logn(2^17-19, 17)
|
||||
~-1.88860925162778125111 6 ~4.15900804831225415076
|
||||
; print logn(2, 42), logn(1024, 42), logn(2^500, 42), logn(1/2^23209, 42)
|
||||
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)
|
||||
2 1 ~0.80360095345990217753-~0.25441159318835790311i
|
||||
2 1 0.80360095345990217753-0.25441159318835790311i
|
||||
|
||||
; print logn(22+3i, 3i, 1e-50)
|
||||
~0.98489914201047045408-~1.28484657882287682702i
|
||||
; print logn(22+3i, 3i), logn(22+3i, 3i, 1e-50)
|
||||
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
|
||||
x != 0
|
||||
n != 0 && n != 1
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qlogn(NUMBER *x, NUMBER *n, NUMBER *eps)
|
||||
|
@@ -7,7 +7,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -21,6 +21,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
abs(x) <= 1
|
||||
eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qlegtoleg(NUMBER *q1, *epsilon, BOOL wantneg)
|
||||
@@ -28,7 +29,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -7,7 +7,7 @@ SYNOPSIS
|
||||
TYPES
|
||||
x real
|
||||
y real
|
||||
eps real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return -1, 0 or 1
|
||||
|
||||
@@ -22,7 +22,7 @@ EXAMPLE
|
||||
-1 1
|
||||
|
||||
LIMITS
|
||||
eps >= 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
FLAG qnear(NUMBER *x, NUMBER *y, NUMBER *eps)
|
||||
@@ -30,7 +30,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/pi
6
help/pi
@@ -5,7 +5,7 @@ SYNOPSIS
|
||||
pi([eps])
|
||||
|
||||
TYPES
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -18,7 +18,7 @@ EXAMPLE
|
||||
3.14159 3.1415926536 3.141592653589793 3.14159265358979323846
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpi(NUMBER *eps)
|
||||
@@ -26,7 +26,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -26,7 +26,7 @@ EXAMPLE
|
||||
1.41421+1.41421i 2i -1.414215+1.41421i
|
||||
|
||||
LIMITS
|
||||
none
|
||||
eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
COMPLEX *c_polar(NUMBER *r, NUMBER *t, NUMBER *eps);
|
||||
@@ -34,7 +34,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -45,7 +45,7 @@ LIMITS
|
||||
except in the case of y = 0; power(0, 0, eps) is the multiple of
|
||||
eps nearest 1.
|
||||
|
||||
eps > 0
|
||||
eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
void powervalue(VALUE *x, VALUE *y, VALUE *eps, VALUE *result)
|
||||
@@ -55,7 +55,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/r2d
6
help/r2d
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
@@ -25,7 +25,7 @@ EXAMPLE
|
||||
180+~229.18311805232928350739i 60+180, 36+900i
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv180(NUMBER *eps)
|
||||
@@ -34,7 +34,7 @@ SEE ALSO
|
||||
d2r, g2r, r2g, d2g, g2d,
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/r2g
6
help/r2g
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
@@ -25,7 +25,7 @@ EXAMPLE
|
||||
200+~254.64790894703253723043i 50+200i 40+1000i
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv200(NUMBER *eps)
|
||||
@@ -34,7 +34,7 @@ SEE ALSO
|
||||
d2r, r2d, g2r, d2g, g2d,
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -42,7 +42,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
n >= 0
|
||||
eps > 0
|
||||
eps != 0
|
||||
|
||||
LINK LIBRARY
|
||||
void rootvalue(VALUE *x, VALUE *n, VALUE *eps, VALUE *result)
|
||||
@@ -52,7 +52,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/sec
6
help/sec
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -20,7 +20,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
unlike sin and cos, x must be real
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qsec(NUMBER *x, NUMBER *eps)
|
||||
@@ -28,7 +28,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -22,7 +22,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
unlike sin and cos, x must be real
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qsech(NUMBER *x, NUMBER *eps)
|
||||
@@ -30,7 +30,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/sin
6
help/sin
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
@@ -26,7 +26,7 @@ EXAMPLE
|
||||
0.5 1 0
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qsin(NUMBER *x, NUMBER *eps)
|
||||
@@ -35,7 +35,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -22,7 +22,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
unlike sin and cos, x must be real
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qsinh(NUMBER *x, NUMBER *eps)
|
||||
@@ -30,7 +30,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -15,7 +15,7 @@ TYPES
|
||||
For other argument types:
|
||||
|
||||
x real or complex
|
||||
eps nonzero real
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
z integer
|
||||
|
||||
return real or complex
|
||||
@@ -119,7 +119,7 @@ EXAMPLE
|
||||
0 0.0002
|
||||
|
||||
LIMITS
|
||||
none
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
COMPLEX *c_sqrt(COMPLEX *x, NUMBER *ep, long z)
|
||||
@@ -130,7 +130,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
6
help/tan
6
help/tan
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -20,7 +20,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
unlike sin and cos, x must be real
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qtan(NUMBER *x, NUMBER *eps)
|
||||
@@ -28,7 +28,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -6,7 +6,7 @@ SYNOPSIS
|
||||
|
||||
TYPES
|
||||
x real
|
||||
eps nonzero real, defaults to epsilon()
|
||||
eps 0 < real < 1, defaults to epsilon()
|
||||
|
||||
return real
|
||||
|
||||
@@ -22,7 +22,7 @@ EXAMPLE
|
||||
|
||||
LIMITS
|
||||
unlike sin and cos, x must be real
|
||||
eps > 0
|
||||
0 < eps < 1
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qtanh(NUMBER *x, NUMBER *eps)
|
||||
@@ -30,7 +30,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
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
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
1
qmath.h
1
qmath.h
@@ -189,6 +189,7 @@ E_FUNC NUMBER *qexp(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qln(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qlog(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 *qsec(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcot(NUMBER *q, NUMBER *epsilon);
|
||||
|
105
qtrans.c
105
qtrans.c
@@ -49,6 +49,8 @@ STATIC NUMBER *ln_10 = NULL;
|
||||
STATIC NUMBER *ln_10_epsilon = NULL;
|
||||
STATIC NUMBER *ln_2 = NULL;
|
||||
STATIC NUMBER *ln_2_epsilon = NULL;
|
||||
STATIC NUMBER *ln_n = NULL;
|
||||
STATIC NUMBER *ln_n_epsilon = NULL;
|
||||
|
||||
/*
|
||||
* cache pi
|
||||
@@ -1049,10 +1051,14 @@ qln(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *qtmp, *res;
|
||||
bool neg;
|
||||
|
||||
if (qiszero(q) || qiszero(epsilon)) {
|
||||
if (qiszero(q)) {
|
||||
math_error("logarithm of 0");
|
||||
not_reached();
|
||||
}
|
||||
if (qiszero(epsilon)) {
|
||||
math_error("Zero epsilon value for ln");
|
||||
not_reached();
|
||||
}
|
||||
if (qisunit(q))
|
||||
return qlink(&_qzero_);
|
||||
q = qqabs(q); /* Ignore sign of q */
|
||||
@@ -1161,10 +1167,14 @@ qlog(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *ret; /* base 10 logarithm of x */
|
||||
|
||||
/* firewall */
|
||||
if (qiszero(q) || qiszero(epsilon)) {
|
||||
if (qiszero(q)) {
|
||||
math_error("logarithm of 0");
|
||||
not_reached();
|
||||
}
|
||||
if (qiszero(epsilon)) {
|
||||
math_error("Zero epsilon value for log");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* shortcut for small integer powers of 10
|
||||
@@ -1238,10 +1248,14 @@ qlog2(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *ret; /* base 2 logarithm of x */
|
||||
|
||||
/* firewall */
|
||||
if (qiszero(q) || qiszero(epsilon)) {
|
||||
if (qiszero(q)) {
|
||||
math_error("logarithm of 0");
|
||||
not_reached();
|
||||
}
|
||||
if (qiszero(epsilon)) {
|
||||
math_error("Zero epsilon value for log2");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* special case: q is integer power of 2
|
||||
@@ -1256,7 +1270,7 @@ qlog2(NUMBER *q, NUMBER *epsilon)
|
||||
* compute ln(c) first
|
||||
*/
|
||||
ln_q = qln(q, epsilon);
|
||||
/* quick return for log(1) == 0 */
|
||||
/* quick return for ln(1) == 0 */
|
||||
if (qiszero(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.
|
||||
* The result is calculated to the nearest or next to nearest multiple of
|
||||
|
Reference in New Issue
Block a user