31 votes
Accepted

Why Except is so slow as compared to equivalent RegularExpression?

Using StringPattern`PatternConvert we can find the regexp into which Mathematica converts the original string expression: ...
Alexey Popkov's user avatar
31 votes
Accepted

What's the default colormap (or color scheme) used in mathematica?

"DefaultColorFunction" /. (Method/. Charting`ResolvePlotTheme[Automatic, ContourPlot]) "M10DefaultDensityGradient" ...
kglr's user avatar
  • 392k
29 votes
Accepted

What's behind Method -> {"EquationSimplification" -> "Residual"}

This post contains several code blocks, you can copy them easily with the help of importCode. As mentioned in the comment above, the answer is hidden in this ...
xzczd's user avatar
  • 65.4k
28 votes
Accepted

What happens if you don't Reap what you've Sown?

Preamble This complements the answer of Roman with a few more details. Reap - Sow implementation is based on an internal object <...
Leonid Shifrin's user avatar
26 votes
Accepted

How was Mathematica built?

In the Mathematica book (5th edition), Stephen Wolfram writes the following (sec. 1.12.4): The Software Engineering of Mathematica Mathematica is one of the more complex software systems ever ...
Sjoerd C. de Vries's user avatar
26 votes
Accepted

How was Nothing implemented?

Ok, I failed to find a duplicate so here is my comment: I don't know how Nothing is internally implemented but you can do something like this with ...
Kuba's user avatar
  • 137k
22 votes

Mathematica's morphological thinning algorithm

Prologue Some five years ago I have asked exactly this question to the Wolfram support people. Below I have taken their respective answers (one sentence for each ...
UDB's user avatar
  • 1,835
22 votes
Accepted

What is the definition of Curl in Mathematica?

The definition used (motivated by exterior calculus) is as follows: Given a rectangular array $a$ of depth $n$, with dimensions $\{d, ..., d\}$ (so there are $n$ $d$'s) and a list $x = \{x_1, ..., ...
jose's user avatar
  • 6,213
22 votes

What happens if you don't Reap what you've Sown?

It looks like there's no memory being used by Sow when there is no encompassing Reap. With ...
Roman's user avatar
  • 46.9k
21 votes

What algorithm do the Compress and Uncompress functions use?

After a bit of poking around, it looks like the binary format is pretty simple to parse. Mark Adler's answer is correct - the strings Compress[] returns are just ...
Andy C.'s user avatar
  • 623
21 votes
Accepted

What algorithm do the Compress and Uncompress functions use?

It is using the zlib format followed by Base64 coding, and then preceding the resulting string with "1:". So to use it externally, you can strip the "1:", do Base64 decoding, and feed the result of ...
Mark Adler's user avatar
  • 4,949
20 votes
Accepted

Why does setting SyntaxInformation add a definition to DefaultValues

In my view, the Mathematica front end would have needed a complete rewrite a long time ago to be in a shape where it can compete with modern UI's. Looking at MATLAB, it's clear that you always find ...
halirutan's user avatar
  • 113k
19 votes

NDSolve uses different difference order for different spatial derivative when solving PDE

Note: fix is broken since v11.3, a new question has been started aiming at upgrade it. Here's my approach for fixing the difference order. The key idea is ...
xzczd's user avatar
  • 65.4k
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.8k
18 votes

How do the functions Reap and Sow actually work behind the scenes?

I do not know how Sow and Reap are actually implemented, but to show you that it isn't magic, I can provide the following toy ...
Henrik Schumacher's user avatar
17 votes

How does Mathematica calculate $\sin(\pi/5)$?

In the course of answering this question, I ran into a little bit of weirdness that doesn't square with my experience with previous versions of Mathematica. I think writing this answer is as good a ...
J. M.'s eventual burnout's user avatar
17 votes
Accepted

How does Mathematica calculate the Standard error during a non linear fit?

Rather than give formulas here is how to duplicate the results (coefficient estimates and standard errors) from NonlinearModelFit. First show the example from <...
JimB's user avatar
  • 41.1k
17 votes
Accepted

Why is FreeQ so much faster for some specific variable names?

TLDR: If you run into performance issues related to symbol names, rename your symbols such that System`Private`GetContentCode returns different values for each ...
Ray Shadow's user avatar
  • 7,806
17 votes

What's the principle behind the new MoleculeRecognize function?

Using ResourceFunction["PrintDefinitions"][MoleculeRecognize], one can determine that the source implementation is MolVec. The specific source code is: ...
Carl Lange's user avatar
  • 13.1k
16 votes
Accepted

Show how Mathematica defines a function

This isn't necessarily how these functions are implemented, but MathematicalFunctionData gives a way to access definitions that are equivalent to the ones ...
Greg Hurst's user avatar
  • 35.7k
16 votes
Accepted

How does Mathematica solve a certain differential equation?

@Nasser's method seems to be what Mathematica does internally. The following gives hints of the steps taken, and one can see the elements of Nasser's solution. Some is left to the user to guess. The ...
Michael E2's user avatar
  • 234k
16 votes
Accepted

What stopwords list is the Wolfram language using?

A little spelunking of the code for DeleteStopwords[] yields the internally used stopword list: ...
J. M.'s eventual burnout's user avatar
16 votes
Accepted

Evaluated vs. unevaluated Association

Summary The confusion we observe here is largely due to ambiguous use of the symbol Association as an expression head. On the one hand, ...
WReach's user avatar
  • 68.6k
15 votes
Accepted

How does FunctionDomain work?

Evaluate ((x - 2) (x + 1))/((x - 2) (x + 3)) and see what it gives. It automatically simplifies to (1 + x)/(3 + x). The second ...
Szabolcs's user avatar
  • 234k
15 votes

What stopwords list is the Wolfram language using?

The stop-words are documented and can be looked up as (see Details section of WordList): WordList["Stopwords"] As it might be ...
Vitaliy Kaurov's user avatar
15 votes
Accepted

How do the functions Reap and Sow actually work behind the scenes?

I will make an exception to the usual practice I try to follow on this site, and fully replicate my post from this answer of mine here, since it answers this question just as directly or even more, ...
Leonid Shifrin's user avatar
14 votes

Accuracy of PrimeQ function

Turning my comment into an answer, One of the tests performed by PrimeQ for machine-sized integers, namely Miller-Rabin using up to the first 12 primes as bases (...
ilian's user avatar
  • 25.5k
14 votes

NDSolve uses different difference order for different spatial derivative when solving PDE

Complete control over the spatial decomposition of the PDE given in the answer by xzczd can be achieved by decomposing the PDE into a large set of ODEs, as described in the Introduction to the ...
bbgodfrey's user avatar
  • 61.3k
14 votes
Accepted

how to take ImageFeatures?

Some introduction Feature extraction is a very important idea in machine learning. It allows us to build a neural network based on some of the pretrained high-performance networks. This is also the ...
xslittlegrass's user avatar
14 votes

What's the default colormap (or color scheme) used in mathematica?

ColorData[97] is the default color scheme. The answer is found in a few different answers throughout this site. For example, Discussion of ...
user6546's user avatar
  • 1,059

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