chapter 6: mupad objects ii sequence, list, set, function matlab for scientist and engineers using...
TRANSCRIPT
Chapter 6:
MuPAD Objects IISequence, List, Set, Function
MATLAB for Scientist and Engineers
Using Symbolic Toolbox
2
You are going to See that MuPAD handles objects Get to know MuPAD sequences, lists, sets,
and function types Use these objects for various purposes
4
Sequences (cont.)
Range using in
Application: Repeated differentiation
Manipulation
Apply to all operands
Modify 1st Object
Delete 2nd Object
7
Exercise
Use a simple command to generate the dou-ble sum
Hint: the function _plus accepts arbitrarily many argu-ments. Generate a suitable argument sequence.
8
Lists – DOM_LIST
An ordered sequence of arbitrary MuPAD ob-jects enclosed in square brackets
Parallel Assignment
Swap
Two. assignments happen atthe same time
11
Lists – Other Operations
Returns TRUE if the elementhas it as an operand.
TRUE FALSE UNKNOWN L1 L2
13
Exercise
Generate two lists with the elements a, b, c, d and 1, 2, 3, 4, respectively. Concatenate the lists. Multiply the lists pairwise.
14
Exercise
Multiply all entries of the list [1, x, 2] by 2. Suppose you are given a list, whose ele-ments are lists of numbers or expressions, such as [[1, x, 2], [PI], [2/3, 1]], how can you multiply all entries by 2?
15
Exercise
Let X = [x1, . . . , xn] and Y = [y1, . . . , yn] be two lists of the same length.
Find a simple method to compute their
“inner product”
x1 y1 + · · · + xn yn,
You can achieve this by using zip, _plus, map and appropriate functions
16
Sets – DOM_SET
An unordered sequence of arbitrary objects enclosed in curly braces
Basic Operations
20
Exercise Instead of the binary operators intersect and union, you
can also use the corresponding MuPAD functions _in-tersect and _union to compute unions and intersec-tions of sets. These functions accept arbitrarily many ar-guments. Use simple commands to compute the union and the intersection of all sets belonging to M:
M := {{2, 3}, {3, 4}, {3, 7}, {5, 3}, {1, 2, 3, 4}}:
24
Exercise
Define the functions f(x) = x2 and g(x) = .
Compute f (f (g(2)) and f(f(. . . f (x) . . .)).x
100 times
26
Key Takeaways
Now, you are able to generate sequences using a range operators, manipulate lists, apply basic operations on sets, and to define/derive functions using @ operators.
27
Summary
Explain the following expressions
$ 10..20 x $ 3 [a,b] := [b,a] list1.list2
sort(list) min(list) max(list)
select(list,has,x) split(list,has,x)
zip(list1,list2,_plus,x)
map(set1,sin)
set1 union set2
f @ g
f @@ 3