4
|
5388 Views
|
3 Replies
|
8 Total Likes
View groups...
Share
GROUPS:

# Teaching: Compiling a list of beginner mistakes.

Posted 9 years ago
 I teach a physical sciences class in which I use Mathematica as a vehicle for instruction. For the first week or so, I teach Mathematica basics. I've been compiling a list of typical beginner mistakes and "gotchas". In addition to the working examples in the documentation, I find it useful to illustrate typical mistakes as well. Here is a list of typical beginner mistakes. Can anyone add to it? (Again, this is for students who are at the beginning of the learning curve for Mathematica). These aren't necessarily mistakes, but examples of doing something with unintended consequences. ()-parentheses for function calls: Cos (kx)  upper case/lower case arccos[Pi]  List indexing someList = {1, 2, 3, "a"}; someList  Operator precedence ( -b + Sqrt[b^2 - 4 a c])/2 a  No patterns in a function definition myFunction[x, y, z] := Sin[x] Sin[y] Sin[z] myFunction[1, 2, 3]  Prior definition and no set delayed in function definiition x = Pi/2; absSin[x_] = Abs[Sin[x]]  Plotting things that don't evaluate to numbers x = Pi/2; absSin[x_] = Abs[Sin[x]] Plot[absSin[z], {z, -Pi, Pi}]  *Not using == in Solve** Solve[{p = 2 q + r a, q = a - p - q^2}, {p, q}]  Evaluate in functions with Hold attributes Plot[Table[Sin[ k x], {x, 0, 2 Pi}], {k, 1, 4}]  Typeset forms are not what they appear to be matrix = {{1, 4}, {4, -2}} // MatrixForm Eigenvalues[matrix]  Small imaginary parts appear as a result of numerical evaluation sinExp[x_] := (Exp[Sqrt[-1] x] - Exp[-Sqrt[-1] x])/(2 Sqrt[-1]) Table[sinExp[x], {x, -Pi, Pi, .1}]  =============================== Not recognizing when there is Nonstandard Argument Evaluation myExpression = ( -b + Sqrt[b^2 - 4 a c])/(2 a) Manipulate[ myExpression, {a, -1, 1}, {b, -1, 1}, {c, -1, 1} ]  (note: here is how one might go about fixing the above "error") With[{myManipulateExpression = myExpression}, Manipulate[myManipulateExpression, {a, -1, 1}, {b, -1, 1}, {c, -1, 1}] ]  =============================== Integer arguments to Part in Manipulate randomWalk = Accumulate[RandomReal[{-1, 1}, {1024}]]; Manipulate[ListPlot[randomWalk[[1 ;; step]]], {step, 1, 1024}]  Mathematica is chronological and not spatial: the value of something depends on when it was defined and not where (within a notebook) it appears. with thanks to David Reiss: Notebooks that share the same kernel (and have the same context). In other words, notebooks typically share definitions of symbols
3 Replies
Sort By:
Posted 9 years ago
 The main one I find not on the list is forgetting to put a space for multiply between variables: k x is not the same as kx 
Posted 9 years ago
 Your list is good. Fyi, there is a large list here also what-are-the-most-common-pitfalls-awaiting-new-users
Posted 9 years ago
 On thing that I often encounter is the confusion about the fact that values (of parameters, function definitions, & c...) are common to a Mathematica session rather than localized to each notebook separately. (Of course one can set a notebook to have its own context, but that's an advanced concept.)The error for myExpression = ( -b + Sqrt[b^2 - 4 a c])/(2 a) Manipulate[ myExpression, {a, -1, 1}, {b, -1, 1}, {c, -1, 1} ] falls into the area of Mathematica's standard evaluation sequence (from the inside out) and how some functions (with various Hold attributes) are designed to bypass the standard evaluation process. http://reference.wolfram.com/language/tutorial/Evaluation.htmlPerhaps call it "Not recognizing when there is Nonstandard Argument Evaluation" or something long winded like that.