All Questions

13,418 questions
486 views

Unexpected behavior of rule matching a pattern

I am a beginner exploring the world of Mathematica. I expected the following code T[6, 5, 4, 1, 2, 3] /. {T[a___, 1, b___] -> Length[List[b]]} should return ...
3k views

How to “Copy as Unicode” from a Notebook?

I spent some time manually editing a post replacing Mathematica ASCII \[Alpha] with Unicode α. I did this by laboriously ...
2k views

Mathematica Destructuring

Context I'm writing a function that look something like: ...
4k views

How to differentiate formally?

I have been wrapping my head around this for a while now and I have not found a solution so far. I want to work with an arbitrary number of variables in Mathematica and use some built in functions. To ...
26k views

How do I identify the source of a “Tag times protected” error?

I have some code that looks like Table[ a = 1; b = {2, 3} c = i;, {i, 2} ] which gives an error: Set::write: Tag Times in c {2,3} is Protected....
4k views

5k views

Extruding along a path

I'm trying to render a 3D image of a path by extruding a circular cross-section along the path, to create a "snake-like" path. Here is an image I found to illustrate: I can't seem to figure out if ...
12k views

About the number format in ticks

I want to LogPlot a function, but I have the trouble in the number format in the ticks. For example, ...
2k views

I have been working on picking expressions apart using Head and Part and encountered a little mystery. Consider the canonical ...
5k views

Error entering equation in DSolve

I entered a command incorrectly as follows: DSolve[{y'[x]=y[x]},y[x],x] I am now experiencing: ...
364 views

Expressions containing globally undefined symbols inside a function where they are defined

Consider the following code. f[a_,b_]:=x x=a+b; f[1,2] (* a + b *) From a certain viewpoint, one might expect it to return 3 ...
5k views

Programmatic formatting for Mathematica code - possible?

It seems to be both an interesting programming challenge and a very useful practical application to have a Mathematica program which would allow one to pretty-print Mathematica code, so that it is ...
4k views

Functions vs. patterns

Every time I define a new function, I wonder which construct I should use: true functions obtained by using Function, or rule-based syntax. For example, these are ...
3k views

Character edge finding

The following line of code finds the edge of a character: ...
4k views

How to splice together several instances of InterpolatingFunction?

I have a set of InterpolatingFunction returned by NDSolve which are valid over different (but overall continuous) domains. How ...
2k views

Transferring a large amount of data in parallel calculations

Bug fixed in version 11.1 Functions like MemberQ, FreeQ, etc. no longer unpack. Yay! This question is inspired by one of @...
4k views

Annoying display truncation of numerical results

I have a lot of data to inspect. An example of a number in my program is 123.189094 This gets displayed as 123.189 ...
183k views

xkcd-style Plots

I received an email to which I wanted to respond with a xkcd-style graph, but I couldn't manage it. Everything I drew looked perfect, and I don't have enough command over ...
13k views

Placing a ContourPlot under a Plot3D

I would like to combine a 3-dimensional graph of a function with its 2-dimensional contour-plot underneath it in a professional way. But I have no idea how to start. I have a three of these I would ...
3k views

Levels: how do they work?

I cannot understand how Mathematica manages levels, and so it's always a painful try-and-fail to use Flatten. Can someone please give me a very clear definition? ...
11k views

ListPlot with each point a different color and a legend bar

I would like to generate a ListPlot with the color for each point in the plot corresponding to a particular value (not associated with the position in the plot). I'...
3k views

Aligning plot axes in a graphics object

I need to align the y-axes in the plots below. I think I'm going to have to do some rasterizing and searching for vertical lines, then vary x and ...
2k views

Why does Simplify ignore an assumption?

Here is the example: Simplify[x + y, x + y == a] Simplify[x + y, x + y == 5] Mathematica 9 output: x+y 5 I expect the ...
2k views

Toady,I have a problem about N,described as below: For example N[1/3, 5] (* ==> 0.33333*) and ...
5k views

How do I convert an argument list to a sequence of arguments?

I think this is a basic question, but I am having difficulty finding the answer in the documentation. Thread is not what I am looking for, I think. Suppose that I ...
2k views

Why are numeric division and subtraction not handled better in Mathematica?

There is something that has been troubling me for a while. At least through version 10.0 the performance of a / b and a - b is ...
4k views

How can we make publication-quality PlotMarkers without version 10?

Suppose that for certain reasons we are not yet using Mathematica version 10, or we have a version with buggy PlotMarkers. It is well known that the default markers ...
5k views

Avoiding white lines inside filled area in RegionPlot exported as PDF or PS

When doing a RegionPlotand then exporting (or saving from the front end) as PDF or EPS, there are small white lines in the filling of the region. Here's an example ...
7k views

Clear complains that a subscripted variable is not a symbol or a string?

Here's a small listing where I've used EscqEsc to typeset θ in the notebook: ...
9k views

Find all roots of an interpolating function (solution to a differential equation)

I'm trying to find all the roots of the solution to a differential equation. Using NSolve or Reduce I don't get the roots, so I'm using an iterative method which I found in physicsforums.com. This ...
936 views

How can I make threading more flexible?

Threading automatically with Listable functions requires the argument expressions to have the same length (or for one of them to be atomic). For nested lists the ...
912 views

Where can I get detailed information on how the Plot command works?

The command Plot[x^2, {x, -3, 3}, PlotStyle -> Arrowheads[{-.025, .025}]] /.Line -> Arrow produces this output. What I don't understand is what ...
5k views

Problem with ContourPlot

I tried these ...
3k views

White regions in DensityPlot — is this a bug with ColorFunctionScaling?

Is this a bug with ColorFunctionScaling? When I try to supply my own ColorFunction Mathematica seems to partially ignore it, ...
10k views

How to make use of Associations?

I have been curious about it for long. Now that Mathematica 10 arrives, I think it's time to ask the question: How the new Association data structure would be used ...
11k views

Minimal effort method for integrating C++ functions into Mathematica

Update: While at the time of writing the question loading DLLs with .NET/Link seemed easier, now I always use LibraryLink, which I recommend to anyone with a similar problem! As of Mathematica 8, ...
3k views

The clearest way to represent Mathematica's evaluation sequence

WReach has presented here a nice way to represent the Mathematica's evaluation sequence using OpenerView. It is much more clear way to go than using the standard <...
2k views

Incompatible Changes since Mathematica Version 7?

There is documentation of the incompatible changes made to Mathematica with each major release: Incompatible Changes since Mathematica Version 1 Unfortunately that documentation simply stopped ...