# Tag Info

86

Link to the code on GitHub I have been using this. It's mostly Leonid's code from the stackoverflow question you linked to, but it uses Definition instead of DownValues. Symbol names are printed without any context, but the full symbol name is put into a Tooltip so you can always find out what context a symbol is in. Update FullDefinition[symbol] claims ...

75

In version 10.1, I've built something like Spelunk into GeneralUtilities. To use it, run Needs["GeneralUtilities"] PrintDefinitions[symbol]; This will pop up a window that shows all definitions of symbol. Here is a short summary of features: The window shows code cells containing all DownValues, OwnValues, UpValues, SubValues, and Attributes of a ...

56

From inspection, some investigation and ruebenko's help, what I've found so far is that InterpolatingFunction has the following underlying structure: InterpolatingFunction[ domain, (* or min/max of grid for each dimension *) List[ version, (* 3 in Mathematica 7, 4 from 8 onwards *) ...

50

Interpolation function methods Interpolation supports two methods: Hermite interpolation (default, or Method->"Hermite") B-spline interpolation (Method->"Spline") Hermite method I really can't find any good reference to Hermite method within Mathematica's documentation. Instead, I recommend you to take a look at this Wikipedia article. The ...

46

I think you can actually see (most of) what Mathematica is doing by using Trace[..., TraceInternal -> True]. For example, Select[Flatten[ Trace[NDSolve[y'[x] == x && y == 0, y, {x, 0, 6}], TraceInternal -> True]], ! FreeQ[#, Method | NDSolveMethodData] &] shows the DE was evaluated using NDSolveLSODA and Newton's method. (I ...

36

I can add to Mr.Wizards' answer that when InputForm is wrapped by any head like List (// InputForm // List) or by SequenceForm the output is much more readable because in this case it is represented in StandardForm instead of pure textual representation (and still avoids the evaluation leaks of StandardForm!). StandardForm allows semantic selection by double-...

32

I can now offer a solution which leverages the full power of the code formatter, in its new, more robust form. Load the formatter: Import["https://raw.github.com/lshifr/CodeFormatter/master/CodeFormatter.m"] Some examples: CodeFormatterSpelunk[RunThrough] CodeFormatterSpelunk[PacletManagerCreatePaclet] In the last example, using MakeBoxes would ...

30

What you observed seems to be an instance of the general behavior of the pattern-matcher when used with what I call "syntactic patterns" - patterns which only reflect the rigid structure of an expression, like e.g. _f. The speed-up with respect to the scanning is because the main evaluation loop is avoided - for FreeQ and MemberQ, the scannng is done all ...

26

You can control how the Jacobian is calculated via the Jacobian option: Grid[Module[{s = 0, e = 0}, {#, FindRoot[ArcTan[1000 Cos[x]], {x, 1}, StepMonitor :> s++, EvaluationMonitor :> e++, Jacobian -> #, Method -> {"Newton"}], "Steps" -> s, "Evaluations" -> e }] & /@ {"Symbolic", "FiniteDifference"}] ...

26

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 constructed. Its source code is written in a combination of C and Mathematica, and for Version 5, the code for the kernel consists of about 1.5 million ...

26

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 UpValues: nothing /: {a___, nothing, b___} := {a, b}

25

Using StringPatternPatternConvert we can find the regexp into which Mathematica converts the original string expression: StringPatternPatternConvert[Except["b"] .. ~~ "b"][] "(?ms)(?:[^b])+b" The only difference as compared to the direct semantic translation is that the negated character class [^b] is enclosed by redundant non-capturing group (?: … )....

24

Since nobody has mentioned it yet... V8 introduced the undocumented flag Debug$ExamineCode. When it is set to true, the information functions will display the definitions of ReadProtected symbols: Debug$ExamineCode = True ??BinLists It is sometimes useful to suppress some of the internal package names to make it easier to scan the definitions. Here is ...

24

If you want to have a description of the method used by a given ClassifierFunction you can do: ClassifierInformation[myclassifier, "MethodDescription"] Also, the methods used are quite classic, so you can easily find documentation on the web. If you want to know why Classify uses a given model there is a simple answer: Classify tries to find the model ...

23

It looks like the blend colours can be extracted with: DataPacletsColorDataDump`getColorSchemeData["SunsetColors"][] (* {RGBColor[0., 0., 0.], RGBColor[0.372793, 0.1358, 0.506503], RGBColor[0.788287, 0.259816, 0.270778], RGBColor[0.979377, 0.451467, 0.0511329], RGBColor[1., 0.682688, 0.129771], RGBColor[1., 0.882236, 0.491094], RGBColor[1., 1., ...

22

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 Method) but have added a lot of further reading. Finally, in an Add-On I demonstrate my own implementation of Rosenfeld's 1971 variant of a 2D thinning algorithm, in order to let you compare a few ...

20

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 that to a zlib decoder. However what you get out may not be immediately useful. I compressed the result of D[x^x, {x,9}], like one of the examples in the ...

20

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 zlib-compressed data. If you have Python installed, this function should take a compressed string and return the actual serialized bytes: pyDecompress[c_] := StringDrop[StringDrop[StringTrim[...

19

Reposting my answer from here (its relevant part about SparseArray) The anatomy of sparse arrays We start with a generally useful API for construction and deconstruction of SparseArray objects: ClearAll[spart, getIC, getJR, getSparseData, getDefaultElement, makeSparseArray]; HoldPattern[spart[SparseArray[s___], p_]] := {s}[[p]]; getIC[s_SparseArray] := ...

18

I can only direct you to Some Notes on Internal Implementation: Differentiation and Integration Differentiation uses caching to avoid recomputing partial results. For indefinite integrals, an extended version of the Risch algorithm is used whenever both the integrand and integral can be expressed in terms of elementary functions, ...

18

Major update at the bottom. First part may be obsolete. A brute force approach: Define a function that provides a measure of the difference between the automatically adjusted image and an image with given contrast, brightness and gamma adjustments (for now, this only works for images that are made of a raster of color triplets): ClearAll[f]; f[c_?...

18

I know this isn't exactly what you want, but just a stupid idea: ClearAll[newf]; points = RandomReal[1, {1000000}];(*we have lots of points...*) nf = Nearest[points];(*... and the corresponding NearestFunction*) newf[oldf_, newpoints_List] := (Nearest[Union[oldf[#], Nearest[newpoints][#]], #] &); newf[nf, {3, 4, 5}][1.98] Edit Here is a version that ...

18

Using Accumulate for 20,000,000 size list. Time < 1 Hour Your timings seem way too high. On my PC, Accumulate on an 20.000.000-element packed array takes about 50ms. A For loop (not compiled!) needs about one minute for 20 million values. My PC may be fast, but not that fast. Make sure your array contains only machine-precision reals and is packed. ...

18

As indicated in the comments, machine-precision linear algebra operations in Mathematica use the Intel MKL library optimized implementation of BLAS/LAPACK. That is the case for all platforms where MKL is available: Windows, Linux and Mac OS X (there will be no obvious MKL library files present in the layout on OS X in versions 10.1 through 11.2 due to ...

18

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, ..., x_d\}$ of variables, then Curl[a, x] == (-1)^n (n+1) HodgeDual[Grad[a, x], d] If $a$ has depth $n$, then Grad[a, x] has depth $n+1$, and therefore HodgeDual[...

17

After some work and clarification from Leonid it becomes clear this is a case where SubValues is the exact solution. As this answer points out SubValues are patterns of the form food[d][f] := a; which is the correct form for accessing parts of an "data-like" object since the sub value has access to the containing expression parts. Now to build on a ...

17

First answer Ok, Simon Woods killed the fun but I was already wiriting this: spec = List @@@ Table[ ColorData["SunsetColors", i] , {i, 0, 1, .001}] // Transpose; ListLinePlot[spec, ImageSize -> 900, PlotStyle -> {Red, Green, Blue}, BaseStyle -> Thick] Here we can see how colors are changing across 0-1. ...

17

So I think the docs are mostly clear, if hard to visualize. Here's my version of such a table: { "Numerics" -> { "Negative Integer" -> -1, "Zero" -> 0, "Positive Integer" -> 1, "Negative Float" -> N@-\[Pi], "Positive Float" -> N@\[Pi], "Symbolic Constant (Pi)" -> \[Pi], "...

17

According to the documentation of Image3D, "an interactive color function editor is available via the Image3D contextual (right-click) menu". (And yes! I only found it after reading your question!) And you can get the explicit function by clicking the "Copy Function" button. Blend[{ {0., RGBColor[0.05635, 0.081, 0.07687, 0.00343663]}, {0.1, ...

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