# Basic Functions

## Logarithms

Computing logarithms with Maple is quick and powerful. The basic syntax is:

ln(x) - natural logarithm

log(x) - natural logarithm

log[b](x) - logarithm with base b

log10(x) - logarithm with base10

Here denotes any matheatical expression. Note that the two common notations, ln and log, both refer to the natural logarithm

> ln(2);

ln(2)

What you might want Maple to do is compute the number. To do this would be to give an approximation to the exact number. Maple's default output is the exact result or there is none, no result. Maple will not give approximate numbers unless requested to do so. Several commands are available for this: The most useful is the evalf() command. The syntax is

evalf(expr) - evaluate the expression

evalf(expr, n) - evaluate the expression using n digits accuracy

evalf[n](expr) - evaluate the expression using n digits accuracy

Here expr means some mathematical expression and n is the number of digits for the computation. For example

> evalf(ln(2));

.6931471806

> evalf(ln(2),35);

.69314718055994530941723212145817657

Alternatively, we could write

ln(2);evalf(%);

ln(2)

0.6931471806

The % refers to the results of the last computation. The evalf(%); command is very useful. It evaluates to floating-point or complex floating-point numbers, expressions (or subexpressions) involving constants such as Pi, exp(1), gamma, and functions such as exp, ln, sin, arctan, cosh, GAMMA, and erf.

#### Does Maple know the rules of logarithms?

Suppose we input Do we obtain what we know is true: Similarly, does yield The answer is NO! Typically we get

> ln(a*b);

ln(a*b)

Even using the expand command doesn't help. The reason for this is that Maple does not know that both numbers are positive. However, if we could tell Maple to assume that the variables are positive, then it uses the rules. Note the following commands.

> assume(a>0); assume(b>0);

>expand(ln(a*b));

ln(a~) + ln(b~)

The expression "a~" indicates that an assumption has been made on the variable. We still use the expand command, for otherwise there is no reason for Maple to expand the expression. However, sometimes Maple will expand the expression without prompting.

However, ... Here is a numerical example, where no assumptions are needed.

> ln(sqrt(2)*sqrt(3));expand(%);

ln(sqrt(2) sqrt(3))

1/2 ln(2) + 1/2 ln(3)

Exercise: If the last statement read ln(sqrt(2)*sqrt(3));expand(%);evalf(%) what would have happened? What was the effective value of expand(%); in the final result of this command sequence.

## Exponentials

The exponential function in Maple is given by

exp(expr)

where denotes any mathematical expression. This is typical, and expected when you are fully aware of the exactness-paradigm of Maple.

> exp(1);

exp(1);

To get the decimal approximation of this number we can use any of the commands: evalf(exp(1)); evalf(exp(1),23); we can even use the following exp(1.0);

> exp(1.0);

2.718281828

When you write 1.0 for the number one, Maple assumes that you are dealing in decimal approximations and it is most happy to "go along" and give you decimals right back.

#### Does Maple know the rules of exponentials?

As you might expect, Maple does know them, if the conditions are correct. And conditions are always right here.

For example Maple gives the following:

> expand(exp(c+d));expand(exp(c-d));

expexp

exp()- exp()

> exp(ln(c));

The latter is true no matter what is, of course.

Exercise

What happens if we try to compute

## Trigonometric functions

The basic trig functions are

sin

cos

tan

ctn

sec

csc

where is any mathematical expression in the units of radians. Examples:

> sin(1.2);

0.9320390860

> cos(Pi);

-1

Here we use a special symbol, Pi, which represents the exact As you might expect, Maple knows all the expansion formulae for the trig functions. Example,

> expand(tan(c+d));

Remember, Maple will not expand expressions unless instructed to do so.

## Inverse Trig functions

The inverse trigonometric functions use notation consistent with mathematics generally. For example,

> arctan(1);

The definition of the functions is to place an "arc" infront of the corresponding trigonometric function. We have

arcsin

arccos

arctan

arcctn

arcsec

arccsc

where is any mathematical expression in the units of radians. Pay attention to the domain, Maple does. A special example:

> arccos(2);

arccos(2)

> evalf(%);

1.316957897 I

As you know "I" means the complex number Here you will note that while is not in the domain of the inverse cosine function as we teach it with domain on the real line (in fact with domain ), it is fully defined in the complex plane. Students will report such things, and they will want to know why their answer is marked wrong. Little things like this must be thoroughly understood to avoid a number of pitfalls in using Maple, and by the way also with Mathematica and Scientific Notebook.

This document created by Scientific Notebook 4.0.