Example: marketing

MathematicaTM programming: an advanced …

Mathematica programming: an advanced introductionLeonid ShifrinPart I: The core languageVersion 2 To my parents First principle: everything is an Atoms and the built-in AtomQ Mathematica normal (composite) Literal equivalents of built-in functions, and FullForm All normal expressions are trees - TreeForm .27 Heads of expressions and the Head Accessing individual parts of expressions through indexing ..28 Levels of expressions and the Level Second principle: pattern-matching and rule Rewrite An example of a simple pattern-defined Functions are really rules : DownValues Example of a function based on a restricted A bi

MathematicaÒ programming: an advanced introduction Leonid Shifrin Part I: The core language Version 1.01

Tags:

  Introduction

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of MathematicaTM programming: an advanced …

1 Mathematica programming: an advanced introductionLeonid ShifrinPart I: The core languageVersion 2 To my parents First principle: everything is an Atoms and the built-in AtomQ Mathematica normal (composite) Literal equivalents of built-in functions, and FullForm All normal expressions are trees - TreeForm .27 Heads of expressions and the Head Accessing individual parts of expressions through indexing ..28 Levels of expressions and the Level Second principle: pattern-matching and rule Rewrite An example of a simple pattern-defined Functions are really rules : DownValues Example of a function based on a restricted A bit about Patterns allow for multiple definitions of the same Non - commutativity of rules Automatic rule Third principle: expression Elementary Symbols and.

2 34 Legitimate symbol 34 Getting information about symbols4 Getting information about "Proper" variables and Indexed variables and Composite variables and Clearing Does a variable have a value? Assignments attach rules to Dynamic data Immediate and delayed assignments: Set and The difference between Set and SetDelayed : an Chain Don t use SetDelayed with more than two Set and SetDelayed : when which one is Equality.

3 44 Beware: Equal may return "unevaluated"..44 Equal is used by built-in solvers to build Assigning the result of Equal to a variable, and more on The role of side A digression: standard and non-standard Pass by reference semantics - possible to Logical The If If may return "unevaluated"..50 If returns a value 5 If returns a Operators Which and For While Do Side effects induced by Blocks of operators - the CompoundExpression Local goto statements: Break, Continue, Programs using loops are often inefficient in Four types of brackets in Parentheses ().

4 55 Curly braces {}..55 Single square brackets [].. 55 Double square brackets [[ ]]..56 .57 III..58 The main rule of thumb when working with lists in The content of Generation of Generating a list by Generation of lists of equidistant numbers by the Range Generation of lists with the Table A comment on universality of Generation of lists inside Internal (full) form of Working with lists and their parts6 Working with lists and their List indexing and element extraction with the Part Take and First, Rest, Last and Modification of list elements by direct indexing (using Part).

5 68 Adding elements to the list and removing them from the Append, Prepend, AppendTo and Insert and Working with nested Flatten ..82 Working with several The Join The Intersection The Complement Functions related to list sorting ..86 The Sort The Union The Split Rules, patterns and Rules and patterns 7 Rules and Rule, RuleDelayed, Replace and ReplaceAll Rule substitution is not An interplay between rules and evaluation Rules and simple (unrestricted) Applying rules repeatedly - the ReplaceRepeated Conditional (restricted) Alternative Giving names to entire patterns - the Pattern command.

6 121 Optional Repeated Built-in functions that use Position - a second A note on the Heads A more complicated example - finding Functions - starting examples and A definition and a simple More on function names and evaluation On the necessity of More on the correct syntax of the function On function definitions and assignment Assigning values to function symbols (names).

7 143 advanced topic: parameter Function calls: prefix and postfix syntax ..149 Function name Examples of functions of a single argument8 Examples of functions of a single Example: Integer part of a What we will not call a function Example: some trigonometric Example: a function to reverse a string of symbols ..153 Example: A function of Example: a function which exchanges another function and its Example: a recursive factorial Infinite iteration and recursion An esoteric example: a self-destructive printing Mathematical functions and programming Functions of several Starting examples and a Putting constraints on the Examples of functions of several variables (arguments).

8 163 Functions with the variable number of Functions with multiple Example: a discontinuous Adding more Changing definitions Warning: a common Selective removal of the Case study: changing the weights of .176 Larger functions, local variables and the code Function Listable attribute and SetAttributes command 9 Listable attribute and SetAttributes Clearing Attributes - the ClearAll Orderless Flat Protected Attributes are properties of Attributes HoldFirst, HoldRest and Attributes and the evaluation advanced topic: parameter passing and local 4.

9 11 Pure The # - & Pure functions defined with Differences between pure functions defined with Function and with # - & Functions with defaults and options ..205 Functions with Functions with Functions on lists and functional Core higher-order When short-hands let us down: the Heads Generalizations10 Nest Family ..292 Nest and NestWhile and Fold and Fold: syntax and starting More Restriction of Fold-ed function to two arguments is Case study: Gram - Schmidt Small case study: local maxima for a FixedPoint and FixedPointList.

10 342 The syntax and Example: the Collatz problem How to reformulate a problem for Example: deleting numbers from the list Example: approximating the square root of a number FixedPoint Small case study: merging overlapping intervals - Functional vs. Example: local (relative) maxima in a list Operators on Summary 11 Writing efficient programs: some techniques and Case study I: checking if a square matrix is The The test Procedural Functional Implementations based on structural Case study II: extracting matrix The Test Extract - based Procedural The fastest version for all diagonal


Related search queries