Mathematical Functions
Date: 2020-10-07 18:10:00

Up | Next | Prev | PrevTail | Tail

### 7.2 Mathematical Functions

REDUCE knows that the following represent mathematical functions that can take arbitrary scalar expressions as their argument(s):

ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN
ASINH ATAN ATANH ATAN2 BETA CI COS COSH COT COTH CSC
CSCH DILOG EI EXP GAMMA HYPOT IBETA IGAMMA LOG
LOGB LOG10 SEC SECH SI SIN SINH SQRT TAN TANH
AIRY_AI AIRY_AIPRIME AIRY_BI AIRY_BIPRIME
BESSELI BESSELJ BESSELK BESSELY
HANKEL1 HANKEL2 KUMMERM KUMMERU LOMMEL1 LOMMEL2
STRUVEH STRUVEL WHITTAKERM WHITTAKERU
POLYGAMMA PSI ZETA
SOLIDHARMONICY SPHERICALHARMONICY

where LOG is the natural logarithm, and LOGB has two arguments of which the second is the logarithmic base.

The derivatives of all these functions are also known to the system.

REDUCE knows various elementary identities and properties of these functions. For example:

cos(-x) = cos(x) sin(-x) = - sin (x)
cos(n*pi) = (-1)^n sin(n*pi) = 0
log(e) = 1 e^(i*pi/2) = i
log(1) = 0 e^(i*pi) = -1
log(e^x) = x e^(3*i*pi/2) = -i

Beside these identities, there are a lot of simpliﬁcations for elementary functions deﬁned in the REDUCE system as rulelists. In order to view these, the SHOWRULES operator can be used, e.g.

SHOWRULES tan;
{tan(~n*arbint(~i)*pi + ~~x) => tan(x) when fixp(n),
tan(~x) => trigquot(sin(x),cos(x)) when knowledge_about(sin,x,tan),
~x + ~~k*pi x k k 1
tan(-------------) => - cot(--- + i*pi*impart(---)) when abs(repart(---))=---,
~~d d d d 2
~~w + ~~k*pi w k k
tan(--------------) => tan(--- + (--- - fix(repart(---)))*pi)
~~d d d d
k
when ((ratnump(rp) and abs(rp)>=1) where rp => repart(---)),
d
tan(atan(~x)) => x,
2
df(tan(~x),~x) => 1 + tan(x) }

For further simpliﬁcation, especially of expressions involving trigonometric functions, see the TRIGSIMP package (chapter 16.77) documentation.

Functions not listed above may be deﬁned in the special functions package SPECFN.

The user can add further rules for the reduction of expressions involving these operators by using the LET command.

In many cases it is desirable to expand product arguments of logarithms, or collect a sum of logarithms into a single logarithm. Since these are inverse operations, it is not possible to provide rules for doing both at the same time and preserve the REDUCE concept of idempotent evaluation. As an alternative, REDUCE provides two switches EXPANDLOGS and COMBINELOGS to carry out these operations. Both are oﬀ by default, and are subject to the value of the switch PRECISE. This switch is on by default and prevents modiﬁcations that may be false in a complex domain. Thus to expand LOG(3*Y) into a sum of logs, one can say

ON EXPANDLOGS; LOG(3*Y);

whereas to expand LOG(X*Y) into a sum of logs, one needs to say

OFF PRECISE; ON EXPANDLOGS; LOG(X*Y);

To combine this sum into a single log:

OFF PRECISE; ON COMBINELOGS; LOG(X) + LOG(Y);

These switches aﬀect the logarithmic functions LOG10 (base 10) and LOGB (arbitrary base) as well.

At the present time, it is possible to have both switches on at once, which could lead to inﬁnite recursion. However, an expression is switched from one form to the other in this case. Users should not rely on this behavior, since it may change in the next release.

The current version of REDUCE does a poor job of simplifying surds. In particular, expressions involving the product of variables raised to non-integer powers do not usually have their powers combined internally, even though they are printed as if those powers were combined. For example, the expression

