Exploring Mathematics by Computer
Mathematics Summer School
University of Oxford
16–21 July 2000
Preface
This mini-manual is designed to get you interested in exploring the world of mathematics
by computer. Whatever your view of computers, their use is becoming more widespread
in all areas of life, and at universities they are increasingly used in both teaching and
research. In particular, the influence and power of computing is fundamentally affecting
many areas of both applied and pure mathematics.
The notes below incorporate quite a few exercises, but how much of the material you will
cover will depend on your own experience in using computers. It does not matter in the
least if you have none, but in this case don’t be ashamed to get help from an assistant
in the computer room, and don’t get disheartened if everything takes a long time to do.
You can flick through the manual and try any part you like in any order, once you have
read at least the end of the Introduction. If you get bored with the problems, think
up one of your own and get help to translate it into Maple. It is expected that the
9–10am session each morning will be more than enough for everyone, but arrangements
can probably be made to use the computer room at other times if you want.
A fuller list of commands can be found in the list at the back, and this may give you
alternative ideas. For example, you can spend your time plotting pretty pictures using
programs like those listed under animate and plot . There are bound to be errors and
things that don’t work below, and others can help correct this for you.
You are welcome to keep this manual as a souvenir. Even if you manage very little during
the week, it may be that you will have an opportunity to take it up again at some time
in the future!
The Mathematics Summer School is being run by David Acheson, and the Maple component by Kristine Embree and Minh Pham. This manual was written (rather hurriedly)
by Simon Salamon and is loosely based on some undergraduate projects.
2
Introduction to XMaple
Maple is one of several sytems used in Oxford for doing mathematics by computer;
others include Mathematica and Matlab. To some extent, these systems are like glorified
pocket calculators, though much more powerful and versatile than anything you have
probably seen before. In particular they allow one to plot and display multiple graphs,
3-dimensional pictures, and write programs to accomplish quite complicated tasks.
The purpose of this section to is give a brief introduction to using XMaple, an interactive
version of Maple that allows you to type and enter commands, and then remodify them
without having to do everything again. You can even save your work in order to avoid
retyping things the next day, though this should not really be necessary during the
summer school. The expectation is that you will type between 1 and 5 lines at a time
to investigate a particular question posed below, occasionally taking brief notes of what
you observe on paper as a record of your progress. If you are interested, you may discuss
the work with a tutor, or with others in a class.
You may be working as a pair or individually at the terminal. On Monday morning,
everyone will be assigned a password and it will be explained how to log on to our
Institute’s computer network. Once you have done this, you will need to type xmaple in
a window or (possibly) select it from a menu that appears when left-clicking the mouse.
After a few seconds, the shadow of a larger window should appear, and you can bring
this to life using the mouse. You work inside the green window, which can be maximized
by clicking on its top right corner.
XMaple computations are carried out by typing a command so that it appears immediately after the symbol > (called the ‘prompt’). You should finish the command with
either a semicolon or colon, and then press RETURN on the right of the keyboard. Try
entering
> 2*(12+13);
which will display an answer of 50. If you use : instead of ; the answer is not displayed,
and this is sometimes useful when you are merely defining numbers or functions and do
not want to waste space.
Simple mathematical formulae are typed in a familar way, except that multiplication
must ALWAYS be denoted with *. There are also certain conventions regarding ordering
and brackets that take a bit of getting used to. For example,
> 2^12+5;
is interpreted as 212 + 5, and
> 24/4*3;
3
as (24/4) × 3 and NOT as 24/(4 × 3) (this leads to frequent errors!). If you want to
express a fraction in decimals, you need to use the command evalf (f stands for ‘floating
point’). Try entering
> 355/113;
If you want a decimal expansion you need to modify the line (using arrow keys to position
the cursor precisely) to evalf(355/113); or you could type
> evalf(%);
on another line. The percentage sign is a symbol that stands for the last thing that
XMaple computed.
The constants π and e are entered as Pi and E. To evaluate π more accurately than you
will ever need to know, enter
> evalf(Pi,10000);
A more interesting example is e
√
163π
which could be computed as
> evalf(E^(sqrt(163)*Pi),30);
and is very close to an integer.
One great advantage of the system is that it encourages one to break calculations up
into several lines. This helps you to work in an orderly fashion and tends to reduce the
number of errors. For example, to plot a curve or surface, it is convenient to first define
the function, as in
> f:= x->sin(x)/x:
and then issue the plotting command
> plot(f(x),x=-9..9);
on another line. The graph will be shown on a separate window, and you may be able
to change some of the features of the picture using a pull-down menu. When you have
finished with the graph, close its window by first clicking on the top left corner.
Here is a 3-dimensional example:
> z:= (x,y)->y*sin(x)/x:
plot3d(z(x,y),x=-9..9,y=-1..1);
4
You will have to be patient for the complete surface to materialize. It is formed by taking
each point with ‘height’ z(x, y) above the corresponding point in the (x, y)-plane. Can
you see how it relates to the graph of f ? You can try other examples by modifying the
definition of function z .
Things get more interesting when you write a program, which means one or more lines
designed to accomplish a specific task. If you were to enter
> x:=1: y:=0:
for n from 2 to 50 do
x:=x+y: y:=x-y
od;
the last value of x displayed would be 12586269025; it is the 50th in the sequence
1, 1, 2, 3, 5, 8, 13, 21, 35, . . .
of Fibonacci numbers.
Try typing these lines yourself. At the end of each line you must hold down the SHIFT
key as you enter RETURN; this will prevent the individual line being evaluated and a
prompt symbol > from appearing on the next line. When you enter RETURN (without
SHIFT) after typing od; all four lines get treated together as if they formed one single
unit. The spacing is designed to make the commands easier to follow, but is entirely
optional; for example you may find it easier to type the last three lines as one.
If you want to, you can subsequently get rid of ‘junk output’ on the screen as follows.
Use the up-arrow key (or the mouse and right-hand scrollbar) to return to near the top
of the page. Then remove lines of text by pressing CTRL and DELETE together. You
have to be very careful if there are some lines you want to keep, and it might be better
to use the mouse to highlight and then CUT and PASTE from the EDIT menu. You
can also delete areas highlighted in black by pressing the BACKSPACE key. Another
trick is to re-enter a program having first replaced its final semicolon by a colon.
5
IMPORTANT: Do not worry if something below does not work. First check to see if
you have typed everything correctly; a ‘syntax error’ message probably means you have
forgotten a bracket or a (semi)colon. If Maple seems to be on strike, try entering
> 2+2;
if 4 does not appear, the chances are the system is waiting for you to type a missing
bracket or something!
Until you learn to use the mouse and position the cursor easily, you are likely to make
lots of typing mistakes, so do not let this put you off. If you can’t spot an error, try
typing
> restart;
on a separate line, and then re-enter your program. This has the effect of resetting all
the variables, and may be successful at clearing the problem.
LOGGING OUT: When you have finished a session, choose EXIT from the FILE
menu and confirm you desire to exit. The helpers will tell you if it is possible to save a
file.
6
Prime numbers
Throughout this section the word ‘number’ will mean a positive integer, one of the
numbers 1, 2, 3, 4, . . .. A number is called prime if it is not 1 and the only numbers
which divide it are itself and 1. An equivalent definition (and one used more in advanced
algebra) is that p is prime if whenever p divides the product of two numbers, it divides
one or the other. For example 6 is not prime because it divides 18 = 2 × 9, but it divides
neither 2 nor 9.
It is well known that there exist infinitely many prime numbers, and the list begins
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, . . .
We say that 11 is the 5th prime number. In Maple, the command ithprime can be used
to compute the nth prime number for (in theory) any n. Type
> restart;
and then
> ithprime(100);
There are several ways to repeat operations in Maple. To list all the first 100 primes
numbers, enter one of the two commands
> seq(ithprime(n),n=1..100);
> for n from 1 to 100 do ithprime(n) od;
The commands between do and its ‘opposite’ od are then carried out for each value of n
that has been stipulated. (You can leave out ‘from 1’ provided you wish to start with n
equal to 1.)
To test whether a given number is prime you can use the command isprime. For example
> isprime(2^16+1);
will return ‘true’, but
> isprime(2^32+1);
7
‘false’. Try
> for n to 100 do
if isprime(2^n-1) then print(n) fi
od;
This lists those values of n for which 2n − 1 is prime. What do you notice? Prime
numbers of the form 2n − 1 are called Mersenne primes; can you explain why n must be
prime in this case?
Do the same with 2n + 1. To do this there is no need to retype hardly anything. Just
use the mouse to position the cursor immediately after the -, press the BACKSPACE
n
key, type +, and enter RETURN. Incidentally, a prime number of the form 22 + 1 is
5
called a Fermat prime, and it was Euler who first showed that 22 + 1 is not prime.
Let pn denote the nth prime number. It is easy to think up your own questions about
pn , and use Maple to try to guess the answer.
‘Twin primes’ are prime numbers which differ by 2. Although there appear to be infinitely
many of these, the assertion is unproved to this day. You can list values of n for which
(pn , pn+1 ) are twin primes as follows:
> for n to 100 do
if ithprime(n+1)-ithprime(n)=2 then print(n) fi
od;
Modify the command ‘print(n)’ so that it prints the two prime numbers instead.
The numbers 3, 5, 7 are all prime. Can you explain why there are no other values of n
greater than 2 for which the nth, (n + 1)st and (n + 2)nd primes are consecutive odd
numbers?
Do you think there are infinitely many numbers n for which the n and (n + 2)nd primes
differ by 6? How many are there for n between 10000 and 10100?
You can plot the points (n, pn ) by letting x = n and y = pn using
> s:= seq([n,ithprime(n)],n=1..100):
plot([s],style=POINT);
Make sure you get all the brackets and punctuation correct. What happens if you omit
‘,style=POINT’ ? Compare this with the curve y = x ln x by entering
> plot({x*ln(x),[s]},x=1..100);
8
(ln denotes logarithms to base e). You will see that the difference pn − n ln n is getting
larger and larger, and this may be verified by defining
> f:= n->ithprime(n)-n*ln(n):
and then evaluating f(100) or any other value.
Define in Maple the function
g(n) =
pn
,
n ln n
and see what happens to this as n gets larger.
Copy the following program and enter it.
> n:=
s:=
a:=
for
10:
seq(ithprime(i),i=1..n);
i->abs(s[i+1]-s[i]):
k to n-1 do s:= seq(a(i),i=1..n-k) od;
Can you explain what the output represents? Is there any particular feature of it that
is striking? Try replacing 10 by much larger numbers to see what happens.
9
Curve plotting
To sketch the function x3 e−x for x > 0, try entering
> restart;
y:= x->x^3*exp(-x):
plot(y(x),x=0..15);
You can experiment to find the range of x that supplies the best picture, although in
practice you may get fed up waiting for the graphics to appear! To conserve resources,
close each extra window when you are finished with it using EXIT from the FILE menu.
It is easy to get a series of graphs in the same picture in one of the following two ways
> plot({exp(-x),x*exp(-x)},x=0..5):
> s:=seq(x^n*exp(-x),n=1..5):
plot({s},x=-1..2):
The second example is especially attractive. Which two points do all these graphs pass
through? Explain the answer without reference to the graphs.
You can even plot functions which are not defined at one point, as in the example
> plot(x*ln(x),x=0..9);
Note that the natural logarithm ln x is not defined when x = 0 though informally we
may write ln 0 = −∞. But can you explain why x ln x approaches 0 as x does?
Next, let f (x) = xx . Try plotting f (x) for 0 ≤ x ≤ 2, after first entering the definition
> f:= x->x^x:
As it stands, the function f (x) is undefined when x = 0. But what is the most appropriate value that one could assign to f (0)? What is the value of x for which f (x) is
df
minimum? To solve this, you need to find where f 0 (x) = dx is zero, and it helps to take
logs and then differentiate the equation ln f = x ln x. Check your answer by typing
> diff(f(x),x);
solve(%=0);
This illustrates the versatility of packages such as Maple.
10
What does knowledge of f 0 (x) tell you about the gradient of the graph of f (x) when x
is very close to 0? Try a smaller range of x to get a clearer picture of what is going on.
You can draw graphs of implicitly-defined functions using the command implicitplot.
To do this, first type
> with(plots):
You may be able to predict what will happen when you enter
> eq:= x^2+y^2=1:
implicitplot(eq,x=-1..1,y=-1..1);
Is the result what you expected? What happens when you replace the equation with
x4 + y 4 = 1?
The hyperbolic tangent function tanh x equals any one of
tanh x =
sinh x
ex − e−x
1 − e−2x
= x
=
.
cosh x
e + e−x
1 + e−2x
Enter one of
> plot({tanh(x),tanh(x)/x},x=-4..4);
> plot({arctan(x),tanh(x)},x=-2..2);
and explain how the graphs are related.
11
Euclid’s algorithm
Let a, b be non-negative integers (each one of 0, 1, 2, 3, . . .). One writes a|b to mean ‘a
divides b’, i.e. there exists an integer c such that ac = b. If a|b, we say that ‘a is a
divisor or factor of b’. Then the highest common factor or greatest common divisor of
a, b is the largest integer which divides both a and b, and is written gcd(a, b).
If p is prime then for any a we must have gcd(p, a) = 1 or gcd(p, a) = p. It is well
known that any positive integer can be uniquely factored as a product of prime numbers,
and given such factorizations of a and b it is easy to spot gcd(a, b). For example
5432 = 23 .7.97,
2345 = 5.7.67 ⇒ gcd(5432, 2345) = 7.
However, factorization does not provide an effective procedure for computing the gcd of
large numbers, as you can see by entering
> ifactor(10^30-1); ifactor(10^30-3);
Given non-negative integers a, b with b > 0, it is fairly obvious that there exist unique
integers q, r such that
a = qb + r,
with 0 ≤ r < b.
A precise recipe for a computer to determine the quotient q is called the ‘division algorithm’, and can be reduced to the task of finding ba/bc, where bxc denotes the largest
integer less than or equal to x and in Maple is called trunc(x).
With the above notation in which r is the remainder of dividing a by b,
gcd(a, b) = gcd(b, r)
To see this, let d = gcd(a, b). Note that not only is d|b true, but also d|r because d|a
and r = a − qb; thus d is at least a common divisor of b and r. To show that it is the
greatest, suppose that e|b and e|r. Then e|(qb + r), so e is a common divisor of a and
b, and so e ≤ d. Therefore d = gcd(b, r), as required. Observe also that gcd(a, 0) = a;
this follows since a|a and a|0, and if e|a and e|0 then obviously e ≤ a.
The boxed equation is the essence of Euclid’s algorithm for computing gcd(a, b). It is
already contained in Maple by means of the command gcd. Check it out with
> gcd(5432,2345);
This algorithm, or mechanical procedure, is the world’s oldest, dating from 300BC.
However, only in middle of this century, with the advent of electronic computers, was
the study of algorithms taken seriously and developed further.
12
To see how effective it is try also
> a:=100!-3; b:=100^100+5;
gcd(a,b);
You may know that n! (read ‘n factorial’) means the product of all the numbers between
1 and n inclusive, and gets enormous very quickly.
As another application, try
> for n from 1 to 100 do
if gcd(ithprime(n),53!+1)>1 then print(n) fi
od;
and repeat it with different values of n. Is 53! + 1 prime?
We shall now write our own explicit versions of Euclid’s algorithm, using Maple’s proc
command which is essentially a fancy way of defining a function. The boxed equation
leads us to define
> g:= proc(a,b)
if b=0 then a
else g(b,a-b*trunc(a/b)) fi;
end:
Test that this works by typing
> g(100!-3,100^100+5);
and checking that you get the same answer as above.
Now change the last line in the program defining g to ‘print(a) end:’ and then enter
> g(20365011074,12586269025);
Can you explain what the output represents? If you change the last digits of these
numbers in any way you like and re-enter g of them, you should notice that the output
shrinks, indicating that the gcd is computed in fewer steps.
13
Chaos
If you were interested in iteration, you may wish to attempt this section, time permitting.
Although it is related to the earlier example on Newton’s method, it was written before
the author knew the content of the summer school’s lecture courses and can therefore be
attempted independently of them.
We shall examine the function y = f (x), where
f (x) = ax(1 − x),
and a is a positive constant that we shall vary. The graph of y = f (x) is an inverted
parabola passing through the points (0, 0) and (1, 0) and is easy to imagine.
First of all, define the function as follows:
> restart;
f:= x->a*x*(1-x):
and press RETURN. Now define a to equal 2 and plot the function by typing
> a:= 2:
plot(f(x),x=0..1);
After you have typed the colon at the end of the first line, remember to keep the SHIFT
key held down as you press RETURN.
Now see how the shape changes as you alter the value of a. As usual, remove any old
graphs you do not want. Replace 2 by 3 in the definition of a (there is no need to
retype anything else) and then press RETURN to register the change and the plotting
command.
For which values of a is it true that 0 ≤ f (x) ≤ 1 whenever 0 ≤ x ≤ 1?
Now take a = 2.5. For which value of x (other than 0) is it true that f (x) = x?
It will be quicker to answer these questions from the equations alone, but you can plot
another graph to check the answer if you want.
Next, we carry out an iteration by repeatedly applying f to a previous value. Type
> Digits:=20:
a:= 2.5: x(0):= 0.7;
for n to 10 do x(n):= f(x(n-1)) od;
The first line sets the number of decimal places. The new definition of a will replace any
other that may still be on screen. When you enter these lines, Maple should display the
sequence of numbers xn (typed as x(n)) where x0 = 0.5 and xn = f (xn−1 ) for n ≥ 1.
14
What is happening to xn as n gets larger? You can also try ‘for n to 50’ to make the
results more dramatic. Now repeat everything with x0 = 0.8. How is this case different?
Can you explain what is going on with reference to the graph?
Next, fix x = 0.2, but keep changing the value of a between about 3.35 to 3.55 to see
what happens to the sequence. Show that there are values of a for which the sequence
ultimately oscillates (to any required accuracy) between (i) two different values, (ii) four
different values, (iii) eight different values. You will need to use the mouse and scrollbar
each time to return to retype the value of a.
Now take x0 = 0.5, and (iv) a = 3.830, (v) a = 3.843, and ‘for n to 200’ in each
case. You might also like to replace f(x) by f(f(f(x))) temporarily. The phenomenon
you should discover is called ‘period doubling’. This takes place when a lies in certain
well-defined intervals or ‘windows’, outside of which the behaviour of (xk ) will be seen
to be chaotic.
Consider the collection of points
S = {(xk , xk+1 ) : 50 ≤ k ≤ 100}.
It is instructive to join every successive pair (xk , xk+1 ), (xk+1 , xk+2 ) by a straight line
and plot the result, after one has defined the sequence for given values of a and x0 . For
example, in (ii), S should consist of only 4 points, and there will be exactly 4 lines.
One way to carry out this plotting is to define
> Digits:=20:
a:= 3.56: x(0):= 0.2:
for n to 100 do x(n):= f(x(n-1)) od:
y:= k->[x(k),x(k+1)]:
S:= seq(y(k),k=50..100):
plot([S]);
Observe that you only need type the last three lines if you do so immediately below your
existing program using SHIFT RETURN. Replace the semicolon after od by a colon to
suppress the 200 values.
Try this for various values of a between 3.5 and 3.6. Pay particular attention to what
happens as a increases through 3.57.
15
List of commands
Some of the commands below are not ones that have been used in the text so far. Most
of the entries are explained by example, and you must type the commands to see what
they achieve. In some cases you will need to first enter
> restart;
to avoid an error. A full explanation of a Maple command such as plot can be obtained
by entering
> ?plot
abs The absolute value function –
f:= x->1-abs(x):
plot(f(x),x=-2..2);
animate Can only be used after first entering the command with(plots); and it plots
a sequence of graphs in time –
f:= (x,t)->x^3+10*t*x+1:
animate(f(x,t),x=-4..4,t=-1..1);
diff The standard command for differentiation –
diff(E^x,x);
diff(ln(ln(x)),x);
Higher derivatives can be computed as in
diff(exp(-x^2),x$4);
do Used with for and closed by od; to carry out an operation for incrementing values
of a variable –
for n from 0 to 20 by 2 do n^2 od;
16
There is no need to insert punctuation before od; and the termination may be specified
using while –
for n from 0 while n<11 do
seq(binomial(n,k),k=0..n)
od;
Observe that by 1 and from 1 are understood if omitted –
ln:
for k to 5 do y:=int(%(x),x): x->y od:
y:
dsolve Solves many differential equations symbolically –
eq:= (D@@2)(y)(x)+3*D(y)(x)-4*y=(1+x)^3:
dsolve(eq,y(x));
eq:= diff(y(x),x$2)-2*diff(y(x),x)+5*y(x)=4*exp(x):
ic:= y(0)=1,D(y)(0)=0:
dsolve({eq,ic},y(x),series);
evalf Evaluates a quantity numerically whenever this is possible, rounding to 10
significant figures (f stands for ‘floating point’) –
evalf(Pi); evalf(Pi,70);
s:=evalf(sqrt(5)): phi:=(1+s)/2;
To get all evaluations to 70 decimal places (the length of a line!) without having to ask
for it each time, type Digits:=70: If one number is already evaluated, so will subsequent
expressions containing it. Other examples –
evalf(int(exp(-x^2),x=0..2)); evalf(%);
product(365-i,i=0..22)/365^23); evalf(%);
expand Splits an expression up into a sum of terms, for example by multiplying out
brackets or removing a common denominator:
expand((1+x)^7);
expand((1+x+x^2)/y);
17
factor Picks out common factors over the integers, and often acts as the ‘inverse’ of
expand –
factor(x^6-y^6);
factor(1+x^100);
Factor(x^8+x+1) mod 2;
The last command factorizes modulo 2.
if Conditional that also uses else and is closed by fi; Can be used to define a
function, as in
f:= x-> if x>0 and x<10 then x^2 else 0 fi:
f(5); f(10);
but no good for plotting.
implicitplot Can only be used after first entering the command with(plots);.
Draws the graph of a curve defined by an implicit equation, as in
eq1:= y^2=x^3:
implicitplot(eq1,x=0..2,y=-1..1,title=‘a bit rough‘);
eq2:= x^3+1=sin(y):
implicitplot(eq2,x=-2..2,y=-2..2,numpoints=2000);
int The standard command for integration, as in
int(sec(x),x);
int(arcsin(x),x);
int(ln(ln(x)),x);
Definite integrals can be computed as in
area:= int(exp(-x^2),x=-4..4):
evalf(area-sqrt(Pi));
log The logarithm function –
[log(3), log[10](3), log[a](b)];
evalf(%);
A base other than e has to be put in square brackets.
18
matrix Can only be used after first entering the command with(linalg);. Converts
a list into a matrix of specified size, in one of the following ways –
matrix([[a,x,z],[0,b,y],[0,0,c]]); det(%);
matrix(3,3,[1,x,z,0,1,y,0,0,1]); evalm(1/%);
matrix(4,4,[seq(i^2,i=1..16)]); %^2;
matrix(4,4,(i,j)->i*j); evalm(%^2);
Use evalm if necessary to display functions of matrices.
min Finds the minimum of a sequence of numbers –
max(1,2,8,9,45,34,23);
plot Graphs one or more functions –
f:= x->sin(x): g:= x->sin(x)/x:
plot(f(x),x=0..4*Pi):
plot({f(x),g(x)},x=-7..7);
You can specify a range for the vertical coordinate, and include ‘options’ to enhance the
quality of the graph, as in
plot(sin(1/x),x=0..1,0..2);
plot(sin(1/x),x=0..1,numpoints=2000):
Can also draw a curve defined parametrically, and plot points or lines between them –
plot([cos(t),sin(Pi*t),t=0..40*Pi],title=‘Lissajous figure‘);
pts:= seq([cos(2*i),sin(2*i)],i=1..80):
plot([pts],style=POINT): plot([pts]);
product carries out repeated multiplication –
p:= product(1/(1-x^k),k=1..10):
series(p,x,10);
restart Wipes out all previous definitions made in an XMaple session. Helps to
eliminate the frequent error of introducing a symbol that you used previously as a variable
and which therefore has a value –
for k to 10 do evalf(exp(k)) od;
diff(k^3,k);
restart:
diff(k^3,k);
19
seq Produces a sequence of objects, which can easily be converted into a set or sequence
for plotting or other purposes –
s:= seq((5-i)^2,i=0..10);
{s}; [s]; sort([s]);
t:= seq(exp(-x^2/k),k=1..5):
plot({t},x=-2..2);
series Expands functions as a power series –
a1:= series(tan(x),x,9);
a2:= series(log(x),x=1,5);
convert(a2,polynom); expand(%);
b1:= sum(x/(1-x^j)^2,j=1..20);
b2:= sum(x^j/(1-x^j),j=1..20):
series(b1,x,20);
series(b2,x,20);
simplify Converts an expression into a ‘simpler’ form if possible –
simplify(x+x^2); simplify(1-1/x);
x:= r*cos(t): y:=r*sin(t):
simplify(x^2+y^2);
Lap:= diff(f(x,y),r$2)+diff(f(x,y),r)/r+diff(f(x,y),t$2)/r^2:
simplify(Lap);
solve Finds solutions to algebraic equations –
eq:= {x+y^2=a, 2*x+7*y=3}:
solve(eq);
solve(eq,{x,y});
subs Substitutes expressions or values for variables –
poly:= x^3+x+1:
subs(x=3,poly);
subs(x=x+1,poly); expand(%);
sum Carries out repeated addition –
sum(i^5,i=1..100);
20
© Copyright 2026 Paperzz