This preview shows page 1. Sign up to view the full content.
Unformatted text preview: the lefthand side of the :=. The function deﬁnition (using the arrow notation) is on the righthand side. The following statement deﬁnes f as the squaring function.
> f := x > x^2; f := x → x2 Evaluating f at an argument produces the square of the argument of f.
> f(5); 25
> f(y+1); (y + 1)2 Predeﬁned and Reserved Names
Maple has some predeﬁned and reserved names. If you try to assign to a name that is predeﬁned or reserved, Maple displays a message, informing you that the name you have chosen is protected.
> Pi := 3.14; Error, attempting to assign to ‘Pi‘ which is protected > set := {1, 2, 3}; Error, attempting to assign to ‘set‘ which is protected 2.5 Basic Types of Maple Objects • 21 2.5 Basic Types of Maple Objects This section examines basic types of Maple objects, including expression sequences, lists, sets, arrays, tables, and strings. These ideas are essential to the discussion in the rest of this book. Also, the following concepts in Maple are introduced. • Concatenation operator • Square bracket usage • Curly braces usage • Mapping • Colon (:) for suppressing output • Double quotation mark usage Types Expressions belong to a class or group that share common properities. The classes and groups are known as types. For a complete list of types in Maple, refer to the ?type help page. Expression Sequences
The basic Maple data structure is the expression sequence . This is a group of Maple expressions separated by commas.
> 1, 2, 3, 4; 1, 2, 3, 4
> x, y, z, w; x, y, z, w Expression sequences are neither lists nor sets. They are a distinct data structure within Maple and have their own properties. • Expression sequences preserve the order and repetition of their elements. Items stay in the order in which you enter them. If you enter an element twice, both copies remain. • Sequences are often used to build more sophisticated objects through such operations as concatenation. 22 • Chapter 2: Mathematics with Maple: The Basics Other properties of sequences will become apparent as you progress through this manual. Sequences extend the capabilities of many basic Maple operations. For example, concatenation is a basic nameforming operation. The concatenation operator in Maple is “”. You can use the operator in the following manner.
> ab; ab When applying concatenation to a sequence, the operation aﬀects each element. For example, if S is a sequence, then you can prepend the name a to each element in S by concatenating a and S .
> S := 1, 2, 3, 4; S := 1, 2, 3, 4
> aS; a1 , a2 , a3 , a4 You can also perform multiple assignments using expression sequences. For example
> f,g,h := 3, 6, 1; f, g, h := 3, 6, 1
> f; 3
> h; 1 2.5 Basic Types of Maple Objects • 23 Lists
You create a list by enclosing any number of Maple objects (separated by commas) in square brackets.
> data_list := [1, 2, 3, 4, 5]; data _list := [1, 2, 3, 4, 5]
> polynomials := [x^2+3, x^2+3*x1, 2*x]; polynomials := [x2 + 3, x2 + 3 x − 1, 2 x]
> particip...
View
Full
Document
This note was uploaded on 08/27/2012 for the course MATH 1100 taught by Professor Nil during the Spring '12 term at National University of Singapore.
 Spring '12
 NIL
 Math, Division

Click to edit the document details