

Programs using loops are often inefficient in Mathematica.54įour types of brackets in Mathematica.55 Local goto statements: Break, Continue, Return.53 Side effects induced by loops.53īlocks of operators - the CompoundExpression command.53 Pass by reference semantics - possible to imitate.47 The role of side effects.46Ī digression: standard and non-standard evaluation.46 Set and SetDelayed : when which one is used.44Įquality checks.44Įqual.44īeware: Equal may return "unevaluated".44Įqual is used by built-in solvers to build equations.45Īssigning the result of Equal to a variable, and more on evaluation.45 The difference between Set and SetDelayed : an example.41Ĭhain assignments.42ĭon’ t use SetDelayed with more than two arguments.43 Immediate and delayed assignments: Set and SetDelayed.41

ValueQ.39ĭynamic data typing.40Īssignments.41 Indexed variables and DownValues.36Ĭomposite variables and SubValues.37Ĭlearing variables.37Īssignments attach rules to Symbol-s.39 Third principle: expression evaluation.33 Non - commutativity of rules substitution.32Īutomatic rule reordering.32 Patterns allow for multiple definitions of the same function.31 Rewrite Rules.30Īn example of a simple pattern-defined function.30įunctions are really rules : DownValues command.31Įxample of a function based on a restricted pattern.31Ī bit about evaluation.31 Second principle: pattern-matching and rule substitution.30 Levels of expressions and the Level command.28 Heads of expressions and the Head command.27Īccessing individual parts of expressions through indexing. Literal equivalents of built-in functions, and FullForm command.26Īll normal expressions are trees - TreeForm command.27 Mathematica normal (composite) expressions.26 Introduction.26 1.1įirst principle: everything is an expression.26Ītoms and the built-in AtomQ predicate.26 Other symbols, where used, respective owners.ĭigitally signed by Leonid Shifrin DN: cn=Leonid Shifrin, o=Brunel University, ou,, c=GB Date: 2009.02.04 11:30:22 -08'00'Ĭontents Preface.18 I. MathematicaTM is a registered trademark of Wolfram Research Inc. To view a copy of this license, visit or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. Put another way: how Mathematica does things doesnt necessarily correspond to 'manual' methods.

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. A typical problem is that Mathematica has many internal optimizations, and the efficiency of a computation can be greatly affected by whether the details of the computation do or do not allow a given internal optimization to be used. Mathematica programming: an advanced introduction Leonid Shifrin Copyright © Leonid Shifrin, 2008 In this case, your best bet is to quantify all but one parameter and use numerical solving.MathematicaÒ programming: an advanced introduction Leonid would be the exact solution to your equation. Thus, MMA does the best it can, showing that the root of a polynomial which takes in an argument #1 (equivalent to #) and transforms it into #1^8 c^4. For some expressions, such as yours, which can be rewritten as a degree-8 polynomial, there exist no exact algebraic solutions. Thus, something like #^2 & evaluates to 9 (more examples in the linked tutorial). The ampersand denotes the end of the pure function (so that in more complicated expressions one could use several pure functions and limit what they do). In other words, the Slot indicates the parameter of my unnamed - "pure" - squaring function. Reveals that what is actually going on is Function,2]]. The Slot is treated as the argument in an anonymous function. While the tutorial will undoubtedly explain better that I could the entire topic of pure functions, which is what Slot, or # has to do with, I'll answer the specific question at hand. I'll save you from an explanation about radicals and finding polynomial roots. So, Root is a kind of stenographic writing for roots of polynomials with order > 3. It's just the first root of the polynomial.
#MATHEMATICA 7 NOTEBOOK IN MATHEMATICA 10 HOW TO#
That means Mathematica doesn't know how to calculate a symbolic result for the root. So, if your polynomial is $x^2 - 1$, using what we saw above: f = #^2 - 1 &īut if we try with a higher order polynomial: f = -1 - 2 #1 - #1^2 + 2 #1^3 + #1^4 &

Root represents the exact kth root of the polynomial equation f=0. Or you may have a function operating on a list, like: f = #] + #] & If you have a function operating on two variables, you could do: f = #1 + #2 & That is important for pairing & and # when you have nested functions. The & "pumps in" the expression into the # sign. If you want to define a function, $y(x)=x^2$, you just could do: f = #^2 &
