Speeding up a numerical constrained quadratic optimization

I'm trying to solve a quadratic optimization problem in 35 variables, $\vec{α} = \left< α_1, \ldots, α_{35}\right>$: $$ \begin{aligned} &\operatorname*{maximize}_\vec{α}&&1.0\cdot α_1 - 2.7\cdot {α_1}^2 + 1.0\cdot α_2 + \cdots + 0.6\cdot α_{34} \cdot α_{35} -1.6 \cdot {α_{35}}^2 \\\ &\operatorname*{subject to}&&0 = α_1 + α_2 + \cdots - α_{34} + α_{35} \\\ &&& \forall_i(α_i \geq 0) \end{aligned} $$ where the expression to be maximized has 665 terms, all linear or quadratic. The obvious command:               nn = 35;     objective = 1.0*Subscript[α,1] - 2.7*Subscript[α,1]^2 + [...];     equalityConstraint = 0 == Subscript[α,1] + Subscript[α,2] + [...];     NMaximize[{objective, equalityConstraint} ~Join~ Table[Subscript[α, n] >= 0, {n, 1, nn}],         Table[Subscript[α, n], {n, 1, nn}]]      runs too slowly. I suspect that Mathematica's full nonlinear-optimization machinery, unneeded for this type of problem, may be slowing it down. What can I do to increase performance?


Setting OperatorSubstitution to False has issues with PDF and EPS exports. Are these bugs?

In `Plot`, I would like to use my own font, eg Inconsolata, for operators such as ×, so I set `OperatorSubstitution` to `False` as follows.               Plot[       x,       {x, 0, 10^10},       BaseStyle -> {PrivateFontOptions -> {"OperatorSubstitution" -> False}},        LabelStyle -> {FontFamily -> "Inconsolata"}     ]      There are three vector formats into which I can export the figure: SVG, EPS, and PDF. Only the SVG export gives the correct result, ie the character × is in the font specified. The others have the following issues. My first question is: **Are they bugs?**   * PDF export: operators are omitted altogether.   * EPS export: the instruction of setting `OperatorSubstitution` is omitted, ie font substitution for operators still occur. I'm using Mathematica 9 for Mac. My second question is: **Is there any way to work around the issue with PDF export?**


Unexpected behavior of confidence bands for data presenting two regions with uneven noise