x^(1/3)*x^(1/6);

will print as

SQRT(X)

but will have an internal form containing the two exponentiated terms. If you now subtract sqrt(x) from this expression, you will not get zero. Instead, the confusing form

SQRT(X) - SQRT(X)

will result. To combine such exponentiated terms, the switch COMBINEEXPT should be turned on.

The square root function can be input using the name SQRT, or the power operation ^(1/2). On output, unsimpliﬁed square roots are normally represented by the operator SQRT rather than a fractional power. With the default system switch settings, the argument of a square root is ﬁrst simpliﬁed, and any divisors of the expression that are perfect squares taken outside the square root argument. The remaining expression is left under the square root. Thus the expression

sqrt(-8a^2*b)

becomes

2*a*sqrt(-2*b).

Note that such simpliﬁcations can cause trouble if A is eventually given a value that is a negative number. If it is important that the positive property of the square root and higher even roots always be preserved, the switch PRECISE should be set on (the default value). This causes any non-numerical factors taken out of surds to be represented by their absolute value form. With PRECISE on then, the above example would become

2*abs(a)*sqrt(-2*b).

However, this is incorrect in the complex domain, where the is not identical to |x|. To avoid the above simpliﬁcation, the switch PRECISE_COMPLEX should be set on (default is oﬀ). For example:

on precise_complex; sqrt(-8a^2*b);

yields the output

2
2*sqrt( - 2*a *b)

The statement that REDUCE knows very little about these functions applies only in the mathematically exact off rounded mode. If ROUNDED is on, any of the functions

ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN
ASINH ATAN ATANH ATAN2 COS COSH COT COTH CSC CSCH
EXP HYPOT IBETA IGAMMA LN LOG LOGB LOG10 PSI SEC
SECH SIN SINH SQRT TAN TANH

when given a numerical argument has its value calculated to the current degree of ﬂoating point precision. In addition, real (non-integer valued) powers of numbers will also be evaluated.

If the COMPLEX switch is turned on in addition to ROUNDED, these functions will also calculate a real or complex result, again to the current degree of ﬂoating point precision, if given complex arguments. For example, with on rounded,complex;

2.3^(5.6i) -> -0.0480793490914 - 0.998843519372*I
cos(2+3i) -> -4.18962569097 - 9.10922789376*I

For log and the inverse trig. and hyperbolic functions which are multi-valued, the principal value is returned. The branch cuts chosen (except for acot) are now those recommended by W. Kahan (Branch Cuts for Complex Elementary Functions, or Much Ado About Nothing’s Sign Bit, in The State of the Art in Numerical Analysis, A. Iserles, M.J.D. Powell Eds., Clarendon Press, Oxford, 1987).

The exception for acot is necessary as elsewhere in Reduce acot(−z) is taken to be π − acot(z) rather than −acot(z). The branch cuts are:

log: | {r∣r ∈ ℝ ∧ r < 0}
asin, acos: | {r∣r ∈ ℝ ∧ (r > 1 ∨ r < −1)}
acsc, asec: | {r∣r ∈ ℝ ∧ r≠0 ∧ r > −1 ∧ r < 1}
atan, acot: | {r ∗ i∣r ∈ ℝ ∧ (r > 1 ∨ r < −1)}
asinh: | {r ∗ i∣r ∈ ℝ ∧ (r ≥ 1 ∨ r ≤−1)}
acsch: | {r ∗ i∣r ∈ ℝ ∧ r≠0 ∧ r ≥−1 ∧ r ≤ 1}
acosh: | {r∣r ∈ ℝ ∧ r < 1}
asech: | {r∣r ∈ ℝ ∧ (r > 1 ∨ r < 0)}
atanh: | {r∣r ∈ ℝ ∧ (r > 1 ∨ r < −1)}
acoth: | {r∣r ∈ ℝ ∧ r > −1 ∧ r < 1}

Up | Next | Prev | PrevTail | Front