# All Questions

1k views

### Meaning of backtick in floating-point literal

If I compute, say, 1/3//N, Mathematica displays 0.333333 as the result. When I copy that output to use elsewhere, the paste ...
1k 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 ...
415 views

### Help on evaluation control?

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

### xkcd-style graphs

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 ...
5k views

### How to make a 3D globe?

There are many ways to create a 3D Earth that is rotatable (see here, here, related here), but most of them have some drawbacks. These issues mainly stem from either ...
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 ...
3k views

### How can I make an X-Y scatter plot with histograms next to the X-Y axes?

I just saw a nice plot there: How could I implement that in Mathematica — by which I mean the plot structure, not so much the styling.
1k 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 solve the ...
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 F and G F[x_] := x + 2 G[x_] := x And I want ...
687 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 ...
634 views

### How to make MapAt work with Span?

Span (;;) is very useful, but doesn't work with a lot of functions. Given the following input ...
923 views

### Can a Trie be implemented efficiently?

What is the most space and time efficient way to implement a Trie in Mathematica? Will it be practically faster than what is natively available in appropriate cases?
1k views

### Why is there no PositionFunction in Mathematica?

Too often I have seen the programs of inexperienced users greatly slowed by using Position in an iterative fashion, when far faster would have been to compute a ...
5k views

### Density plot on the surface of sphere

I would like to make density plots of a list of (size 2 or 3) spherical harmonics on the surface of a sphere. I'd like to plot it so that each element of that list is using a different color (red ...
976 views

### Local variables in Module leak into the Global context

From the Mathematica documentation on Module: Module allows you to set up local variables with names that are local to the module. But after using ...
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 ...
2k views

### I'd like to display field lines for a point charge in 3 dimensions

I'd like to display field lines for a point charge in 3 dimensions. Not a force field (short arrows) but continuous field lines that start on the charge.
4k views

### How to calculate contour integrals with Mathematica?

How to calculate the integral of $\frac{1}{\sqrt{4 z^2 + 4 z + 3}}$ over the unit circle counterclockwise for each branch of the integrand?
1k views

### Reading periodic elements from a large file

I have a large binary data file (big endian) with 100+ million "rows" of 11 elements, combination of floats and integers. This is the format: ...
10k views

### Is it possible to export the equations from Mathematica to MATLAB?

Is it possible to export the output expressions from Mathematica computations (e.g., equations) in valid MATLAB syntax?
869 views

### Can a function be made to accept a variable amount of inputs?

I have a function that takes two inputs and processes them for a single output. What I need is one that can take a varying number of inputs. and process them to a single output. Is this possible in ...
3k 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 ...
604 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 ...
3k 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, ...
4k views

### What does # mean in Mathematica?

I asked Mathematica to compute the following Solve[c (1-x)^2-x^(1/4) == 0, x] and it returned this: x = Root[#1^8 c^4 - 8 #1^7 c^4 + 28 #1^6 c^4 - 56 #1^5 ...
2k views

### Can 2D and 3D plots be combined so that the 2D plot is the bottom surface of the 3D plot boundary?

I have a ListlinePlot function, that I would like to combine with both a Graphics3D plot and a ...
2k views

### How to find rows that have maximum value?

Suppose if I have following list { {10,b,30}, {100,a,40}, {1000,b,10}, {1000,b,70}, {100,b,20}, {10,b,70} } How to find rows that have max value in ...
2k views

### Way to improve “show me this decimal number to M places, don't use scientific notation”?

The best way I can come up with to say "show me this fraction as a decimal number to M places, don't use scientific notation" is: ...
874 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 ...
10k views

### Creating a table/Matrix during a For loop

I have a For loop (with i as a counter), which calculates different values (y1, ...
2k views

### First positive root

Simple question but problem with NSolve. I need help how to extract first positive root? For example: ...
286 views

In the ideas shared in my answer to this post Struct equivalent in Mathematica? at the end I propose a solution that changes the way Set works in a particular case that can be expressed in plain words ...
632 views

### Applying And to lists of Booleans

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

### RevolutionPlot3D: but NOT revolving about the z axis

I want to demonstrate generating a solid of revolution by revolving a planar region about, say, a horizontal axis. However, RevolutionPlot3D doesn't seem to have an ...
411 views

### Why do buttons with ChoiceDialog freeze the front end?

Pressing the button below will freeze my front end. An unpainted white dialog box comes up, then it completely freezes, and I need to forcibly kill the front end. CPU usage stays at zero during ...
718 views

### How to Map a subset of list elements to a function?

How would you, given a list {1, 2, 3, 4}, apply a function f to 1 and ...
582 views

### Why does Integrate declare a convergent integral divergent?

When I try this command Integrate[1/Sqrt[(s^2 - u)^2 - 1], {s, m, Infinity}, Assumptions -> u > 2 && m > 10] Mathematica declares that the ...
2k views

### How to use “Drop” function to drop matrix' rows and columns in an arbitrary way?

The built-in function "Drop" can delete a Matrix's row and column. Typical syntax for "Drop" is as follows: Drop[list,seq1,seq2...] But what if I want to drop a ...
1k views

### Combined numerical minimization and maximization

I want to numerically calculate the maximum of a function defined by the minimization of another function, like the following: ...
893 views

### Automatically load packages at startup

I'm a physics student and I try to simplify my day with Mathematica. Every time I use Mathematica I need Div[], Grad[], ...
1k views

### Why is ContourPlot not displaying this curve?

I am using the general form of a second-degree plane curve: $$Ax^2+2Bxy + Cy^2+2Dx + 2Ey + F = 0$$ I want to randomly generate plane curves of this form, so I am using ...
241 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 ...
733 views

### Solve an equation in $\mathbb{R}^+$

How can I solve this equation (both numerically and literally) only in the positive reals $\mathbb{R}^+$? Solve[x == (v0 - (A CD t v0^2 ρ)/(4m)) Cos[θ] t, t] And ...
2k 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 ...
285 views

### Confused by (apparent) inconsistent precision

$$e^{\pi \sqrt{163}} \approx 262537412640768743.99999999999925$$ E^(Pi Sqrt[163.0]) N[E^(Pi Sqrt[163.0]), 35] NumberForm[E^(Pi Sqrt[163.]), 35] returns ...
1k 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 ...
641 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: ...
5k views

### How can I extract data points from a black and white image?

Consider the following graph (source): Is there any way to extract the data points from this image in a semi-automatic way? I have seen, and tried the methods suggested in this question, but they ...