Let's generate some noisy data with uneven noise.                   data = Table[{x,Exp[-(x-2)^2] + Exp[-(x+2)^2]*RandomReal[{0.5, 1.5}]},                {x, RandomReal[{-4, 4}, 500]}];      ![enter image description here](http://i.stack.imgur.com/VrQVD.png) Let's fit it with a nonlinear model                   fit = NonlinearModelFit[data, b Exp[-(x-a)^2] + c Exp[-(x+a)^2],               {a, b, c}, x]      from which we extract the σ and 2σ prediction bands for single observations:                   {bands1[x_], bands2[x_]}=Table[fit["SinglePredictionBands",ConfidenceLevel -> cl],           {cl, {.683, .954}}];      The bands seem not to take into account the unevenness of the noise:                   Show[ListPlot[data, PlotStyle -> {Opacity[0.5]}], Plot[{fit[x], bands1[x], bands2[x]},              {x, -4, 4},Filling -> {2 -> {{1}, Directive[{Green, Opacity[0.25]}]}, 3 -> {{2}, Directive[{Yellow, Opacity[0.25]}]}},              PlotStyle -> {Directive[Thickness[0.0075], Red],Black, Black}]]      ![enter image description here](http://i.stack.imgur.com/0j7dt.png) Am I misinterpreting confidence bands, or am I calculating them in the wrong way?


Version 7 and 8, different behavior of NSolve. Is it reproducible?

I noticed the following difference, and I wonder if it's a problem of my system or the results difference is actually due to the two different versions               oldsa = {0.29289321881345254` -          0.6666666666666666` Sin[0.5235987755982988` + phi] ==         0.75` Cos[psi1], -0.7071067811865475` + h +          0.6666666666666666` Cos[0.5235987755982988` + phi] ==         0.75` Sin[psi1], -0.5` +          0.6666666666666666` Sin[0.5235987755982988` - phi] ==         0.75` Cos[psi2], -0.4660254037844386` + h +          0.6666666666666666` Cos[0.5235987755982988` - phi] ==         0.75` Sin[psi2]}          NSolve[oldsa, {h, phi, psi1, psi2}]      gives solutions in Mathematica version 7, and no solution in ver. 8 Both run on Ubuntu 12.04 x64 Do you get the same resuts?


How to get the real PlotRange using AbsoluteOptions?

The problem in general involves the unreliable behaviour of `AbsoluteOptions` when option values are implicitly specified (e.g. `Automatic`, `All`, `Full`, etc.), for example the graphics below clearly has a different plot range than the one reported by `AbsoluteOptions`:               {g = Graphics[{}, Frame -> True], AbsoluteOptions[g, PlotRange]}      ![enter image description here](http://i.stack.imgur.com/Jbjwy.gif) * * * ## Original example For demonstrating the problem, have a look at the following example, and try adjusting the rotation angle `a` and/or the `Locator` position, comparing the real `PlotRange` of `pic` indicated by the frame-ticks with the one under the graph obtained by `AbsoluteOptions[pic, PlotRange]`:               Manipulate[      DynamicModule[{pic},       Column[{         pic = Graphics[{FaceForm[], EdgeForm[Black],            GeometricTransformation[Rectangle[], RotationTransform[a]],            Red, Point[p]},           Frame -> True],         p,         AbsoluteOptions[pic, PlotRange]         }]       ],      {{a, 0}, 0, 2 Pi},      {{p, {.1, .2}}, {-2, -2}, {2, 2}, Locator}]      ![Mathematica graphics](http://i.stack.imgur.com/k7ysd.png) As shown in the screen capture above, in my **Mathematica 9.0** on **Windows 7 64-bit** system, the `PlotRange` from `AbsoluteOptions` is not consistent with the real range. And the angle `a` seems to do nothing with it. Additional tests in my system suggest this problem is not restricted on the attendance of `RotationTransform`, but comes with the `GeometricTransformation`. And it happens not only on `Graphics` but also on `Graphics3D`. So my questions are:   * What is going on here?   * How can I obtain the real `PlotRange` of the `Graphics`/`Graphics3D` when there are `GeometricTransformation`s in it?


TreeForm display with nested lists as nodes

If i have a nested list representing nodes in a binary tree, `{3, {2, {1, None, None}, None}, None}`, what is the easiest way to show the hierarchy, without all the List heads being displayed as intermediate nodes?


Is there a shortcut to select all cells above the current cursor position?

Is there a command / menu entry / keyboard shortcut to evaluate all cells above / up to the current cursor position? I have the feeling I am missing something elementary here... **Addendum** : In fact, it is more about selection of those cells, evaluation is not the problem as such.


3D plots wrongly displayed when using GraphicsRow in Linux

I get an incorrect vertical offset in 3D plots when using GraphicsRow in Mathematica 9 (Linux - Ubuntu 12.04). When displayed by itself, the plot is fine. Here's an example:               f[x_, y_] := Exp[-x^2 - y^2]      Showing the plot by itself works as expected:               a = Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}]      ![Gaussian shown once](http://i.stack.imgur.com/KZHDM.png) However an incorrect vertical offset appears when showing the plot _multiple_ times with GraphicsRow:               GraphicsRow[{a, a}, ImageSize -> Large]      ![Gaussian shown twice](http://i.stack.imgur.com/BXBL0.png) Does anybody also have this problem? Any idea how to fix this?


_?NumericQ equivalent for lists

A few months ago I got a simple answer (see: 1 ) to the question of how to force numeric evaluation during use of functions such as NMinimize - namely the use of _?NumericQ in the argument list. I now have the same problem, only this time the argument to the user-defined function I'm trying to minimize is a list. Is there an equivalent to _?NumericQ for lists?


Calculating the median difference between elements with a (particular pair) of consecutive integer indices residing in the same sublist

NOTE: I formally made a serious mistake in the first example provided. `pointLists[[1]]` had an extra element, and we should have a guarantee that `Length[pointLists[[i]]] == Length[indexLists[[i]]]`. I apologize for wasting people's time with this. * * * I have a list `pointLists` of sublists of 2D coordinates, where an `N = 3` example looks like this:               pointLists =       {{        {131.048, 243.364}, {131.046, 243.321}, {131.037, 243.357},         {130.931, 243.391}, {130.909, 243.377}}, {{164.911, 244.039}, {164.929, 243.942},         {164.74, 244.083}}, {{98.1685, 239.618}, {98.1913, 239.6}, {98.1528, 239.623}      }};      I also have another list `indexLists` (where `indexLists[[i]]` corresponds to `pointLists[[i]]`) which assigns an integer value $\geq 1$ to each coordinate in each sublist. An example of `indexLists` for the above example looks like this:               indexLists = {{1, 2, 3, 5, 6}, {1, 2, 4}, {1, 2, 3}};      What I'd like to calculate here, as quickly as possible, is a list `differenceList` where a position `k` in `differenceList` corresponds to the mean or median difference between coordinates in the same sublist of `pointLists` where the first coordinate and the second coordinate have values of `k` and `(k-1)` in `indexLists`. Sometimes, however, there will be no examples in any of `pointLists` satisfying this criterion. In this case I'd like to simply set `differenceList[[k]] = "NULL"` (or really anything distinct and addressable). * * * Here's another way of thinking about the question: Imagine, for example, that we have a bunch of cells growing in different colonies/plates, and their color changes over time. But we can't always measure the change for each colony at every time point, just whenever we can. Each time we measure a color, we add it on the end of a sublist corresponding to the colony in `pointLists` and we time stamp the addition by adding the time to a position at the same index as `pointLists` in `indexLists`. We then ask... for some time point (e.g. $T = 5$), what's the median change from the previous timepoint (e.g. $T = 4$)? And now imagine that I unfortunately have no control over this data formatting. I just have a structure like `pointLists` and `indexLists` to work with from measurement device. * * * Descriptive Example - Since the description provided is a little wordy, let's plug through the above example in a step-wise fashion (this is optimized for easy reading, and should in no way constrain any algorithm that can achieve the same result): (k = 1) We set `differenceList[[1]] = {0,0}` to handle this special case. (k = 2) For `k=2` we notice that `pointLists[[1]]`, `pointLists[[2]]`, and `pointLists[[3]]` have coordinates with `indexLists` values of $k = 2$ and $1$. We compute the differences as, for the first sublist: `{131.046, 243.321} - {131.048, 243.364} = {-0.002, -0.043}`, for the second sublist: `{164.929, 243.942} - {164.911, 244.039} = {0.018, -0.097}`, and for the third sublist: `{98.1913, 239.6} - {98.1685, 239.618} = {0.0228, -0.018}`. We then set: `differenceList[[2]] = Median[{{-0.002, -0.043}, {0.018, -0.097}, {0.0228, -0.018}}] = {0.018, -0.043}`. (k = 3) For `k=3` we notice that `pointLists[[1]]` and `pointLists[[3]]` have coordinates with `indexLists` values of $k = 3$ and $2$ (and that `pointLists[[2]]` does NOT have any coordinates satisfying this criterion). We compute the differences as - for the first sublist: `{131.037, 243.357} - {131.046, 243.321} = {-0.009, 0.036}`, and for the third sublist: `{98.1528, 239.623} - {98.1913, 239.6} = {-0.0385, 0.023}`. We then set: `differenceList[[3]] = Median[{{-0.009, 0.036}, {-0.0385, 0.023}}] = {-0.02375, 0.0295}`. (k = 4) For `k=4` we notice that none of the sublists have coordinates with an associated index value of $4$ AND ALSO a coordinate with an associated index value of $3$ in `indexLists`, so we set `differenceList[[4]] = "NULL"`. (k = 5) For `k=5` we notice that, while `pointLists[[1]]` has a coordinate with an index value in `indexLists` of $5$, and `pointLists[[2]]` has a coordinate with an index value in `indexLists` of $4$, two coordinates with indices $4$ and $5$ not present in the same sublist, and there are no other examples where a sublist has both values, so we set `differenceList[[5]] = "NULL"`. (k = 6) For `k=6` we notice that `pointLists[[1]]` has coordinates with indices $k = 6$ and $k = 5$ in `pointLists`, and that this is a lone example, so we set `differenceList[[6]] = {130.909, 243.377} - {130.931, 243.391} = {-0.022, -0.014}`. Done. And our result is:               differenceList =        {{0,0}, {0.018, -0.043}, {-0.02375, 0.0295}, "NULL", "NULL", {-0.022, -0.014}}      * * * Is there a clever way to achieve the same result as above for very large instances of `pointLists` (in terms of both the number and length of component sublists)? If it matters, I'd like to optimize for speed and not necessarily memory usage. Also, since I'd like to be able to rerun the algorithm after updating `pointLists`, is there some way to quickly calculate the `differenceList` value at specific positions (i.e. for specific values of $k$) without recalculating the entire list? * * * * * * * * * Let's do one more quick example where we calculate `differenceList[[5]]` for new versions of `pointLists` and `indexLists`.               pointLists = {{{122.534, 191.041}, {122.735, 191.023}, {122.692, 190.999}, {122.742, 191.051}}, {{16.2591, 182.679}, {16.2429, 182.681}, {16.3327, 182.726}, {16.4354, 182.733}, {16.4144, 182.737}, {16.3727, 182.759}, {16.3141, 182.783}, {16.3692, 182.77}, {16.4068, 182.745}, {16.3346, 182.712}}};          indexLists = {{1, 3, 4, 5}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};      Here's a description of how to to calculate `differenceList[[5]]` in the new example: From `pointLists[[1]]` we calculate: `{122.742, 191.051} - {122.692, 190.999} = {0.05, 0.052}`. From `pointLists[[2]]` we calculate: `{16.4144, 182.737} - {16.4354, 182.733} = {-0.021, 0.004}`. And finally, we take the median of those values: `differenceList[[5]] = Median[{{0.05, 0.052},{-0.021, 0.004}}] = {0.0145, 0.028}`. Here, `{122.742, 191.051}` & `{16.4144, 182.737}` have indices of `5` at the same position in the associated `indexLists`. And points `{122.692, 190.999}` & `{16.4354, 182.733}` have indices of four at the same position in `indexLists`. We calculate: `{122.742, 191.051} - {122.692, 190.999`} since these values are in the same sublist of `pointLists` (`pointLists[[1]]`), and `{16.4144, 182.737} - {16.4354, 182.733}` are both in `pointLists[[2]]`. So that's how we do `k = 5` in the new example. If `{122.742, 191.051}` OR `{16.4144, 182.737}` OR both are missing, we'd have `differenceList[[5]] = {-0.021, 0.004}` (and `differenceList[[5]] = {0.05, 0.052}` if `{122.692, 190.999}` OR `{16.4354, 182.733}` OR both are missing). If three of those coordinates are missing `differenceList[[5]] = "NULL"`.


mysql insert set problem

I need some help.               set = {0, 0};     Print[set];     Needs["DatabaseLink`"];     JDBCDrivers["MySQL(Connector/J)"]     conn = OpenSQLConnection[              JDBC["MySQL(Connector/J)", "localhost:3306/test"],              "Username" -> "root", "Password" -> "root"]     SQLExecute[conn, "INSERT INTO numbers VALUES ([set]) "]      I don't know know how to escape `[set]` in the insert statement In the database the field type is text


calculating a sequence of functions using iteration

I am trying to compute a sequence of functions using iteration and keep running into problems trying to use built in looping commands because of the recursive nature of the definition. The code below (version 8) shows the first two functions `y1` and `y2`. The output functions are also piecewise linear. Is there an easier way to compute `yn` for any $n$?               {a1, b1} = {.3, .6}; {a2, b2} = {.6, .3};          y0[x_] := x;          f1[x_] := b1*y0[x/a1];          g1[x_] := (b2 - b1)*y0[(x - a1)/(a2 - a1)] + b1;          h1[x_] := (1 - b2)*y0[(x - a2)/(1 - a2)] + b2;          y1[x_] := If[0 <= x < a1, f1[x], If[a1 <= x < a2, g1[x], h1[x]]];          Plot[y1[x], {x, 0, 1}]          f2[x_] := b1*y1[x/a1];          g2[x_] := (b2 - b1)*y1[(x - a1)/(a2 - a1)] + b1;          h2[x_] := (1 - b2)*y1[(x - a2)/(1 - a2)] + b2;          y2[x_] := If[0 <= x < a1, f2[x], If[a1 <= x < a2, g2[x], h2[x]]];          Plot[y2[x], {x, 0, 1}]


How to construct a list in a For Loop nested in a Parallel Loop

I've the following problem I cannot solve. I allocate an empty matrix, v, of size n x m. Then I want to do a Parallel loop (ex. ParallelDo), and do some operations (described by a function operation[j,y] of two arguements) that as a result gives a numerical output. I want to "store" the i-th output in the i-th element of the list. If I use a Parallel loop with inside a For loop, there is no way to in fact store the output in the list, and at the end of the loop, v, is empty. If I do the same thing with a regular loop (ex. Do), then it works. Here I report a generic expample:               v = Table[{}, {j, 1, m}, {i, 1, n}];          ParallelDo[For[j = 1, j < n+1, j++, v[[j,i]] = operation[j,i]], {i, 1, m}]      But in this case, no matter of what the operation function is, V is still an empty matrix. If I use Do, instead of ParallelDo, then it works. All DistributeDefinitions and related stuff I think are taken care correctly. Thanks!


Getting clearer StreamPlot output

When I do a `StreamPlot`of a rather complicated pair of differential equations, it loses some details. For example:               StreamPlot[{Tan[y - x], 2^y - 2 Cos[Pi/3 - x]}, {x, -4, 4}, {y, -4, 4}]       Here is the result: ![enter image description here](http://i.stack.imgur.com/uewBK.png) Is there any way to:   * Change the color near each of the critical points to a different set of colors?   * Increase the level of detail near the saddle points and spirals? That is, add more streams?   * Any way to make a collage (for example, a landscape variant in order to capture more of the rich details and global behaviors of all critical points, including the periodic ones in this particular example)?


Plot 3D boolean Array or matrix in Mathematica

![enter image description here](http://i.stack.imgur.com/47NjD.jpg) I have been attempting several methods to plot a 3D diagram of a n by n boolean array in _Mathematica_ but none of them produced satisfactory result. I want the $3D$ plot to have a cube when `M[i,j,k] == 1` and when `M[i,j,k] == 0` just leaves as blank. Below is the best result I got.               L=10     M = RandomReal[{0, 1}, {L, L, L}];     For[k = 1, k <= L, k++,       For[j = 1, j <= L, j++,        For[i = 1, i <= L, i++,         If[M[[i, j, k]] < 0.5,          M[[i, j, k]] = 1,          M[[i, j, k]] = 0          ]]]];     Image3D[M, ImageSize -> 500, Boxed -> True]      The `Image3D` function gives a very fluffy and opaque look on the cubes which I couldn't change!! Is there someway I can change the opacity and color of the `Image3D` function in this case? Or is there a better way to plot this matrix?


Clustering of space-time data

Below is an example of a gaze sequence I recorded during a 3 seconds display. That is, where the eye was at every millisecond. While we should have 3000 points, we are missing some due to blinking. ![enter image description here](http://i.stack.imgur.com/O3CXlm.png) **Fixation or visual fixation is the maintaining of the visual gaze on a single location.** I need to extract those fixations. That is group of gazes that are both contiguous in time and space. Below is the location of fixations. Of course we'll have to implement thresholds. ![enter image description here](http://i.stack.imgur.com/Io08Vm.png) In this file available for download, you will find 7 sequences there if you simply open and run the attached notebook. `gazeSeq[1]` is the first out of 7 sequences made out of 3000 sublists representing each gaze record as `{x,y,time}`:               gazeSeq[1][[1]]      Out[1]= {-0.562, 0.125, 1000.}      where `time` goes from 1000 to 4000 corresponding to the 3 seconds of display. As said above some data points might be missing. While I tried to use `GatherBy`, I could not manage to include the condition of "time contiguity" and would get grouping of gazes that did not happen during the same interval during the trial.


Is it possible to manipulate graphs by hand?

> **Possible Duplicate:**   >  Generating graphs interactively (GUI) If I plot a graph, is it possible for me to manipulate the vertices such that when I move them, their attached edges will follow. One option that I tried is to change the graph into a graphics object, but then the edges and vertices lose their sense of being connected to each other.


Roots of characteristic equation of sixth order

I have problem how to localize the roots of the sixth order polynomial given in the form of determinant. Classical Solve gives the solution which are in the long form. Is there way how to present roots in analytical form of constants with some substitutions not to looks so long                c11 = b11 - a11 X;      c22 = b22 - a22 X;      c33 = b33 - a33 X;      c44 = b44 - a44 X;      c55 = b55 - a55 X;      c66 = b66 - a66 X;           poly = Det[({      {c11, b12, b13, b14, 0, 0},      {b21, c22, 0, 0, b25, b26},      {b31, 0, c33, b34, 0, 0},      {b41, 0, b43, c44, 0, 0},      {0, b52, 0, 0, c55, b56},      {0, b62, 0, 0, b65, c66}     })];           Solve[poly == 0, X]


Cycles of length N in a graph

If I have an undirected graph represented with an adjacency matrix, how can I find all the subgraphs which are a cycle of length N? I don't really know the math nor the programming language well, so I find myself resorting to making a bunch of for loops to try traversing the graph. This is very slow, and I might as well just write it in C at that point. So I'm hoping to learn how to work better with mathematica here. So far, I think I've found a way to tell me the number of such subgraphs. For example, I might be able to get the number of cycles of length 3 in the graph given by the matrix m by doing something like...               Digitize[matrix_] := Map[Sign[#]&,matrix,{2}]      m=Digitize[m]; (* ensure it is normalized *)     ident = Table[KroneckerDelta[i,j],{i,1,Length[m]},{j,1,Length[m]}];     m1 = m*(1-ident); (* remove self-loops, giving steps away of length 1 *)     m2 = (m1.m1)*(1-ident); (* matrix of steps of length 2, with no repeats *)     m3 = (m2.m1); (* matrix of steps of length 3 *)     (* reading diagonal of m3 will tell how many paths lead back to the start? *)       This already looks a bit messy, and I'm not sure how much I can generalize it to larger N. And even then, it doesn't help me get the actual paths. Help? Clarification: Ideally I'd like to eventually write a module that given a length N and an adjacency matrix for an undirected graph, outputs a list of all the unique (up to cyclic reordering) lists of vertices which form a cyclic path of length N.


How can I make a grid of plots with no spacing, and have the plots line up perfectly?

I am making a bunch of two dimensional plots and I would like to have them arranged in a grid with no space in between them. That is, I want their frames touching each other. My problem is twofold. First I don't know how to get the plots to have a consistent size. When I try to give the plots the same size via `ImageSize`, it applies the size to the overall image, including the tick marks and labels. But when I have two different plots, one with tick labels and one without, giving the same value to `ImageSize` doesn't give the result I'm looking for. Secondly, I want to get rid of any white space around the images such that when I give `Grid` the option `Spacings ->{0,0}` there really is no visible space between the plots. In the example code I use the `CustomTicks` package.               (*an example of what I might plot, simple sum of two dimensional \     Lorentzians*)     lzn[x_, w_, g_] := (x - w + I g)^-1;     exampledata2D =        Table[Re[lzn[w1, .2, .1] lzn[w2, .3, .2] +           lzn[w1, .4, .1] lzn[w2, .8, .1] +           lzn[w1, .8, .2] lzn[w2, .4, .2]], {w1, 0, 1, .01}, {w2, 0,          1, .01}];     << "CustomTicks`";       standardticks = LinTicks[0, 1, .2, 4];     (*I don't want the last tick label for one plot overlapping with the \     first tick label of the plot right next to it.*)     ticks2 = LinTicks[0, 1, .2, 4, ShowLast -> False];     (*Custom plotting function so I don't have to reprint the same \     options over and over *)     plottingfunction[list_, plotopts : OptionsPattern[]] :=        ListContourPlot[list,         Evaluate[FilterRules[{plotopts}, Options[ListContourPlot]]],         Contours -> 30, PlotRange -> All, DataRange -> {{0, 1}, {0, 1}},         BaseStyle -> 18,         ColorFunction -> (Blend[{Red, Orange, Yellow, Green, Blue,              Darker[Blue]}, #] &)];          bottomleft =        plottingfunction[exampledata2D,         FrameTicks -> {{ticks2, StripTickLabels[standardticks]}, {ticks2,            StripTickLabels[standardticks]}}];     bottomright =        plottingfunction[exampledata2D,         FrameTicks -> {{StripTickLabels[standardticks],            StripTickLabels[standardticks]}, {standardticks,            StripTickLabels[standardticks]}}];     topleft =        plottingfunction[exampledata2D,         FrameTicks -> {{ticks2,            StripTickLabels[standardticks]}, {StripTickLabels[            standardticks], StripTickLabels[standardticks]}}];     topright =        plottingfunction[exampledata2D,         FrameTicks -> {{StripTickLabels[standardticks],            StripTickLabels[standardticks]}, {StripTickLabels[            standardticks], StripTickLabels[standardticks]}}];          Grid[{{topleft, topright}, {bottomleft, bottomright}},       BaseStyle -> ImageSizeMultipliers -> 1, Spacings -> {0, 0}]      ![enter image description here](http://i.stack.imgur.com/usCDh.png)


TableForm with a title

My question is rather simple. I want to put a title into a table. For example, consider a list with depth two and a title               list = Range[4] & /@ Range[4];     title = "Bravo";      And I want to create a table from `list`, i.e.,               TableForm[list]      This will generate a table without a title. Let's say I want to make a title "Bravo" on top of the table(which is center-aligned). Can you suggest a neat way to achieve it? I looked up the possible options for `TableForm`, but I could not find a relevant one.


Accessing Reduce from DSolve

When solving transcendental equations, `Solve` frequently warns us that inverse functions are being used so that some solutions may not be found. ![enter image description here](http://i.stack.imgur.com/ZfqAV.png) We also see that `Reduce` might provide a more complete solution and, indeed, simply changing `Solve` to `Reduce` provides a complete, quantified result. ![enter image description here](http://i.stack.imgur.com/NIQ6q.png) Somtimes, however, this same message is produced by `DSolve`. ![enter image description here](http://i.stack.imgur.com/7Mhfz.png) My guess is that `DSolve` calls `Solve` which in turn generates the message. Is it possible, though, to access `Reduce` through `DSolve`? For this particular equation, it would be easy enough to separate variables, `Integrate` and then apply `Reduce`. I'm wondering about a more general solution, though.


Epilog->Inset crops text with large font sizes

Why does `Epilog->Inset` crop the first and last letters here ("a" and "g") when `FontSize` is set to large values (which varies with font family):               Plot[Cos[t], {t, -32 Pi, 32 Pi}, AspectRatio -> 1/4, PlotRange -> All,       Axes -> True, ImageSize -> 600,       Epilog ->        Inset[Graphics@         Text[Style["a   b   c   d   e   f   g", FontSize -> 30]], {0, 0}]      ]      This renders as: ![enter image description here](http://i.stack.imgur.com/mBAew.png) Are there options or a hack which still uses `Epilog -> Inset`, as opposed to using `Show` and passing the text as `Graphics` (which works correctly)?


Why is LogLogPlot[] slower than Plot[]?

I notice that `LogLogPlot` runs quite bit more slowly than ordinary `Plot`. For example, consider the following two blocks of code which plots (using `Manipulate`) a region in linear scale and log-linear scale. Notice how the log-log-scale manipulation runs more sluggishly. Is there a way to speed up the log-log-scale version? Linear-scale code:                Mhad = 0.93827;      Table[Tooltip[(MxSq - M^2) x/(1 - x) /. M -> Mhad, "x=" <> ToString[x]], {x, 0, .9, .1}];      Manipulate[Plot[{1/s (s - M^2) (s - MxSq) /. M -> Mhad, %},        {MxSq, Mhad^2, 100}, PlotRange -> {{0, 100}, {0, 100}},        AspectRatio -> 1, Filling -> {1 -> Axis}, Frame -> True,        PlotStyle -> Table[If[i == 1,          RGBColor[0, 0, 0],          {RGBColor[1, 0, 0], Thickness[.001]}], {i, 1, 11}]], {{s, 50}, 1,          400}]      Log-log-scale:                Table[Tooltip[(MxSq - M^2) x/(1 - x) /. M -> Mhad, "x=" <> ToString[x]], {x, 0, .9, .1}];      Manipulate[LogLogPlot[{1/s (s - M^2) (s - MxSq) /. M -> Mhad, %},        {MxSq, Mhad^2, 100}, PlotRange -> {{.8, 100}, {.8, 100}},        AspectRatio -> 1, Filling -> {1 -> Axis}, Frame -> True,        PlotStyle -> Table[If[i == 1,          RGBColor[0, 0, 0],          {RGBColor[1, 0, 0], Thickness[.001]}], {i, 1, 11}]], {{s, 50}, 1,          400}]


Optimizing an energy functional in mathematica using variational calculus

I have an energy functional which I want to optimize using calculus of variation. It would be nice if someone could please post a working example using mathematica. The procedure is as follows, specify the energy functional, compute the Euler-Lagrange equation, discretize them and if possible run for a sample data. There are some links to the package for calculus of variation. But none of them is providing a complete example as I have described in the above paragraph. _**UPDATE1_** I am trying the simple Lucas-and-Kanade energy functional $E(u(x_0,y_0),v(x_0,y_0)) = \int(f_x(x,y,t)u+f_y(x,y,t)v+f_t)dx dy$ I have tried to do it with [this link] _**UPDATE2_** The correct form of the energy functional is, courtesy of [rcollyer] $E(u(x,y),v(x,y)) = \int(f_x(x,y,t)u+f_y(x,y,t)v+f_t)^2dx dy$ The question is now how to descritize the Euler-Lagrange equations. and solve it for some artificial data. (this is not extra thing specified in the question already) *** UPDATE3*** the complete solution procedure is as follows: The E-L equations for the integrand of the above energy functional are as follows and we set the first variation to zero $2f_x(f_x(x,y,t)u+f_y(x,y,t)v+f_t)=0$ $2f_y(f_x(x,y,t)u+f_y(x,y,t)v+f_t)=0$ in the matrix form it will look as follows Now we can simply solve for u and v because we have two equations and two unknowns but the derivatives are needed to be descritized. For example if we take the forward difference assuming the distance is 1 $f_x = f_{i+1}-f_{i}$ $f_y = f_{j+1}-f_{j}$ In above equations i and j represent the indexing in x and y direction respectively. $f_t = f_{2}-f_{1}$ Here in the above equation the function is described by indices 1 and 2 describe the function in the temporal direction. (Mathematica provides a lot of variety for descritizing as per the documentation) So the idea is to be able to replace the derivative with finite differences and we should be able to solve the equation system for u and v given the data. thanks a lot


Interpolate specific columns of data

I have a txt file with 3 columns of data: x y1 y2 How do I import the file then create 2 functions, one interpolated with {x,y1} values and the other interpolated with {x,y2} values? This is the sort of thing I want to achieve (in pseudocode):               Import "data.txt" into A     f1 = Interpolation(A,{x,y1})     f2 = Interpolation(A,{x,y2})


Why is held expression evaluated?

Context: I'm studying non-linear dynamics. As part of a bigger problem, I'd like to generate lists of the form `{{deq, ic1}, {deq, ic2}, ...}`, where `deq` is a differential equation and `ic` are initial conditions. **EDIT** : (Use `r` instead of `t` for the tuples as per @Kuba's suggestion *)               ClearAll["Global`*"];     deq = x''[t] == x[t] - x[t]^3 + x[t]^2 + Cos[t];     r = Tuples[{Hold@deq, {{x[0] == 0, x'[0] == 0}, {x[0] == 0, x'[0] == 1}}}]     NDSolve[First@r, {x, x'}, {t, 0, 1000}]      I have the following related questions:   1. ~~Why do I need to`Hold[]` `deq` at the first place ? If I don't use it, `Tuples[]` will "break" `deq` in == and combine all the `{lhs, rhs}` with all the `ic`'s.~~ It's due to the fact that `deq` isn't list which is what `Tuples[]` expects. See @Kuba's answer.   2. Why when later on I pass the result of to `NDSolve[]`, `Hold@deq` is evaluated without me releasing it first ? I checked the documentation of `Hold[]` and it says that this should happen only when the held expression is of the form `f[args]` and UpValues have been defined for f. I don't mind that it does, but I'm trying to understand the logic.   3. How would using `Unevaluated@deq` differ compared to `Hold@deq` ?


Levels and slots

I am struggling with levels and `#`, if I understand this I think I will be able to grasp the entire concept.                Apply[#1 &, {envelope[1, order["sku1", 5, 10, 4.98]],        envelope[2, order["sku2", 3, 67, 98]]}, {1}]      > >     {1,2} >   This makes perfect sense. Keeping everything els equal but changing the slot to `#2`: > >     {order["sku1", 5, 10, 4.98], order["sku2", 3, 67, 98]} >   This makes also perfect scence. Then I am going back to `#1` but now at level `2` > >     {envelope[1, "sku1"], envelope[2, "sku2"]} >   Why do I get this output I was only expecting `Sku1` and `Sku2`. I also wonder why Depth in this case equals 4, but if I put level 3 I get the entire list? I know this is very simple but I have been struggling with seeing the logic. I have spent quite a lot of time trying to grasp this so please try make it as clear as possible. And If you do not understand the question or think it is poorly explained give me a comment before downgrading the question.


How to make an inkblot?

How to effectively create a polygon that looks like a realistic inkblot? So far, I could come up with this (borrowing from Ed Pegg Jr.'s Rorschach demonstration):               RandomBlot[num_, opts___] := Module[{pts},        pts = RandomReal[{0, 1}, {num, 2}];        pts = pts[[Append[Last@FindShortestTour[pts, Method -> "TwoOpt"], 1]]];        Graphics[{Polygon@           Table[BSplineFunction[pts, SplineKnots -> "Clamped"][a], {a, 0, 1, 0.001}]}, opts]        ];          blot = RandomBlot[40, ImageSize -> 200, AspectRatio -> 1]      ![Mathematica graphics](http://i.stack.imgur.com/ibwxP.png) There are two problems with this:   * it is a bit slow due to `FindShortestTour`   * the blot contains corners being too sharp and has 'bays' reaching too far inward.  Compare it to a desired outcome: ![inkblot](http://i.stack.imgur.com/loyng.gif) **Update:** I should mention that it is not necessary to actually create a Rorschach-like image, so mirroring is not a requirement.


Delete False values from a list

I have table:               t = {False, False, False, a <= 456, a <=567, a<= 897}      I want to delete all values which are 'False' and make my table to looks like:               t = {a <= 456, a <=567, a<= 897}      I was tried to make a commend like above:               For[i=1,i< Length[tt], i++, If[tt[[i]]==False, Delete[tt,i], Print[no]]]      But it didn't work. I don't want to delete each 'False' value separately, because I have many tables, and each has a different number of `False` values. How can I improve that?


3- dimensional plot of 2-dimensional systems of differential equations

Let's take this first example of a 2D output:               sol = DSolve[             {y''[t] + y'[t] + y[t] == 3 Sin[t] - 4 Cos[t],               y[0] == a, y'[0] == 0},              y[t], t           ];     toplot = Table[ sol[[1, 1, 2]] /. a -> i, {i, 0, 3, 0.5}];     Plot[Tooltip[toplot], {t, 0, 2 \[Pi]}]       How can I visualize these solutions with a 3-D output like the ones obtainable by ListSurfacePlot3D , the independant variable (a) of my example being the 3d coordinate? Here I would like to see 7 parallel curves. Also another example this time for a system of two differential equations:               sol = DSolve[             {x'[t] == x[t]/8 - y[t]  ,              y'[t] == x[t]   + y[t]/8,               x[0] == 0,              y[0] == 1},              {x[t], y[t]}, t           ];     ParametricPlot[{x[t], y[t]} /. sol, {t, -2 \[Pi], 2 \[Pi]}]      How can I get a 3D output of these solutions, the 3d coordinate being the variable t (and I expect to get a helix)? Thanks


Using Transpose with a list as the second argument

I'm having difficulty understanding the `Transpose` function. I know what the transpose of a matrix is, not a problem, and I see that applying the `Transpose` function to a 3×3 matrix does what is expected. What I am having difficulty with is the definition, which says: > `Transpose[list]`, "transpose the top two levels of list" Consider:               A = {{a, b}, {c, d}}     Transpose[A]      What does it mean when the definition says "transpose the top two levels of the list?" I've read about levels in lists, experimented with `TreeForm`, but something like this is giving me a lot of trouble.               A = {{{a, b}, {c, d}}, {{e, f}, {g, h}}, {{i, j}, {k, l}}}     Transpose[A, {3, 1, 2}]      Can someone help me (gently) understand the definition: > `Transpose[list,{n1,n2,...}]`, "put the $k^{th}$ level in list at level > $n_k$" ?


I am looking for the evaluation of a Hypergeometric function with a matrix argument as for example in Ploev and Edelman or as showcased in this Wikipedia article. From what I understand from _Mathematica_ 's documentation, it only accepts a scalar as the last argument.


How to change type order in PearsonDistribution?

I need to estimate a Pearson distribution from a batch of tables `tab`: `EstimatedDistribution[tab, PearsonDistribution[a1,a0,b2,b1,b0], ParameterEstimator -> "MethodOfMoments"]` I don't want to specify the type, but rather have it automatically picked. Mathematica does this in the order: 4, 1, 6, 3, 5, 2, and 7. Is it possible to change this default order?


What are the hidden specifications for FindRoot

The Help page of `FindRoot` says: > "by default, FindRoot uses Newton's method (Newton-Raphson) to solve a > nonlinear system" (or a nonlinear equation I suppose). Nevertheless, there is something hidden for me in the `FindRoot` command. Consider the function               f[x]:=Exp[1 - x] - 1,       whose Newton iteration function is               Nf[x_]:=E^(-1 + x) (-1 + E^(1 - x)) + x      Iterating with this function using `NestList` you obtain the sequence of values produced by Newton's method. The Newton method for large values of the initial guess presents slow convergence for this problem.Taking $x_0=10$ we get:               NestList[Nf, 10., 8]     (* {10., -8092.08, -8091.08, -8090.08, -8089.08, -8088.08, -8087.08, -8086.08, -8085.08} *)      where we can see the slow convergence. A plot of the function `Nf[x]` helps to understand the behaviour of the method. But taking               Module[{s = 0, e = 0}, {FindRoot[f[x], {x, 10.}, StepMonitor :> s++,       EvaluationMonitor :> e++], "Steps" -> s, "Evaluations" -> e}]      produces               {{x -> 1.}, "Steps" -> 7, "Evaluations" -> 11}      needing only 7 steps to get the solution $x=1$. Why `FindRoot` produces this result?. Obviously, `FindRoot` is not using the standard Newton's method, isn't it? Can anyone help me? Thanks.


Recommended book on random processes to understand new functionality in Mathematica 9?

I am interested in exploring the new functionality on random processes available in _Mathematica_ 9, but I am not familiar with all of the underlying mathematics. Could you recommend a book that provides a foundation on these topics? I am thinking about a book that favors intuition and breadth over proofs. I have an engineering background (and know probability and statistics decently well) and would like to rapidly take advantage of these functions. I am interested in both modeling and estimation issues.


How do I identify each surface in a multi-surface Plot3D?

I am plotting three surfaces on a 3D plot. They differ in the value of one parameter. Is there a way to distinguish each surface for various values of the parameter. My code is               Plot3D[{2*(Cosh[ h/ T]*(2 + Exp[2 /( T)]) +           Exp[-2  /( T)]*Cosh[3  h/T] ),        2*(Cosh[ h/ T]*(2 + Exp[2 10/( T)]) +           Exp[-2*10 /( T)]*Cosh[3  h/T] ),        2*(Cosh[ h/ T]*(2 + Exp[2 100/( T)]) +           Exp[-2*100 /( T)]*Cosh[3  h/T] )}, {T, 0.001, 1000}, {h, 0, 1},       PlotLabel ->        Style[Framed["Partition Function Z"], 20, Red,         Background -> Lighter[LightYellow]], Background -> LightGray,       ColorFunction -> "BlueGreenYellow",       AxesLabel -> {T[kelvin], B[tesla]}, BoundaryStyle -> Thick,       ClippingStyle -> Opacity[0.5]]      **EDIT** I am trying to use `ShowLegend` because `PlotLegend` cannot work with `Plot3D` in v8... The Code I am using is               Z[T_, h_, a_] :=        2*(Cosh[h/T]*(2 + Exp[2 a/(T)]) + Exp[-2/(T)]*Cosh[3 h/T]);     params = {1, 10, 100};     ShowLegend[Plot3D[       Evaluate[Table[         Tooltip[Z[T, h, a], StringForm["a = ``", a]], {a, params}]], {T,         0.001, 1000}, {h, 0, 1},        PlotLabel ->         Style[Framed["Partition Function Z"], 20, Red,          Background -> Lighter[LightYellow]],        MeshFunctions -> {(*#1&,*)#2 &, #3 &},        Mesh -> {(*15,*)15, Range[7.5, 11, 0.1]},        MeshStyle -> {(*Gray,*)Gray, Black}, Background -> LightGray,        PlotStyle -> {Red, Green, Blue}(*,PlotLegends->Table[StringForm[       "a = ``",a],{a,params}]*), AxesLabel -> {T[kelvin], B[tesla]},        BoundaryStyle -> Thick, ClippingStyle -> Opacity[0.5]],       Graphics3D[{Table[{Arrowheads[0.0004],           Arrow[{{900, 0.2 + 0.25 Log10[a], 9.5}, {50. + 5 a,              0.01 + 0.005 a, Z[50. + 5 a, 0.01 + 0.005 a, a]}}],           Text[Style[Framed[StringForm["J = ``", a]], Red,             Background -> Lighter[LightYellow]], {900, 0.2 + 0.25 Log10[a],             9.5}]}, {a, params}]}],{{{Graphics[{Table[StringForm["a = ``", a], {a, params}]}]}},       LegendPosition -> {1.1, -.4}}]


Fast DensityPlot

Is it possible to increase the perforamce the `DensityPlot`? For example, let's try to plot this "flower"               f[x_, y_] := (x^2 + y^2) Exp[-x^2 - y^2] Sin[10 Sqrt[x^2 + y^2] + 10 ArcTan[x, y]]^4;          DensityPlot[f[x, y], {x, -3, 3}, {y, -3, 3}, PlotPoints -> 200,       MaxRecursion -> 3, ColorFunction -> Hue, PlotRange -> All,       ColorFunctionScaling -> False, ImageSize -> 600]      ![enter image description here](http://i.stack.imgur.com/aSwfo.png) This toy example takes about 12 seconds on my laptop, eats about 1GB of RAM while plotting and the 34MB result slow down the notebook. The question is   1. How to increase the speed?   2. How to decrease the `MaxMemoryUsed`?   3. How to decrease the size of the output?


Problem with plotting a function consisting of HeavisideTheta(s)

I have the following data               data={{1.5, 10}, {25, 26.5}, {29.25, 32.75}, {39.25, 42.5}, {62.5, 67}, {73.5, 80.75}, {87.5, 93}, {102, 104.75}, {111, 114.5}, {123, 129}, {146.5, 152.75}, {161.5, 164.5}, {177, 182.25}, {195.75, 206}, {218.25, 226.25}, {234.75, 237.75}, {246, 252.5}, {258.5, 260.25},{266.25, 272.75}, {280.5, 280.75}, {281.5, 283}, {292,301.25}, {314, 322}, {327.5, 328.5}, {329, 330.25}}      Each set of point denotes the starting and ending point of the pulse, so here there are as many pulses as               Length[data]      I make the function consisting of all these pulses as follows:               f[x_] := Sum[HeavisideTheta[x - Part[data, i, 1]] + HeavisideTheta[-x+Part[data,i,2]], {i, 1, Length[data]}]      This - as it can be checked - uses 2 Heaviside functions to create each pulse. The problem is while plotting the net pulse function:               Plot[f[x], {x, 0, Part[Last[data], 2] + 10}, Filling -> Bottom]      ![enter image description here](http://i.stack.imgur.com/JwN5h.jpg) As it can be seen from the "data" list, there are supposed to be the               {146.5, 152.75}, {161.5, 164.5} and {280.5, 280.75}, {281.5, 283}      **pulses in the plot that are just missing**. I _just_ can't figure out how this is happening. Any help will be greatly appreciated!


Bounded Voronoi Diagram

I am trying to compute a Voronoi diagram bounded by a box. In some cases, the points used to compute the diagram form a diagram such that at least two boundary points are within the same polygon. For Example:               centres = {{0, 1250}, {4750, 2000}, {-2500, -2500}, {500, 750}};     boundaries = {{10000, 10000}, {-10000,          10000}, {-10000, -10000}, {10000, -10000}};     {diagvert, diagval} = BoundedDiagram[boundaries, centres];      With the Voronoi diagram: ![enter image description here](http://i.stack.imgur.com/Hbg4q.jpg) This leads to the error: > BoundedDiagram::notuniq: BoundedDiagram requires that boundary vertices lie > in unique Voronoi polygons. Since I am trying to generalize the scenario, I can't design a specific boundary for the points, and I would like to use a general big enough boundary. Is there any way to allow multiple boundary points within the same polygon? Or perhaps a different approach?


PaneSelector and options in a Module

Consider the following snippet of code:                 Module[{pr, ps, var, option},        option = 1;        var = 0;        pr[] := Module[{}, var++; Print[var]];        ps[] := Print["Test..."];             PaneSelector[         {1 ->           Button["Defaults 1",           option = 2,           ImageSize -> 100],          2 ->           Button["Defaults 2",           option = 1;           pr[],           ImageSize -> 100]},          Dynamic[option]]       ]      Note that pr[] is executed when the button "Defaults 2" is clicked. **Question: I want to execute a function immediately after a Pane is selected in a PaneSelector construction. How should this be implemented?** ( Question translated to the context of the above snippet: how to execute either ps[] or pr[] immediately after setting option to 1 or 2?)


How to create blurred Graphics3D objects?

Initially I was interested in renderring a 3D analog of a blurred disk like this               DensityPlot[1 - HeavisideLambda[(x^2 + y^2)/8]/2, {x, -4, 4}, {y, -4, 4},       FrameTicks -> False, ColorFunctionScaling -> False,       ColorFunction -> "SunsetColors", PlotRange -> {0, 1},       PlotPoints -> 50]      ![enter image description here](http://i.stack.imgur.com/oxsud.png) The only idea that came to my mind was playing with `Opacity`, which gives hardly an impressive result:               Graphics3D[{Orange}~Join~        Table[{Opacity[i], Sphere[{0, 0, 0}, 1 - i]}, {i, 0.1, 1, 0.1}] //        Flatten]      ![enter image description here](http://i.stack.imgur.com/7PgYj.png) So, **1) is it possible to get "true" blurred ball and 2) how to extrapolate this idea to other 3D objects?**


Construct 3D image from multiple 2D images

My goal: How to (1) construct 3D image for visualization. (2) how to write 3D array or image into binary raw file. Is there a way to accomplish this in Mathematica? Alternative_Answer for: (1)               slices={1,2,3,4,5};     ss = Map[ImageData, slices];     ListContourPlot3D[ss, Mesh -> None, Contours -> Automatic]


Is it possible to simplify a trigonometric expression only in terms of $\cos (u)$ OR $\sin (u)$?

I want to expand the following expression into powers of $\cos(u)$ only:               a1 + a2 Cos[2 u] + a3 Cos[4 u] + a4 Cos[6 u]      The answer that I want (and which I found by hand) is :               (a1 + a3 - a2 - a4) + (2 a2 - 8 a3 + 18 a4) Cos[u]^2 + (8 a3 - 48 a4) Cos[u]^4 + (32 a4) Cos[u]^6      As you see it contains only powers of $\cos (u)$. But when I use the `TrigExpand`, which is supposed to simplify the expression into powers of trigonometric functions, it gives this:               1 + a2 Cos[u]^2 + a3 Cos[u]^4 + a4 Cos[u]^6 - a2 Sin[u]^2 - 6 a3 Cos[u]^2 Sin[u]^2      - 15 a4 Cos[u]^4 Sin[u]^2 + a3 Sin[u]^4 + 15 a4 Cos[u]^2 Sin[u]^4 - a4 Sin[u]^6      Is it possible to make `TrigExpand` to simplify only in terms of $\cos (u)$ or $\sin (u)$? (or maybe using another command instead of `TrigExpand`) By the way, It is my first _work_ done in Mathematica.


I would like to typeset the following in a _Mathematica_ notebook: $$\langle P \rangle$$ Is it possible to typeset left and right angle brackets? In $\LaTeX$, they are given by `\langle` and `\rangle`. I do not see such symbols in the documentation, but I may be overlooking them.


How to know at which point of a calculation I am while using Table

If I use a code of this type:               Table[foo[i], {i, 0, 10}]      _Mathematica_ won't output anything until it is done: is it possible to know at which point of the calculations I am, without using some slow `For` loop (in this way it would be easy to print something like `i=1`, `i=2`...)? I want to check if everything is OK at each step.


Cannot save array to CSV file from EvaluationMonitor[]

Here is my Mathematica function.               fourVertEnrgy[x11_, x12_,x13_, x14_, x21_, x22_, x23_, x24_, x31_, x32_, x33_, x34_, x41_, x42_, x43_, x44_]:=     1 + 2x11 x12 + 2x11 x13+ 2x11 x14+2x12 x13 + 2 x12 x14+ 2x13 x14 -x11 -x12 -x13 - x14 +     1+2x21 x22+2x21 x23+2x21 x24+ 2x22 x23+ 2x22 x24+ 2x23 x24 - x21 -x22 -x23-x24 +      1 + 2x31 x32 + 2x31 x33 + 2x31 x34 + 2x32 x33 + 2 x32 x34 + 2 x33 x34 -x31 -x32- x33-x34 +      1+2x41 x42 + 2x41 x43 +2 x41 x44 + 2x42 x43 + 2x42 x44 + 2x43 x44 - x41-x42 -x43 -x44 +      1 + 2x11 x21 + 2x11 x31 + 2x11 x41 + 2x21 x31 + 2x21 x41 +2x31 x41 -x11-x21-x31-x41+     1+2x12 x22 + 2x12 x32 + 2x12 x42 + 2x22 x32 + 2x22 x42 + 2x32 x42 -x12 -x22-x32-x42 +      1+2x13 x23 + 2x13 x33 + 2x13 x43 + 2x23 x33 + 2x23 x43 + 2x33 x43 -x13-x23-x33-x43+     1+2x14 x24 + 2x14 x34 + 2x14 x44+ 2x24 x34 + 2x24 x44 + 2x34 x44 -x14-x24 -x34 -x44;      I am trying to find the minima using Simulated Annealing.               destFile=OpenWrite["/home/shehab/Documents/shehab-isi/quantum-shehab/docs/presentations/lucas-gi-algo/values-"<>DateString[]]     i=0; list={{0,9999999}};      NMinimize[{fourVertEnrgy[x11, x12,x13, x14, x21, x22, x23, x24, x31, x32, x33, x34, x41, x42, x43,x44],     x11\[Element]Integers,x12\[Element]Integers,x13\[Element]Integers, x14\[Element]Integers,x21\[Element]Integers, x22\[Element]Integers, x23\[Element]Integers,x24\[Element]Integers, x31\[Element]Integers, x32\[Element]Integers,x33\[Element]Integers, x34\[Element]Integers, x41\[Element]Integers, x42\[Element]Integers, x43\[Element]Integers,x44\[Element]Integers,     0<=x11<=1,0<=x12<=1,0<=x13<=1,0<=x14<=1,0<=x21<=1,0<=x22<=1,0<=x23<=1,0<=x24<=1,0<=x31<=1,0<=x32<=1,0<=x33<=1,0<=x34<=1, 0<=x41<=1, 0<=x42<=1,0<=x43<=1,0<=x44<=1},{x11, x12,x13, x14, x21, x22, x23, x24, x31, x32, x33, x34, x41, x42, x43, x44},     Method->"SimulatedAnnealing",EvaluationMonitor:>Join[list,{{i++,fourVertEnrgy[x11, x12,x13, x14, x21, x22, x23, x24, x31, x32, x33, x34, x41, x42, x43, x44]}}]]     Export[destFile,list,"CSV"]      Close[destFile]      I am using EvaluationMonitor[] to store the function value against the step number for all the steps in a CSV file. But the file only has $0, 9999999$ when the computation is done. Did I do anything wrong?


How to arrange elements of a list

A file consists out of (x,y,z) data and I need the z-values arranged like this: `{{z[1],z[2],...z[idimx]},{z[idimx+1],z[idimx+2],...z[idimx*2]},{....}}` With               y=data[[All,2]]; z = data[[All, 3]];     iall=Length[z];     idimy=Length@Position[y,0];     idimx=iall/iy;      I get the dimensions of the array: {idimx,idimy}. But how can I now arrange it's elements? Thanks a lot.


Using EdgeList on a once empty Graph crashes the kernel

Note: this is fixed in version 9. * * * Calling `EdgeList` on a non-empty graph which was previously empty causes the math kernel to crash. For example,               EdgeList[       EdgeAdd[         VertexAdd[           Graph[{}],           {x, y}],         DirectedEdge[x, y]       ]     ]      and               EdgeList[       EdgeAdd[         VertexAdd[           VertexDelete[             Graph[{DirectedEdge[x,y]}],             {x, y}],           {x, y}],         DirectedEdge[x, y]       ]     ]      both will crash the kernel. I've recently posted this issue to the Mathematica Bug List but haven't received any response. Is this the correct place to report bugs, or should I use the contact page for WRI instead. Can other people reproduce this? Also, how could WRI possibly mess this up / not notice this? Edit: fixed second example.


How to construct a polyhedron from its vertex graph?

Consider the graph given by               graph = Graph[{2 <-> 1, 3 <-> 1, 7 <-> 1, 5 <-> 1, 6 <-> 1, 3 <-> 2, 4 <-> 3,         4 <-> 7, 4 <-> 5, 7 <-> 5, 6 <-> 5, 2 <-> 6}]      ![enter image description here](http://i.stack.imgur.com/YSTlc.png) Via Steinitz's theorem, this is the vertex graph of a convex polyhedron:               KVertexConnectedGraphQ[graph, 3] && PlanarGraphQ[graph]     -> True      **How can one construct that polyhedron (i.e. a spatial representation of it) from the graph?** Embedding the graph in 3-space using `GraphPlot3D` comes close, but does not actually build a polyhedron as the side view reveals:               GraphPlot3D[graph, Boxed -> False,          EdgeRenderingFunction -> (Cylinder[#1, .05] &),          VertexRenderingFunction -> (Sphere[#1, .1] &)]      ![enter image description here](http://i.stack.imgur.com/G8FKC.png) (Note how the quadrilateral face is "bent".) I have experimented with various embeddings such as `"SpringEmbedding"`, `"SpringElectricalEmbedding"` etc. but none of them seem to produce a true polyhedron even from this simple graph. I am aware that the polyhedron representation of a polyhedral graph is not unique (maybe not even _topologically_ unique(?)) but any embedding that is a polyhedron would suffice. The polyhedral graphs supplied in Mathematica's graph database all come with such embeddings, so I am confident this must be possible.


Emulating R data frame getters with UpValues

What's the best way to emulate R's data frames functionality? This includes the ability to select rows and columns in a 2-dimensional table by the string identifiers positioned typically in the first row or column, see this related question, (and thanks to Leonid Shifrin for cluing me to the term 'data frame.') Wrapping a 2D array in the symbol `DF` enables leveraging upvalues to essentially overload `Part` for the getters, here defined separately for singleton and list string arguments; matching uses Position. To select rows at level 1 of the array:               Part[DF[expr_], r_String, rest___] ^:=       expr[[Position[expr, r][[1, 1]], rest]]          Part[DF[expr_], r_List /; And @@ StringQ /@ r, rest___] ^:=       expr[[Position[expr, #][[1, 1]] & /@ r, rest]]      Similarly to get columns at level 2 of the array:               Part[DF[expr_], All, c_String] ^:=       Transpose[expr][[Position[Transpose@expr, c][[1, 1]]]]          Part[DF[expr_], All, c_List /; And @@ StringQ /@ c] ^:=       Transpose[expr][[Position[Transpose@expr, #][[1, 1]] & /@ c]]      These seem to work correctly (though I've not implemented preconditions checks that the header strings are at the correct level or that the array Dimension length is 2), eg given data:               data = {{"ID", "COL1", "COL2", "COL3"}, {"ROW1", 1, 2, 3}, {"ROW2", 4,          5, 6}, {"ROW3", 7, 8, 9}};      yields:               DF[data][[{"ID", "ROW1", "ROW3"}]]          (* {{"ID", "COL1", "COL2", "COL3"}, {"ROW1", 1, 2, 3}, {"ROW3", 7, 8, 9}}*)      and               DF[data][[All, {"ID", "COL2"}]]          (* {{"ID", "ROW1", "ROW2", "ROW3"}, {"COL2", 2, 5, 8}} *)      Note that this mechanism is somewhat more elegant than R, where the string arguments are wrapped in the 'c' function. Several related questions: First, these definitions raise similar errors - why?               UpSetDelayed::write: "Tag String in DF[expr_][[r_String,rest___]] is Protected."      Second - key question - how to define general getter passing row & column arguments to return a subarray, eg `DF[data][[{"ID","ROW1"},{"ID","COL2"}]]` but avoiding replicating the list and singleton combinations above? Is there an implementation of the general case that avoids the special cases?   * Arguments need not include the "ID" row or column, composing the row getter followed by column getter, or vice versa, won't work directly.   * Note the asymmetry and limitation between the methods to access rows and columns: the row accessor is more general since All can be passed as a special case, but also numeric parameters and Spans. Finally, can the UpValues mechanism be used to emulate other data frames functionality? Would it be possible to use as setters? Also, Apparently in R data frames are used to query the data with conditionals. **EDIT** Note, given the comments on computational complexity and scalability, I would like to stress that the primary purpose of this approach is to deal with small to medium datasets imported from Excel, where string headers, unlike RDBMS, are not separated as metadata. In many data analysis applications, for example biomedicine and healthcare, Excel-based workflows are the norm (for input data, intermediates and output). Moreover, query (and statistical) development time dominates execution time. So syntax and modular approaches to data frames outweigh computational complexity considerations.


Creating multicolored meshed plots (connected scatter plots) using ListPlot

I would like to make colored scatter plots where the dots are connected by lines. I have tried the following, using `Joined->True` to connect the dots and `Mesh->Full` to actually show the dots. I have tried using both `PlotStyle` and `MeshStyle` to color the lines and dots, respectively:               data1 = {{0, 1}, {1, 2}, {2, 3}};     data2 = {{0, 2}, {1, 3}, {2, 4}};     data3 = {{0, 3}, {1, 4}, {2, 5}};          ListPlot[{data1, data2, data3}, PlotRange -> All, Joined -> True,       Mesh -> Full, PlotStyle -> {Red, Green, Blue}, MeshStyle -> {Red, Green, Blue}]      which gives ![ListPlot](http://i.stack.imgur.com/6qaEZ.gif) Why are _all_ of the dots blue? I would like their colors to match those of the lines (`data1` should be red, `data2` should be green, and `data3` should be blue). Is this possible? Thank you!


Problems with setting style options

Consider the following:               FirstOutput=Style["Test", FontSize -> 20]          SetOptions[Style, FontSize -> 20];     SecondOutput=Style["Test"]      I would like the string `"Test"` to appear in `SecondOutput` as in `FirstOutput`. Why does `SetOptions[Style, FontSize -> 20]` not apply to `SecondOutput`? Does anyone have an idea?


Automatically sending to Print (using CutePDF Writer)

I use CutePDF for creating PDF output, but this requires manually selecting Print (Ctrl+P), with CutePDF Writer as the printer, and pressing OK. Can this be automated?


Why does Mathematica give an incorrect answer to this multiple integral?

This is not a new problem but I would like to understand why Mathematica gives the result that it does. (Volume of a hypersphere)               In[4]:= Integrate[       Boole[x1^2 + x2^2 + x3^2 + x4^2 + x5^2 + x6^2 < r^2], {x1, -Infinity,       Infinity}, {x2, -Infinity, Infinity}, {x3, -Infinity,        Infinity}, {x4, -Infinity, Infinity}, {x5, -Infinity,        Infinity}, {x6, -Infinity, Infinity}, Assumptions -> {r > 0}]          Out[4]= -(1/6) \[Pi]^3 r^6      A negative answer is obviously incorrect. Replace r^2 by 4               In[3]:= Integrate[       Boole[x1^2 + x2^2 + x3^2 + x4^2 + x5^2 + x6^2 < 4], {x1, -Infinity,        Infinity}, {x2, -Infinity, Infinity}, {x3, -Infinity,        Infinity}, {x4, -Infinity, Infinity}, {x5, -Infinity,        Infinity}, {x6, -Infinity, Infinity}, Assumptions -> {r > 0}]          Out[3]= (32 \[Pi]^3)/3      This is correct. If we reduce the number of variables, then we obtain a correct answer:               In[5]:= Integrate[       Boole[(x1^2 + x2^2 + x3^2 + x4^2 ) < r^2], {x1, -Infinity,        Infinity}, {x2, -Infinity, Infinity}, {x3, -Infinity,        Infinity}, {x4, -Infinity, Infinity}, Assumptions -> {r > 0}]          Out[5]= (\[Pi]^2 r^4)/2


Setting default Mathematica version

Is there a way to set the default Mathematica version? I would like to run both versions 7 and 8 (on a Win7 PC), but when version 8 is installed it takes priority. Clicking on a notebook automatically opens in version 8. What can I set to make version 7 the default?


Manipulating horizontal and vertical 'guidelines'

Is it possible to create an interactive plot that has drag-down / across horizontal & vertical guides a la Illustrator / InDesign? I would like to generate something like this: ![enter image description here](http://i.stack.imgur.com/pt5pG.gif) I would ideally like to drag multiple (unlimited?) horizontal and vertical guide lines, which would then stay in the positions that they are left in. In addition (if it is not asking too much!) I would really like the guidelines to 'snap' to integers as well. I have looked at various locator manipulations, with no success. Apologies for not including my _Mathematica_ coding effort, but I don't really know where to start with this one :/


Finding the linear regression of data and plotting it

This is for a physics report that I have to hand in. I have a list of two- dimensional data points that approximately form a linear line. I want to:   1. calculate the best linear fit.    2. put both data points and the linear fit line on a plot   3. put names and units on x and y axis   4. (if possible) put slope and intersection of best fit on plot Is it possible to do this in _Mathematica_ and if so how? Example data:               Time, Displacement              t (s)   d (m)         0       0         1       1.9         2       3.8         3       5.9         4       8.1         5       10.1


Replacements/Substitutions in Mathematica

I am a new user of Mathematica and have some questions about the simplifications of calculated expressions. I am unable to attach an image of the session, but my Mathematica commands are:               Element[{x,y,z},Reals]      Element[{x0,y0,z0},Reals]     rhatV={x-x0,y-y0,z-z0}     rhat=Norm[rhatV]      In the expression for rhat, I am unable to get rid of the `Abs` functions, despite the Reals declarations.               phi=1/rhat     D[phi,x]      In the evaluated derivative is there a way to have x-x0 in the numerator recognized as rhatV[[1]] and the denominator as rhat^3, such that it can be used in additional operations?


Selective evaluation of blocks of code in a Manipulate

Is it possible to attach certain pieces of code to certain controls in a Manipulate? For example, consider the following Manipulate               Manipulate[      data = Table[function[x], {x, -Pi*10, Pi*10, Pi/1000}];      ListPlot[{x, data}, PlotRange -> {{start, stop}, Automatic}]      , {function, {Sin, Cos, Tan}}      , {start, 1, Length[data]}      , {{stop, 300}, 1, Length[data]}      ]      Generation of the data is expensive but it only needs to be done if I change function. So, I'd like the line               data = Table[function[x], {x, -Pi*10, Pi*10, Pi/1000}];      to only run when I change the function control...i.e. I want to attach that line of code to the 'function' control. As it stands, the data is generated when I move the plot range too which is not what I want. ![enter image description here](http://i.stack.imgur.com/OHJeN.png)


Detect highest order of derivative in expression?

Is it possible to detect the highest order (or generally all orders) of derivatives in an expression? Consider               eqn = D[a[x,t],t] == D[a[x,t],x,x]      How would I go about detecting that the highest order of the partial derivative in x is 2 in eqn? I was thinking of using MatchQ, however this               MatchQ[Derivative[2, 0][a][x, t], eqn]      just returns False. Thank you!


Restrict Sensitivity of Locators in LocatorPane

We can restrict the **movement** of locators in a `LocatorPane` as follows: ![locator movement](http://i.stack.imgur.com/Is904.png) In the following example, the first locator's movement is confined to the x-axis and the second locator's movement is confined to the y-axis.               Manipulate[LocatorPane[Dynamic[pts],       Graphics[{}, PlotRange -> max, Axes -> True, ImageSize -> 350],      {{{-max, 0}, {max, 0}},      {{0, -max}, {0, max}}}],     {{pts, {{9, 0}, {0, 11}}}, ControlType -> None}, Initialization :> {max = 25}]      ![enter image description here](http://i.stack.imgur.com/NvUL8.png) However, a locator can be dragged without necessarily being selected. You can begin dragging a locator by clicking down on just about any point in the four quadrants and dragging from there. I would like to have the locator respond only to drags that are initiated by "mousedown"ing on the locator itself. Any ideas as to how I might achieve this? * * * **Addendum** In my the more complicated example I've been working with, I've made use of jump parameters to confine locators to integer values:               {{{-maxX, 0}, {maxX, 0}, {1, 0}},     {{0, -maxY}, {0, maxY}, {0, 1}}}      I'm not sure whether such constraints (to integers) can be imposed on locators outside of `LocatorPane`s.


How to obtain an approximate function for SmoothHistogram3D?

I have a random distribution of points in the $x\\!-\\!y$ plane. I can obtain a graphical representation of the probability distribution function using `SmoothHistogram3D`. Now I need to use this in another calculation. To do this I need a function that approximates `SmoothHistogram3D`. Could you please tell me how to do it?


How can I fill under a function in a plot just to right of a specified vertical line?

How do I plot a normal curve with filling under the curve and to the right of a vertical line. I would prefer that the vertical line starts at the x-axis and stops at the plotted curve. Basically trying to shade the area under the curve for a specific region.


Is there a version of Together that doesn't cancel common factors?

I'm running code that produces a long combination of rational functions with free constants that need to be tuned such that the combination vanishes. My current method is to put the combination over a single denominator with Together[], then look at the CoefficientArrays[] of the numerator and make sure all entries vanish. The trouble is, the step using Together[] is very time consuming, and seems in some cases to get stuck (basically, the process just runs the CPU with a fixed memory usage for hours, when normally Together has a pattern of rising and falling memory usage as it shrinks the expression it creates). My assumption is that the problem with using Together in this context is that it doesn't just put everything over a single denominator, it also tries to factor out common terms. But I don't _need_ it to factor out common terms, since a failure to factor something will just mean a few more redundant equations to solve. Is there anything like Together, that doesn't bother with trying to cancel things? Or an option to make Together give up after a certain (reasonable) amount of time? Edit: To those suggesting just multiplying through by the product of the denominators, one issue is that not all of the objects are expressed as P/Q. So for example, say I have:               (1/(1-v)-v/(1-w))/((1-v)(1-u)) - (1-w)/(u v w(1-v))      I want this expressed as one object, P/Q, and I don't care about canceling common factors between P and Q. Is there a function that does that? I suppose I could just repeatedly multiply through by all denominators for each subexpression, but that seems inefficient.


How to plot points with uncertainties and dates assigned?

I want to plot a graph from list of points, but each point also has uncertainty assigned AND date. Without uncertainties DateListPlot works great, without dates ErrorListPlot works OK, but how it could be done both at the same time? I tried displaying 2 plots (DateListPlot + ErrorListPlot) using Show, but it didn't work. Any ideas?


Shortcuts for integration and differentiation?

I am trying to learn the most useful keyboard shortcuts for doing basic operations such as integration, differentiation etc in standard form. A few questions -   1. I have checked the documentation and i found shortcuts such as Esc[intt]Esc for an integral and Esc[dintt]Esc for definite integral in standard mathematical form but i can't find a short cut for a standard derivative i.e d/dx ? I am aware you can use D[] function but i would like to be able to input in standard mathematical form. Esc[dt]Esc gives me a partial derivative but i just want standard d/dx for single variable calculus.   2. If i enter a indefinite integral and i want to change this into a definite integral is there anyway i can add the upper and lower limits or do i need to re-enter the whole integral using Esc[dintt]Esc ?  Thanks David.


curve on the surface

I have a bezier polygon aa=Table[{i^2.5, 2*Sqrt[i]}, {i, 1, 5}],is anyone can give me a example in Mathematica code that how to create another iso parametric curve on this bezier surface?Display the control polygon of this iso curve and the iso curve on the surface.


Using Multiple Kernels When Making Plots

I am running a notebook that makes multiple plots. I define a function and then I want to plot that function for different choices of parameters, using `RegionPlot`. Given the complexity of the function (which is why I'm not copying the code here), it takes ~2 hours to make each plot, and I need about 20 separate plots. Since the plots are completely independent of each other, this seems like the sort of thing that should be parallelized. This is my goal. I've figured out how to launch the subkernels and how to move the definition of the function to the subkernels using `DistributeDefinitions`. (Sorry if that's not quite the right terminology.) I've been trying to use the subkernels like this (pseudo-code):               ParallelSubmit[RegionPlot[* code with function[x,y,z] here *]]          ParallelSubmit[RegionPlot[* code with function[a,b,c] here *]];      However, it seems to me that the `ParallelSubmit` doesn't actually get evaluated until `WaitAll` is called, and I can only find a way to apply `WaitAll` to one of the two instances above; hence, I still end up evaluating them sequentially, which is not what I wanted. So my question is this: what is the easiest way to parallelize the production of plots (for different parameters) in _Mathematica_? Thank you in advance for all your help! It occurred to me that perhaps an example will help to clarify:               f[x_,y_,z_]:=x^2+y^2+z^2;     DistributeDefinitions["Global`"];            (* I do have a back tick on the Mathematica code but I'm revising this on my phone which      can't type one. *)     ParallelSubmit[RegionPlot[f[x,y,1]>5,{x,-10,10},{y,-10,10}]];     ParallelSubmit[RegionPlot[f[x,y,2]>5,{x,-10,10},{y,-10,10}]];      How can I run `WaitAll` so both `ParallelSubmits` evaluate at the same time? *** Clarification: *** I should have realized that my "simplified" example is amenable to using ParallelTable, whereas (so far as I know) my actual function is not. The reason being that I have two variables that I want to substitute, and I don't want all combinations of them. Let me try to explain with a revised version:               f[x_,y_,z_,w_]:=x^2+y^2+z^2+w^2;     DistributeDefinitions["Global`"];          ParallelSubmit[RegionPlot[f[x,y,1,1]>5,{x,-10,10},{y,-10,10}]];     ParallelSubmit[RegionPlot[f[x,y,2,2]>5,{x,-10,10},{y,-10,10}]];      When you run a table with the indices like `{i,1,2},{j,1,2}`, you get four entries: `i=1,j=1`, `i=1,j=2`, `i=1,j=2` and `i=2,j=2`. This is not what I want; it would increase the number of plots made dramatically. I tried making a table with `{{i,j},{1,1},{2,2}}`, but that gives the expected error that iterator does not have the expected bounds. Thanks for all the help!


Random Choice: List Format & Minimizing Memory Use

This is a two part question, and for that I apologize.. but they're related! Here's what I'm working with:               d1 = Import["file.CSV", "List"]          size = Length[d1]          dis1 = RandomChoice[{d1}, {100, size}]        * **Q1** : Length views `d1` as $300,000$ individual elements but `RandomChoice` views it as a single element. Thus when I execute I get $100$ repetitions of `d1` in the exact order `d1` is presented in.  Have I made an annotation error in assigning the `RandomChoice` number pool as `{d1}`? If I replace `{d1}` with a hand written list of values it executes perfectly, so I assume it is a presentation issue.. but I can't tell what I've done wrong from the documentation of the function.   * **Q2** : Asking to make $100$ random lists of `size` ~ $300,000$ elements requires a lot of memory. The thing is I don't need to save each `RandomChoice` output, I just need the mean/median/SD/SEM for each of the $100$ sets I've tasked `RandomChoice` with.  Is there a way to tell the program to spit out those end-point values and dump the accumulated list after each one is generated?


How can I add options to functions

One wish take easy advantage of the packages/codes buildt through our engagement with mathematica. Through building packages I see that I have made several functions which are simple and closely related. However, I would prefer one function with several options instead of many simple. I therefore wish to make a collection of ideas and examples, could be your own code, code located on this page or any other that show good practice of adding options to functions. Efficient smart/neat solutions that can be extended to arbitrarily large functions is appreciated. It is also easier to remember how to use the custom functions if they reassemble built in functions.I wish to provide an example Stefans answere of how an expansion where you can query certain properties using a string, very similar to LinearModelFit, even though I would assume that the code behind is very very different. Hopefully answer to this question would help the reader get an idea of how one can expand and add functionality to one function in a good way. I sure know that good examples definitely would help me. I would like to point out that any change/edit of the question that would increase its usefulness is appreciated!


Requiring NumericQ in Pure Function

Potential duplicate, but doesn't seem to solve my problem: Using patterns in pure functions I have a function that returns an `InterpolatingFunction`, and it works exactly the way I needed for passing to `NIntegrate` etc.: if I pass on a symbolic argument, the function returns itself; if the argument is numeric, it evaluates and gives a number.               func := Module[{...}, ... (y /. First@NDSolve[{y[1] == 1, y'[x] == x}, y, {x, -1, 1}])]     func[x] (* gives InterpolatingFunction[(-1. 1.),<>](x) *)     func[0.5] (* gives 0.625 *)       I need a slightly modified behavior: the returned function should return 0 if outside the range instead of attempting to interpolate. Seems easy enough:               func := Module[{interpolation,...}, ...             interpolation = (y /. First@NDSolve[{y[1] == 1, y'[x] == x}, y, {x, -1, 1}]);             Function[x,If[Not@IntervalMemberQ[Interval[interpolation[[1, 1]]], x], 0,                      interpolation[x]]]]     func[0.5] (* gives 0.625 *)      func[2] (* gives 0 since it's outside the interpolation interval *)     func[x] (* gives 0!! *)      How can one mimic the behavior of `InterpolatingFunction` such that `func[x]` for non-numeric `x` gives something like `Function[<>](x)` instead?


Centering date labels over the year in a DateListPlot

The canonical formatting for date labels in a `DateListPlot` is for the year or other date label to be centered over the tick at the start of the relevant period.               aapl = FinancialData["AAPL", {2000}];     DateListPlot[aapl, Joined -> True]      ![canoncial DateListPlot of Apple share price](http://i.stack.imgur.com/qWxK5.png) I would like the label to instead be centered on that year, like this. ![annual date labels, centered](http://i.stack.imgur.com/Ig28Y.png) Relevant facts:   * I know the font family and size I am using, so specifying offsets for `AdjustmentBox`es can be fixed explicitly.   * Custom functions for the plot are ok, especially if that is necessary to work out how many years there are in the data and therefore how far to offset an `AdjustmentBox`.   * I am assuming that the solution is a custom auxiliary function that can be passed to the `FrameTicks` option. I would be interested to know if that can be specified using `SetOptions` for `DateListPlot` instead of doing a custom plotting function.   * If there are a lot of years in the data, it is ok to specify explicitly that only every $x$th year label is shown. (We have explicit rules for the mapping from number of years to $x$).   * The partial last year can be specified explicitly by the user. The default would be to show the full year even if there is only a little bit of data for it. I already have something that works but would be interested in how other people approach it, to see if I can make my solution faster/ more elegant/ more concise. Currently it is a big mess because year labels are not the only option I have implemented.   As a bonus, please consider how one would implement labels like this: ![two-row date labels](http://i.stack.imgur.com/h2TBH.png)


CUDA 5.5 and Mathematica 9 code problem

In Mathematica 9, I entered the following sample code, but it returns an error. I can not figure what is not right. Any help?               CUDACCompilers[]          {{"Name" -> "GCC",        "Compiler" -> CCompilerDriver`GCCCompiler`GCCCompiler,        "CompilerInstallation" -> "/usr/bin", "CompilerName" -> Automatic}}          doubleFun = CUDAFunctionLoad["       __global__ void doubleVec(mint * in,  mint length) {           mint index = threadIdx.x + blockIdx.x * blockDim.x;              if (index < length)           in[index] = 2*in[index];         }", "doubleVec", {{_Integer}, _Integer}, 256,        ShellOutputFunction -> Print]          CUDAFunctionLoad::cmpf: The kernel compilation failed. Consider setting the option "ShellOutputFunction"->Print to display the compiler error message. >>          gcc: error trying to exec 'cc1plus': execvp: No such file or directory          CUDAFunctionLoad["      __global__ void doubleVec(mint * in,  mint length) {          mint index = threadIdx.x + blockIdx.x * blockDim.x;              if (index < length)           in[index] = 2*in[index];        }", "doubleVec", {{_Integer}, _Integer}, 256,       ShellOutputFunction -> Print]


How well does Mathematica code exported to C compare to code directly written for C?

Essentially what it says in the title. Mathematica can, IIRC, export it's code to C. How much overhead does that inflict on the code, as compared to writing it from scratch in C?


Connect to a MS Access database (*.accdb)

The _JDBC Connections_ section of the help file http://reference.wolfram.com/mathematica/DatabaseLink/tutorial/DatabaseConnections.html gives me the impression that I can connect to a MS Access Database (*.accdb) using the following statements:               << DatabaseLink`;     conn = OpenSQLConnection[JDBC["odbc", "MTData.accdb"]];      where _MTData.accdb_ is the name of my database. I have verified that the file does exist using `FileNames[]`. Upon executing the statements above, however, I receive the following error message: > JDBC::error: "[Microsoft][ODBC Driver Manager] Data source name not found > and no default driver specified ...". Typing `JDBCDriverNames[]` gives a list with " _Microsoft Access(ODBC)_ " Would somebody please be able to clarify whether I should be able to access a MS Access database using these statements? Thanks. **EDIT:** I have also tried accessing the database by providing a DSN (Data Source Name), created by opening the ODBC Source Administrator (as I have a 64-bit operating system, but 32-bit Office, I used the program at location C:\Windows\SysWOW64\odbcad32.exe). Executing the following code, where "MTDB" is the DSN: `conn = OpenSQLConnection[JDBC["odbc", "MTDB"]];`, I get the following error message: > JDBC::error: [Microsoft][ODBC Driver Manager] The specified DSN contains an > architecture mismatch between the Driver and Application


How can I compile function with Apply?

For example, I tried to compile this function but Mathematica gives "The only function arguments supported are Times, Plus, or List", I have no a way to compile this.               isPrime = Compile[{{n, _Integer}},       And @@ (Mod[n, #] != 0 & /@ Range[2, Sqrt@N@n])       ]


Solving a nasty equation

Here's an equation that I need to solve for $t_k$ $$ \theta_0 = \tan^{-1}\left(\frac{2(w_x - m)}{p - g {t_k}^2 - 2 t_k w_y}\right) - {\frac{1} {r}} \left( \left(\frac{m}{t_k}\right)^2 + \left( \frac{p - g {t_k}^2}{2t_k} \right)^2 \right) $$ All other variables ($m,p,r,g,w$) are constants. _Mathematica_ **fails** solve it with the constants in place, but **succeeds** when the actual values are substituted in, so I know it's **possible**. Unfortunately, I need the general form for a computer program. I'm certain it's failing due to the $tan^{-1}$. So is there a way to convince _Mathematica_ that the $tan^{-1}$ won't do anything funky on the interval in which I'm interested and just solve for the general case? Here's the code.               ass[c_] := c /. {p -> -400, g -> -4/50, m -> -300, a -> 0.45/50, r -> 27, u -> -2.3, v -> 0}     vx[t_] := (m/t) - u     vy[t_] := (p - g t^2)/(2 t) - v     rat[t_] := Simplify[-vx[t]/vy[t]]     ksq[t_] := (vx[t])^2 + (vy[t])^2     wholeWeak[t_] := ArcTan[rat[t]] - 1/(2 r^2 a)*ksq[t]


Plotting ErrorBars with a different style

I would like to plot the error bars of `ErrorListPlot` with a different style than the points. I know of `ErrorBarFunction`, but then I have to recreate the automatic ErrorBarFunction... Here is my current butt ugly hack (I draw the plot twice):               data = Table[{x, f[x], RandomReal[]}, {f, {Exp[2 #] &, Exp}}, {x, -5, 2, 0.2}];     Needs["ErrorBarPlots`"]          Show@{ErrorListPlot[data,         PlotStyle -> Directive[Thick, PointSize -> 0., Opacity@0.5],         ImageSize -> Large],       ListPlot[data[[All, All, {1, 2}]],         PlotStyle -> Directive[Thick, PointSize -> 0.015],         ImageSize -> Large]       }      ![example plot](http://i.stack.imgur.com/dJKmN.png) **What is a more elegant way of doing this?** Something like:               ErrorListPlot[data,             PlotStyle -> Directive[Thick, PointSize -> 0., Opacity@0.5],             ImageSize -> Large,            ErrorBarFunction -> {Opacity@0.5,Automatic}]


nonlinearnodelfit with a matrix as weights

I have to fit a non linear model to my data and I am trying to use `nonlinearmodelfit`. The problem is that I have systematic errors, so the `weights` options is not a simple vector but a matrix. To be clear: my chi squared is written as:               (diff)T*(weight)^(-1)*(diff)      Where `diff` is the difference between my model and the data (T means trasposed). Does anyone have any idea? I use Mathematica 8.


I integrate a real function, I want a real result

I want to count some integral in _Mathematica_ (actually, check that this integral is zero...) I arrive to an answer which has a zero real part but has some imaginary part! Why? This could be a mistake but I suppose that I am not writting down the commands correctly... What do you think?               r[ϕ_] = 2*(1 - (1/3)^2)/(1 + (1/10) *Cos[ϕ])          Integrate[(Sqrt[(r'[ϕ])^2 + r[ϕ]^2])/(Sqrt[2 (-1 + 1/(r[ϕ]))]), {ϕ, 0, 2 π}]      _Mathematica_ gives the following answer > >     0.` - 13.028165432276161` I >


Symbolic Integration along contour: branch cut problem?

**Context** Following this question on path integrals in the complex plane, having defined again a numerical and symbolic integrator along a path as                ContourIntegrate[f_, par : (z_ -> g_), {t_, a_, b_}] :=         Integrate[Evaluate[(f /. par) D[g, t]], {t, a, b}]      and                NContourIntegrate[f_, par : (z_ -> g_), {t_, a_, b_}] :=         NIntegrate[Evaluate[D[g, t] (f /. par) /. t -> t1], {t1, a, b}]      when I try on this path               ParametricPlot[Cos[t] + I (Sin[t] + Cos[2 t]/2) // {Re[#], Im[#]} &, {t, 0, 2 Pi}]      ![Mathematica graphics](http://i.stack.imgur.com/00B0E.png) I get numerically (note that I divide by $2\pi \imath$)               NContourIntegrate[1/x, x -> (Cos[t] + I (Sin[t] + Cos[2 t]/2)), {t, 0, 2 Pi}]/(I 2 Pi)           (* 1. *)      and symbolically (after a couple of minutes)               ContourIntegrate[1/x, x -> Cos[t] + I (Sin[t] + Cos[2 t]/2),          {t, 0, 2 Pi}]/(I 2 Pi) // N // Chop          (* 1.57088 *)      which suggests a branch cut problem in the symbolic solution(?) I have evaluated numerically the result of the above integration as it is a couple of pages long. ![Mathematica graphics](http://i.stack.imgur.com/8muIG.png) Note interestingly that this result is only equal to $\pi/2$ up to 4 digits! **Question** > Could anyone please reproduce what seems to be a bug?


Making a fit to my empirical data

I want of plot the fit for the graph ![enter image description here](http://i.stack.imgur.com/dLDYl.jpg) The Data for this graph is               {{0., -0.2203}, {0.034, -0.2075}, {0.067, -0.2006}, {0.1, -0.197},      {0.134, -0.1936}, {0.167, -0.189}, {0.2, -0.1855}, {0.234, -0.1802},      {0.267, -0.1704}, {0.301, -0.1678}, {0.334, -0.1573}, {0.367,      -0.1532}, {0.401, -0.1428}, {0.434, -0.1372}, {0.467, -0.1334},      {0.501, -0.1274}, {0.534, -0.1191}, {0.567, -0.111}, {0.601,      -0.1109}, {0.634, -0.1122}, {0.668, -0.1121}, {0.701, -0.1174},      {0.734, -0.1178}, {0.768, -0.1163}, {0.801, -0.1133}, {0.834,      -0.1132}, {0.868, -0.1077}, {0.901, -0.1028}, {0.934, -0.0994},      {0.968, -0.0977}, {1.001, -0.0929}, {1.035, -0.0913}, {1.068,      -0.0892}, {1.101, -0.0867}, {1.135, -0.0869}, {1.168, -0.085},      {1.201, -0.0847}, {1.235, -0.0822}, {1.268, -0.0822}, {1.301,      -0.083}, {1.335, -0.0865}, {1.368, -0.0884}, {1.402, -0.0923},      {1.435, -0.0975}, {1.468, -0.1079}, {1.502, -0.1115}, {1.535,      -0.1183}, {1.569, -0.1268}, {1.602, -0.137}, {1.635, -0.1464},      {1.669, -0.1532}, {1.702, -0.1647}, {1.736, -0.1789}, {1.769,      -0.1834}, {1.802, -0.197}, {1.836, -0.213}, {1.869, -0.2271}, {1.902,      -0.2353}, {1.936, -0.2432}, {1.969, -0.2642}, {2.002, -0.2804},      {2.035, -0.2881}, {2.069, -0.2996}, {2.102, -0.3128}, {2.136,      -0.3256}, {2.169, -0.3369}, {2.202, -0.3411}, {2.236, -0.3576},      {2.269, -0.3682}, {2.302, -0.3789}, {2.337, -0.3869}, {2.369,      -0.3965}, {2.402, -0.4033}, {2.436, -0.4121}, {2.469, -0.4163},      {2.502, -0.4202}, {2.536, -0.4214}, {2.569, -0.4209}, {2.603,      -0.4221}, {2.636, -0.4214}, {2.669, -0.4139}, {2.703, -0.4057},      {2.736, -0.394}, {2.769, -0.3857}, {2.803, -0.3828}, {2.837,      -0.3778}, {2.869, -0.3658}, {2.903, -0.3554}, {2.936, -0.3475},      {2.97, -0.3335}, {3.003, -0.3289}, {3.036, -0.3239}, {3.07, -0.3037},      {3.103, -0.2918}, {3.136, -0.289}, {3.17, -0.2812}, {3.203, -0.2754},      {3.236, -0.2594}, {3.27, -0.2453}, {3.303, -0.2388}, {3.337,      -0.2321}, {3.37, -0.2272}, {3.403, -0.2178}, {3.437, -0.2051}, {3.47,      -0.2013}, {3.503, -0.195}, {3.537, -0.1872}, {3.57, -0.1818}, {3.604,      -0.1758}, {3.637, -0.1612}, {3.67, -0.1523}, {3.704, -0.1458},      {3.737, -0.1458}, {3.77, -0.1458}, {3.804, -0.1445}, {3.837,      -0.1488}, {3.87, -0.1572}, {3.904, -0.1668}, {3.937, -0.1815},      {3.971, -0.1911}, {4.004, -0.2013}, {4.037, -0.2177}, {4.071,      -0.2349}, {4.104, -0.2464}, {4.137, -0.2637}, {4.171, -0.2757},      {4.204, -0.2825}, {4.238, -0.2914}, {4.271, -0.3086}, {4.305,      -0.3262}, {4.338, -0.3302}, {4.371, -0.3329}, {4.404, -0.3469},      {4.438, -0.3551}, {4.471, -0.364}, {4.504, -0.3701}, {4.538,      -0.3751}, {4.571, -0.3775}, {4.605, -0.383}, {4.638, -0.3953},      {4.671, -0.4037}, {4.705, -0.4078}, {4.738, -0.4144}, {4.771,      -0.4228}, {4.805, -0.4295}, {4.838, -0.4378}, {4.871, -0.4474},      {4.905, -0.455}, {4.938, -0.4648}, {4.972, -0.4697}, {5.005,      -0.4737}, {5.038, -0.473}, {5.072, -0.4675}, {5.105, -0.4561},      {5.138, -0.4466}, {5.172, -0.4368}, {5.205, -0.4258}, {5.239,      -0.4153}, {5.272, -0.3981}, {5.305, -0.386}, {5.339, -0.38}, {5.372,      -0.3693}, {5.405, -0.3535}, {5.439, -0.346}, {5.472, -0.3403},      {5.505, -0.3335}, {5.539, -0.3286}, {5.572, -0.3202}, {5.606,      -0.3111}, {5.639, -0.3035}, {5.672, -0.2954}, {5.706, -0.2865},      {5.739, -0.2776}, {5.773, -0.2655}, {5.806, -0.2516}, {5.839,      -0.2405}, {5.873, -0.237}, {5.906, -0.2302}, {5.939, -0.2204},      {5.973, -0.2095}, {6.006, -0.1968}, {6.039, -0.1929}, {6.073,      -0.1803}, {6.106, -0.1718}, {6.14, -0.1636}, {6.173, -0.1581},      {6.206, -0.151}, {6.24, -0.1381}, {6.273, -0.1225}, {6.306, -0.1185},      {6.34, -0.1153}, {6.373, -0.1049}, {6.406, -0.0932}, {6.44, -0.0855},      {6.473, -0.0732}, {6.506, -0.0675}, {6.54, -0.0593}, {6.573,      -0.0509}, {6.607, -0.0428}, {6.64, -0.0344}, {6.673, -0.0309},      {6.707, -0.0237}, {6.74, -0.0216}, {6.773, -0.0187}, {6.807,      -0.0188}, {6.84, -0.0183}, {6.874, -0.0192}, {6.907, -0.0143}, {6.94,      -0.0041}, {6.974, -0.0014}, {7.007, -0.0032}, {7.04, -0.0032},      {7.074, -0.0036}, {7.107, -0.0072}, {7.141, -0.0116}, {7.174,      -0.0196}, {7.207, -0.0246}, {7.241, -0.0311}, {7.274, -0.0419},      {7.307, -0.0484}, {7.341, -0.0665}, {7.374, -0.0792}, {7.408,      -0.0977}, {7.441, -0.1136}, {7.474, -0.1341}, {7.508, -0.1482},      {7.541, -0.1654}, {7.574, -0.1781}, {7.608, -0.1871}, {7.641,      -0.2008}, {7.674, -0.2182}, {7.708, -0.233}, {7.741, -0.2419},      {7.775, -0.2501}, {7.808, -0.2665}, {7.841, -0.2732}, {7.875,      -0.2784}, {7.908, -0.2848}, {7.941, -0.2894}, {7.975, -0.2984},      {8.008, -0.3096}, {8.041, -0.316}, {8.075, -0.322}, {8.108, -0.328},      {8.142, -0.329}, {8.175, -0.3312}, {8.208, -0.3441}, {8.242,      -0.3517}, {8.275, -0.3538}, {8.308, -0.3586}, {8.342, -0.366},      {8.375, -0.3684}, {8.409, -0.3689}, {8.442, -0.3684}, {8.475,      -0.3615}, {8.509, -0.3527}, {8.542, -0.3403}, {8.575, -0.3319},      {8.609, -0.3279}, {8.642, -0.3197}, {8.675, -0.3157}, {8.709,      -0.3132}, {8.742, -0.3012}, {8.776, -0.2907}, {8.809, -0.2884},      {8.842, -0.2847}, {8.876, -0.2776}, {8.909, -0.271}, {8.942,      -0.2561}, {8.976, -0.2431}, {9.009, -0.24}, {9.042, -0.2357}, {9.076,      -0.23}, {9.109, -0.222}, {9.143, -0.2137}, {9.176, -0.2081}, {9.209,      -0.1938}, {9.243, -0.1884}, {9.276, -0.1834}, {9.309, -0.1716},      {9.343, -0.1577}, {9.376, -0.153}, {9.41, -0.141}, {9.443, -0.1348},      {9.476, -0.1232}, {9.51, -0.1198}, {9.543, -0.1183}, {9.576,      -0.1109}, {9.61, -0.1083}, {9.643, -0.1024}, {9.676, -0.1018}, {9.71,      -0.107}, {9.743, -0.1158}, {9.776, -0.1319}, {9.81, -0.1418}, {9.843,      -0.1519}, {9.877, -0.1746}, {9.91, -0.1847}, {9.943, -0.1963},      {9.977, -0.2034}, {10.01, -0.2048}, {10.044, -0.2293}, {10.077,      -0.2595}, {10.11, -0.2873}, {10.144, -0.309}, {10.177, -0.3167},      {10.21, -0.317}, {10.244, -0.3063}, {10.277, -0.2916}, {10.31,      -0.2876}, {10.344, -0.2835}, {10.377, -0.2791}, {10.411, -0.2782}}      And I want to fit with the equation ,               de[c_, Omega, Phi_, k_] =      Total[Abs[B[c, Omega, Phi, k] - g]].      where               B[c_, Omega_, Phi_, k_] = c Sin[Omega t+Phi]+k      And the `t` is the 1st Column of the data and g is the 2nd column.


Solarized stylesheet and other goodies. Feedback welcome!

I was inspired by this post so I've made a Solarized stylesheet after mucking around with the text options and asking stupid questions on here. I know you can change the syntax highlighting by running option-setting commands [1][2][3], but I'd rather have a stylesheet that takes care of all that stuff. Here is the link to a notebook with the solarized stylesheet. After you open the notebook, you can access the stylesheet by going to Format > Edit Stylesheet and follow my instructions on there on how to modify the stylesheet to fit your needs, while observing the changes in the notebook as you change the stylesheet. One way to learn how to edit stylesheet is to look inside a style cell (select the cell and press Ctrl+Shift+E) and modify the parameters in there--such as color paramters in RGBColor[x,y,z]--and see what your notebook looks like after you exit the cell view (Ctrl+Shift+E again). You can switch between light and dark theme by going to File > Screen Environments and choose between Working (light) and Dark (dark) themes. When you're happy with the way it looks just install/add the stylesheet by clicking on the "Install Stylesheet..." button and choose the Source as the "NotebookObject", then choose a name and if you'd like to install it for just you or for all users of your computer. After that, you can apply the stylesheet to any notebook you'd like by going to Format > Stylesheet, and choose the name of the stylesheet you saved it as. I know the steps are pretty obvious but as a newbie to MMA I really appreciated the people who gives out step-by-step instructions, and I'd like to do the same here. Please let me know if you have any trouble testing and installing the stylesheet and I could help you if I'm able to. I do appreciate any feedback you guys might have. Do you find the color scheme too much? What do you think could be improved upon it? Enough talk: some examples of the theme, and there's also more examples in the notebook in the link. Reference (you can download the journal notebook reformatted in solarized theme here). ![Kobai Light](http://i.stack.imgur.com/g3rZ5.png) Reference ![Miydera Dark](http://i.stack.imgur.com/m0CYo.png) ![Miyadera Dark 2](http://i.stack.imgur.com/Tecut.png)


Rank functions of n by their order of growth

I'd like to rank some functions according to their order of growth (e.g. `n^2 < n^3`). I'm not sure how to do order of growth in mathematica, so I was trying to rank the functions by their `Limit[x,x->Infinity]`. Here's what I have so far:               v = {2^(Log[2, n]), n^(1/2), Log[10, n], 2^(2^n), Log[2, Log[2, n]],       n*Log[2, n], n!, Iteratedlog[2, n], 1, n^3,       Log[2, n], (n^2)*Log[2, n], n, n^n, 100, n^2, 2^(2^(n + 1)), 2^n}          Sort[v, Limit[#1, n -> Infinity] < Limit[#2, n -> Infinity] &]      However, this doesn't even seem to work to sort the functions as a limit. What steps should I take to solve my problem? Thanks!


Mathematica gives wrong answer for an integral

When I execute the following,               Integrate[ Exp[-w^2 + I w^3], {w, -∞, ∞}]      I get > >     (2 E^(2/27) BesselK[1/3, 2/27])/(3 Sqrt[3]) >   which agrees with the result obtained from `NIntegrate`, which is `1.38811`.   However, when I execute               Integrate[ Exp[ -a w^2 + b I w^3], {w, -∞, ∞}]      I get > >     ConditionalExpression[ 0, b ∈ Reals && Re[a] > 0] >   which evaluates to `0` when `a = 1` and `b = 1`. This is obviously wrong. The integral itself has no convergence issues, as the integrand is simply a Gaussian multiplied by a modulus-one third-order chirp factor, which clearly converges when integrated over the real line.   Why does _Mathematica_ give an incorrect answer for the second integral?


What is ImageDistance measuring?

What quantity is `ImageDistance` measuring, and what do the numbers mean? I found the `ImageDistance` command in _Mathematica_ 9, but I've been unable to find much explanation about what it's doing. I originally thought it might be calculating the distance between features on images, but I don't think it is any more. I created two images that had some obvious differences:               original = ExampleData[{"TestImage", "Mandrill"}];     shiftedImage =        Sharpen[         ImagePad[original, {{30, -30}, {5, -5}},           Padding -> "Reflected"]];      ![twin mandrills](http://i.stack.imgur.com/okCEM.png) and ran a set of `ImageDistance` operations past them:               flist = {EuclideanDistance, SquaredEuclideanDistance,         NormalizedSquaredEuclideanDistance, ManhattanDistance,         CosineDistance, CorrelationDistance, "MeanEuclideanDistance",         "MeanSquaredEuclideanDistance",         "MeanReciprocalSquaredEuclideanDistance",        {"MeanReciprocalSquaredEuclideanDistance", .3},         "MutualInformationVariation", {"MutualInformationVariation", 32},         "NormalizedMutualInformationVariation",        {"NormalizedMutualInformationVariation", 32},         "DifferenceNormalizedEntropy", {"DifferenceNormalizedEntropy", 32},        "MeanPatternIntensity", {"MeanPatternIntensity", .1, 3},         "GradientCorrelation", "MeanReciprocalGradientDistance",         "EarthMoverDistance", {"EarthMoverDistance", 4}};          results = Sort[        Table[         {f, ImageDistance[original, shiftedImage,            DistanceFunction -> f]}, {f, flist}],        #1[[2]] > #2[[2]] &];          Grid[      Table[       {First[row], PaddedForm[ Last[row], {Automatic, 6}]}, {row,         results}],       Alignment -> {{Left, "."}}]      ![results](http://i.stack.imgur.com/j71GQ.png) Trying different pairs of images hasn't helped, yet. Can anyone enlighten me (in novice-friendly terms)?