If you try to assign to a name that is predened or

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the left-hand side of the :=. The function definition (using the arrow notation) is on the right-hand side. The following statement defines 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 Predefined and Reserved Names Maple has some predefined and reserved names. If you try to assign to a name that is predefined 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 name-forming operation. The concatenation operator in Maple is “||”. You can use the operator in the following manner. > a||b; ab When applying concatenation to a sequence, the operation affects 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 > a||S; 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*x-1, 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.

Ask a homework question - tutors are online