title: Faster Alternatives to DateDifference

text: I need a faster implementation of `FractionOfYear` and `FractionOfMonth`, which do the following: **Input:** A time/date specified by `{y_, m_, d_, h_, n_, s_}` **Output:** A real number from 0 to 1 representing the fraction of the year or month that the given time/date spec occurs in. Leap days and leap seconds complicate things, so I thought I could just rely on `DateDifference`, but it is too slow:               RandomDateList[] := {RandomInteger[{1800, 2100}], RandomInteger[{1, 12}], RandomInteger[{1, 28}], RandomInteger[{0, 23}], RandomInteger[{0, 59}], RandomInteger[{0, 59}]};     RandomDates[n_] := Table[RandomDateList[],{n}]          secondOfYear[{y_, m_, d_, h_, n_, s_}] :=         First[DateDifference[{y - 1, 12, 31, 24, 0, 0}, {y, m, d, h, n, s},                     "Second"]] / First[DateDifference[{y - 1, 12, 31, 24, 0, 0}, {y, 12, 31, 24, 0, 0}, "Second"]]          secondOfMonth[{y_, m_, d_, h_, n_, s_}] := First[DateDifference[{y, m, 1, 0, 0, 0},      {y, m, d, h, n, s}, "Second"]]/First[DateDifference[{y, m, 1, 0, 0, 0}, If[m==12, {y+1, 1, 1, 0, 0, 0}, {y, m+1, 1, 0, 0, 0}], "Second"]]      `AbsoluteTiming [secondOfYear /@ RandomDates[1000]]` takes 6 seconds. There must be a faster easier way of doing this! I'll accept the first answer that takes under a second for 100,000 elements.


title: Mathematica Opens Each Session With Beep

text: First off, I am using Mathematica 8.0 and Mac OS X 10.7.4. Recently, when starting a new Mathematica session, I am confronted with an error beep and message window stating "The file you tried to open was not found or could not be opened." That said, I can simply click OK, and the error box vanishes which seemingly no more problems. This is potentially a problem for me, because I have scripts set up on my computer that instruct Mathematica to open at particular times, then do particular tasks. I also want to add that I am using Dropbox to access Mathematica files in the cloud, but I never open and evaluate any one file in the cloud at the same time. Any advice or thoughts would be appreciated.


title: LibraryLink parallel performance

text: I'm trying to use a LibraryLink function in parallel. It is an embarrassingly parallel problem, so that no dependency between those parallel tasks. However I can only get the parallel efficiency about 0.68. So is it possible to increase this parallel efficiency, or that is just the best I can expect from Mathematica? Here is a simplified example and some benchmark of the performance. The test was performed in version 9 for linux on Red Hat Enterprise Linux 6, on a computer node with 16 cores (two 8-Core Sandy Bridge Xeon E5-2670 64-bit processors). **Define of the library function**               lf = Compile[{{n, _Real}},        Sum[Sin[Sin[Exp[I x]]]^2, {x, 0., 1000 n, 0.1}],        CompilationTarget -> "C"];          lf[10] // AbsoluteTiming     (*{0.028269, 2.3085 + 0.363265 I}*)          LCM[2, 4, 6, 8, 10, 12, 14, 16]     (*1680*)      **Test the performance using different parallel methods** single evaluation time 0.028 second               lf[10] // AbsoluteTiming     (*{0.028207, 2.3085 + 0.363265 I}*)          tSerial = AbsoluteTiming[Sum[lf[10], {x, 1, 1680}]][[1]]     (*47.253332*)      Method->"FinestGrained"               speedupIdeal = Table[{n, n}, {n, 2, 16, 2}];     timeIdeal = Table[tSerial/n, {n, 2, 16, 2}];     timeFG = Table[       CloseKernels[]; LaunchKernels[n]; DistributeDefinitions[lf];       {n, AbsoluteTiming[          ParallelSum[lf[10], {x, 1, 1680}, Method -> "FinestGrained"]][[1]]},       {n, 2, 16, 2}]     (*{{2, 27.148232}, {4, 14.178885}, {6, 9.885146}, {8, 7.751356}, {10,        6.633211}, {12, 5.887295}, {14, 4.141049}, {16, 3.978317}}*)      Method->"EvaluationsPerKernel"->1               time1perK = Table[       CloseKernels[]; LaunchKernels[n]; DistributeDefinitions[lf];       {n, AbsoluteTiming[          ParallelSum[lf[10], {x, 1, 1680},            Method -> "EvaluationsPerKernel" -> 1]][[1]]},       {n, 2, 16, 2}]     (*{{2, 24.009900}, {4, 12.616673}, {6, 8.320600}, {8, 6.372430}, {10,        5.095200}, {12, 4.477966}, {14, 4.131756}, {16, 3.680885}}*)      Method->"CoarsestGrained"               timeCG = Table[       CloseKernels[]; LaunchKernels[n]; DistributeDefinitions[lf];       {n, AbsoluteTiming[          ParallelSum[lf[10], {x, 1, 1680}, Method -> "CoarsestGrained"]][[1]]},       {n, 2, 16, 2}]         (*{{2, 23.918878}, {4, 13.041166}, {6, 8.958082}, {8, 6.629995}, {10,        5.615827}, {12, 4.408525}, {14, 4.123634}, {16, 3.507930}}*)      compare speedup               ListPlot[{       speedupIdeal,       timeFG /. {x_, y_} -> {x, tSerial/y},       time1perK /. {x_, y_} -> {x, tSerial/y},       timeCG /. {x_, y_} -> {x, tSerial/y}       }, PlotRange -> All, Joined -> True, Mesh -> All, Axes -> False,       Frame -> True, FrameLabel -> {"number of kernel", "speedup"},       FrameStyle -> Large,       PlotLegends ->        LineLegend[{"ideal", "FinestGrained", "EvaluationsPerKernel\[Rule]1",          "CoarsestGrained"}]]      ![enter image description here](http://i.stack.imgur.com/NqMe3.jpg) * * * **Update** In order to test whether this slow down comes from the LibraryLink or just the parallel mechanism, here are two tests. The first one using a function that only compiled to the virtual machine, the second one without compile. **Compile to VM** The same as above, just change               lf = Compile[{{n, _Real}},        Sum[Sin[Sin[Exp[I x]]]^2, {x, 0., 1000 n, 0.1}]]      ![enter image description here](http://i.stack.imgur.com/BIkzi.jpg) **No compile** The same as above, but change               lf = Function[{n}, Sum[Sin[Sin[Exp[I x]]]^2, {x, 0., 1000 n, 0.1}]]      and also all `lf[10]` were changed to `lf[1]` to account for the slowness of uncompiled function. ![enter image description here](http://i.stack.imgur.com/zijYU.jpg)


title: Rasterize uses default stylesheet if ImageSize is specified

