# All Questions

1k views

### Plot showing discontinuity where it shouldn't

I was trying to integrate a continuous function with a kink and I did it two ways and both ways the plot of the result shows a discontinuity. I also later want to differentiate the Integrated ...
2k views

### Create complicated text formulas in graphics

I want to put somewhat complicated, or at least non-standardly formatted, text on some of my graphics. For example, I'd like to be able to use f^[4](x) (where the ...
5k views

### Metaprogramming in Mathematica

Being functional, and having no "quotation", i.e. essentially treating data and programs semantically same, Mathematica seems naturally capable of doing metaprogramming. But could anyone construct a ...
2k views

### Implementing a first person view of 3D objects in a scene

I've created the following scene with a Chinese-style building surrounded by trees, and a horse and a rabbit grazing on the grass in Mathematica (don't ask me why there's a bust of Beethoven in ...
2k 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? ...
4k views

### Saving data inside a notebook so that I don't have to run it again?

Piggybacking on this, I am somehow not fully convinced that I can't save data generated by a calculation in a mathematica file so that when I re-launch said file, I wouldn't have to run my ...
1k views

### Compiling more functions that don't call MainEvaluate

I would like to use Compile with functions defined outside Compile. For example if I have the two basic functions ...
2k views

### How to distribute proprietary Mathematica code

If I want to make package-code completely unreadable, in a way that the end-user can only call my functions, but has no way to re-engineer my definitions, how would I do that? I know I can use ...
2k views

### How to plot ternary density plots?

How can I get a ternary density plot just like the plots from OriginLab? ContourPlot and DensityPlot seemingly can accept the ...
852 views

### Are there guidelines for avoiding the unpacking of a packed array?

Packed arrays are very useful because they save memory and generally allow speedier and more efficient calculation times. If a list of data currently stored as a packed array is unpacked, it can slow ...
1k views

### Items known by CurrentValue

CurrentValue can be used to poll the state of numerous system values such as the mouse position. Its help page doesn't list all possible items, though. An item like ...
3k views

### How to find out which method Mathematica selected?

There are commands like NonlinearModelFit[] or NDSolve[] that have the option Method it ...
2k views

### Map a function across a list conditionally

It seems that this is a really basic question, and I feel that the answer should be obvious to me. However, I am not seeing. Can you please help me? Thanks. Suppose I have a list of data ...
994 views

### Why is the new PositionIndex horribly slow?

This issue has largely been mitigated in 10.0.1. New timings for the final test below are: ...
2k views

### How to select minimal subsets?

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
838 views

### How to program a F::argx message?

How useful is it to program a user-built function in a package to produce a red warning message F::argx if you give the wrong number of arguments to that function? ...
1k 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 ...
1k views

### What tools can help in realizing tail recursion?

I had nice discussions with Leonid and Rojo that got me interested in tail recursion. Tail recursion is not always easy to realize with Mathematica, so it would be nice to have some tools to help with ...
1k views

### How to collect result continuously (interruptible calculation) when running parallel calculations?

