12
votes
5answers
718 views

How to improve this code for solving the “Mr.S and Mr.P” puzzle?

Mr.S and Mr. P puzzle — "Formalization of two Puzzles Involving Knowledge", McCarthy, John (1987) We pick two numbers $a$ and $b$, such that $a\geq b$ and both numbers are within the range ...
12
votes
4answers
2k views

Reshape vectors exactly like in MATLAB

This gives a 64×1 column vector in Mathematica: ...
12
votes
3answers
1k views

Adapt ticks in plot and font in legend

Some of my 2-dimensional data are displayed with a code similar to this: ...
12
votes
4answers
337 views

Arranging connector lines

Heike gave an absolutely wonderful answer to my question about arranging subplots around a main plot and including connector lines. This is the result: Starting from Heike's answer, what is the ...
11
votes
10answers
526 views

How to pick increasing numbers from the list

How to pick increasing numbers from the list. lst = {5, 3, 6, 2, 7, 4, 8}; out: {5,6,7,8} So many interesting ...
11
votes
2answers
671 views

How to plot a figure like this

I saw a beautiful figure illustrating the optical lattice clock, and would like to make a similar one. This is the figure (taken from here) Is it possible to make a similar one using Mathematica? ...
11
votes
2answers
406 views

Putting ticks with values on a parametric plot

I need to plot ticks with values on the following ParametricPlot[] The ellipse can be obtained by ...
11
votes
2answers
307 views

Clever use of DownValues, or failure to understand the “Mathematica Way.”

I needed to look at the changes in the values of about 4000 items from one year to the next. I have a table with identifiers and values for each year. Not all of the items are in each list. The ...
11
votes
1answer
1k views

Write C/C++ programs calling Mathematica functions

I need to write a C/C++ program and call some functions in Mathematica especially those like Solve or NDSolve. The problem is ...
11
votes
1answer
354 views

How do I seamlessly migrate from the older Units package to Mathematica 9's Quantity objects?

I have several notebooks that make use of the Units package and would like to be able to work simultaneously with the older units and ...
11
votes
1answer
267 views

Is it possible to use Compile on a function with optional arguments?

My Mathematica is a little rusty, so apologies in advance. I think my problem is quite simple, but I can't seem to find the answer on my own! Simple example : ...
11
votes
1answer
815 views

Load a Mathematica Package via .Net code

I'm using C# to pass data to Mathematica and return graphs: ...
11
votes
4answers
1k views

Import[ ] drops leading zeros from data when importing a CSV file

I need to load data from the CSV file shown below. Import[ ] drops the leading zeros in column 3 when it imports the CSV file, but they are security identifiers, and I need them. ReadList[ ] ...
11
votes
1answer
906 views

How could I add arrows to the axis of a figure?

It is easy for me to add arrows to the axes of the a figure by taking advantage of AxesStyle -> Arrowheads[] when the differences between the horizontal and ...
11
votes
1answer
1k views

Make a density list plot/histogram from large, pre-binned data set?

I have a large data set consisting of $\mathcal{O}(10^9)$ two-dimensional points. In order to save memory and time I have pre-binned these into a uniform grid of $500 \times 500$ bins using Fortran. ...
11
votes
4answers
498 views

Assessing argument type in set delayed function definitions

I'm wondering how to properly assess the type of arguments passed to functions defined with :=. I want my functions to be the most efficient, unambiguous and clear ...
11
votes
7answers
2k views

Recursive function with if-statement

I am trying to represent the following function definition in Mathematica: $$\begin{align*} f(1)&=1 \\ f(2n)&= \begin{cases}f(n) & \text{if}\space n\equiv0\pmod{2} \\ 2f(n) & ...
11
votes
2answers
555 views

What's the most “functional” way to do Cholesky decomposition?

I can do Cholesky in a procedural style, such as: ...
11
votes
1answer
254 views

Old values are not freed/garbage collected when you re-evaluate an assignment

For this code: (* Cell 1 *) generate := Module[{x}, x = Range[100 * 1000 * 1000]; x]; (* Cell 2 *) g = generate[]; MemoryInUse[] If I evaluate cell 2 ...
11
votes
7answers
2k views

Combination and Permutation

How could I obtain the list of all the groups of 5 numbers taken from Range[12] such that the 2 lists have an empty intersection : ...
10
votes
2answers
218 views

Is there a way to control V10's undo length?

This may be a duplicate (if so I will remove this), but I was having trouble finding the relevant bit of documentation to fix it. I noticed that my FrontEnd memory ...
10
votes
1answer
491 views

Are there tools for getting Mathematica 9 Notebooks working in Mathematica 10?

As often happens with Mathematica updates, nearly all of my notebooks no longer work as they did with the previous version. The upgrade from 9 to 10 has changed the appearance or introduced errors ...
10
votes
1answer
197 views

Why is my rasterized graphic blank?

Consider the following code: ...
10
votes
7answers
614 views

How can I Flatten this List with Inner List of Lists?

Given the following List ...
10
votes
1answer
160 views

Are formal characters like \[FormalA] to be used differently than other symbols?

I noticed that Mathematica has a set of special 'Formal' characters such as \[FormalA], \[FormalB] , etc.. In the front end, it ...
10
votes
2answers
599 views

How to send output of Information[] command to a text file?

I am having little hard time sending output of Information[] command to a text file. related question How to write output to an external text file in addition to ...
10
votes
4answers
440 views

