Mathematical functions

The Maple programming environment has many pre-defined mathematical functions as you may expect. These functions take both floating point and algebraic expressions as arguments. Unlike C++, if any of these functions obtain an argument for which it does not know a result, it leaves the result unevaluated. We'll look at this now by first looking at the trigonmetric functions.

Trigonometric functions

The cosine function evaluates as expected from secondary school:

[> cos( 0 );

$1$

You'll notice that this is the interger $1$, and not a floating-point $1.0$. The cosine function is aware that cosine of 0 is 1. On the other hand, we do not know the value of $\cos(1)$, so Maple leaves this unevaluated:

[> cos( 1 );

$\cos( 1 )$

You can, however, ask Maple to evaluate $\cos(1)$ to a floating-point number:

[> evalf( cos( 1 ) );

$0.5403023059$

[> Digits := 30;

$Digits := 30$

[> evalf( cos( 1 ) );

$0.54030230586813971740093660744298$

On the other hand, Maple is aware of $\pi$, so you can ask:

[> cos( Pi );

$1$

Again, notice that this is the integer $1$, and not a floating-point $1.0$. Maple, however, is aware of other values:

[> cos( Pi/3 );

$\frac{1}{2}$

[> cos( Pi/4 );

$\frac{\sqrt{2}}{2}$

[> cos( Pi/6 );

$\frac{\sqrt{3}}{2}$

[> cos( Pi/12 );

$\cos\left(\frac{\pi}{12}\right)$

Why cannot Maple determine the value of $\cos\left(\frac{\pi}{12}\right)$? Actually, it can, and you can, too, by using the double-angle formula:

[> cos( 2*x );

$\cos(2x)$

[> expand( cos( 2*x ) );

$2\cos(x)^2 - 1$

Consequently, we have that:

$\cos(2x) = 2\cos^2(x) - 1$

or, alternatively

$\cos(x) = 2\cos^2\left(\frac{x}{2}\right) - 1$

Thus, we can actually solve for cosine of $\frac{\pi}{12}$, but so can Maple:

[> convert( cos( x/12 ), 'radical' );

$\frac{\sqrt{2}\left(1 + \sqrt{3}\right)}{4}$

A radical is any algebraic expression involving rational numbers or such expressions raised to rational exponents.

Of course, Maple implements the other common trigonmetric functions: sin, tan, sec, csc and cot. You'll notice that I describe as $\sin$ as the function, and not $\sin(x)$. The function sine when evaluated at an argument $x$ is $\sin(x)$, but the function is $\sin$. If $x$ is a real number, then $\sin(x)$ is a real number, and if $z$ is a complex number, then $\sin(z)$ is a complex number.

In addition to trignometric functions, there are the inverse trigonometric functions, and these are named arcsin, arccos, arctan, arcsec, arccsc and arccot. Of course, these are also aware of the appropriate mathematical formulas:

[> arccos( 1/2 );

$\frac{\pi}{3}$

Notice also that Maple can deal with more general questions:

[> cos( arccos( x ) );

$x$

[> arccos( cos( x ) );

$arccos( cos( x ) )$

If you're wondering why the second does not simplfy to $x$, recall that $\cos$ is many-to-one, while $\arccos$ is one-to-one. For example,

[> arccos( cos( 2*Pi ) );

$0$

Hyperbolic functions

The hyperbolic functions, like the trigonometric functions, are also defined: sinh and arcsinh, cosh and arccosh, tanh and arctanh, sech and arcsech, csch and arccsch, and coth and arccoth. One may argue that the inverse of a hyperbolic function should be described as arsinh, etc., as the inverse represents an area and not an arc or angle, but whowever authored the original functions chose to parallel the naming convention of the inverse of the trigonometric functions.