2
$\begingroup$

Occasionally, when you ask Mathematica to carry out a task for which there is no good compact representation for the output, it will generate a special icon in v10, or an abbreviation in lower versions.

For example (in v10):

NDSolve[{x'[t] == 2, x[0] == 1}, x, {t, 0, 4}]

enter image description here

giving just the essential information about the output; Domain and Output. Applying FullForm on this output reveals the internal data. Clicking on the "+" sign gives a little bit more information about the function.

How does one mimic this behavior in user-defined functions (that could potentially go into publicly used packages)?


Concrete task Here is a function that can generate a long expression:

SetAttributes[tap, Orderless]
myFunc[list_List] := Expand[Total[(Total[#]) tap @@ # & /@ Tuples[list, 2]]^2]

In particular, it gives a polynomial in tap[x,y] (which is symmetric under $x\leftrightarrow y$). For example, myFunc[{a,b}] generates 4a^2 tap[a, a]^2 + 8a^2 tap[a, a]tap[a, b] ....

Now, instead of displaying the whole expression, how would I make it generate a little graphic? Let's have it display two pieces of information: (1) the different taps that are in the expression, and (2) the number of terms. For example let's have the graphic look like:

enter image description here

It should still be possible to use this output as an input to future evaluations. And ideally, applying FullForm should display the original polynomial.

$\endgroup$

Browse other questions tagged or ask your own question.