This is the most common pattern to compute a table of results: Table[function[p], {p, parameters}] (regardless of how it's implemented, it could be a ...
2k views

### “Covering up” text in Graphics

Consider the following code: ...
590 views

### Constructing symbol definitions for With

I would like to be able to define two arrays, one containing symbol names and one containing the values of those symbols, for use in constructs such as With. For ...
1k views

### Transpose uneven lists

Is there a quick method to transpose uneven lists without conditionals? With: Drop[Table[q, {10}], #] & /@ Range[10] Thus the first list would have the ...
2k views

### Find intersection of pairs of straight lines

I have a list of 24 points, in which two consecutive points (1st and 2nd, 3rd and 4th, …) are supposed to form a line: ...
5k views

### Given a Table of Plots with some parameter, how would I mark each of the plots with that parameter

I've got a two variable function that I'm plotting against one axis for a few different values of a parameter ...
1k views

### Optimising 2D binning code

I have a set of (x,y,z) data, 45,000 to be precise and I want to bin the z values in 256 equidistant bins based on their (x,y) values. The final array should be a set of 256x256 array with each slot ...
422 views

### What does None mean in a control specification for Manipulate?

I am now struggling to understand code that contains the following (simplified) Manipulate structure. ...
4k views

### Plotting complex Sine

I've got another plotting problem. I want to plot Sin[z] where z is complex. So, I've tried the following: ...
3k views

### Delete duplicate elements from a list

If a list contains duplicate elements, for example list = {a, 1, 5, 3, 5, x^2, x^2}, how can the duplicate elements be removed? The result would be ...
848 views

### Block attributes of Equal

I answered “Equating matrices (or higher order tensors) element-wise” with: ...
5k views

### Multivariable Taylor expansion does not work as expected

The basic multivariable Taylor expansion formula around a point is as follows:  f(\mathbf r + \mathbf a) = f(\mathbf r) + (\mathbf a \cdot \nabla )f(\mathbf r) + \frac{1}{2!}(\mathbf a \cdot ...
779 views

### Returning an unevaluated expression with values substituted in

Let's say I have a function formula[x_List] := (x[[1]] - x[[2]]) + (x[[3]] - x[[4]]); and I want to pass it a variable and get back the unevaluated formula with ...
556 views

### Copying one symbol into another

I would like to know how can I completely copy one Symbol to another. When I say copy, a refer to UpValues, DownValues, ...
3k views

### Plotting piecewise function with distinct colors in each section

I have a piecewise function that I would like to plot but I was wondering if it is possible that each part of the function that is plotted when its corresponding condition is true be plotted with a ...
1k views

### PolarPlot render oddities

I apologize if this is a obvious question and answer, I don't often use Mathematica to display plots or graphics in general to be honest. So, I was tutoring my cousin yesterday in relation to Polar ...
2k views

### How do you check if there are any equal arguments(even sublist) in a list?

I would like to set up a function which has to return True if at least two arguments of a given List are equal. So if I give {1,4,6,2} to the function it has to ...
737 views

### Applying And to lists of Booleans

I'd like to take {True,True,False} and {True,False,False} and apply And to get ...
391 views

### How to automate generation of image files?

I need to generate a large number of figures as PNG files, and I'm trying to decide whether Mathematica would be the quickest way to do this. All the figures have the same basic structure, and I'm ...
2k views

### Select/Delete with Sublist elements?

Probably easy and short question, I still didn't fully figure out how to easily select/delete sublists from a list. Example: tt = {{2, 4}, {4, 8}} I want to delete/select all the elements where ...
2k views

### Mathematica won't give eigenvectors but Wolfram Alpha will? What am I doing wrong?

If I ask Mathematica to find the eigenvectors and eigenvalues of the matrix: ...
2k views

### ParallelTable and Table do not give same result

I have a question regarding the use of Parallelize. In the help one can read that “Parallelize[Table[expr,iter, …]] (which is ...
3k views

### The difference between 0. and 0

I have a function for which 0 is a special case: f[A___, 0, B___] := 0 But since I am doing numerics, sometimes in the course ...
368 views

### Position function not always returning an answer even with no apparent problems

I'm having some problems with Position. Sometimes it will give an empty list instead of the actual position of the element I am looking for when that element is ...
843 views

### Evaluating an If condition to yield True/False

I would like to decide whether an option passed to my custom function has the value Automatic or something else. This is my attempt: ...
554 views

### Help on evaluation control?

I want to plot series of slopes: x, 2x, 3x, 4x, 5x, 6x... I'm trying to do this: ...
6k views

### How can I generate this “domain coloring” plot?

I found this plot on Wikipedia: Domain coloring of $\sin(z)$ over $(-\pi,\pi)$ on $x$ and $y$ axes. Brightness indicates absolute magnitude, saturation represents imaginary and real magnitude. ...
2k views

### Sketch-type graphics with transparency and dashed hidden lines?

I'd like to create transparent graphs like the following from P1095, Calculus 6th Ed, by James Stewart. Can Mathematica accomplish this? By "transparent," I mean the ability to see the interior, ...
4k views

### Does Mathematica have advanced indexing?

I have two $M \times K$ arrays $L, T$ where I would like to set all the elements in $L$ to zero whenever the corresponding element of $T$ is greater than 15. The ...
4k views

### Torn edge paper effect for images

In my answers to Plotting Error Bars on a Log Scale I used a so called "torn edge" effect from on one of the images. @SjoerdC.deVries commented: "BTW I liked the ripped-out look of your InputForm ...