As of May 31, 2023, we have updated our Code of Conduct.
118 votes

Why should I avoid the For loop in Mathematica?

If you are new to Mathematica, and were directed to this post, first see if you can use Table to solve your problem. I have often told people, especially beginners,...
Szabolcs's user avatar
  • 231k
43 votes

What are the most common pitfalls awaiting new users?

The default $HistoryLength causes Mathematica to crash! By default $HistoryLength = Infinity, which is absurd. That ensures ...
41 votes

What are the most common pitfalls awaiting new users?

Using Sort incorrectly Sorting mathematical expressions without numeric conversion New users are often baffled by the behavior of ...
34 votes
Accepted

What are the requirements for a well behaved indexed variable? Subscript, ToExpression, Downvalue?

General usage Here is what I think Using strings and subsequently ToString - ToExpression just to generate variable names is ...
Leonid Shifrin's user avatar
33 votes

Why should I avoid the For loop in Mathematica?

Illustration of the timings required to compute the squares i^2 from i=1 to i=10^n for ...
33 votes
Accepted

Why it seems that there is no counterpart function as to multiplication, to `Total` as to addition?

In addition to the previous answer... I designed and implemented Total 17 years ago. Its first version was named ListSum. The ...
Anton Antonov's user avatar
32 votes
Accepted

++ is dangerous for C programmers

I believe Increment (more accurately PreIncrement as george2079 noted) is essentially this: ...
Mr.Wizard's user avatar
  • 267k
29 votes

What are all the "magic" Symbols in the Mathematica language?

uh oh, another "work in progress" answer from me that may never be finished. Unevaluated Robby Villegas, Working with Unevaluated Expressions: ...
Mr.Wizard's user avatar
  • 267k
27 votes

What are the most common pitfalls awaiting new users?

Why do I get an empty plot? Often new Mathematica users (and some not-so-new users) post questions asking why their plot of some expression just shows axes, with no plotted curve appearing. The key ...
27 votes

What is the use of FullForm in Mathematica?

Perhaps there are other uses, but I've primarily used FullForm to "see" what Mathematica "sees". This can be useful when you are trying to do replacements on ...
MassDefect's user avatar
27 votes

Difference between HashTable datastructure and Association datastructure

Summary Important differences between Association and CreateDataStructure["HashTable"] include: associations are ...
WReach's user avatar
  • 68.1k
26 votes

Resolving my Entity* Crisis

As an employee at Wolfram who is partly involved with development of the entity framework, let me give my take on things. Particularly, I want to address the following points raised by the OP and in ...
Paco Jain's user avatar
  • 877
25 votes
Accepted

How can one manually change the rule ordering

General The definitions get reordered at definition-time by a part of the pattern matcher, that takes care of automatic rule reordering. It does so, based on relative generality of rules, as far as ...
Leonid Shifrin's user avatar
25 votes

Unexpected behaviour from Table[]

This is just a long comment trying to shed light on where the problem may be coming from. Since version 10.2, the following is valid syntax: Table[x, 5] Before ...
Szabolcs's user avatar
  • 231k
25 votes

Learn Mathematica (Wolfram) Language in one day

I would recommend these two, in the order listed: Wolfram Language: Fast introduction for programmers Besides the generic edition, there are currently two special editions of this tutorial available ...
C. E.'s user avatar
  • 69.5k
24 votes
Accepted

Around usage results

There's a subtlety here. When operating together multiple Arounds, the two uncertainties will be considered separate and independent (in the statistical sense). ...
Szabolcs's user avatar
  • 231k
24 votes
Accepted

Row vectors and column vectors (Mathematica vs. MATLAB)

This is a limitation of MATLAB, as MATLAB is only able to work with matrices. It does not have true vectors. It cannot even represent a character array as a 1D array or a structure array as a single ...
Szabolcs's user avatar
  • 231k
24 votes
Accepted

A clean way to conceptually extract Parts from a circular list

Perhaps ArrayPad: ClearAll[f1] f1 = ArrayPad[##, #] &; Examples: ...
kglr's user avatar
  • 364k
24 votes
Accepted

What's the difference between these 2 associations?

Preamble The real problem here seems somewhat deeper than what the (mostly correct) observations in comments indicate. In Mathematica, a number of objects, which are so-called raw objects (including ...
Leonid Shifrin's user avatar
23 votes

What are the most common pitfalls awaiting new users?

Misunderstanding Dynamic Although this FAQ is to "focus on non-advanced uses" and Dynamic functionality is arguably advanced it ...
23 votes

What are the most common pitfalls awaiting new users?

Use Rasterize[..., "Image"] to avoid double rasterization [UPDATE: starting from version 11.2.0 Rasterize[...] defaults to <...
23 votes
Accepted

Why use pure functions?

Think of it as a macro. It shortens up your code. It stops your namespace from being polluted with extra function definitions. In some cases it can be faster than defining an auxiliary function. I ...
Greg Hurst's user avatar
  • 34.7k
22 votes

How can one manually change the rule ordering

Actually we have direct control over this via a System Option. Set: SetSystemOptions["DefinitionsReordering" -> "None"]; Then: ...
Mr.Wizard's user avatar
  • 267k
22 votes
Accepted

Version inconsistency with optional arguments: what if the default value doesn't match the pattern?

Update: Daniel Lichtblau authoritatively comments: This change was intentional, and per request of the boss. I can find no mention of this in the documentation, though I am still looking. My ...
Mr.Wizard's user avatar
  • 267k
21 votes
Accepted

Using Sequence to delete a part of an expression

What happens to the list after we assign an element to Sequence[] The answers given so far already contain most of the pieces needed to explain this behavior, but I ...
Leonid Shifrin's user avatar
21 votes
Accepted

PostScript-like drawing in Mathematica?

As J.M. notes in a comment, AnglePath allows paths to be specified in relative terms instead of absolute terms: ...
WReach's user avatar
  • 68.1k
21 votes
Accepted

Getting the "root" Head

With a few functions to try, defined in differentfunctions, try this headF: ...
MarcoB's user avatar
  • 64.5k
20 votes

What are the most common pitfalls awaiting new users?

Fourier transforms do not return the expected result Many users know a particular definition of the Fourier transform. When Mathematica returns an unexpected result and users cannot comprehend what ...
20 votes
Accepted

What is a function?

A function is really a mathematical idea. In Mathematica, we can represent, or denote, a function in a few ways. But Mathematica is really working with expressions. ...
lericr's user avatar
  • 18k
18 votes

Is there a "precedence table" for the canonical Sort ordering?

So I think the docs are mostly clear, if hard to visualize. Here's my version of such a table: ...
b3m2a1's user avatar
  • 46.3k

Only top scored, non community-wiki answers of a minimum length are eligible