Lecture 1
Lecture 1
Lecture 1
H.Ali Merina
2023-2024
Introduction to Maple
The term "symbolic computation" or "computer algebra" involves representing and manipulating
mathematical objects within a computer. This leads to powerful tools known as "Computer
Algebra Systems" (CAS), essential for professionals in various fields, including mathematicians,
physicists, chemists, engineers, technicians, psychologists, and sociologists. Maple, an example
of such software, performs precise calculations without relying on specific numerical values for
variables. But before diving into Maple, it's essential to differentiate between other types of
mathematical computation.
02
Numeric computation, or scientific computation, simplifies calculations to basic arithmetic
operations on numbers represented by limited symbols (digits). This introduces approximation and
error due to floating-point representations and discretization. Programming languages like Fortran, C,
and Pascal, as well as numerical software like Matlab, are commonly used for numeric computations.
On the other hand, symbolic computation involves working with symbols representing various mathematical
objects, such as numbers, polynomials, rational functions, and algebraic structures. The emphasis is on
exact computations following algebraic rules, avoiding the imprecision of approximate floating-point
arithmetic. Examples include factorization of polynomials, differentiation, integration, series expansion,
analytic solution of differential equations, and simplification of mathematical expressions.
03
Maple: A powerful all-in-one math tool for diverse user groups, Maple, introduced in 1981 by
Waterloo Maple Inc., is a versatile software that combines:
04
This combination makes Maple the preferred choice for a wide range of users:
05
I. Getting Started with Maple
I.1.1 Interface Presentation :
To begin, ensure Maple is installed on your computer. Then, open the program by either
clicking the Maple icon. If you start Maple by selecting the Maple icon, a blank untitled
worksheet is opened, as illustrated in the following screenshot.
06
Provides access to various commands and functions.
07
Menu Bar
Contains shortcuts to frequently used tools and commands.
08
ToolBar
Provides tools and symbols for creating and editing
mathematical expressions.
09
Palette
Displays the prompt where users enter Maple commands.
10
Maple Prompt
Allows users to input Maple commands and
expressions and displays the results of Maple
computations and commands.
11
Worksheet
In the Startup dialog box, select "Open Blank Worksheet". A blank document will appear. Alternatively,
❑ From the File menu, select New, then Worksheet Mode. A blank document will appear.
In Maple, the default format for entering mathematical expressions is the Math 2-D format. This
results in mathematical expressions of the same quality as those found in textbooks. Entering
mathematical expressions in Math 2-D in Maple can be done using common keyboard keys or
expressions from the palettes.
12
13
When starting Maple, you should begin by opening a worksheet using the File menu (File menu, select
New, then Worksheet mode). This will allow you to work in worksheet mode (there is also a document
14
I.1.2 The worksheet mode
Once Maple has been started, computations can be carried out immediately. The worksheet mode
is preferable for mathematical use of Maple and for experimenting with small programs.
The worksheet starts with a red prompt ([>), indicating where you can enter commands.
To execute a command, either end it with a semicolon or press Enter directly.and vivid as
possible.
In the top toolbar, you will find two symbols: "T" and "[>".
15
By clicking on "T," you can open a text area where you can type comments about your work.
By clicking on "[>", you open a Maple command line for performing calculations.
16
I.2 Getting Help from Maple
Becoming competent with Maple can take a serious investment of time. Maple is a feature-rich
software, and it is not feasible to know all the commands and their syntax that will be covered in
your Labs. Maple's help documentation is highly useful for finding this kind of information, and it's
crucial to know how to use it. There are various ways to access this assistance :
17
Help Menu in Maple
This menu offers guidance on Maple functions and definitions of utilized objects. The help page
includes the function's syntax, an operational description, and illustrative examples. It's often
beneficial to review examples before delving into the detailed function description. The Help
Menu also provides access to diverse tutorials. To access it, press "Open the help system" and
search for a topic to perform a thematic search. This allows you to explore help topics related to
a specific theme or concept.
18
19
?
Use of "?" or help(object)
Command Menu in Maple
Alternatively, you can type "?object" or "help(object)" that provides a basic description and syntax
information for the Maple object. For instance, "?plot" or help(plot)offers fundamental
information about the plot function. Understanding these methods will significantly enhance
your efficiency in working with Maple.
20
Remember, Maple's help system is your best friend
21 don't hesitate to use it! work overview
22
Rule 1:
Always end commands with either a semicolon (;) or a colon (:). The semicolon shows the result, while
the colon hides it. (To run a command in Maple without seeing its output, use a colon (:) instead of a
semicolon (;).)).
Rule 2 :
Rule 3 :
First and foremost, to ensure the preservation of your work, it is recommended that you
immediately utilize the "File" menu and select "Save" or "Save As". Your saved file will possess the
".mw" extension. To open a saved worksheet, use the "File" menu and select "Open." Note that
only the worksheet, not the calculation results, is retrieved in this case.
23
If you want to work on the worksheet again and have the previous results available, you will need to re-
execute all the commands in the worksheet. This can be done by validating each command one by one
using the "Enter" key or by using the "Edit" menu, selecting "Execute", and then "Worksheet". Alternatively,
you can choose to re-execute each line individually. Additionally, there is a button with three exclamation
marks (!!!) located on the toolbar above the worksheet that can be used to execute all the commands in
the worksheet.
24
Rule 4 :
Maple distinguishes between uppercase and lowercase letters. For example: The lowercase "pi" (:pi) is
Rule 5 :
A hashtag "#" allows you to write a comment that will not be taken into account in the
evaluation.
25
Rule 6 :
The command "restart;" in Maple is used to reset a worksheet, effectively clearing all variables and
operations that have been defined. It is recommended to use it at the beginning of each exercise.
Rule 7 :
In Maple, the percent symbol "%" can be used as an argument to refer to the last result calculated
chronologically. Similarly, "%%" refers to the second-to-last result, and "%%%" refers to the third-to-
last result. This recall technique stops at the third-to-last result.
26
Using these percent symbols eliminates the need for copy-pasting previous results and provides a
Rule 8 :
27
Rule 9 :
When you close your worksheet (after saving), the sheet is saved, but not the calculation results.
Therefore, you have to re-run everything: each line one by one, or by pressing the !!! button on the
toolbar.
Rule 10 :
Sections and subsections are a useful way to organize your worksheet. To create them,
select Insert -> Section for a section and Insert ->Subsection for a subsection.
Once these calculations are done, they remain in the machine's memory for the entire
session. You can navigate up and down the worksheet, reusing these results as needed.
28
I.4 Loading Packages
In Maple, not all functions are predefined, requiring the loading of certain functions using the
command [> readlib(nomfn):. Maple offers a variety of packages, categorized by domain or topic,
each containing numerous functions. For instance, the plots package gathers graphical
representation functions, while the linalg package groups linear algebra functions.
29
To simplify complex matrix calculations, Maple provides also the LinearAlgebra package, loaded using
the "with" command [> with(LinearAlgebra);. If you wish to suppress the display of procedure names
during package loading, use a colon (:) instead of a semicolon (;) at the end of the with command.
You have also: [> with(package) for loading all package resources and [>
30
II. Basic Operations on Numbers,
Expressions, and Functions
II.1 Numerical Calculations and Built-In Functions
31
Operator Maple Notation Operator Maple Notation
Addition + The remainder of division mod
Subtraction - The absolute value abs
Multiplication * The integer part floor
Division / Exponentiation exp
Exponentiation ^ or ** The square root sqrt
Factorial !
32
The name of a variable can be a combination of letters and numbers, but it must start with a letter,
contain no spaces, and be different from reserved words (Maple commands). The type of a variable is
Example: if A takes the value 2, A will be of type integer, if A takes the value 2., A will be of type float)
some of the predefined types in Maple are: integer (integer), real (float), rational (fraction), complex
(complex), string (string), boolean (boolean), array (array), matrix (matrix).
33
The variable name must not contain punctuation marks, spaces, or special symbols (e.g., +,*,#,%,@).
You can use upper and lowercase letters (but be careful! Maple differentiates between the two!).
● To access the content of a variable in Maple, you can simply refer to its name in an expression
or statement.
34
Multiple assignments are possible
35
II.1.1 Built-In Constants
Maple has built-in definitions of many commonly used constants. In particular, e ≈ 2.71828 is
denoted by exp(1), π ≈ 3.14159 is denoted by Pi, and i = √-1 is denoted by I. Usually, Maple
performs complex arithmetic automatically. Other built-in constants include ∞, denoted by infinity.
36
37
In Computer Algebra system, the operations on integers or rationals are exact. Maple can process
long integers and has a variety of arithmetic functions (factorial, Euclidean division, factorization,
least common multiple, primality test, etc.). The subtypes of integers are: posint, negint, even
(even), odd (odd) and prime (prime), which you can easily identify using type or is functions.
39
Example : A typical integer calculation is that of factorial 10.
41
II.3 Float computations
Maple's automatic simplification rules for exact numbers (rational numbers) become less well-
defined when dealing with decimal numbers (floats). In calculations involving both types, like sums,
products, or quotients, the decimal numbers 'dominate,' causing the entire expression to become a
decimal number.
42
For other expressions, the primary function for these computations is evalf, which numerically evaluates
an expression (all numbers are converted to floats). An optional argument enables the specification of
Example
Here is Pi with 50 significant digits
43
The precision can also be set by the global variable Digits, which is 10 by default (global change of
44
II.4 Rational Computations
A rational number is a fraction of the form a/b, where a and b are two integers and b≠0.
Example
In this example, the factorials are first evaluated, and then the resulting rational number is simplified :
45
• numer(Fraction); # extracts the numerator of a fraction
46
II.5 Boolean computations
Boolean expressions constitute a fundamental category. The two standard forms are true and false. Additional expressions
can be simplified to these forms using the evalb(evalb(expression)) command, which assesses an expression containing
relational operators. Boolean expressions are commonly employed in computer science to govern decisions in algorithms
and programs.
47
II.6 Complex numbers computations
a + b * I where a is the real part and b is the imaginary part, and the complex number i =
sqrt(-1) is represented by the uppercase letter I.
48
• The evalc(X) command is used to force the result to be in the algebraic form, i.e., to
simplify a complex expression X into the form a * I + b
49
II.6.2 Polar form :
• The polar(X) command allows obtaining the polar representation of a complex number. The
result will be polar(r, t), where r is the modulus and t is the argument
• The abs(X) command gives the modulus of a complex number X
• The argument(X) command gives the argument of X
• The conjugate(X) command gives the conjugate of a complex number X.
50
Summary