# Tag Info

52

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 ...

44

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 ...

43

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 *) ...

32

It is interesting to compare the Plot algorithms of Mathematica 5.2 and Mathematica 6+. Based on acl's code: In Mathematica 5.2 we get: Plot[Sow[x]; Sin[x], {x, 0, 10}, DisplayFunction -> (Null &)] // Reap // Last // Last // ListPlot In Mathematica 7.0.1: Plot[Sow[x]; Sin[x], {x, 0, 10}] // Reap // Last // Last // ListPlot One can see ...

31

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 ...

30

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] == 0, y, {x, 0, 6}], TraceInternal -> True]], ! FreeQ[#, Method | NDSolveMethodData] &] shows the DE was evaluated using NDSolveLSODA and Newton's method. (I ...

26

I can add to Mr.Wizards' answer that when InputForm is wrapped by any head like List (// InputForm // List) the output is much more readable because in this case it is represented in StandardForm instead of pure textual representation. StandardForm allows semantic selection by double-clicking, wraps the code by window width, highlights the brackets etc. From ...

25

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 ...

24

If the problem is that a symbolic argument is passed, you can avoid it thus: ClearAll[sin]; sin[x_?NumericQ] := Module[{}, Print[x]; Sin[x] ] which simply defines sin so that it only matches for numeric arguments. To see what it does, try sin[3.] and sin[x] and notice that the second evaluates to itself, as the definition above does not match. You ...

21

Evaluation stops when there is no definition in place whose pattern matches the expression being evaluated. Conversely, evaluation will continue as long as there is a matching definition. Thus, if I have this definition: zot[x_] := zot[x] and I evaluate zot[1], the evaluation will never terminate even though the expression never changes. (Well, in ...

21

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"}] ...

20

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 ...

18

It looks like the blend colours can be extracted with: DataPacletsColorDataDumpgetColorSchemeData["SunsetColors"][[5]] (* {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., ...

17

Major update at the bottom. First part may be obsolescent. 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]; ...

16

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 ...

16

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 ...

15

This is an incomplete answer; I will continue it tomorrow. Work In Progress: errors may abound. Preamble hat-tip to Leonid For the variations with custom test or ordering functions we can snoop on applications of that function to deduce the algorithm that is used. In the case of the default methods we must rely on observed complexity and guesswork ...

14

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 ...

14

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 ...

13

Update: The answer below is for Mathematica 9 or earlier. Since version 10, Finite Element Methods are included: https://reference.wolfram.com/language/FEMDocumentation/tutorial/FiniteElementOverview.html The methods NDSolve uses are documented in detail here: Advanced Numerical Differential Equation Solving in Mathematica This section says that ...

13

As Danny points out, you can find the list of licensed software using the "About Mathematica..." box, available under the Mathematica menu on my Macintosh and under the Help menu for a PC. As a dialog box, that Notebook is not searchable and a bit inconvenient to work with. If we open it with a text editor and examine the contents, we find that the cells ...

13

I would just use strings, for all their fragility: ClearAll[print]; print[sym_, {conts_String}] := With[{altptrn = Alternatives @@ Reverse[SortBy[{conts}, StringLength]]}, Print@StringReplace[ToString[InputForm@FullDefinition@sym], (x : (_ | "") ~~ altptrn ~~ y : (_ | "")) /; ! (x === "\"" && y === "\"") :> ...

13

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]}, ...

13

As far as I know the specific output format of Plot (and similar commands) is not documented. I believe it has changed between versions therefore any post-processing (such as your replacement rule) must be considered potentially version dependent. As Michael comments above the documentation does state: Plot normally returns Graphics[{Line[...],...}]. ...

12

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 ...

12

This is not a full answer, but too long for a comment. We can try to look at the C code that Mathematica generates. Needs["CCodeGenerator"] cf = Compile[{{n, _Integer}}, RandomReal[1, n]] CCodeStringGenerate[cf, "fun"] Excerpt from the output: ... FP0 = funStructCompile->getFunctionCallPointer("RandomReals"); ... err = FP0(libData, 3, FPA, ...

12

The Experimental function FindFormula at the moment is using a combination of different methods: it combines non linear regression with Markov chain Monte Carlo methods (e.g. Metropolis–Hastings algorithm). In the future (possibly in 10.3) there will be an option allowing the user to choose which method to use.

11

I've always considered the "suitable for symbolic manipuation" line to be a bit of truth wrapped in marketing speak and not meant to mean anything mathematically precise. The documentation center guides and tutorials are good examples of hyperbole in technical documentation (see for instance, the opening lines in Mathematical Typesetting). Coming to the ...

11

I like to use properties like those in SparseArray and I find subvalues very useful for defining and accessing them. This is best used with a dummy head. The following is some code pulled out from one of my packages and modified. I've defined func here to be a minimal example of what your actual function might look like. Clear[func, myHead] func[str_] := ...

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