text: If I make a style definition which affects `GraphicsBox`, the style is used by `Rasterize` _unless_ I specify an explicit `ImageSize`. For example, I set a style for `GraphicsLabel`: ![enter image description here](http://i.stack.imgur.com/juvzS.png) Then I can rasterize a plot and the defined style is used:               p = Plot[x, {x, 0, 1}];     Rasterize[p]      ![enter image description here](http://i.stack.imgur.com/ZqPsJ.png) But if I specify the `ImageSize` the default style is used instead:               Rasterize[p, ImageSize -> 200]      ![enter image description here](http://i.stack.imgur.com/0T7yK.png) I would be interested to know why this happens and how I can work around it, i.e. rasterize at a specific size using the local style definitions.


title: Solving Heat equation

text: I want to compute the exact solution of the heat equation but I got an error. u(x,t) (equation of transmition of heat) is the solution of this differential equation: $$du/dt - \alpha d^2u/dx^2 = 0$$ $$u(x,0) = g(x) = 1/(1+x^2)^{0.25}$$ $$ u(-10,t) = u(10,t) = 0$$ $\alpha = 2/10$ I computed:               pde = D[u[x, t], t] - 0.2 D[u[x, t], {x, 2}] == 0     DSolve[pde, u[x, 0] == 1/(1 + x^2)^0.25`, u[-10, t] == 0, u[10, t] == 0, u[x, t], {x, t}]      However, I got an error: DSolve::dsvar: u[-10,t]==0 cannot be used as a variable. >> What am I doing wrong? Thanks for your help.


title: Specific entry of inverse of large matrix

text: Given a large (say 10x10) sparse Hermitian matrix with symbolic entries, I need four specific entries of the inverse matrix. It seems wasteful to me to compute 100 entries of which I only need a few in the end. Is there a way to compute a small number of specific entries of the inverse matrix that is significantly more efficient than finding the inverse matrix and then extracting the elements? Here's an example. N is half the dimension of the matrix. For N = 8, inverting takes 51 seconds on my university's computer, and we would ideally like to reach much larger N.               A = Table[If[Abs[i - j] == 1, (j - i) a, 0], {i, #}, {j, #}] &;     B = Table[If[Abs[i - j] == 1, b, 0], {i, #}, {j, #}] &;          \[Sigma]1[N_] := B@N + Table[         If[Abs[i - j] == 0, 2 \[Mu], 0] + If[i == j == 1, -x, 0] +           If[i == j == N, -x, 0]         , {i, N}, {j, N}];     \[Sigma]2[N_] := -B@N + Table[         +If[i == j == 1, -y, 0] + If[i == j == N, -y, 0]         , {i, N}, {j, N}];          (* Elements of M *)     el[N_, i_, j_] := Which[i <= N && j <= N,       \[Sigma]1[N][[i, j]], i > N && j > N,       \[Sigma]2[N][[i - N, j - N]], i > N && j <= N,       A[N][[i - N, j]], i <= N && j > N,       -A[N][[i, j - N]]]           M[N_] := Table[el[N, i, j], {i, 2 N}, {j, 2 N}];      Daniel Lichtblau's idea `LinearSolve[M@8,UnitVector[16,8]]` takes 4.1 seconds, so it is certainly much faster than inverting the entire matrix, even if it has to be done seperately for each entry.


title: Georeferenced bitmaps

text: The command `Export["filename.jpg", graphic]` will export the graphic object `graphic` to the file `filename.jpg` in versions > 8 (at least). TIFF's are also used. I am interested in georeferenced bitmaps which can be used with various GIS's, and the default export command does not produce appropriate files. Has anybody found a way of exporting graphics in such a way that they are georeferenced?


title: Define a function with the condition that it must be positive

text: I have a function `f(x)` and I want to define a new function `g(x)` that is equal to `f(x)` only when `f(x)` is positive. What is the right way to do that? Sorry for this silly question, but I cannot find the proper way to accomplish this simple task in _Mathematica_.


title: AccuracyGoal, PrecisionGoal, WorkingPrecision and NDSolve

text: I'm trying to understand exactly what `WorkingPrecision`, `AccuracyGoal` and `PrecisionGoal` mean for the result of `NDSolve`. I presume `WorkingPrecision` simply means the number of decimal places used internally by _Mathematica_ at various points throughout the calculation on its scratchpad, and therefore essentially gives upper limit to what the accuracy/precision of final result can be. Now I understand Accuracy/Precision somewhat in the lab sense (Accuracy is how close you are to the true value, Precision is how repeatable the value you get is in some sense; or to use the dartboard analogy-if you're near the bullseye that's accurate-if you hit the the outskirts in the same place 100 times that's precise but not accurate), but not sure I know how these correlate to the _Mathematica_ concepts... If I set `AccuracyGoal->3`, `PrecisionGoal->4` in `NDSolve`, what does that say about the function I get spat out? It looks like the definition on the help pages is that `AccuracyGoal` of 3 would mean 3 significant figures are correct, whereas `PrecisionGoal` of 4 would give 4 digits after the decimal are correct... e.g if the answer spat out is $89.7895$. What does it mean though in this case to say 3 significant figs are correct, but 4 digits after decimal place are also correct? Seems inconsistent (just a rule of thumb?). The help pages also state: > With `AccuracyGoal->a` and `PrecisionGoal->p`, _Mathematica_ attempts to > make the numerical error in a result of size be less than > $10^{-a}+|x|10^{-p}$ Does this mean if I did have `AccuracyGoal->3`, `PrecisionGoal->4` and `NDSolve` spat out $89.7895$ the numerical error would be $10^{-3}+89.7895\cdot 10^{-4}=0.0997895$ ? so my answer is really $89.7895\pm 0.0997895$ ? or is there a different definition of numerical error here? Thanks for any clarifications.


title: Double integral with variable in the limits

text: I'm trying to solve this integral: $$ \left(\int_{-\infty}^{\infty}\frac{1}{\sqrt{2\pi}\sigma}e^\frac{-x^2}{2\sigma^2}\left(\int_{x}^{\infty}\frac{1}{\sqrt{2\pi}\sigma}e^\frac{-(y-\mu)^2}{2\sigma^2}dy\right)^ndx\right)^k $$ and that is what i found in one of post:               NIntegrate[((1/(Sqrt[2*Pi]*\[Sigma]))*Exp[-(x^2/(2*\[Sigma]^2))])*        ((1/(Sqrt[2*Pi]*\[Sigma]))*      Exp[-((y - \[Mu])^2/(2*\[Sigma]^2))]),       {x, -Infinity, Infinity}, {y, x, Infinity}]^k      dont know where to put the 'n' power ?


title: how to generate mesh functions according to more that one condition?

text: how to generate mesh functions according to more than one condition? This plot will have mesh according to z:               Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, MeshFunctions -> {#3 &}]      This plot will have mesh according to x:               Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, MeshFunctions -> {#3 &}]      how to generate MeshFunctions with more that one conditions? I want something like this:               Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2},       MeshFunctions -> {#1 || #3 &}]


title: Matrix Rotation

text: If I have a matrix of any size, say $\begin{pmatrix} 72 & 32 & 64 \\\ 18 & 8 & 16 \\\ 63 & 28 & 56 \\\ \end{pmatrix}$ $\begin{pmatrix} 72 & 32 \\\ 18 & 8 \\\ 63 & 28 \\\ \end{pmatrix}$ How can I rotate/transform it exactly 45 Degrees (diagonal becomes row) to look like below matrix (preferably sparse array) (not as image) ? Prefer a generic solution Imagine looking towards 63 in the above matrix diagonally from 64 and fill the space between numbers with zero ![diagram for rotating a matrix](http://i.stack.imgur.com/stwgt.png) ![another diagram](http://i.stack.imgur.com/13NRe.png) $\begin{pmatrix} 0 & 0 & 64 & 0 & 0 \\\ 0 & 32 & 0 & 16 & 0 \\\ 72 & 0 & 8 & 0 & 56 \\\ 0 & 18 & 0 & 28 & 0 \\\ 0 & 0 & 63 & 0 & 0 \\\ \end{pmatrix}$ $\begin{pmatrix} 0 & 32 & 0 & 0 \\\ 72 & 0 & 8 & 0 \\\ 0 & 18 & 0 & 28 \\\ 0 & 0 & 63 & 0 \\\ \end{pmatrix}$ **Background**               below function f generates outer product of digits     f = Outer[Times, ##] & @@ IntegerDigits /@ # &     f[{123, 456}]               4   5   6     8   10  12     12  15  18      When this Matrix is rotated 45 degrees               rotate45@f[{123, 456}]          0   0   6   0   0     0   5   0   12  0     4   0   10  0   18     0   8   0   15  0     0   0   12  0   0      Total of rotated matrix results in               Total@rotate45@f[{123, 456}]          4  13       28      27      18      Adding above list in following way result is 123 * 456 .               04      13       28        27         18      56088      I am trying to create a demonstration to depict this in an interesting way _will share the details when done_. See this for further details


title: how to solve this ode problem?

text: NDSolve::ndnum: Encountered non-numerical value for a derivative at x \ == 0.`. >> ![enter image description here](http://i.stack.imgur.com/589Md.png)


title: Assumptions for simplifying a long equation

text: I'm having trouble combining assumptions with the execution of `Simplify` in a long equation. The idea is to separate imaginary and real parts of a complex equation. Therefore I am trying to assume the variables as reals.               Simplify[-Re[(a+I b) (2-c-d-I e-I f)],       {a ∈ Reals, b ∈ Reals, c ∈ Reals, d ∈ Reals, e ∈ Reals, f ∈ Reals}]          But the output is just ignoring the assumptions. How should I implement it?


title: Adjusting the pixel values underlying a morphological component when computing an "IntensityCentroid"

text: When calculating an `"IntensityCentroid"` with `ComponentMeasurements`, i.e. for an image $I$ and set of components $C$, calculating:               ComponentMeasurements[{C, I}, "IntensityCentroid"][[All, 2]]      Is there an easy way for me to threshold or manipulate the underlying pixel values used to compute the intensity centroid? Specifically, I would like to subtract the minimum or mean pixel value in the region defined by the morphological component from all other pixel values in that region, or Floor (i.e. set to zero) pixel values below a certain threshold. Again, I would like to do this locally in the context of each morphological component rather than globally on the image $I$. Is this possible without a lot of work? **Motivation:** Say you're attempting to determine the center of some object to sub-pixel accuracy. If you have a significant amount of "local" background noise (s.t. global thresholding works poorly), a calculated `"IntensityCentroid"` will be biased towards the `"Centroid"` of the morphological component, and this will become worse with the morphological component's size (relative to the size of the object of interest). As such, it would be fantastic to be able to manipulate and do local thresholding on pixels strictly in the region defined by a particular morphological component. Here is an example image (a 450 x 449 pixel PNG file): ![enter image description here](http://i.stack.imgur.com/olryT.png)


title: Labeled and Graph don't mix?

text: In an attempt to create a legend for a graph drawing, I find that Labeled only works without the position options (except for `Center`).                  Graph[Range[2], {       Labeled[DirectedEdge[1, 2], "BEFORE"]}]      ![enter image description here](http://i.stack.imgur.com/MeuUW.jpg) But               Graph[Range[2], {       Labeled[DirectedEdge[1, 2], "BEFORE", Bottom]}]      ![enter image description here](http://i.stack.imgur.com/dlFmc.jpg) Similarly for the other `Labeled` position options like `Top`, `Left`, `Right`. Also, adding ImagePadding doens't help. I've tried some - but not all - `Labeled`'s other options:               {Alignment -> {Center, Baseline}, Background -> None,       BaselinePosition -> Automatic, BaseStyle -> {},       DefaultBaseStyle -> "Labeled", DefaultLabelStyle -> "LabeledLabel",       Editable -> Automatic, Frame -> None, FrameMargins -> 0,       FrameStyle -> Automatic, ImageMargins -> 0, ImageSize -> Automatic,       LabelStyle -> {}, RotateLabel -> False, RoundingRadius -> 0,       Selectable -> Automatic, Spacings -> Automatic,       SyntaxForm -> Automatic}      Known issue?


title: Random numbers that sum up to specific value

text: I would like to generate a list with random numbers, which add up to a specific value.               While[Total[x] == 28, x = RandomInteger[{0, 28}, 5];Print[x]]      The random number list should be returned if their sume is 28. Unforunately, this loop does not work. :( Can anybody help me?


title: How to simultaneously change the color and thickness in ContourStyle?

text: When plotting contours with `ContourPlot`, one can use the option `ContourStyle` to change the contours of the plot. With the instruction,               ContourPlot[f[x,y],{x,-1,1},{y,-1,1},ContourShading -> False, Contours -> Range[1,10], ContourStyle -> ColorData[10] /@ Range[10]]      I am able to change the colors of the contours, but they are thin. On the other hand, if I use the instruction               ContourPlot[f[x,y],{x,-1,1},{y,-1,1},ContourShading -> False, Contours -> Range[1,10], ContourStyle -> Thick]      I am able to draw thicker contour lines, however, they are black. I would like to draw the same contours **simultaneously thicker and colored**. How could I proceed ? Mathematica seems to indicate to use `Directive[...]`, but I have not been able to use it...


title: About auto-compiling and performance between Do and Fold

text: I was investigating how `Fold` could improve performance vs `Do`. I tested the code               AbsoluteTiming[        sum = 1.0;        inc = 1.0;        Do[inc = inc*Sin[10.5]/i; sum = sum + Tan[inc], {i, 10^5}];        sum]      The output is               Out[] = {2.303896, 0.105747}      I have hoped that using `Fold` could improve the performance:               AbsoluteTiming@          Fold[{#[[1]]*Sin[10.5]/(#2 + 1), #[[2]] + Tan@#[[1]]} &,             {Sin[10.5], 1.0}, N@Range[10^5]]      However, this code is not faster:               Out[] = {2.471189, {-5.537337857006675*10^-462146, 0.105747}}      I have some questions concerning the above example: (1) [Partially solved. See EDIT] Why the `Fold` here is not faster? I thought it should have been auto-compiled and thus faster. But it didn't. (2) [Solved. See EDIT] Here Mathematica is using precision much higher than double precision (by having number as small as 10^{-462146}). Would it be possible to set precision to boost performance? I tried `SetPricision` and `SetAccuracy`. The precision changes but it doesn't improve performance. (3) [Solved. See Mr. Wizard's example in his answer] Another problem of `Fold` is that one has first to generate a long list (length 10^5 in this example). For much larger list, the `Fold` method may use too much memory. Is it possible to use functional way (not necessarily `Fold`) in a more memory- efficient way? Thank you very much! PS: I met this question when trying to reproduce Mr.Wizard's answer of the below thread, with some modifications. I can reproduce Wizard's result, where `Fold` boots the performance greatly compared with `Do`. But I don't understand why my above example is not as good. Alternatives to procedural loops and iterating over lists in Mathematica **EDIT:** (a) Rojo's comment is the answer of (2): `SetSystemOptions["CatchMachineUnderflow" -> False]` (b) About the performance of Fold: on Mathematica v7 after disabling `CatchMachineUnderflow`, the Fold code is 10x faster then Do code. However, on Mathematica v9 the Fold code is a bit slower than Do. This seems like a regression in Mathematica. For comparison, this code has 10x improvement than the Do version: `Fold[# + Sin[#2] &, 1.0, Range[10^6]]` both on v7 and v9.


title: How to substitute numeric values in a symbolic Jacobian matrix?

text: I have a multi-variate function from $\mathbb{R}^n\to\mathbb{R}^n$. Choosing any desired initial vector, we can produce the corresponding function value, which is a vector as follows. The main problem lies in the computation of the Jacobian matrix. In the code below:               dim = 10;     X = Table[Subscript[x, i], {i, 1, dim}]     f[x_] := (n = Length[x];         Table[If[i <= n - 1, x[[i]] x[[i + 1]] - 1, x[[1]] x[[n]] - 1], {i,           1, n}]);     f[X]     J[X] = D[f[X], {X}];     J[X]     Y0 = Table[2, {i, 1, dim}];     f[Y0]     J[Y0]      the Jacobian (the differentiation of `f[x]`) is defined (theoretically) correctly, but I cannot plug any data to obtain the numerical values of the Jacobian matrix!? It would be appreciated if anyone take a look and give some suggestions to find `J[Y0]` correctly? Here `Y0` is the initial vector chosen arbitrary.


title: How can I make the Cartesian product of a list with itself?

text: I'm trying to build the table               {{1, 1}, {1, 2}, {2, 1}, {2, 2}}      given the list               {1, 2}      I can do it like this               Flatten[Table[{x1, x2}, {x1, {1, 2}}, {x2, {1, 2}}], 1]      But how can I do this given a very long list, say {1, 2, 3, ..., 100}? I've searched the documentation on `Nest` and `Fold`, but didn't find a solution.


title: How to use $\LaTeX$ for typesetting labels and titles in Mathematica

text: I need to typeset large number of equations to be used for `PlotLabel` and `Titles` and such. These have to look nice. Hence I use `TraditionalForm` with `HoldForm` and this works well, except for a tiny little annoying thing. This below is just an example:               TraditionalForm[HoldForm[(v/w) Sin[w t]]]      displays as $\frac{v \ \sin(t)}{w}$ and not as $\frac{v}{w} \sin(t)$. In otherwords, the `Sin[x]` was put in the numerator as well, where I'd like it to remain on its own as was typed. I used `()` above as a hint to leave `Sin[]` alone, but this hint did nothing. An easy fix is to use `HoldForm` around each small sub-expression as follows               TraditionalForm[Row[{HoldForm[(v/w)], HoldForm[Sin[w t]]}]]       which now generates $\frac{v}{w} \sin(t)$ But the above is a small example. I have much larger equations, and would be nice if I could tell _Mathematica_ when I type it, using `()` or another trick, to please not group these subexpression as it did in the above example (I'd like the equations to look exactly as they appear in the text book. It is not a big issue really to use `HoldForm` many times to force the shape to look exactly as I wanted, but just thought to check if someone knows an easier way to do this other than what I have shown. I just had a thought! is it possible to use $\LaTeX$ directly to typeset things in _Mathematica_ for purpose of display? i.e. it would be nice if one can write _something_ like `Text["$\frac{v}{w} \sin(t)$"]` and have _Mathematica_ interpret this as $\LaTeX$, and typeset it as $\LaTeX$ output. If possible, I can just write everything in $\LaTeX$ as strings, and problems solved. What I mean by the above is as follows (only to help explain the point): In MATLAB I can do this:               text(.5,.5,'$\frac{v}{w} \sin(t)$','interpreter','latex','FontSize',18)      which generates ![LaTeX'd formula](http://i.stack.imgur.com/J6D0u.png) Notice I had to tell MATLAB to use the $\LaTeX$ interpreter. But that is all. It will be really nice to be able to do something like this in _Mathematica_ if possible. Using `String`s also avoids many other problems when typesetting symbolic expressions in _Mathematica_ since a string is inert and a raw `Symbol` and can't have value other than itself. Thanks.


title: How to plot a x bar control chart?

text: Does anyone know how to plot a x bar control chart? With mu=12.5, sigma=.8? I have searched all over mathematica documentation center but still couldn't figure out how?


title: Getting data through a serial port

text: I need to receive data from a serial port and save it to a list so I can use it later. Since the input will depend on human interaction, My program must keep running and saving as long as data is available from the port. Whats the best way to do that?


title: Graphically representing error in a Riemann Sum

text: I am trying to graphically represent the error in a Riemann sum. My current code looks like:                   Show[DiscretePlot[Log[t], {t, 1, 10, 1}, ExtentSize -> Left, PlotMarkers -> "Point"],                Plot[Log[t], {t, 1, 10}]]      ![The output of the above code](http://i.stack.imgur.com/gZCcT.png) I would know like to plot JUST the curve-linear triangles above the plot of ln(x) that represents the error in the Riemann Sum.


title: How to combine DifferenceRoot objects for odd and even-indexed terms

text: I'm trying to analyze a certain infinite sequence $S$, indexed by positive integers starting from $1$. It can be split into two subsequences:   * $S^{odd}$ by removing all even-indexed elements and keeping all odd-indexed ones, and   * $S^{even}$ by removing all odd-indexed elements and keeping all even-indexed ones. Each of these two sequences has its own indexing by positive integers starting from $1$, so indexes of their elements do not match indexes of corresponding elements in $S$, e.g. $S^{odd}_3=S_5$, $S^{even}_2=S_4$. I got two different `DifferenceRoot` expressions representing $S^{odd}$ and $S^{even}$. I would like to merge them into a single `DifferenceRoot` expression representing $S$. I suppose I need to somehow align their indexing and then use `DifferenceRootReduce`. > What is the simplest way to do that?


title: Getting all physical units with prefixes

text: How we can get the list with all physical units and prefixes from WolframAlpha and make symbols from the result to be equal their corresponding quantities like described in this post?


title: Plot 3D vector that is a function of one variable

text: I have a function, `r[t]`, which is a piecewise function that generates a 3D vector. It looks like this:               r[t_] = Piecewise[{{{5 t, 0, 3 (1 + Cos[t])}, 0 <= t <= π},      {{5 Cos[t - 3  π/2] + 5*π, 5 Sin[t - 3 π/2] + 5, 0},  π < t <= 2 π},      {{5*π + 3*Cos[t - 3 π/2], 2*5 - 3 + 3*Sin[t - 3 π/2],  1/(2 π) (t - 2 π)^2},       2 π < t <= 4 π},      {{-3 (t - 17 π/3), 10, -1/π t^2 + 10 t - 22 π},   4 π < t <= 5 π},      {{-3 t + 17 π, 10, -972 π + 540 t - (99 t^2)/π + (6 t^3)/π^2},        5 π < t <= 6 π},      {{-π - 3 Sin[t], 9/40 (1/3 (20 + 18 π) - t)^2, 3 Cos[t] - 3}, 6 π < t <= 8 π},      {{-25 π + 25 t - (19 t^2)/(4 π) + t^3/(4 π^2),  -(25/2) (140 - 132 π + 27 π^2) +      (15 (80 - 74 π + 15 π^2) t)/(2 π) -  (3 (180 - 164 π + 33 π^2) t^2)/(8 π^2) -      ((-50 + 45 π - 9 π^2) t^3)/(20 π^3), 1056 - (360 t)/π + (81 t^2)/(2 π^2) - (3 t^3)/(2 π^3)},        8 π < t <= 10 π}}];      I am very new to Mathematica (this is my first day using it), and I am unsure of how to plot this function in a 3D space. I have tried `Plot3D` and `VectorPlot3D`, but neither seems to offer a good way to do this (that I can think of). How might I go about plotting the function?


title: Exported PDF copy-and-pastable

text: Is it possible to export pdf documents that allow the user to copy and paste the exported code/text? The following table demonstrates what is pasted after copying the example symbols from a pdf exported from Mathematica.               pasted actual      @       [     8       {     ®       →      If this isn't possible an explanation of why not(what about pdfs prevents this functionality) would be appreciated. **EDIT:** After reading Alexey's answer, it has become clear that the pdf editor that you use to copy the text makes a big difference. When you copy text from the pdf reader Foxit or from Google Chrome's built in reader the clipboard stores the following. If you copy the data from the pdf using Adobe Reader 11(W7 and M9) in addition you get a RTF format on the clipboard. The RTF format allows Mathematica to reconstruct the original data.


title: Ordered indices of a multiple product or sum

text: Given a summation like $$\sum_{1 \leq i_1 < i_2 < \dotsc < i_k \leq n} f(i_1, i_2, \dotsc , i_k)$$ how can the lists of indices be enumerated? For example, if $n=4$ then the possible lists of indices are               k=1: {1}, {2}, {3}, {4}     k=2: {1,2}, {1,3}, {2,3}, {2,4}, {3,4}     k=3: {1,2,3}, {1,2,4}, {2,3,4}     k=4: {1,2,3,4}      It doesn't matter in what order the lists appear in, and it doesn't matter if they are separated by $k$, i.e., this function could give the lists of indices for a given $k$ value, or list all lists for $k=1 \dotsc n$ (the 14 in the example) in arbitrary order. This is similar to the question Sequential Subsets of a list except that in the example given there, given a list               {1, 2, 3, 4}      the output is               {1}, {2}, {3}, {4},      {1,2}, {2,3}, {3,4},     {1,2,3}, {2,3,4},     {1,2,3,4}      (in some order) and in this case, we additionally need               {1,3}, {2,4}, {1,2,4}      to appear in the output.


title: How can I build an inline documentation utility?

text: I often have a large function to which I add inline comments, but then I can't see the forest for the trees. How can I make a tool that extracts the comments and tokens within them to generate an overview or structured outline of the large complex function? For instance:                BigNastyFunction[input_List, xSpecArg_, ySpecArg_, OptionsPattern[]] :=       Module[      {         (*1:1 Local variables*)        data, ySpecContinousQ, xSpecContinousQ, groupsQ, joinedCounts, colors, ymin, ymax, xmin,              (*1:2 Option variables*)        axesLabelsQ, barOrigin, background, diskSizeScaling, displayFunction, frameQ      }            (*2:1 Check for null Input*)       If[times === {}, Return[$Failed]];            (*2:2:1 Check for groups *)       check1 = Depth[input] === 4;         (*2:2:2 Check for nongroups *)       check2 = Depth[input] === 3;              etc...      Would be transformed into something like: Outline of BigNastyFunction Part 1. .....Step 1. Local variables .....Step 2. Option variables Part 2. .....Step 1. Check for null Input .....Step 2. ..........a) Check for groups ..........b) Check for nongroups


title: Problems with FindMinimum for Constrained Optimization

text: I am trying to define a simple optimization problem, arising from the discretization of a simple Optimal Control problem. The problem that results is essentially linear, with bilinearities only appearing in some equality constraints. The problem is not big and should be solvable by `FindMinimum`. However I get the following message:               Power::infy: Infinite expression 1/0. encountered. >>       Min::nord: Invalid comparison with ComplexInfinity attempted. >>       FindMinimum::conv: Interior point method fails to converge. >>      I note that the constraints do not contain divisions at all, and the objective is totally linear. The complete model is given below: > Simple car problem   >  $\begin{align*}\frac{dv}{dt} &= u\\\ \frac{dx}{dt} &= v\end{align*}$   >  $x(0)=0,\quad v(0)=0,\quad x(t_f)=300,\quad v(t_f)=0, \qquad \text{minimize > } t_f$.   >  $-2 \leq u\leq +1$.               In[51]:= (* try to define the car problem directly below *)     (* v is velocity and x is distance, h is the stepsizes, u are the controls *)          nsteps = 10;          vlist = Table[v[i], {i, 0, nsteps}]          Out[52]= {v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10]}          In[53]:= xlist = Table[x[i], {i, 0, nsteps}]          Out[53]= {x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10]}          In[54]:= hlist = Table[h[i], {i, 1, nsteps}]          Out[54]= {h[1], h[2], h[3], h[4], h[5], h[6], h[7], h[8], h[9], h[10]}          In[55]:= ulist = Table[u[i], {i, 1, nsteps}]          Out[55]= {u[1], u[2], u[3], u[4], u[5], u[6], u[7], u[8], u[9], u[10]}          In[56]:= varslist = Join[vlist, xlist, hlist, ulist]          Out[56]= {v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], x[0],       x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], h[1], h[2],       h[3], h[4], h[5], h[6], h[7], h[8], h[9], h[10], u[1], u[2], u[3], u[4],       u[5], u[6], u[7], u[8], u[9], u[10]}          In[57]:= obj0 = Sum[h[i], {i, 1, nsteps}]          Out[57]= h[1] + h[2] + h[3] + h[4] + h[5] + h[6] + h[7] + h[8] + h[9] + h[10]          In[58]:= odes = Flatten[       Table[{x[i] - x[i - 1] == v[i]*h[i], v[i] - v[i - 1] == h[i]*u[i]}, {i, 1,          nsteps}]]          Out[58]= {-x[0] + x[1] == h[1] v[1], -v[0] + v[1] == h[1] u[1], -x[1] + x[2] ==        h[2] v[2], -v[1] + v[2] == h[2] u[2], -x[2] + x[3] ==        h[3] v[3], -v[2] + v[3] == h[3] u[3], -x[3] + x[4] ==        h[4] v[4], -v[3] + v[4] == h[4] u[4], -x[4] + x[5] ==        h[5] v[5], -v[4] + v[5] == h[5] u[5], -x[5] + x[6] ==        h[6] v[6], -v[5] + v[6] == h[6] u[6], -x[6] + x[7] ==        h[7] v[7], -v[6] + v[7] == h[7] u[7], -x[7] + x[8] ==        h[8] v[8], -v[7] + v[8] == h[8] u[8], -x[8] + x[9] ==        h[9] v[9], -v[8] + v[9] == h[9] u[9], -x[9] + x[10] ==        h[10] v[10], -v[9] + v[10] == h[10] u[10]}          In[59]:= ubounds = Flatten[Table[{u[i] <= 1.0, u[i] >= -2.0}, {i, 1, nsteps}]]          Out[59]= {u[1] <= 1., u[1] >= -2., u[2] <= 1., u[2] >= -2., u[3] <= 1., u[3] >= -2.,       u[4] <= 1., u[4] >= -2., u[5] <= 1., u[5] >= -2., u[6] <= 1., u[6] >= -2.,       u[7] <= 1., u[7] >= -2., u[8] <= 1., u[8] >= -2., u[9] <= 1., u[9] >= -2.,       u[10] <= 1., u[10] >= -2.}          In[60]:= hbounds = Flatten[Table[{h[i] <= 100.0, h[i] >= 0.01}, {i, 1, nsteps}]]          Out[60]= {h[1] <= 100., h[1] >= 0.01, h[2] <= 100., h[2] >= 0.01, h[3] <= 100.,       h[3] >= 0.01, h[4] <= 100., h[4] >= 0.01, h[5] <= 100., h[5] >= 0.01,       h[6] <= 100., h[6] >= 0.01, h[7] <= 100., h[7] >= 0.01, h[8] <= 100.,       h[8] >= 0.01, h[9] <= 100., h[9] >= 0.01, h[10] <= 100., h[10] >= 0.01}          In[61]:= boundary = {x[0] == 0.0, v[0] == 0.0, v[nsteps] == 0.0, x[nsteps] == 300.0}          Out[61]= {x[0] == 0., v[0] == 0., v[10] == 0., x[10] == 300.}          In[62]:= constr0 = Join[odes, ubounds, hbounds, boundary]          Out[62]= {-x[0] + x[1] == h[1] v[1], -v[0] + v[1] == h[1] u[1], -x[1] + x[2] ==        h[2] v[2], -v[1] + v[2] == h[2] u[2], -x[2] + x[3] ==        h[3] v[3], -v[2] + v[3] == h[3] u[3], -x[3] + x[4] ==        h[4] v[4], -v[3] + v[4] == h[4] u[4], -x[4] + x[5] ==        h[5] v[5], -v[4] + v[5] == h[5] u[5], -x[5] + x[6] ==        h[6] v[6], -v[5] + v[6] == h[6] u[6], -x[6] + x[7] ==        h[7] v[7], -v[6] + v[7] == h[7] u[7], -x[7] + x[8] ==        h[8] v[8], -v[7] + v[8] == h[8] u[8], -x[8] + x[9] ==        h[9] v[9], -v[8] + v[9] == h[9] u[9], -x[9] + x[10] ==        h[10] v[10], -v[9] + v[10] == h[10] u[10], u[1] <= 1., u[1] >= -2.,       u[2] <= 1., u[2] >= -2., u[3] <= 1., u[3] >= -2., u[4] <= 1., u[4] >= -2.,       u[5] <= 1., u[5] >= -2., u[6] <= 1., u[6] >= -2., u[7] <= 1., u[7] >= -2.,       u[8] <= 1., u[8] >= -2., u[9] <= 1., u[9] >= -2., u[10] <= 1., u[10] >= -2.,       h[1] <= 100., h[1] >= 0.01, h[2] <= 100., h[2] >= 0.01, h[3] <= 100.,       h[3] >= 0.01, h[4] <= 100., h[4] >= 0.01, h[5] <= 100., h[5] >= 0.01,       h[6] <= 100., h[6] >= 0.01, h[7] <= 100., h[7] >= 0.01, h[8] <= 100.,       h[8] >= 0.01, h[9] <= 100., h[9] >= 0.01, h[10] <= 100., h[10] >= 0.01,       x[0] == 0., v[0] == 0., v[10] == 0., x[10] == 300.}          In[63]:= nvars0 = Dimensions[varslist][[1]]          Out[63]= 42          In[64]:= vars0 = Transpose[{varslist, Table[Random[Real, {0., 1.}], {nvars0}]}]          Out[64]= {{v[0], 0.994273}, {v[1], 0.132455}, {v[2], 0.7492}, {v[3], 0.422551}, {v[4],        0.3127}, {v[5], 0.734046}, {v[6], 0.386862}, {v[7], 0.95813}, {v[8],        0.319134}, {v[9], 0.0195711}, {v[10], 0.547824}, {x[0], 0.126578}, {x[1],        0.91368}, {x[2], 0.385664}, {x[3], 0.195437}, {x[4], 0.589594}, {x[5],        0.369296}, {x[6], 0.437719}, {x[7], 0.205286}, {x[8], 0.210231}, {x[9],        0.145847}, {x[10], 0.225091}, {h[1], 0.572089}, {h[2], 0.681713}, {h[3],        0.151574}, {h[4], 0.0926365}, {h[5], 0.822889}, {h[6], 0.259161}, {h[7],        0.838874}, {h[8], 0.35859}, {h[9], 0.436027}, {h[10], 0.301031}, {u[1],        0.51974}, {u[2], 0.339019}, {u[3], 0.888204}, {u[4], 0.174453}, {u[5],        0.60606}, {u[6], 0.953355}, {u[7], 0.692767}, {u[8], 0.584859}, {u[9],        0.236764}, {u[10], 0.515636}}          In[65]:= constr0 = Apply[And, constr0]          Out[65]= -x[0] + x[1] == h[1] v[1] && -v[0] + v[1] == h[1] u[1] && -x[1] + x[2] ==        h[2] v[2] && -v[1] + v[2] == h[2] u[2] && -x[2] + x[3] ==        h[3] v[3] && -v[2] + v[3] == h[3] u[3] && -x[3] + x[4] ==        h[4] v[4] && -v[3] + v[4] == h[4] u[4] && -x[4] + x[5] ==        h[5] v[5] && -v[4] + v[5] == h[5] u[5] && -x[5] + x[6] ==        h[6] v[6] && -v[5] + v[6] == h[6] u[6] && -x[6] + x[7] ==        h[7] v[7] && -v[6] + v[7] == h[7] u[7] && -x[7] + x[8] ==        h[8] v[8] && -v[7] + v[8] == h[8] u[8] && -x[8] + x[9] ==        h[9] v[9] && -v[8] + v[9] == h[9] u[9] && -x[9] + x[10] ==        h[10] v[10] && -v[9] + v[10] == h[10] u[10] && u[1] <= 1. && u[1] >= -2. &&       u[2] <= 1. && u[2] >= -2. && u[3] <= 1. && u[3] >= -2. && u[4] <= 1. &&       u[4] >= -2. && u[5] <= 1. && u[5] >= -2. && u[6] <= 1. && u[6] >= -2. &&       u[7] <= 1. && u[7] >= -2. && u[8] <= 1. && u[8] >= -2. && u[9] <= 1. &&       u[9] >= -2. && u[10] <= 1. && u[10] >= -2. && h[1] <= 100. && h[1] >= 0.01 &&       h[2] <= 100. && h[2] >= 0.01 && h[3] <= 100. && h[3] >= 0.01 &&       h[4] <= 100. && h[4] >= 0.01 && h[5] <= 100. && h[5] >= 0.01 &&       h[6] <= 100. && h[6] >= 0.01 && h[7] <= 100. && h[7] >= 0.01 &&       h[8] <= 100. && h[8] >= 0.01 && h[9] <= 100. && h[9] >= 0.01 &&       h[10] <= 100. && h[10] >= 0.01 && x[0] == 0. && v[0] == 0. && v[10] == 0. &&       x[10] == 300.          In[66]:= FindMinimum[      {obj0, constr0}, vars0, Method -> "InteriorPoint"      ]          During evaluation of In[66]:= Power::infy: Infinite expression 1/0. encountered. >>          During evaluation of In[66]:= Min::nord: Invalid comparison with ComplexInfinity attempted. >>          During evaluation of In[66]:= FindMinimum::conv: Interior point method fails to converge. >>          Out[66]= FindMinimum[{obj0, constr0}, vars0, Method -> "InteriorPoint"]


title: Rotated text in "plot" cannot be copied  to MS Word

text: When I add some text to a simple plot with drawing tools, the text cannot be copied and pasted out with the graphic itself to Microsoft Word. Do you know how to copy the manually added text out to Word? Thank you! This is what I did in Mathematica plot with drawing tool (I got this by output it as a .bmp file): ![](http://i.stack.imgur.com/S8EaY.png) This is what was copied and pasted to Word (result of direct copy and paste): ![](http://i.stack.imgur.com/ECkGy.png) After a few tries, I think it works for newly added text, but once I rotate & move the text to align with my curves it disappear again. The following screenshot shows how bmp image lose resolution when the document coverted to PDF eventually. ![](http://i.stack.imgur.com/Nau16.png) The topic has been a little diverted. We still haven't solve the problem "copy & paste do not work for rotated text in plot". I think it's a MMA bug. Any hints?


title: Problem in RegionPlot3D

text: I tried to plot the region bounded by the three planes. This is supposed to give me a pyramid type of shape (actually two, but I am just taking one of them). The code is given by               RegionPlot3D[      x - Sqrt[2]*z >= 0 && Sqrt[2]*x + Sqrt[3]*y + z >= 0 &&        Sqrt[2]*x - Sqrt[3]*y + z >= 0, {x, 0, 12}, {y, -20, 20}, {z, -20,        20}, AxesLabel -> Automatic, Mesh -> None,       PlotStyle -> Directive[Yellow, Opacity[0.5]]]      I am getting kinkiness in the lines created by joining of two planes, ![plot of pyramid](http://i.stack.imgur.com/MfMsB.png) Is it a problem in my graphics card? However, I have checked in different machines and in versions 6, 7 and 8. I got the same situation in all of them. May be it is the similar kind of problem as posted here. I am not sure exactly what modification has to be made. Advanced thanks for any help.


title: Export and Import with graphics characters

text: I exported a list of characters say: Export["hello.txt", {t, r, $\theta$, $\phi$}, "List"]; the file has the correct symbols when opened with a text editor, however, when I imported it with Mathematica: old = Import["hello.txt", "List"] I get: {t, r, Î¸, Ï} Any idea of How can I recover the original symbols?


title: Is it possible to add page break in front-end?

text: **Description** : I have accomplished my undergraduate paper as a _Mathematica_ notebook. In this condition, I find it convenient to typeset formula and words in a notebook environment. However, I feel that the front-end is lacking a `page break` tool, so I cannot make good page-breaking that I need. Namely, the front-end of _Mathematica_ always breaks the page automatically when been printed. **Question** :   1. How can I break a page manually when saving the notebook as a PDF file?   2. Is it possible to add a `page break` in the `notebook environment`, for example like in _Microsoft Word_ , where the words jump to the next page when there is no space left in the current page ? ![enter image description here](http://i.stack.imgur.com/VD0cU.jpg)


title: Evaluation of elements in a list and then sorting them

text: This is probably a simple problem, but I'm having a lot of issues with it because I'm unfamiliar with _Mathematica_ syntax. I have a list               S = {{-1 + x + y}, {x^2 + y}, {x + 2y}}      I am trying to create a function `f` which returns a sorted list _after_ substitution, I've tried variations of the following:               f[x_, y_] := Sort[Evaluate[Table[u, {u, S}]]];      but it simply returns the original list. Any help would be much appreciated!


title: How to expand set of fonts for mathkernel.exe?

text: If I am running standard Mathematica and I am choosing from the menu Format->Font, I've got everything I need. All necessary scripts are present (Western, Central European,etc.). Whereas If I run mathkernel.exe and I am choosing Edit->Set Font, I've got only "Western" script. I would like to change it and have this same state like in main application Mathemathica.exe. Does anybody know how to do it?


title: The Flat Attribute, Unevaluated and the Evaluation Process

text: To make this question easy to follow let's give some symbols a couple attributes.               Attributes[f] = {Flat};     Attributes[s] = {Orderless};      Now consider the following: `f[a, b, g[c, d], f[e, h], j, k]` gives > `f[a, b, g[c, d], e, h, j, k]` as expected since f is `Flat` Now, we wrap `Unevaluated` around `f`               f[a, b, g[c, d], Unevaluated[f[e, h]], j, k]       This gives > `f[a, b, g[c, d], Unevaluated[e], Unevaluated[h], j, k]` To understand what happened here, we use `Trace`               f[a, b, g[c, d], Unevaluated[f[e, h]], j, k] // Trace      > >      {f[a, b, g[c, d], f[e, h], j, k], f[a, b, g[c, d], e, h, j, k], f[a, >      b, g[c, d], Unevaluated[e], Unevaluated[h], j, k]} >   Finally, let's also wrap `Unevaluated` around `s`.               f[a, b, g[c, d], Unevaluated[f[e, h]], Unevaluated[s[n, m]], j, k]      > >     f[a, b, g[c, d], Unevaluated[e], Unevaluated[h], >      Unevaluated[s[n, m]], j, k] >   Now, here comes my question/confusion. In the case of `f`, the `Unevaluated` head was removed, so the elements of `f`( that has a `Flat` attribute ) was now spliced in and the `Unevaluated` head replaced on the elements of `f`. According to the standard evaluation process, if any part of an expression has the form `Unevaluated[expr]`, we replace that part with `expr` and keep a record of the original expression (So we can later replace the `Unevaluated` head). Now as I've shown, if the expression `expr` has a head with `Flat` `Attribute`, then the expression gets spliced in (i.e. it actually gets evaluated) but as we saw with `s` that has the `Orderless` `Attribute`, the expression remains unevaluated as described by the Evaluation process. So why does the `Flat` attribute supersede `Unevaluated`? This shouldn't be the case according to the standard evaluation process. What am I missing?


title: How can I get the function of a plotted trajectory?

text: I solved two ODEs, which are a function of `t`, numerically. The first ODE is the vertical equation of motion and the second one is the horizontal equation of that motion. Then I tried to find the path equation. I used `ParametricPlot` to plot the path. Now I want the equation of that path. How can I express it using the solutions of my ODEs? * * * The Point of my question is as follows: Assuming that we solved an ODE Numerically and I got the answer like this: > >     {{y-> InterpolatingFunction[{{0.,0.386145}},<>]}} >   How can I `Approximate` the function to do some calculus on it?               γ = 6;      g = -9.8;      NDSolve[{y''[t] + γ*(y'[t])^2 == g, q''[t] == -γ*(q'[t])^2,        y[0] == 0, q[0] == 0,        y'[0] == 1.5, q'[0] == 7}, {q, y}, {t, 0, 10}]


title: Vertically aligning two separate plots

text: How do I vertically align plots so that the two plots are displayed in a way that lines up with respect to the axes? The code I have so far is:               GraphicsColumn[      {       Plot[0.125 x^2 + 0.05 x^3 + 0.005 x^4, {x, -8.0, 3.0},          AspectRatio -> .4, PlotRange -> {-.19, .7}, Frame -> True,         FrameStyle -> Thickness[.003],         FrameLabel -> {Null, "V(x)", "m=1.0,   w=0.5,   y=2.0,   g=1.0"},          FrameTicks -> {{Automatic, Automatic}, {None, All}}],        Plot[0.5 + 0.2 x, {x, -8.0, 3.0}, AspectRatio -> .4,          PlotRange -> {-1, .9}, Frame -> True,  FrameStyle -> Thickness[.003],          FrameLabel -> {"x", "B(x)", Null},          FrameTicks -> {{Automatic, Automatic}, {Automatic, Automatic}}]      },       ImageSize -> 500, Frame -> None, Spacings -> -20]      ![My horrid attempt to align plots](http://i.stack.imgur.com/3UMRH.png) I'm looking at this right now, and realized how ugly this is... like why is the lower frame thicker than the upper one???


title: How to plot stacked curves with sharing the horizontal axis

text: ![enter image description here](http://i.stack.imgur.com/yhlLm.gif) How to plot the curves in the image.


title: How can I stack plots so that they are aligned nicely?

text: Suppose that I have two plots (e.g., `Plot`, `ListPlot`, etc) that cover two regions of space. I would like to display them "stacked" vertically, so that they align nicely in publication-quality form. Suppose that I am dealing with `ListPlot` and I have the following data:               xdata = Range[0, 2 Pi, 0.2];     ydata1 = Sin[xdata];     ydata2 = 1 + Sin[xdata];      So for plot1, I will plot `Transpose[{xdata, ydata1}]`; for plot2, I will plot `Transpose[{xdata, ydata2}]` (both using `ListPlot`). Plot1 covers both negative and positive $y$ values, whereas plot2 covers only positive $y$ values; this fact will be important later. For both plots, I will use `BaseStyle -> {18, FontFamily -> "Arial"}` so that the labels are large and legible. I will also use `Frame -> True` and will include frame labels with `FrameLabel -> {"x (Meter)", "y (Meter)"}`. Now if I do the following...               plot1 = ListPlot[Transpose[{xdata, ydata1}], Frame -> True,        FrameLabel -> {"x (Meter)", "y (Meter)"},        BaseStyle -> {18, FontFamily -> "Arial"}, PlotStyle -> Red, ImageSize -> 375]          plot2 = ListPlot[Transpose[{xdata, ydata2}], Frame -> True,        FrameLabel -> {"x (Meter)", "y (Meter)"},        BaseStyle -> {18, FontFamily -> "Arial"}, PlotStyle -> Blue, ImageSize -> 375]      ...I get the following... ![Image1](http://i.stack.imgur.com/40AKD.png) Notice that above, the frames are not aligned. To fix this, I can specify the same `ImagePadding` for both plots...               plot1 = ListPlot[Transpose[{xdata, ydata1}], Frame -> True,        FrameLabel -> {"x (Meter)", "y (Meter)"},        BaseStyle -> {18, FontFamily -> "Arial"}, PlotStyle -> Red, ImageSize -> 375,       ImagePadding -> {{70, 10}, {55, 10}}]          plot2 = ListPlot[Transpose[{xdata, ydata2}], Frame -> True,        FrameLabel -> {"x (Meter)", "y (Meter)"},        BaseStyle -> {18, FontFamily -> "Arial"}, PlotStyle -> Blue, ImageSize -> 375,       ImagePadding -> {{70, 10}, {55, 10}}]      ...which gives me the following output... ![Image2](http://i.stack.imgur.com/hAIjv.png) Now the frames are nicely aligned. **_However_** , the $y$ axis frame labels are not aligned. This is because plot1 includes negative $y$ values in addition to positive ones, and the negative signs "push away" the $y$ axis frame label (i.e., `"y (Meter)"`) in plot1. So, **_my question is:_** is it possible to somehow align the $y$ axis frame labels? Apparently, `ImagePadding` does not do the trick for that particular issue. Thanks for your time.


title: Aligning axes labels on multiple plots

text: I'm trying to create some "publication quality" figures, but _Mathematica_ is fighting me all the way. So my question is: **Should I switch to Origin?** Please help! * * * Well, all joking aside: I'm trying to create a multipanel figure. Here is an example:               p1 = Plot[100 Sin@x, {x, -5, 5}, Frame -> True,         FrameLabel -> {"XXX", "YYY"}, LabelStyle -> Large,         ImageSize -> 400, ImagePadding -> {{100, 1}, {0, 10}}];     p2 = Plot[5 Sin@x, {x, -5, 5}, Frame -> True,         FrameLabel -> {"XXX", "TTTT"}, LabelStyle -> Large,         ImageSize -> 400, ImagePadding -> {{100, 1}, {40, 0}}];     Column[{p1, p2}, Spacings -> 0]      ![Example image](http://i.stack.imgur.com/Skpd1.png) So the real question is: **How can I align the TTTT and YYYY axes labels?** I also tried using grid, with separate labels but then the TTTT is not centered on the axis, but is too low.


title: Solving linear equation

text: I want to solve following linear equations: \begin{align*} 3 x - y &= 0\\\ y + 2 z &= -1\\\ x + y + z &= 3 \end{align*} The output will be `{x == 7/5, y == 21/5, z == -(13/5)}` I don't know the way of solve this. What function can be used. How can I solve this? Also it will be very thankful if you let me know the ways as many as possible. Also especially, is there any specific way that using 'LU decomposition' to solve this equation??


title: Adapting CoefficientList (and the related functions) to work with Laurent polynomials

text: Is there a slick way to make CoefficientList (and the other similar functions, CoefficientRules etc) work for Laurent polynomials (i.e. where negative exponents can occur), if I don't know a priori what the largest negative exponents are? I can of course do some ugly ad hoc thing by hand, but I'm looking for a method that works generally. Any tips?


title: BubbleChart Text Tooltip's

text: Is it possible to display "name" in the tooltip? It won't chart the full dataset, so I can't make a custom labeling function that takes it in.               data3 = {{"acerbic",3,5,1.3*10^6},     {"acetic",3,7,213000},{"acetonic",1,4,2000},{"achromatic",3,6,16000},     {"acidic",3,6,500},{"acoustic",3,7,2000},{"acrobatic",3,6,3000},     {"acrostic",4,8,Null},{"acrylic",3,5,220000},{"acyclic",6,8,270000},     {"adiabatic",6,7,40000},{"aerobatic",3,6,2000},{"aerobic",7,4,1.6*10^6},     {"aerodynamic",7,7,160000},{"aeronautic",2,2,5000},{"aesthetic",5,3,500},     {"agnostic",3,5,5000},{"agoraphobic",7,3,200000},{"agronomic",3,5,5000},     {"alcoholic",2,1,1000},{"alembic",2,1,20000},{"algebraic",6,3,5000},     {"algorithmic",5,2,2500.},{"aliphatic",7,2,13000},{"allegoric",5,2,1000},     {"allelic",8,5,2400.},{"allergenic",8,5,48000},{"allergic",8,3,1000},     {"allotropic",7,6,3000},{"almanac",6,7,Null},{"alphabetic",7,2,Null},     {"alphanumeric",6,7,1000},{"altruistic",4,7,7000},{"amnesiac",5,6,4000},     {"amnesic",6,5,500},{"amniotic",4,2,500},{"amoebic",2,1,1000},     {"anabolic",4,7,Null},{"anachronistic",4,7,1500.},{"anaerobic",3,5,10000},     {"anagrammatic",8,10,Null},{"analgesic",3,7,60000},{"analytic",7,7,3000},     {"anamorphic",2,6,3000},{"anapestic",3,5,90000},     {"anaphoric",6,4,1000000},{"anarchic",7,5,12000000},     {"anarchistic",4,4,50000},{"anatomic",2,2,30000},     {"androgenic",2,4,60000},{"anechoic",3,4,50000},{"anemic",2,1,200000},     {"anesthetic",2,6,40000},{"angelic",3,6,44000},{"anharmonic",4,7,Null},     {"animistic",3,5,100000},{"anionic",3,7,2.2*10^6},     {"anisotropic",3,6,2.8*10^6},{"anorectic",6,1,60000},     {"anorexic",5,6,4000},{"antagonistic",1,5,550000},     {"antarctic",3,4,320000},{"anthropic",5,5,8000},     {"anthropocentric",2,5,10000000},{"anthropogenic",1,5,12000000},     {"anthropometric",3,6,103000},{"anthropomorphic","","",Null},     {"antibiotic","","",Null},{"antic","","",Null},     {"anticlimactic","","",Null},{"anticyclonic","","",Null},     {"antidemocratic","","",Null}};          labelingfunc[v : {x_, y_, w_}, i_, ___] :=       Placed[Grid[{{"Name"}, {"Usability ", x}, {"Relevancy",           y}, {"Market Size", w}}, Frame -> All, Alignment -> Left],        Tooltip]          BubbleChart[data3[[All, 2 ;; 4]], ChartStyle -> 24,       LabelingFunction -> labelingfunc]      ![bubble chart](http://i.stack.imgur.com/MTS1k.png)


title: How to effectively diff a notebook?

text: How to effectively diff a notebook with another version of it? This is usually needed/encountered in revision control, but can be generally useful. What i currently do is disable notebook history, use less styling, and diff them as text files.


title: "Hiding" cells until the first cell is evaluated

text: This question is based on my earlier question about randomizing labs for students in my computer lab courses. There a perfectly good solution was posted; however, because of privilege problems, I cannot use the exact method there, as I do not have the ability to modify global settings. So now I've decided on a different approach: having an input field at the top of the lab, where the student is prompted to enter their name, and hit a button "Begin Lab". The button will use the name (among other things) as a seed to randomize the lab. All well and good. However, before that button is clicked, I would like **to "gray out" or hide** all other cells in the lab. In other words, the only active, usable cell is this one containing the "Begin Lab" button, until that button is clicked! Is this possible? Can it be done without making changes to the global settings (preferably) ?


title: Problems getting clean sunrise, sunset, civil, nautical and astronomical twilight data

text: If in a notebook you enter:               WolframAlphaResult["Sunrise june 25, 2013", {{"DaylightInformation", 1}, "ComputableData"},                        PodStates -> {"DaylightInformation__More"}]        you get:               {{"begin astronomical twilight","3:16 am EDT"},     {"begin nautical twilight","4:07 am EDT"},     {"begin civil twilight", "4:50 am EDT"},     {"sunrise","5:24 am EDT"},      {"sunset", "8:31 pm EDT"},      {"end civil twilight","9:05 pm EDT"},     {"end nautical twilight","9:48 pm EDT"},      {"end astronomical twilight","10:39 pm EDT"},     {"duration of daylight", {15, 8}}}        as a result (I didn't know there was something called "nautical twilight," but now that I do, I want it). Unfortunately, the result is returned not as a nice list, but instead embedded in a complicated `WolframAlphaResult` format. Despite trying many different approaches, I have been unable to discover a way to get just a list of this data returned. It is possible?


title: How to remove a black border around Graphics3D[Texture[...]]

text: So I can create a 2D image that looks like               contourplot =       ContourPlot[       Sin[ x/2] Cos[y], {x, -4 \[Pi], 4 \[Pi]}, {y, -4 \[Pi], 4 \[Pi]},        PlotRange -> All, BaseStyle -> 30]      ![enter image description here](http://i.stack.imgur.com/o3Bx2.jpg) Notice there is no frame around the image as a whole. Now I want to use this in a 3D plot using the following command               backgroundimage =        Graphics3D[{Texture[contourplot],          Style[Polygon[{{-1000, -500, -500}, {-1000, 500, -500}, {-1000,              500, 500}, {-1000, -500, 500}},            VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}],           Lighting -> {{"Ambient", White}}]}];               Show[backgroundimage, Boxed -> False, ImageSize -> 800,       ViewPoint -> {2, -2, .3}]      ![enter image description here](http://i.stack.imgur.com/KfMpt.jpg) A black border has been added around the 3D object. How can I remove this border? Or is there some way to just make it white? Thanks


title: Dynamic matrix multiplication

text: I have the following problem: I want to multiply two matrices and sum them to another matrix C. A.B+ 2B Easy! The matrix A varies as a function of three inputs a,b and c. The second matrix, B, is a 2x2 identity matrix. here is the code                    Grid[{{"a", "b", "c"},            {InputField[Dynamic[a], FieldSize -> 1],             InputField[Dynamic[b], FieldSize -> 1],             InputField[Dynamic[c], FieldSize -> 1]}}]                  A = {{Dynamic[a]*Dynamic[b], 0}, {0, Dynamic[c]}};             B = IdentityMatrix[2];             A.B + 2 B      Let's say a=c=10 and b=2. Result But I don't want to get 10 2+2 and 10+2, I need 22 and 12! It just shows the value of a and c without multiplying. Using               A = {{Dynamic[a*b], 0}, {0, Dynamic[c]}};      instead of               A = {{Dynamic[a]*Dynamic[b], 0}, {0, Dynamic[c]}};      solves the first problem. I got 20+2 and 10+2, which is good but not enough. It seems that it not possible to simplify operation when using Dynamic... How can I solve the problem? Thx!


title: What is the full list of all font families?

text: I'm having trouble finding a complete list of the FontFamily strings that mathematica supports.


title: Help on how to write a function to be used with NMinimize

text: I need some help to write a proper function to be used as a parameter on NMinimize. Here is the code of the function to be minimized (Please correct, optimize and rewrite the code if you want to - I need to understand how to write proper Mathematica code).               plot[τ_, Ω_] := Module[{arg, abs, aux},         {arg, abs} =           Factor[Together[ComplexExpand[Through[{Arg, Abs}[(1 + I*2*Ω)/(1 + I*2*τ*Ω)]]]]];         aux = arg/Degree;        aux = If[aux < 0, aux = 360 - aux, aux];        {aux, 20*Log10[abs]}]          modFunction1[kc_, gp_, ω_, pm_, variable_:s] := Module[{arg, abs, aux},        {arg, abs} =          Factor[Together[ComplexExpand[Through[{Arg, Abs}[kc*gp /. variable -> I*ω]]]]];        aux = (-arg)*(180/Pi) + pm - 180;       aux = If[aux < 0, 360 + aux, aux];       {-20*Log10[abs], aux}];           functionF1[kc_, gp_, ω_, pm_, variable_:s, τ_, Ω_] := Module[{a, b, c, d},        {a, b} = N[modFunction1[kc, gp, ω, pm, variable]];       {d, c} = N[plot[τ, Ω]];       (a - c)^2 + (b - d)^2];       and finally               NMinimize[functionF1[50, 100/(s*(s + 5)*(s + 10)), 9, 42, τ, Ω],       {{τ, 10.5, 10.6}, {Ω, -0.1988, -0.1987}}]      NMinimize returns > NMinimize::nnum: "The function value 0.000459846 +(54.9326 -aux$584644)^2 is > not a number at {[Tau],[CapitalOmega]} = {10.5919,-0.198714}" but evaluating functionF1 on those same values returns a real number. What am I missing? Any comment on how to write the code is most welcome. I definitely need some guide on how to write proper functions.


title: Aborting from inside a Dialog

text: Suppose I got in a `Dialog` and wanted to not `Return` but `Abort` the computation. How could I do that? Using `Return[]` the computation continues, and sometimes that implies getting inside countless other `Dialog`s of which it is not easy to go out without killing the kernel. How do you handle those situations?


title: Compute percentages in a list

text: I have a data file which contains thousands of lines and each line has eight elements. Here is a small sample of the data file               -4.00      -0.80   0.1886024468848907E+01   0.1467147621657460E+01   -.1217067274319363E+01   0.7206100000000000E+03   0.7693457688734395E-12    5     -4.00      -0.70   0.1430357986632780E+01   -.1404093461650013E+01   -.1742223680347601E+01   0.1824700000000000E+03   0.8439003681169850E-12    8     -4.00      -0.60   -.1324719768465547E+01   0.1740130076002850E+01   0.1497978622206873E+01   0.5479900000000000E+03   0.4264485578634903E-14    2     -4.00      -0.50   0.1358536876189560E+01   -.1580696533502541E+01   0.1621539980382560E+01   0.2881100000000000E+03   0.1319885603098060E-13    4     -4.00      -0.40   -.1588487538231399E+01   0.1275577589608218E+01   0.1707607247015512E+01   0.1337500000000000E+03   0.1057878487713421E-12    2     -4.00      -0.30   0.1755414125374284E+01   0.1332710827520201E+01   0.1477984475201826E+01   0.6426400000000000E+03   0.1459764022611444E-13    1     -4.00      -0.20   0.1245972697710741E+01   0.1540633564543885E+01   0.1777167629372046E+01   0.6112200000000000E+03   0.5718386586661092E-13    1     -4.00      -0.10   -.1311461418732105E+01   -.1594149065989313E+01   0.1661344176980193E+01   0.3507800000000000E+03   0.6765588799377521E-14    3      I read this file using               data = ReadList["data.out", Number, RecordLists -> True];      The total length of the list is obtained, of course as               ntot = Length[data];      The list contains eight elements per row and the last of them is an integer taking values in the interval [0,8]. What I want is the following: (a). Count how many rows have 0 value at the last element (let's suppose there are `n0`), how many have 1, 2, 3, ... , 8. Then calculate the corresponding percentages `per0 = n0/ntot`, `per1 = n1/ntot`, etc. It could be nice if this was inside a DO loop with `i = 0,8`. (b). Count again percentages but using more than one criteria this time. For example, count how many rows have 1 at the last element and the value of the seventh element is smaller than `10^{-4}`. Any suggestions? **EDIT** Using's @Kuba's solution we have               {{5, 656}, {8, 640}, {2, 673}, {4, 663}, {1, 673}, {3, 663}, {6, 656}, {7, 640}, {0, 19}}      Is it possible to divide each sum automatically with `ntot` thus obtaining the percentages?               {{5, 656/ntot}, {8, 640/ntot}, {2, 673/ntot}, {4, 663/ntot}, {1, 673/ntot}, {3, 663/ntot}, {6, 656/ntot}, {7,640/ntot}, {0, 19/ntot}}      Also it would be great if they were sorted from 0 to 8 not randomly as they are now.


title: Mathematica not assigning variable correctly

text: So I have been fiddling with this the last hour and I just can't get it to work. I have 3 matrices of the same size which contain nothing but 0's in a list, I also have 3 matrices of the same size (not same as first 3) that have different values in them (also in a list). I have a Coordinate x and y value as well (x is right, y is down). I want to replace the values of a small part of the matrices containing 0's with their corresponding matrix (corresponding one is the ones with different values) e.g. $a=\begin{matrix}0&0&0&0&0\\\0&0&0&0&0\\\0&0&0&0&0\\\0&0&0&0&0\\\0&0&0&0&0\end{matrix}$ $b=\begin{matrix}1&2&3\\\4&5&6\end{matrix}$ $CoordX=2$, $CoordY=3$ When I use the function, I want the output to be $Output->\begin{matrix}0&0&0&0&0\\\0&0&0&0&0\\\0&1&2&3&0\\\0&4&5&6&0\\\0&0&0&0&0\end{matrix}$ This was my attempt at the function but for the three matrices instead               CreatePlaceholderMatrix[Matrix_,CoordX_,CoordY_]:=     (PlaceholderMatrix=Table[0,{3},{64},{64}];     For[i=CoordX,i==CoordX+Dimensions[Matrix[[1]][[1]]][[1]]-1,i++      For[j=CoordY,j==CoordY+Dimensions[Matrix[[1]][[1]]][[1]]-1,j++       For[k=1,k==3,k++,PlaceholderMatrix[[k,i,j]]=Matrix[[k,1,i,j]]       ]      ]     ];     PlaceholderMatrix)      The value of Matrix is in the form of (and if it helps is square):               MatrixForm/@ImageData[Image,"Byte",Interleaving->False]      and that is why I needed an extra [[1]] whenever I referred to Matrix (not sure exactly why but it was the only value that worked). Anyways, whenever I run the function, it just presents PlaceholderMatrix as 3 64*64 Matrices of 0's and nothing else. It seems as if it didn't even go through the for loop. I also want the final answer to be in the same Format as matrix, so I can do operations with it later and convert it to an image If anyone can explain why this is happening, or any alternative method that may work better, please tell.


title: How to color edges of a graph which has multiple edges connecting certain vertices

text: I'm studying BIBD(Balanced Incomplete Block Design) and want to draw some graphs by coloring their blocks in different colors, respectively. A block is a collection of edges (or vertices). For example, (10,4,2)-BIBD, with blocks               {{0,1,2,3},{0,1,4,5},{0,2,4,6},{0,3,7,8},{0,5,7,9},{0,6,8,9},      {1,2,7,8},{1,3,6,9},{1,4,7,9},{1,5,6,8},{2,3,5,9},{2,4,8,9},      {2,5,6,7},{3,4,5,8},{3,4,6,7}}      can be drawn by               GraphPlot[{0 -> 1, 1 -> 2, 2 -> 3, 0 -> 1, 1 -> 4, 4 -> 5, 0 -> 2, 2 -> 4,                 4 -> 6, 0 -> 3, 3 -> 7, 7 -> 9, 0 -> 6, 6 -> 8, 8 -> 9, 1 -> 2,                 2 -> 7, 7 -> 8, 1 -> 3, 3 -> 6, 6 -> 9, 1 -> 4, 4 -> 7, 7 -> 9,                 1 -> 5, 5 -> 6, 6 -> 8, 2 -> 3, 3 -> 5, 5 -> 9, 2 -> 4, 4 -> 8,                 8 -> 9, 2 -> 5, 5 -> 6, 6 -> 7, 3 -> 4, 4 -> 5, 5 -> 8, 3 -> 4,                 4 -> 6, 6 -> 7},        Method -> "CircularEmbedding",        BaselinePosition -> Top,        VertexLabeling -> True,        MultiedgeStyle -> 0.04]      ![enter image description here](http://i.stack.imgur.com/aBpcq.png) (This example is from the text book _Combinatorial Design - Stinson_ ). I want to draw each block in its own individual color. How do I do that?


title: Retrieving coordinate positions using ChemicalData for input to quanutm modelling software

text: I am trying to set up an input file for a quantum chemical modelling software. How do I obtain the (XYZ) coordinate positions in Angstroms using information obtained using ChemicalData. Have some initial input for fructose below:               ChemicalData["Fructose", "AtomPositions"]      What I expect in the output (just an example not the actual positions)                                Coordinates (Angstroms)      ATOM                X               Y               Z       1  C        2.5130891440   -0.0345557109   -0.2500995821       2  O         0.0459435630    3.3652982874    1.6477735205       3  H        0.0347565292    2.5110247340    0.2498797086     .......


title: DSolve results not what expected

text: I have the following formula:               s'[t] == 230.94 Tan[0.914743 - 0.138564 t]      When I solve this by hand I get:               s[t] == 1666.67*Log[Cos[0.914743-0.138564t]] + c      But Mathematica just returns:               DSolve[s'[t] == 230.94 Tan[0.914743 - 0.138564 t], s[t], t]      > s[t] == Integral[ 230.94 Tan[ 0.914743 - 0.138564t ]dt ] + c Do you know why it isn't solving the integral?


title: Finding 111 plane of Carbon Diamond

text: All, I looked at the example on the Mathematica Website with the Carbon Diamond Lattice. Example I am referring to I am wondering is there a way to highlight an individual plane such as the 111 or 110 plane? I like the example I am just not sure of my orientation. Cheers, BEn * * * Code:               Manipulate[      tet = PolyhedronData["Tetrahedron", "Faces"];      tetv = PolyhedronData["Tetrahedron", "VertexCoordinates"];      sp = {RGBColor[1, 1, 0.3], Sphere[{0, 0, 0}, sizes]};      bar1 = {RGBColor[0.2, 1, 1],         Cylinder[{{0, 0, 0}, {0, 0, Sqrt[2/3] - 1/(2 Sqrt[6])}}, sizec]};      bar2 = {RGBColor[0.3, 1, 1],         Cylinder[{{0, 0, 0}, {-(1/(2 Sqrt[3])), -(1/2), -(1/(2 Sqrt[6]))}},          sizec]};      bar3 = {RGBColor[0.4, 1, 1],         Cylinder[{{0, 0, 0}, {-(1/(2 Sqrt[3])), 1/2, -(1/(2 Sqrt[6]))}},          sizec]};      bar4 = {RGBColor[0.5, 1, 1],         Cylinder[{{0, 0, 0}, {1/Sqrt[3], 0, -(1/(2 Sqrt[6]))}}, sizec]};      sp4 = Map[Translate[sp, #] &, tetv];      base = {bar4, bar3, bar2, bar1, sp4, sp, If[tets, tet, {}]};      dia = Rotate[        Rotate[Map[Translate[base, #] &, tetv], -Cos[Sqrt[3]/3/2], {0, 1,           0}], Pi/4, {0, 0, 1}];           cub = If[cubs,         Scale[PolyhedronData["Cube", "Edges"],          Sqrt[2] {1, 1, 1}, {0, 0, 0}], {}];      diax = Table[Translate[{dia, cub}, {i Sqrt[2], 0, 0}], {i, n}];      diay = Table[Translate[{dia, cub, diax}, {0, i Sqrt[2], 0}], {i, n}];      diaz = Table[        Translate[{dia, cub, diax, diay}, {0, 0, i Sqrt[2]}], {i, n}];           Graphics3D[{dia, cub, diax, diay, diaz}, Boxed -> False,        SphericalRegion -> True, ImageSize -> 380],      {{n, 0, "frequency"}, 0, 2, 1, RadioButton},      {{sizec, 0.025, "cylinder size"}, 0, 0.5},      {{sizes, 0.1, "sphere size"}, 0, 0.5},      {{tets, False, "show tetrahedra"}, {True, False}},      {{cubs, False, "show cubes"}, {True, False}},       TrackedSymbols -> Manipulate]


title: How can I create a custom control which evaluates to a list of values or replacements?

text: I have a set of variables which are used in various places in my calculations (solving a system, initial conditions, etc.). In order to make this easier to deal with, I want to make a control-like thing which makes them easier to manipulate, rather than just using long lists of unlabeled values such as               calculateValues[{0, 0, π, 0.5, 3}]      So far I have something like this: ![](http://i.stack.imgur.com/FyYmo.png) This clearly doesn't work, and I expect in order to get it working properly I'll need to use `Interpretation` or more `Dynamic` incantations, but I can't figure out exactly what needs to happen. Any advice would be appreciated. Thanks in advance!


title: Mathematica: Retrieving PlotRange from Histogram

text: I know that one can retrieve PlotRange of a plot by using               AbsoluteOptions[plot,PlotRange]      but that won't work on Histogram. Here an example:               In[1099]:=          data = {-1.2056, -1.46192, -1.30053, -2.52879, -0.99636, -1.73904, -1.164,     -1.83398,-0.97505, -0.503256, -0.63802, -0.785963, -0.711821, -0.820439, -1.8699,     -3.9659, -1.4456, -1.67021, -1.42009, -2.5644, -1.45002, -1.27806, -1.66529,     -1.67073, -3.31102, -3.38638};     Histogram[%, PlotRange -> Automatic];     AbsoluteOptions[%, PlotRange]      When running the code I get the following message.               PlotRange::prng: Value of option PlotRange -> {{All,All},{-4.,0.}} is not All,     Full, Automatic, a positive machine number, or an appropriate list of range     specifications. >>      As I understood the documentation, PlotRange need to be of a certain format (e.g. two numbers) and `{{All,All},{-4.,0.}}` apparently does not fit to that format, for which reason Mathematica won't give me back the PlotRange of my histogram. Does anybody know how I can get the PlotRange of a Histogram anyway? By the way: In the first place, it will only make sense to get hold of the second value of PlotRange (in my example: `{-4.,0.}`) since one can calculate the first one for instance through `{0,Length[data]}`. Many thanks! John


title: How to use If to select arguments min & max in Range?

text: I want to call `Range[]` with its arguments depending on a condition. Say we have               checklength = {5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6}        I then want to call `Range[]` 13 times (the length of `checklength`) and do `Range[5]` when `checklength[[#]] == 5` and `Range[2, 6]` when `checklength[[#]] == 6`. `If[]` would seem an appropriate way to do it,               Range[If[checklength[[#]] == 5, 5, XXX]]& /@ Range[13]        but I don't know what to put for "XXX", since I need "2,6" there without any brackets. I've tried               Range[If[checklength[[#]]==5, 5, Flatten[{2,6}]]]& /@ Range[13]        but that doesn't help (in fact if you think about it, it shouldn't!). The problem is, I need an unbracketed pair of numbers to be treated as a single argument and I don't know how to do that. I can think of one quite messy solution,               Range[If[checklength[[#]] == 5, 1, 2], If[checklength[[#]] == 5, 5, 6]& /@ Range[13]        but I'd be disappointed if there's not a better way to do it. Even though this does the trick, the general question remains of how to treat unbracketed comma separated numbers as a single item.


title: How to export CSV from Mathematica?

text: I have previously been using               logf[x_, y_] := f[x, y] /. v_ :>(PutAppend[Unevaluated[f[x, y] = v;], "out.txt"];);      which produces output like `f[1,5]=2.566665345435;` on each line of the output file. How could I modify this to produce CSV file, i.e. output lines that look like               1, 5, 2.5666665345435     3, 4, 4.4353453453453     .     .      I tried the obvious guess                  logf[x_, y_] := f[x, y] /. v_ :>(PutAppend[Unevaluated[x, y, v], "out.txt"];);      but this does not work, as the word "Sequence" also gets exported. Also is this the best way I can export data from Mathematica to be read in by c++ code or is there a better way?


title: Button ImageSize x-dimension ignored

text: How can a small square button be created with `ImageSize -> {20,20}`? The x-dimension won't go below about 70. (Using version 9.0.1 on OS X.)               Grid[{       {Button["", ImageSize -> {10, 10}],        Button["", ImageSize -> {20, 20}]},       {Button["", ImageSize -> {30, 30}],        Button["", ImageSize -> {90, 30}]}},      Frame -> All, Alignment -> Left]      ![enter image description here](http://i.stack.imgur.com/R1eu6.png)


title: Efficient Langevin Equation Solver

text: This question is **not** about good algorithms for solving stochastic differential equations. It is about how to implement simple codes in Mathematica _efficiently_ exploiting Mathematica's programming methodology. (Hopefully, this may be useful in a stochastic processes course, for instance). A simple Langevin Eq. in a single random variable $X$ with additive noise reads \begin{equation} \dot{X} = f(X) + \zeta(t) \end{equation} where $f(X)$ is an arbitrary function and $\zeta(t)$ is a Gaussian white noise satisfying \begin{equation} E(\zeta(t)) = 0, \qquad \text{and} \qquad E(\zeta(t) \zeta(t')) = \Gamma \delta(t-t') \end{equation} To solve it we discretize time as $t = n dt$ and write \begin{equation} X_{n+1} = X_{n} + f(X_n)dt + \sqrt{\Gamma dt}\xi_n \end{equation} where $\xi_n \sim N(0,1)$. Here is my best implementation thus far:               Langevin[x0_, f_, G_, tf_, n_, m_: 1] :=          With[{dt = N[tf/n], s = N[Sqrt[ tf G/n]], xx0 = Table[x0, {m}]},          Transpose@NestList[ # + dt f[#] + RandomVariate[NormalDistribution[0, s], m] &, xx0, n]];      It takes as input a initial condition $x_0$, a function $f[x]$, the spectral density $\Gamma$ (here written as $G$), the final integration time $t_f$ and the number of integration points $n$. The time step is then $dt = t_f/n$. It also takes an optional argument $m$ corresponding to the number of realisations. The output consists of $m$ vectors $(X_0, X_1, X_2, \ldots,X_n )$ representing the stochastic realisations. Here is this program applied to the famous bi-stable potential given by $V(x) = -\frac{x^2}{2} + \frac{x^4}{4}$, so that $f(x) = - V'(x) = x-x^3$. It simulates a cold ($\Gamma=0.1$, in **data1** ) and a hot ($\Gamma=1$, in **data2** ) condition:               First@AbsoluteTiming[         data1 = Langevin[0, -#^3 + # &, 0.1, 10, 10^3, 2000];         data2 = Langevin[0, -#^3 + # &, 1, 10, 10^3, 2000];]     0.317665      To analyse the steady state I discard some initial points (80% in this example). This shows how the particle remains distributed close to the potential minima when it's cold, but spread out when it's hot:               Show[       Histogram[{Flatten[data1[[All, 800 ;; 1000]]], Flatten[data2[[All, 800 ;; 1000]]]}, Automatic, "PDF"],        Plot[-z^2/2 + z^4/4, {z, -1.8, 1.8}, PlotStyle -> Red],        AxesOrigin -> {0, 0}, PlotRange -> {-0.3, 1.2}]      ![enter image description here](http://i.stack.imgur.com/CYMG8.png) Now to the questions:   1. Any immediate improvements on this function?   2. Is there a better way through a different approach   3. Can I compile this function _as is_ to gain speed?    4. What about parallelisation?  A follow up would be to extend all this to systems of Langevin equations, replacing $X$, $f$ and $\zeta$ by vector valued functions. But, then, we loose the advantage of computing many realisations at once within the same NestList. I'll think more about this problem and if I come up with any ideas I'll update the question. Thank you all in advance and I hope this may be of use to other researchers as well. **Note:** here is an example using the idea of @R.M.: generate all random numbers at once and use an index through the iteration to move along:               LangevinBad[x0_, f_, G_, tf_, n_, m_: 1] := Block[{i = 1},          With[{dt = N[tf/n], r = RandomVariate[ NormalDistribution[0, N[Sqrt[ tf G/n]]], {n, m}], xx0 = Table[x0, {m}]},         Transpose@NestList[ # + dt f[#] + r[[i++]] &, xx0, n]]];      Maybe my coding is no good, but this version is really bad. Actually; Nest probably has an internal variable to keep track of what iteration step it is, but I have no idea if it is possible to access that. * * * ## ACL's version @ACL came up with a really efficient code, which I copy here for completeness.               (* This was originally called l4 by ACL *)          LangevinACL[fn_] := With[{f = fn},          Compile[{{x0, _Real}, {G, _Real}, {tf, _Real}, {n, _Integer}},          Module[{dt, s, state, r}, dt = N[tf/n];         s = N[Sqrt[tf G/n]];         state = ConstantArray[0., n];         state[[1]] = x0;         r = RandomVariate[NormalDistribution[0, s], n];         Do[state[[nc]] = state[[nc - 1]] + dt*f@state[[nc - 1]] + r[[nc - 1]], {nc, 2, n}];     state], CompilationTarget -> "C"]]      Then to compile for a given function use               ll = LangevinACL[(# - #^3) &];     AbsoluteTiming[dat = Table[ll[0, .1, 10, 10^3], {2000}];]      This code is always faster then the originally posted and allows for easy parallelisation. * * * ## Vector Equations In vector equations there are two possibilities; either all particles have the same fluctuating properties, in which case we usually write $E(\zeta_i(t) \zeta_j(t')) = \Gamma\delta_{i,j} \delta(t-t')$ for the components of the fluctuating vector; or each particle has a specific fluctuation: $E(\zeta_i(t) \zeta_j(t')) = \Gamma_{i,j} \delta(t-t')$, where $\Gamma_{i,j}$ are the entries of a covariance matrix. Here are two implementations of the former (all equations with the same fluctuation). The first is a simple variation of the original code, as suggested by @ACL, so that instead of computing several realisations at once, each function call evaluates only a single realisation, but for a vector system:               LangevinVec[x0_, f_, G_, tf_, n_] :=        With[{dt = N[tf/n], s = N[Sqrt[ tf G/n]], m = Length@x0},        NestList[ # + dt f[#] + RandomVariate[NormalDistribution[0, s], m] &, x0, n]];       Everything is exactly as in Langevin, except that on input $x_0$ should be an array of numbers. Note also that there is no failsafe to check if the function $f$ has the correct dimensionality! (it should be a mapping from $\mathbb{R}^m\rightarrow\mathbb{R}^m$, where $m$ is the length of $x_0$). The second implementation is again motivated by @ACL's code:               LangevinVecACL[fn_] :=        With[{f = fn},        Compile[{{x0, _Real, 1}, {G, _Real}, {tf, _Real}, {n, _Integer}},        Module[{dt, s, state, r, m},       m = Length@x0;       dt = N[tf/n];       s = N[Sqrt[tf G/n]];       state = ConstantArray[0., {n, m}];       state[[1]] = x0;       r = RandomVariate[NormalDistribution[0, s], {n, m}];       Do[state[[nc]] = state[[nc - 1]] + dt*f@state[[nc - 1]] + r[[nc - 1]], {nc, 2,        n}];       state], CompilationTarget -> "C"]]      Now to applications. Here is a model of ferromagnetism reminiscent of the 1D Ising system. There are $m$ random variables in $\vec{x} = (x_1,x_2,\ldots,x_m)$ representing spins in a linear chain of atoms. The interaction potential is given by \begin{equation} V(\vec{x}) = - \sum_{i=1}^m (\frac{a x_i^2}{2} - \frac{b x_i^4}{4}) - c \sum_{i=1}^m x_i x_{i+1} \end{equation} This refers to a bi- stable potential (as in the previous example) for each variable representing the magnetic order, plus a harmonic-type interaction between them. The corresponding force is \begin{equation} f_i = a x_i - bx_i^3 + c(x_{i-1}+x_{i+1}) \end{equation} In matrix notation I can write \begin{equation} f(\vec{x}) = A\vec{x} - b \vec{x}^3 \end{equation} where $\vec{x}^3$ stands for $(x_1^3,x_2^3,\ldots)$ and $A$ is an $m\times m$ tridiagonal matrix with of the form \begin{equation} A = \left( \begin{array}{ccccc} a & c & 0 & 0 & c \\\ c & a & c & 0 & 0 \\\ 0 & c & a & c & 0 \\\ 0 & 0 & c & a & c \\\ c & 0 & 0 & c & a \end{array} \right) \end{equation} Note that I am using periodic boundary conditions $x_{m+1}=x_1$ and thence the c's in the upper-right and lower-left corners. Here is $f(x)$ in Mathematica               m = 100; a = 2.0; b = 3.0; c = 3;     A = SparseArray[{         {m, 1} -> c, {1, m} -> c,          Band[{1, 1}] -> a, Band[{2, 1}] -> c, Band[{1, 2}] -> c},          {m, m}];     f[x_] := A.x - b x^3      The choice of parameters is somewhat arbitrary and perhaps this definition of $f(x)$ is not the fastest due to the dot product. I will use ACL's version LangevinVecACL, which is faster. So I first compile it               llvec = LangevinVecACL[f];      Here are two data sets for $\Gamma = 0.01$ (pretty cold) and $\Gamma = 10$ (pretty hot).               x0 = ConstantArray[0.0, m];     AbsoluteTiming[        data1 = llvec[x0, .01, 4, 10^4];        data2 = llvec[x0, 10, 4, 10^4];     ]      The following code shows the steady-state distribution of a single realisation               GraphicsGrid[{Map[       ListPlot[#, PlotRange -> {{-1, m + 1}, {Floor@Min@#, Ceiling@Max@#}},          Filling -> Axis, Frame -> True, BaseStyle -> 14,          FrameLabel -> {"Position", "Magnetization"}] &,       {Last@data1, Last@data2}]}, ImageSize -> {600}]      ![enter image description here](http://i.stack.imgur.com/AY7SQ.png) As can be seen, at cold temperatures the system tends to divide itself into domains with all spins chunked either "up" or "down"; conversely, at high temperatures the domain configuration is clearly degraded. The following function animates the time evolution of the system.               animateSpinChain[data_] :=  Animate[ListPlot[data[[i]],         PlotRange -> {{-1, m + 1}, {Floor[Min[data]], Ceiling[Max[data]]}},        Filling -> Axis], {i, 1, Length@data, Floor[Length@data/100]}]


title: Finding and interpreting errors

text: This sounds like a fairly trivial question, but I can't think of any way to solve it. I am doing an extensive parameter sampling where a set of ODEs is used together with `NDSolve` to find values of the dependent variables at certain time points. Yet, I am getting several different errors (e.g. convergence errors) when using **certain** parameters. Thus, I would like to ask your help in getting a way to **find which parameters yield the errors** , not how to fix the errors themselves. The algorithm uses the system of ODEs (with defined initial conditions) and defines the function to compute the concentrations at various time points. It is then used to do the parameter sampling               SysODEs={X'[t]==ba+k1 A - b1 X[t], Y'[t]==k2 X[t]-v1 Y[t]-k1,etc};          DFunction[{a1_,b1_,v1_,k1_},ba_]:=         Block[{sol1,c1,c2},         sol1=NDSolve[SysODEs/.k2->2,{X,Y},{t,0,300}];         c1=X[100]/.sol1;         c2=Y[300]/.sol1;         {c1,c2}         ]          SampleP=Flatten[         Table[{h, j, k, l}, {h, 0, 5, 1}, {j, 0.1, 0.9, 0.1}, {k, 1,10, 1}, {l, 5, 10, 1}],3];          ParallelMap[DFunction[#, 0.1] &, SampleP]      **Problem:** I want to know which values of `SampleP` yield errors. Because my original functions `SampleP`, `DFunction` etc. are much more complex, I didn't include them in here (`SampleP` has size ~200 000 in my problem). Is there any way of doing it? I was thinking about some kind of `Trace`, but this will give me too much unneeded information. **Edit:** I was searching and found this link with information about the functions `MLCreateMark()` and `MLSeekMark()` that are used in `MathLink`. Maybe this helps in finding something similar in Mathematica?


title: Creating Multi-Tabbed Grid with Preserved Contents and Overview Grid

text: I am in the process of creating an application/panel that will aide me in scheduling hours for my staff of ten or more. I am hoping to create a multi- tabbed grid within which I may collect data about my staff and ultimately create a final schedule based on their choices. I have started the code, but I find myself stuck in a couple places: creating a grid that pulls that data from the other grids to give an overview of the schedule (in order to find overlapping hours, holes in the schedule, etc.), saving the data in the input fields once entered, and counting the number of check boxes that are ticked on each tab. My code can be found below, any guidance, help, or thoughts would be very helpful at this point. Thank you. ![Mathematica graphics](http://i.stack.imgur.com/NL47R.png)               f = Enabled -> False;     m = ImageMargins -> 20;     week =       Grid[{         {"", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",           "Saturday", "Sunday"},         {"8:00 AM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[f], Checkbox[f]},         {"9:00 AM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"10:00 AM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"11:00 AM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"12:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"1:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"2:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"3:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"4:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"5:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"6:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"7:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"8:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"9:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"10:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"11:00 PM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"12:00 AM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"1:00 AM", Checkbox[m], Checkbox[m], Checkbox[m], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[m]},         {"2:00 AM", Checkbox[f], Checkbox[f], Checkbox[f], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[f]},         {"3:00 AM", Checkbox[f], Checkbox[f], Checkbox[f], Checkbox[m],           Checkbox[m], Checkbox[m], Checkbox[f]}         }, Frame -> All];     Clear[ln, fn, ws, ln2, fn2, ws2, ln3, fn3, ws3]     input =       Panel[        Grid[{          {""},          {Style["Front Desk Assignment Preferences", 14, Bold],            SpanFromLeft, SpanFromLeft, SpanFromLeft},          {""},          {"Last Name:", InputField[Dynamic[ln], String], SpanFromLeft,            SpanFromLeft},          {"First Name:", InputField[Dynamic[fn], String], SpanFromLeft,            SpanFromLeft},          {"-----------------------------------------------", SpanFromLeft,            SpanFromLeft, SpanFromLeft},          {"Workstudy:", RadioButtonBar[2, {1 -> "Yes", 2 -> "No"}],            SpanFromLeft, SpanFromLeft},          {"Workstudy Amount:  $",                InputField[Dynamic[n], Number, FieldSize -> 10], SpanFromLeft,                SpanFromLeft},              {"-----------------------------------------------", SpanFromLeft,                SpanFromLeft, SpanFromLeft},              {"Weekend Preference:",                RadioButtonBar[3, {1 -> "A", 2 -> "B", 3 -> "Either"}],                SpanFromLeft, SpanFromLeft},              {""},              {"-----------------------------------------------", SpanFromLeft,                SpanFromLeft, SpanFromLeft},              {Style[                "Please select the hours you are interested in working from \         the table below:", Bold], SpanFromLeft, SpanFromLeft, SpanFromLeft},              {week, SpanFromLeft, SpanFromLeft, SpanFromLeft},              {""}              }, Alignment -> Left]];         input2 =           Panel[            Grid[{              {""},              {Style["Front Desk Assignment Preferences", 14, Bold],                SpanFromLeft, SpanFromLeft, SpanFromLeft},              {""},              {"Last Name:", InputField[Dynamic[ln2], String], SpanFromLeft,                SpanFromLeft},              {"First Name:", InputField[Dynamic[fn2], String], SpanFromLeft,                SpanFromLeft},              {"-----------------------------------------------", SpanFromLeft,                SpanFromLeft, SpanFromLeft},              {"Workstudy:", RadioButtonBar[2, {1 -> "Yes", 2 -> "No"}],                SpanFromLeft, SpanFromLeft},              {"Workstudy Amount:  $",                InputField[Dynamic[n2], Number, FieldSize -> 10], SpanFromLeft,                SpanFromLeft},              {"-----------------------------------------------", SpanFromLeft,                SpanFromLeft, SpanFromLeft},              {"Weekend Preference:",                RadioButtonBar[3, {1 -> "A", 2 -> "B", 3 -> "Either"}],                SpanFromLeft, SpanFromLeft},              {""},              {"-----------------------------------------------", SpanFromLeft,                SpanFromLeft, SpanFromLeft},              {Style[                "Please select the hours you are interested in working from \         the table below:", Bold], SpanFromLeft, SpanFromLeft, SpanFromLeft},              {week, SpanFromLeft, SpanFromLeft, SpanFromLeft},              {""}              }, Alignment -> Left]];         input3 =           Panel[            Grid[{              {""},              {Style["Front Desk Assignment Preferences", 14, Bold],                SpanFromLeft, SpanFromLeft, SpanFromLeft},              {""},              {"Last Name:", InputField[Dynamic[ln3], String], SpanFromLeft,                SpanFromLeft},              {"First Name:", InputField[Dynamic[fn3], String], SpanFromLeft,                SpanFromLeft},              {"-----------------------------------------------", SpanFromLeft,                SpanFromLeft, SpanFromLeft},              {"Workstudy:", RadioButtonBar[2, {1 -> "Yes", 2 -> "No"}],                SpanFromLeft, SpanFromLeft},              {"Workstudy Amount:  $",            InputField[Dynamic[n3], Number, FieldSize -> 10], SpanFromLeft,            SpanFromLeft},          {"-----------------------------------------------", SpanFromLeft,            SpanFromLeft, SpanFromLeft},          {"Weekend Preference:",            RadioButtonBar[3, {1 -> "A", 2 -> "B", 3 -> "Either"}],            SpanFromLeft, SpanFromLeft},          {""},          {"-----------------------------------------------", SpanFromLeft,            SpanFromLeft, SpanFromLeft},          {Style[            "Please select the hours you are interested in working from \     the table below:", Bold], SpanFromLeft, SpanFromLeft, SpanFromLeft},          {week, SpanFromLeft, SpanFromLeft, SpanFromLeft},          {""}          }, Alignment -> Left]];     final = TabView[{"Worker 1" -> input, "Worker 2" -> input2,         "Worker 3" -> input3}]


title: Plotting plain data (single value lists) in 3D

text: **Some Chemistry data sets** I am trying to plot some titration data with Mathematica. I have done 4 experiments and gathered around 70 pH points (one for each milliliter) during each session, and therefore I have 4 sets of pH measurements. Now, in each experiment I used a different concentration of an extra compound (something that affects the titration), so the curves should, when plotted in 3D, show a nice behavior, since the precipitant forces the protons out of the acid (the Chemistry part here; may ignore). * * * Now, this curves are not meant to be plotted with equals distances, as in the image and what I've managed to do. ![H3PO4 titration with KOH and CaCl2](http://i.stack.imgur.com/Hmvzp.png) The standard why of plotting these 4 curves is by placing them at the $\log_{10}$ of the concentration of the extra compound ($\text{CaCl}_2$ for those who might be interested). My data looks like this:               L1 = {1.63, 1.67, 1.71, 1.76, 1.80, 1.85, 1.90, 1.94, 1.99, 2.03,        2.08, 2.11, 2.16, 2.21, 2.27, 2.35, 2.43, 2.52, 2.62, 2.72, 2.86,        3.05, 3.34, 4.06, 4.93, 5.28, 4.25, 4.26, 4.30, 4.37, 4.41, 4.48,        4.55, 4.60, 4.67, 4.78, 4.85, 4.94, 5.05, 5.19, 5.34, 5.49, 5.70,        5.99, 6.32, 6.76, 7.52, 8.49, 9.56, 10.61, 10.90, 11.09, 11.23,        11.33, 11.41, 11.48, 11.54, 11.59, 11.64, 11.68, 11.71, 11.73,        11.77, 11.80, 11.83, 11.85, 11.88, 11.89, 11.90, 11.91, 11.93}          L2 = {1.36, 1.44, 1.49, 1.55, 1.62, 1.68, 1.74, 1.82, 1.89, 1.98,        2.04, 2.09, 2.16, 2.26, 2.35, 2.47, 2.63, 2.83, 3.18, 4.23, 4.68,        4.89, 3.95, 4.12, 4.07, 4.07, 4.11, 4.15, 4.21, 4.27, 4.34, 4.42,        4.50, 4.59, 4.68, 4.81, 4.93, 5.11, 5.37, 5.78, 7.28, 10.28, 10.92,        11.17, 11.35, 11.45, 11.54, 11.62, 11.67, 11.72, 11.77, 11.81,        11.84, 11.91, 11.93, 11.95, 11.97, 11.98, 12.00, 12.02, 12.04,        12.05, 12.06, 12.08, 12.09, 12.10, 12.11, 12.12, 12.14, 12.14,        12.15, 12.16}          L3 = {1.48, 1.57, 1.62, 1.66, 1.72, 1.75, 1.81, 1.87, 1.92, 2.06,        2.10, 2.16, 2.21, 2.28, 2.35, 2.43, 2.51, 2.62, 2.75, 2.95, 3.19,        3.64, 4.10, 4.61, 4.84, 4.16, 4.11, 4.11, 4.00, 4.07, 4.12, 4.16,        4.19, 4.24, 4.32, 4.35, 4.40, 4.46, 4.53, 4.63, 4.70, 4.79, 4.92,        5.07, 5.23, 5.55, 6.23, 7.50, 7.87, 9.68, 10.49, 10.81, 11.01,        11.13, 11.24, 11.31, 11.37, 11.41, 11.46, 11.49, 11.50, 11.54,        11.57, 11.60, 11.62, 11.64, 11.67, 11.68, 11.70, 11.71, 11.72,        11.73, 11.74, 11.75, 11.5, 11.77, 11.78, 11.80, 11.81, 11.80, 11.82,        11.83}          L4 = {1.79, 1.84, 1.98, 2.01, 2.04, 2.08, 2.12, 2.16, 2.20, 2.24,        2.30, 2.34, 2.39, 2.43, 2.50, 2.58, 2.66, 2.76, 2.89, 3.02, 3.24,        3.72, 4.95, 5.47, 5.68, 4.77, 4.74, 4.82, 4.89, 5.00, 5.15, 5.33,        5.58, 5.89, 6.22, 6.46, 6.64, 6.80, 6.97, 7.11, 7.30, 7.52, 7.82,        8.55, 10.10, 10.70, 10.97, 11.13, 11.21, 11.33, 11.40, 11.46, 11.52,        11.58, 11.62, 11.66, 11.70, 11.70, 11.75, 11.77, 11.80, 11.83,        11.85, 11.87, 11.89, 11.91, 11.92, 11.94, 11.95, 11.97, 11.98}          L5 = {2.07, 2.09, 2.12, 2.17, 2.23, 2.26, 2.28, 2.31, 2.41, 2.45,         2.48, 2.52, 2.58, 2.63, 2.69, 2.76, 2.85, 2.95, 3.14, 3.28, 3.48,         3.82, 5.11, 5.76, 6.06, 6.23, 5.72, 5.83, 6.05, 6.28, 6.47, 6.50,         6.70, 6.82, 6.96, 7.08, 7.18, 7.22, 7.35, 7.47, 7.60, 7.74, 7.91,         8.15, 8.51, 9.54, 10.17, 10.63, 10.98, 11.22, 11.37, 11.49, 11.59,         11.68, 11.74, 11.79, 11.84, 11.90, 11.92, 11.95, 12.02, 12.07,         12.11, 12.15, 12.18, 12.20, 12.22, 12.24, 12.25, 12.28, 12.31,         12.34, 12.36}      So, each value there is the y-value, the number of item is the x-value and the z-value (or whatever it must be) is, for each complete set, the logarithm of the concentration. Any help is appreciated! * * * Example (extract from `L1`):               L = {{1.63,0,-0.7}, {1.67,1,-0.7}, {1.71,2,-0.7}, {1.76,3,-0.7}, {1.80,4,-0.7}, {1.85,5,-0.7}}      * * * The coordinates:               {{L3, L1, L2, L4, L5}, {Log10[0.199], Log10[0.099], Log10[0.15],        Log10[0.054], Log10[0.0265]}}