How to use pattern matching to assign values to Subscript[f,x_]?

I want to define two subscripted functions Subscript[f,1] and Subscript[f,2]. To keep the assignments local, I would like to ...
10
votes
2answers
773 views

Preventing label crowding in PieChart RadialCallout and RadialCenter

Is it possible to avoid this unreadable situation with label crowding when using PieChart's RadialCallout and ...
10
votes
3answers
663 views

Count consecutive positions with the same value

I want to program a function that counts the successive positions with the same value: In[]= ConsecutiveValues[{1, 1, 1, 1, 2, 2, 1, 0}] Out[]= {4, 2, 1, 1} In ...
10
votes
2answers
244 views

Encoding format used by GraphicsData?

I am trying to extract some graphics stored in PICT format from a Mathematica notebook, using a platform that doesn't support PICT. If I look at the .nb file in a ...
10
votes
1answer
446 views

Mathematica Source-Code Control for CDF files in multi-user scenario

Q: I'm putting together a strategy on how its best to maintain cdf documents with multiple users in a source code repository. Ideally I wish for users to create (unit tested) cdf's with data and ...
10
votes
4answers
5k views

subscripts in plot axis labels

Superscripts can be included in axis labels by the use of the caret symbol (e.g., Plot[x^2, {x, -1, 1}, AxesLabel -> {x, x^2}]). How does one include subscripts ...
10
votes
3answers
830 views

Passing down arguments

In R, one can use ... to pass arguments down to another function. For example ...
10
votes
3answers
1k views

Most Efficient Way to Calculate the Product of All Items in a List?

Say that I have a list of returns on a financial asset over time and want to know the total compounded return. To get the answer, I need to add 1 to each return and then calculate the product of all ...
10
votes
5answers
536 views

How do you efficiently return all of a List but one element?

I have a problem that I am working on that requires that I compare several lists of overlapping data points. As I traverse one of the lists, I'd like to only compare those data to the other lists, and ...
9
votes
2answers
714 views

Solve Laplace equation using NDSolve

I am new to Mathematica, a friend recommended this software and started using it, in fact download the trial version to know. I recently did a program in C to calculate numerically the solution to ...
9
votes
1answer
311 views

Converting structured data to a dataset

A Dataset seems perfect to represent structured data. Has anyone already thought about how to convert as efficiently/elegantly as possible an XML or JSON file to a Dataset in Mathematica 10 ?
9
votes
2answers
521 views

Memory leak issues

I am working with noncommuting objects and basically I am using Mathematica to sort large expressions by normal ordering and simplifying them. To this end, I first create an object called ...
9
votes
3answers
12k views

MathLink linking error after OS X 10.9 (Mavericks) upgrade

After macosx 10.9 mavericks upgrade i have a compilation problem, you can see below. Even the examples given in ...
9
votes
4answers
406 views

When should I use Apply (or Function) and when @@ (or &)?

This is a rather general question, which I fail to answer myself. I guess it is mainly due to my insufficient knowledge of the precise terms. If I understand correctly, the following are equivalent: ...
9
votes
2answers
291 views

Is there a way to programmatically set global preferences?

Can I set global preferences that are accessible via "Edit"->"Preferences" programmatically from within a notebook? As learned from this question, turning off anti-aliasing can make a huge difference ...
9
votes
2answers
514 views

Extracting vertex coordinates from an automatically laid out graph

Given a Graph with an automatically computed layout (i.e. not explicitly given VertexCoordinates, but using a ...
9
votes
2answers
317 views

Transition between graphs

I want to visually demonstrate the manipulations made to a graph. For instance, I have a graph g where using the command ...
9
votes
3answers
379 views

Why is AstronomicalData so slow?

I'm having trouble getting some pretty simple functions using AstronomicalData to perform at anywhere near the speed I need them to. For example, I have many ...
9
votes
2answers
235 views

Strange results while nesting scope constructs?

I did a handful of tests with Block, With, and Module and had a couple of new surprises. ...
9
votes
3answers
509 views

Different calculation of median and quartiles, bug in BoxWhiskerChart?

When you plot a dataset with BoxWhiskerChart passing over the box in the plot with your mouse pointer shows some specifics about the dataset (min and max values, ...
9
votes
3answers
638 views

Improve speed for calculating a recursive sequence

I want to calculate following recursive sequence: $\alpha_{0}=0,\\ \cos(\alpha_{i})=\cos(\alpha_{i-1})\cdot\cos(\beta_{i})+\sin(\alpha_{i-1})\cdot\sin(\beta_{i})\cdot\cos(\gamma_{i}).$ In ...
9
votes
3answers
404 views

How to use Locators on a graphic in a tabview

Background: I want to split graphics in a Manipulate in several parts in a tabview control. But the tabview somehow interferes with the locators as in the following simplified example: ...
9
votes
1answer
288 views

How can I add row and column header images to my TableForm output?

I am experimenting with the Eigenfaces algorithm and have my notes and experimental data collected in a Mathematica notebook. The result of an experimental run is a table of scores, where the smallest ...
9
votes
1answer
171 views

Is there a way to have a Tooltip for non-editable raster graphics produced by MakeBoxes?

I have a function which produces a large object I would like to hide. Formatting is of course an option but I'm hoping for something a little more meaningful using raster graphics and ...

15 30 50 per page