Solutions - School of Mathematical Sciences

Goldsmiths' Company
Mathematics Course 2011
Algebraic Computing Workshop
© Francis J. Wright, 2011
Getting started
This is a self-paced workshop but please ask for help whenever you need it. Log in to the teaching
network using the login / password information on your name badge and select the standard
Windows environment. Then start Maple by clicking on the Dept menu at the right of the taskbar and
selecting Maple 14 > Maple 14. Wait while Maple starts and then select Worksheet mode.
Some key points to remember
The Expression and Common Symbols palettes should suffice to enter most expressions. Click on
a palette in the dock on the left to expand it. The Expression palette provides templates containing
coloured placeholders, all of which you must replace with the correct values (even if the
placeholder happens to have the right name). You can use Tab and Backtab (i.e. Shift-Tab) to move
through the placeholders, or select them with the mouse. You can insert another template into a
placeholder to build up complicated expressions.
Type a space for implied multiplication,
Common
Symbols palette), / to enter a denominator, ^ to enter a power and _ to enter a subscript; press the
right arrow key or click the mouse to the right of the current expression to exit a denominator,
power or subscript.
Use only parentheses (round brackets) for function arguments and expression grouping. (Square
brackets denote lists and curly braces denote sets.) Function names must be followed
immediately by parentheses; do not put a space between the function name and the opening
parenthesis.
Right clicking on Maple output (or input) gives a list of context-dependent options that can be
used to manipulate the expression further. You can also re-use output via its "equation number
label" with Insert > Label... or Control-L.
Press the Enter / Return key to evaluate or execute your input and move the cursor to a new input
prompt.
Try the Help menu if you get stuck; Maple contains a huge amount of information (including a
mathematics dictionary) accessible via the help system. You may find Quick Reference and Quick
Help particularly useful for navigating the user interface, and the general Maple Help (also
available via the ? button on the toolbar) useful for more mathematical help.
It is safest to execute a restart command at the start of each new answer (provided it is unrelated
to previous answers), i.e.
If in doubt, experiment and/or ask for help!
Questions
Please attempt some or all of the questions below. The first five are based on 2010 exam questions
for Introduction to Mathematical Computing, a first-semester Mathematical Sciences module at
Queen Mary, and should be fairly straightforward. Subsequent questions explore other aspects of
computer algebra and may be more involved.
Solutions
To see my solutions, open this document in Maple from the course website by selecting Open
from the File menu and typing the URL http://www.maths.qmul.ac.
uk/~fjw/goldsmiths/2011/FrancisWright/ComputingWorkshop.mw. By default, this will give you
a new tab within the same Maple application. If you prefer, you can right click on the new tab and
select Open Tab in New Window. You can then tile the two windows, whereas you cannot tile
documents within the same window. Alternatively, browse to the URL and open it using a web
browser. Click on the triangle preceding a solution to expand it.
Relations
Assign the expression
to the variable . Evaluate at
and
find the value(s) of for which the result is zero (by solving the appropriate equation). Is
when
?
Solution
Polynomial algebra
Assign expressions to the variables and so that
product
and the quotient
option). Is divisible by
help system.)
. Find the factors of
. Compute the
(by using the appropriate right-click menu
? (Hint: simplify the quotient or look up divide or rem in the
Solution
Functions, integrals, plots and equations
Define the function so that
. Plot
and find another zero of
fsolve with second argument
for
. Show that
in the range
(by using the Maple function
to specify the solution range).
Solution
Sets, sequences and lists
(a) Write a (predicate) function that takes two arguments and , assumed to be sets of integers,
and returns true if either 1 or 2 is an element of both and , false otherwise. Test your function
by calling it with appropriate explicit sets as arguments. (You can experiment initially by
evaluating expressions involving explicit sets and set operators.)
Solution
(b) Use the Maple function seq to generate the sequence
where
is an appropriate expression in ).
(hint: use
Solution
(c) Use the Maple function seq as above to generate the list
and assign
it to the variable . Then use seq again but with the relation 2 instead of to generate the list
from the list . Finally, do the same thing by
mapping an anonymous function over .
Solution
Characteristic functions
Write a (predicate) function called that takes one argument and returns true if is an odd
integer and x does not exceed 100, false otherwise. Construct the set of integers from 50 to 150
and then select the subset of those integers for which is true. (Hint: odd is a Maple type and the
logical conjunction is and. You can construct the set of integers by calling seq within curly
braces.) A predicate used in this way is often called a characteristic function, and characteristic
functions are conventionally called .
Solution
Calculus
(a) Enter and evaluate the definite integral
, evaluate it at
and approximate the result
numerically.
Solution
(b) The logarithm function is singular at the origin, but is this singularity integrable? To
investigate this, enter and evaluate
, enter and evaluate
, and enter and evaluate the
. Then insert an empty two-dimensional plot using the Insert menu and
indefinite integral
select and drag the integrand (
) onto the plot (whilst holding down the Control key so that
you copy rather than move it). Note the colour of the graph and note the singularity. Why has the
negative x-axis disappeared? Now select and drag the result of evaluating the integral onto the
plot (which will copy automatically since Maple output is not editable). The resulting graph
shows that the singularity is integrable.
Solution
(c) There is a general results that "any power beats a logarithm", i.e.
for any
and
. Investigate this claim using a few explicit values for .
Solution
Trigonometric functions
(a) Enter, evaluate and, if necessary, approximate each of the following expressions to obtain an
explicit numerical value:
Solution
.
(b) Enter, evaluate and then expand each of the following expressions:
.
Solution
(c) Enter, evaluate and, if necessary, approximate the expression
numerical value. Compute an exact numerical value for
equation of the form
equation at
to obtain an explicit
as follows. Construct an
, solve it for
, and evaluate the resulting
. Approximate this exact equation to check its validity (and note the numerical
error)
Solution
Complex numbers and expressions
In the Common Symbols palette, there is a choice of three symbols (
) that can all be used to
input the imaginary unit, as you can see by hovering the mouse pointer over them, but by default
Maple will always use as the imaginary unit in output (because and also have other
conventional uses). However, you can instruct Maple to use almost any symbol, such as , for both
input and output of the imaginary unit by executing
.
(a) Convince yourself that Maple understands complex arithmetic. For example, enter and
evaluate the complex numerical expressions
and
. Then use the right-
click context menu to find the real and imaginary parts, complex conjugate, and modulus and
argument of each number.
(b) Enter and evaluate the complex expression
and then expand it.
Solution
(c) De Moivre's formula can be written as
. (You
can look it up in the Maple help system.) This formula provides a way to construct trigonometric
identities for multiple arguments. Enter and evaluate De Moivre's formula, then evaluate it at
(say)
. Right-click the result and select Manipulate Equation. Use this dialogue to expand
only the right side using the appropriate Miscellaneous Operations in the bottom right corner of
the dialogue box. Then take the real part of the resulting equation by applying the R function
available in the Common Symbols palette. You will see that this does not fully simplify by
default because Maple assumes that is a complex variable. Re-evaluate the real part with an
appropriate assumption. Do likewise for the imaginary part by applying the I function available in
the Common Symbols palette.
Solution
Set operations
Symmetric difference
Look this up in the Maple help. It is implemented in Maple as the function symmdiff. Use
this to compute the symmetric difference of two sets. Perform the same computation using
only the set union, intersection and difference operators. Hence, implement your own
symmetric difference function.
Solution
Subset
(a) Perform a subset test by using only set union or intersection and an equality test. You will
need to use evalb or is to get a true/false result. Hence, implement your own subset
predicate.
Solution
(b) Now go back to the definition of subset:
. Assign specific sets to
the variables and . Then compute a sequence of logical values for each
that are true
if
. Make the sequence into a set by enclosing it in braces. What must the value of this
set be if
? Hence, write your own subset predicate. [Tricky!]
Solution
(c) Try the same basic algorithm but using andmap to map the member predicate over the
appropriate set. This approach is elegant and very close to the definition.
Solution
Power set
(a) Look up the definition and the appropriate Maple function in the Maple help. Hence,
compute the power set of a small set. The power set of a set is usually written as either
or , because
, hence the name. Here
denotes the cardinality of the set ,
which in Maple can be found by applying the function nops. Check the cardinality relation
for the power set you have constructed.
Solution
(b) Why is the cardinality of a power set as specified above? Consider how many subsets of
each cardinality a set has and add these numbers (symbolically, using Maple). Use the
binomial theorem to prove this result (again using Maple).
Solution
Inverse functions
Does the function have an inverse? Yes, if is onto and one-to-one. We can usually make a
function onto by restricting its codomain and one-to-one by restricting its domain. For example,
the exponential function from to
is invertible but Maple will not necessarily invert it by
default:
x
(10.1)
(10.2)
(a) Why does the second expression not simplify? Make the appropriate assumption to allow
Maple to simplify it.
Solution
(b) Evaluate
and
. Why does one simplify automatically but
not the other? Can you find options in the simplify submenu in the right-click context menu that
will simplify it?
Solution
(c) Evaluate
and
. Why does one simplify automatically but not the
other? Can you find options in the simplify submenu in the right-click context menu that will
simplify it? Can you use the form "
" to simplify it?
Solution