When asking for help with a coding problem it is important to do as much as possible to make certain your audience is able to immediately understand the issue and assist with a solution. Whether it be via forum or by contacting technical support there are things you can do to ensure that your query is given the necessary attention and is properly understood.

Below we describe methods which can help ensure that your code is sufficiently short and properly self-contained.

Leave out the unnecessary parts of your code

Remove code that does not contribute to the issue. This serves two purposes:

  1. it makes it easier for the people reviewing your code to get to the actual problem
  2. it oftentimes is a good troubleshooting step that may help you identify the issue yourself

For example, if you were having a problem with your Plot command:

Plot[{Cos[x], Sin[x]}, {x, 0, 10}, Filling -> Bottom, Frame -> True,
 FrameTicks -> All, Axes -> False, PlotLabel -> "Sin and Cos Plotted"]

one approach would be to try to remove the options one at a time until the issue is no longer present. This will help indicate which option could be causing the problems, and can help focus the issue without the rest of the “clutter”.

Minimize the content that the example relies on

Try and minimize any data the issue relies on. For example, if your issue relies on data from a larger CSV file, see if you can reproduce the problem with a portion of the data. Instead of expecting someone else to obtain and import the data, for example,

data = Import["data.csv"];

just provide a few values they can use to reproduce the problem:

data = {{1, 2}, {2, 3}, {3, 4}, {4, 5}};

Similarly, if your results rely on long computations, see if you can remove these computations from the issue. Let’s say you have a Plot command that isn’t working right, but relies on an integral that takes a few minutes to solve. Instead of sharing the following:

int = Integrate[f[x], x];
Plot[int, {x, 0, 10}]

Send the output of the already evaluated integral directly, to remove that unnecessary information from the request (assuming the Integrate command above eventually evaluates to x^3+Cos[x]):

int = x^3+Cos[x];
Plot[int, {x,0,10}]

Remove unnecessary formatting

Get rid of formatting, and try to present the issue in one-dimensional ASCII text. For example, if you like to work with integrals in their TraditionalForm,

try converting the code to its InputForm before sharing:

Integrate[x^2, {x, 1, 10}]

You can convert a cell to its InputForm by right clicking (Control-click on Mac) on the relevant cell’s bracket and choosing item Convert To ► InputForm.

Similarly, if your code contains non-ASCII characters like Θ or π, it usually does not copy well into ASCII environments:

PolarPlot[Sin[3 \[Theta]], {\[Theta], 0, \[Pi]}]

This can easily be rewritten with more “standard” characters for easier-to-read code:

PolarPlot[Sin[3 t], {t, 0, Pi}]

Ensure others can run your code without issue

Verify that others can run your minimal example. Just before you send your code, quit and then restart your Wolfram Language session, and then immediately rerun the code you plan to send. This tests that your code is not mistakenly relying on any variables or symbols that need to be included.

For example, sending the following Plot command without the definition for fn would be difficult for someone to troubleshoot:

Plot[fn[x], {x,0,10}]

Share your content effectively

If your example can easily be represented in a few lines and has no tricky formatting we would recommend pasting it in the body of the post or email. If the code is longer or more involved we would recommend sending it within a Notebook as this may better preserve the content.