How to use TransformationFunctions on a compound expression?

I was trying to answer this question but having hard time with the correct way to write the transformation rule. Trying to write a rule to transform `Gamma[1/2 + n]` to `Sqrt[Pi] (Factorial2[2 *(n - 1/2) - 1])/2^(n - 1/2)`. Will worry about the conditions when this transformation is valid later on. I now can't even make `Simplify` use this rule. The rule is being invoked (I add a `Print` and see it there), but the final result returned by the transformation function is not being used or returned) I looked at this answer and tried what is there, but still no success. These are my attempts. The result of the `Simplify` command should return `Sqrt[Pi] (Factorial2[2 *(n - 1/2) - 1])/2^(n - 1/2)` in this example. I am not sure if it is scoping issue. Can one use an `If` or `Cases` in the transformationFunction or must it be based only on the syntax of `/. :>`? I wish help has more examples. Only 3 basic examples are shown and that is it. When an expression being used inside the tranformation function (like in this case, `Gamma[1/2 + n]` then `n` here is taken as global symbol, right? I mean it will not have a $$n or it? That what seems to be the case. So I do not see why any of these are not working.               ClearAll[n, f, e];     f = # /. Gamma[1/2 + n] :> Sqrt[Pi] (Factorial2[2*(n - 1/2) - 1])/2^(n - 1/2) &     Simplify[Gamma[1/2 + n], TransformationFunctions -> {Automatic, f}]      ![Mathematica graphics](http://i.stack.imgur.com/uHxEP.png)               ClearAll[n, f, e];     f[e_] := If[MatchQ[e, Gamma[1/2 + n]], Sqrt[Pi] (Factorial2[2 *(n - 1/2) - 1])/2^(n - 1/2), e]     Simplify[Gamma[1/2 + n], TransformationFunctions -> {Automatic, f}]      ![Mathematica graphics](http://i.stack.imgur.com/EcC8w.png) http://reference.wolfram.com/mathematica/ref/TransformationFunctions.html


Locator to show coordinates of plot

# Old I would like to make the locator follow a plot, giving the coordinates as it moves. I don't really know where to start with this one, but I would like the dynamic plot to look something like this: ![enter image description here](http://i.stack.imgur.com/nzDJ9.gif) the code for which is as follows:               Plot[{Sqrt[x]}, {x, 0, 10}, PlotRange -> {{0, 12}, {0, 3.5}},     Epilog -> {PointSize[Large], Red, Point[{4, 2}]}]      with the locator showing its coordinates as it is moved along the plot. Obviously, the movement of the locator needs to be constrained to the plot, just as it is constrained to the coordinates of the circle in this Wolfram Documentation example: ![enter image description here](http://i.stack.imgur.com/X43vW.gif) by the following code:               Deploy[DynamicModule[{p = {1, 0}}, Graphics[{Red, Disk[],      Locator[Dynamic[p, (p = Normalize[#]) &]]}, PlotRange -> 1.5]]]      basically, so it behaves in a similar way to Google graphs: ![enter image description here](http://i.stack.imgur.com/D4jnt.gif) where the coordinates appear to the top right of the plot. # New @Timothy Wofford The solution you gave works great for functions like Sqrt[x], but runs into difficulties when complex values are encountered. For example: ![enter image description here](http://i.stack.imgur.com/3fWht.gif) generated by the code:               f[x_] := ((\[Pi]^x/Zeta[x])^(1/x)/\[Pi]) - 1/Zeta[x]     Manipulate[Plot[f[x], {x, 0, 10}, Epilog -> {PointSize[Large], Red,      Tooltip[Point[#], #] &@{p[[1]], f[p[[1]]]}}, PlotLabel ->      {p[[1]], f[p[[1]]]}], {{p, {1, 0}}, Locator, Appearance -> None},      AppearanceElements -> None]      shows as a red screen when the locator moves off screen into the imaginary values, generating an error screen as follows: ![enter image description here](http://i.stack.imgur.com/cHb7J.gif) Is there any way of preventing this from happening? - ie, from stopping the locator moving past {1,0}?


Why is Mathematica's expansion of expressions with square roots so slow?

_Mathematica_ expansion of expressions with symbols isn't slow, but with square roots it is very slow. In Maple or Mupad both are fast: with square roots they both take less than a second. Here is an example.               Expand[(a + b + c + d + e)^100]; // Timing          Expand[(Sqrt[2] + Sqrt[3] + Sqrt[5] + Sqrt[6] + Sqrt[7])^100]; // Timing      ![enter image description here](http://i.stack.imgur.com/CGLAE.png) ![enter image description here](http://i.stack.imgur.com/8fRmw.png) Can you reproduce this? I used Mathematica9.0.0.0 and Maple16 on windows7 64 bit. **Updated** Maple and Mupad also give the exact result, please see following picture. It's equal to Mathematica' result. ![enter image description here](http://i.stack.imgur.com/TxHrL.png)


Working around behaviour of EdgeRenderingFunction

One can make graphs               GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 1, 1 -> 1, 5 -> 5}]      and one can generalize the input such that one labels edges                GraphPlot[{1 -> 2, {2 -> 3, "my favorite edge"}, 3 -> 4, 4 -> 5,  5 -> 1, 1 -> 1, 5 -> 5}]       Now in the Mathematica help for GraphPlot, under Options and then EdgeRenderingFunction one finds the example               GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 1, 1 -> 1, 5 -> 5},      EdgeRenderingFunction -> (If [      First[#2] == Last[#2], {Red, Arrow[#1]}, {GrayLevel[0.5],        Arrow[#1]}] &)]      I want to use this to change the color of edges according to their naming, i.e. if the edge says "my favorite edge", then that edge should be green. Problem is that once I use EdgeRenderingFunction,               GraphPlot[{1 -> 2, {2 -> 3, "my favorite edge"}, 3 -> 4, 4 -> 5, 5 -> 1, 1 -> 1, 5 -> 5},      EdgeRenderingFunction -> (If [      First[#2] == Last[#2], {Red, Arrow[#1]}, {GrayLevel[0.5],        Arrow[#1]}] &)]      the data beyond "2 -> 3" gets ignored. How to solve this problem? (I don't really have to use EdgeRenderingFunction to change the color, I just want more than just the names to point out some special edges.)


Problem in reading data from a text file with two variables

I want to read in a data file, test.txt, in Mathematica. The file has the following content:               7                                                          9.339746404911912e-01 2.390665790330537e-16     -9.660816659011047e-01 -3.665687545173490e-16          1.315811450789676e+00 -3.728808440402881e-16     5.351989286996225e-02 -4.983348938581225e-17          4.472964563970432e-01 2.924635360279648e-17     6.075434861678513e-01 -5.468444707473763e-17          -4.491183862398205e-01 1.316628013212084e-16     1.433072380629653e-01 1.825593170558248e-16          1.468347618480511e-01 3.826623805151808e-16     -5.510211996466368e-01 9.127627039612340e-18          -5.773829817302568e-16 1.018116881684214e-17     -5.090584408421044e-18 -2.886914908651284e-16          2.973875045664112e-02 2.112972391320319e-16     -2.020849668577390e-01 4.590918574118308e-18      I want to first read the top most integer number which says how many groups of two complex numbers I have. In this case it is 7 groups each of 2 complex numbers. Then I want to take each of these groups, which contains two lines, and assign the first line to `x[1]` and the second line to `x[2]`. e.g., from the first group, I should have `x[1]={9.339746404911912 * 10^(-01) + I 2.390665790330537* 10^(-16)}` and `x[2] = {-9.660816659011047 * 10^(-01) + -3.665687545173490 * 10^(-16)}`. So, I wrote the following code:               SetDirectory["C:\\your_dir_containing_the_data_file"];     Dim = 2;     streamread = OpenRead["test.txt"];     num = Read[streamread, Number];     Skip[streamread, String];     Print[num];     Do[       tmp[j] = {};       Do[        tmp[j] = Append[tmp[j], Read[streamread, {Number, Number}]],        {i, Dim}         ];       tmp[j] = tmp[j] /. {x_, y_} -> x + I  y,       (*Print[Chop[Equations/.Thread[Var-> soltmp[MainCounter]]]],*)       {j, num}       ];          maintmp = Table[tmp[j], {j, num}];     Close[streamread];      But when I execute it, it gives `maintmp`               {{0.933975 - 0.966082 I,        2.39067*10^-16 - 3.66569*10^-16 I}, {1.31581 +         0.0535199 I, -3.72881*10^-16 - 4.98335*10^-17 I}, {0.447296 +         0.607543 I,        2.92464*10^-17 - 5.46844*10^-17 I}, {-0.449118 + 0.143307 I,        1.31663*10^-16 + 1.82559*10^-16 I}, {0.146835 - 0.551021 I,        3.82662*10^-16 + 9.12763*10^-18 I}, {-5.77383*10^-16 -         5.09058*10^-18 I,        1.01812*10^-17 - 2.88691*10^-16 I}, {0.0297388 - 0.202085 I,        2.11297*10^-16 + 4.59092*10^-18 I}}      In short, it screws up the real and imaginary parts of each number to one another. Now, surprisingly, the problem occurs only if `Dim=2`, i.e., if the groups are made of exactly `2` complex numbers. If they were made of `1` or `2+`, then everything is fine. I think Mathematica gets confused here at some point for `Dim=2`. Do you guys know what's going wrong here? Thanks!


Arbitrary number of variables in Module, Block, etc

How do I specify an arbitrary number of variable names and initialize them inside of a Module or Block? For example, I want to do something like:               Module[Join[{mu = 100}, Array[(Symbol["lambda"<> ToString@#] = 0) &, 10]],           lambda3 = 7; Print[mu <> lambda2]; Print[mu <> lambda3];          ]      Instead, I get all sorts of errors about improper local variable definitions. I tried wrapping things in Evaluate, or making my own Hold and then Release sequence, but nothing I did seemed to work. Any help would be much appreciated! Best wishes, Andy


How can I define a Listable function only apply to a vector?

Consider the function `f` which should behave as               f[{{1, 2}, {3, 4}, {5, 6, 7}}]      > >     {f[{1, 2}], f[{3, 4}], f[{5, 6, 7}]} >   The following code doesn't worked as expectation               fromDig[ls_?VectorQ] := 10^Range[Length@ls - 1, 0, -1].ls;     SetAttributes[fromDig, Listable];     fromDig@{{1, 2}, {3, 4}, {5, 6}}      I figured out a way, using `Compile`,               Clear["Global`*"];     cfromDig = Compile[{{A, _Integer, 1}},      10^Range[Length@A - 1, 0, -1].A, RuntimeAttributes -> {Listable}];     cfromDig[{{1, 2}, {3, 4}, {5, 6}}]      Is there a better way?


Find the position of a string element, knowing only part of the string

I have a list, e.g.:               list = {1, 2, 3, "Element 1", 4, 5, "Element 2", "Something else 1", "etcetera"}      Now, I want all elements starting with `"El"`. Using `Position`, I could find the position of e.g. `"Element 1"`:               Position[list, "Element 1"]      But, I would like to know the positions of `"Element 1"` and `"Element 2"`, as both start with `"El"`. So, I would like to have something like               Position[list, "El"_]      I just can't get something like this to work. Thanks for any help.


FullSimplify used with Assuming giving unexpected results

Can someone shed some light on why               Assuming[{x ∈ Reals}, x (Sign[x]^2 - 1)] // FullSimplify      returns               x (-1 + Sign[x]^2)      instead of zero please?   I know one can not expect `FullSimplify` to perform miracles but this example does seem pretty obvious.


Replacing gamma at half integers by double factorial

It is well-known that for any positive integer $n$ the equality $\Gamma(n+\frac12)=\sqrt\pi\,(2n-1)!!/2^n$ holds, where $!!$ stands for the double factorial. I am using `FullSimplify[expr,Assumptions -> n \[Element] Integers]` on certain expression `expr`, and the output contains $\Gamma(-\frac12+n)/\sqrt\pi$. My question is: how can I instruct Mathematica to perform the simplification "$\Gamma(n+\frac12)=\sqrt\pi\,(2n-1)!!/2^n$ whenever $n$ is a positive integer" ? Of course, I want an answer no limited to this specific situation. **Edit:** What I want is to "add" the simplification rule above to the list of simplifications included in `FullSimplify`, not merely "replace" the "string" $\Gamma(\cdots)$ by $\cdots !!/\cdots$.


How do I create matrices with arbitrary list restrictions?

I want to randomly generate a square matrix of dimension n with entries in the list StartingEntries, and also satisfying that for any such matrix M, the matrix Inverse[IdentityMatrix[n] - M] has entries coming from the list EndingEntries. Below is my (not-working) code for the case dimension 3. It's the last line that keeps generating error messages. I'd like to know why. (Also if anyone can think of a better way of solving this problem, I'm all ears!)               (*generate 10,000 possible matrices.*)     mat = {{#1, #2, #3}, {#4, #5, #6}, {#7, #8, #9}} &     candidates = Apply[mat, RandomChoice[StartingEntries, {10000, 9}], 1]          (*get all matrices M so that I-M is invertible*)     invertibleCandidates = Select[candidates, Det[IdentityMatrix[3] - #] != 0 &]      So far so good. Now we want to make sure that the inverted matrix has the correct entries. I couldn't find a boolean Subset function in Mathematica, so I made my own:               SubsetQ[x_, y_] := (Length[Intersection[x, y]] == Length[x])      Now test to see if the inverse has entries lying inside EndingEntries. This is the line that keeps failing on me and I don't know why.               newerCan = Select[invertibleCandidates, SubsetQ[Flatten[Inverse[IdentityMatrix[3] - #]], EndingEntries] &]      Edit 1: SubSetQ modified to be               SubsetQ[x_, y_] := (Length[Intersection[DeleteDuplicates[x], DeleteDuplicates[y]]] == Length[DeleteDuplicates[x]])      Edit 2: The error messages I'm getting are               DeleteDuplicates::normal: Nonatomic expression expected at position 1 in DeleteDuplicates[nums].     Intersection::heads: Heads DeleteDuplicates and List at positions 2 and 1 are expected to be the same.     Inverse::luc: "Result for Inverse of badly conditioned matrix {{0.6,-0.7,-0.2},{-0.4,0.6,-0.1},{-0.2,-0.3,1.}} may contain significant numerical errors."     Inverse::sing: "Matrix {{0.7,-0.8,0.},{0.,0.9,-0.9},{-0.7,0.,0.8}} is singular."      I'm assuming that the first three error messages are because I'm not formatting the input to SubSetQ in the appropriate list format, but I don't know how to fix it, and I don't know why I'd be getting the "singular" error message.


Find asymptotics of Sum[2^i*Binomial[n-i-1,2*n/3-1],{i,0,n/3}]

I have an expression               2^n / Sum[ 2^i Binomial[ n - i - 1, 2n/3 - 1], { i, 0, n/3}]      > >     2^n / ( Binomial[ -1 + n, -1 + (2 n)/3] Hypergeometric2F1[ 1, -(n/3), 1 > - n, 2]) >   I would like to find if there is an exact asymptotic expression for this for large $n$.   I suspect it is something like $\;\sqrt{n}\;\;1.06^{\;n}\quad$ from numerical experiments.   Is it possible to work out it out exactly using _Mathematica_?


Replacing variables in an RSolve expression

I have a recursive expression, which is something like: $$ a(n,x)=f(x,y,m)\,a(n-1,x)+g(x,y)\,a(n-1,y) $$ where $f(x,y,m)$ and $g(x,y)$ are known. So the second $a$ depends on $y$ rather than $x$. I tried to get it into `RSolve` with:               RSolve[{a[n] == f[x, y, n]*a[n-1] + g[x, y]*(a[n] /. {x -> y}), a[0]==1}, a[n], n]      but the `/.{x ->y}` part doesn't seem to change anything. How can I do the replacement?


What are all the named Mathematica styles?

This question came to mind because of this answer to a recent question. Under Style, the _Mathematica_ Documentation Center says the following about named styles. > A few common named styles include: "Button", "Graphics", ..., "Title" Altogether it lists 13 named styles, but the phrase "a few of" implies there are more. Other cell styles such as "SubTitle" and "SubSubSection" come to mind. But strings other than those naming cell styles evidently qualify as named styles. In the referenced answer, Mr.Wizard uses "TI" as a named style for the "Times Italic" font.               Style["The quick brown fox ...", "TI"]      ![TI.png](http://i.stack.imgur.com/pYZxH.png) By trial and error, I have found these addition named styles:               "TR"   (Times Roman -- plain Times)     "TB"   (Times Bold)     "TBI"  (Times Bold Italic)     "SR"   (Sans serif Roman -- plain sans serif)     "SB"   (Sans serif Bold)     "SO"   (Sans serif Oblique)     "SBO"  (Sans serif Bold Oblique)      I wonder what other named styles exist, other than cell styles, that _Mathematica_ will accept in a `Style` expression. I further wonder what sort of spelunking in _Mathematica_ would turn them up.


Simplifying with noncommutative multiplication

I am trying to do some quantum algebra computations in _Mathematica_. Up to now I was able to make the noncommutative multiplication linear and to factorize powers. However, I still have some issues with associativity. In particular, I would like to be able to remove brackets expressions like `a ** ( b ** c )` and get `a ** b ** c`. The reason for that is that I already have a procedure that substitutes `a^2 ** b` to `a ** a ** b`, but this doesn't work when I have brackets `(a ** ( a ** b ))`.   Does anyone know how to overcome this problem?


Variable Boundaries on ParametricPlot3D

Is there any way to plot correctly using the `ParametricPlot3D` command with one of variable's boundaries defined in function of the other ? In the example given here the variables are `u` and `r`.   * `r` boundaries are set from `0.01` to `d/2`   * `u` boundaries are set from the lower limit function `x0(r)` and upper limit function `corda(r)-x0(r)` I noticed a problem on the leading edge of this wing profile present only when using a variable boundary, while if I use a constant boundary limit the wing is plotted correctly. Any ideas on how to solve this problem? The code is presented below for reference.               c = 1;  e = 2;  d = 0.35;     (*Distribuição de Corda*)     corda[r_, c_] := c ( -30.04*r^3 + 4.65*r^2 + 0.116*r + 0.01)     (*Distribuição de Espessura*)     naca[r_, e_] := e ( -47.511*r^3 + 13.346*r^2 - 1.3953*r + 0.1511)     x0[r_, c_] := 0.4 corda[r, c]     (*Imagem do Perfil*)     FNaca[u_, r_, c_, e_] :=         (naca[r, e]/0.2) corda[r,c] (  0.2969 Sqrt[(u + x0[r, c])/corda[r, c]]                                       - 0.126 (u + x0[r, c])/corda[r, c]                                      - 0.3516 ((u + x0[r, c])/corda[r, c])^2                                      + 0.2843 ((u + x0[r, c])/corda[r, c])^3                                       - 0.1015 ((u + x0[r, c])/corda[r, c])^4 )     m = 0.04;  p = 0.4;     (*Camber Bordo de Ataque*)     ba[u_, r_, c_] := m (u + x0[r, c]) ( 2 p - (u + x0[r, c])/corda[r, c])/p^2      (*Camber Bordo de Fuga*)     bf[u_, r_, c_] :=         m ((corda[r, c] - (u + x0[r, c]))/(1 - p)^2) ( 1 + (u + x0[r, c])/corda[r, c] - 2 p)     PerfilSup[u_, r_, c_, e_] := If[ u + x0[r, c] <= p corda[r, c],                                      FNaca[u, r, c, e] + ba[u, r, c],                                      FNaca[u, r, c, e] + bf[u, r, c] ]     PerfilInf[u_, r_, c_, e_] := If[ u + x0[r, c] <= p corda[r, c],                                     -FNaca[u, r, c, e] + ba[u, r, c],                                     -FNaca[u, r, c, e] + bf[u, r, c]]     d1[u_, r_, c_, e_] := PerfilInf[u, r, c, e]     f1[u_, r_, c_, e_] := PerfilSup[u, r, c, e]          ParametricPlot3D[{ {d1[u, r, c, e], u, r}, {f1[u, r, c, e], u, r}},                        {r, 0.01, d/2}, {u, -x0[r, c], corda[r, c] - x0[r, c] } ]


Export high resolution figure causes missing ticks

I understand that _Mathematica_ has a bug when exporting images. The ticks are scaled not correctly when exporting at high resolution. For example: when you do:               Export["xx.png", plot, ImageResolution -> 360];      The image looks good, but all the frame ticks are all gone. When you do               Export["xx.png", plot, ImageResolution -> 100];      The ticks are there, but the resolution of the image is not good enough. I tried the trick of using `ImportString` and `ExportString`:               ImportString[ExportString[plot, "PDF"]      It works, but creates another problem: the `PlotRangeClipping` option is missing, and the figure has plot lines sticking out all the way to the boundary of the image, not the boundary of the axes. Can someone provide an easy and relatively universal workaround?


Explicit StreamPoint

I have trouble with getting the explicit initial StreamPoint to work. The number of streamlines are not the same as the number of initial points. What am I doing wrong?               Clear["Global`*"]     KDIM = 178.2;     KDNA = 9900;     n = 7;     b1 = 1.6;     b4 = 0.003;     b3 = b4/10;     b2 = (b1 + b3)/2;     b1 = b1 - b4; b2 = b2 - b4 ; b3 = b3 - b4;          gamma1 = 0.0012;     gamma2 = 0.0012;     r2 = 2.3;     M[x1_] := (KDIM/KDNA)*((1 + (1 + (4/KDIM)*(2*x1))^(1/2))/(2*(2*x1)))^2;     Y1[x1_, x2_] := r2*x2 - gamma2*x1;     Y2[x1_, x2_] := n*((M[x1]/(1 + M[x1]*3*x1))*(b1 + b2 + b3)*x1) + n*b4 - gamma1*x2;     eqs = { Y1[x, y], Y2[x, y]};          xmin = 20000;     xmax = 50000;     ymin = 0;     ymax = 30;     points = Tuples[{Range[xmin, xmax, xmax/20],Range[ymin, ymax, ymax/5]}];     gv = VectorPlot[eqs, {x, xmin, xmax}, {y, ymin, ymax},VectorPoints -> Fine, VectorScale{Automatic, Automatic},StreamPoints -> points, StreamStyle -> {Red, "Line"},PlotRange -> {{xmin, xmax}, {ymin, ymax}}]      ![Too Few Streamlines\]!\[I expected to get 100 streamlines, but I am only getting 2 and they are short](http://i.stack.imgur.com/6gKj2.jpg) I expected to get 100 streamlines, but I am only getting 2 and they are short


Why are my recursive functions running so slowly? And how do I fix them?

I am working with making numerical solvers for a modeling class I am in, and I want to use the internal recursion handling that is built into mathematcia, but there seems to be a problem. NDSolve gives me very rapid results that match up with these, but they are so slow. Euler's method for 20 steps is taking nearly a minute to complete, and Runge-Kutta simply sits there for forever if I go above 6 steps. I know they should be faster, and I could do them as for loops easily enough, but I want to know how to make these work as quickly as they should be. I am sure that I am just missing something.               (*Euler's Method*)     a = 20;     h1 = 2./(a);     f1[t_, x_] := 2 x - 2 t^2 - 3;     t1[k_] := t1[k - 1] + h1;     y1[k_] := y1[k - 1] + h1*f1[t1[k - 1], y1[k - 1]];     t1[0] = 0;     y1[0] = 2;     y1[a]          (*Runge-Kutta*)     b = 6;     h2 = 2/b;     K1[k_] := h2*f2[t2[k], y2[k]];     K2[k_] := h2*f2[t2[k] + 1/2*h2, y2[k] + 1./2*K1[k]];     K3[k_] := h2*f2[t2[k] + 1/2*h2, y2[k] + 1/2*K2[k]];     K4[k_] := h2*f2[t2[k] + h2, y2[k] + K3[k]];     f2[t_, y_] := 2 y - 2 t^2 - 3;     t2[k_] := t2[k - 1] + h2;     y2[k_] := y2[k - 1] + 1/6 (K1[k - 1] + 2*K2[k - 1] + 2*K3[k - 1] + K4[k - 1]);     t2[0] = 0;     y2[0] = 2;     y2[b]


How can I calculate the limit without using the L'Hopital's rule

I need to prove this limit without using the L'Hopital's rule: $$\lim_{x\to 0} \frac{(1+a\,x)^{1/4} - (1+b\,x)^{1/4}}{x} = \frac{a-b}{4}$$ How can I do it in _Mathematica_?


Find the longest constant sublist

Given a list               list = {1,2,2,2,2,5,1,3,2,6,6,6,6,6,6,6,6,6,6,6,10,-3};      how to find the longest constant sublist (or equivalently the element and the number of times it is repeated)? (in this example, {6,6,6,6,6,6,6,6,6,6,6} or {6,11})


Read in bezier curve from svg file

I am trying to do some calculation of some svg file,After read in with `Import["filename","XML"]`and some easy operation, I can get the string of the bezier curve, which is               "m", "10.297065,122.86673", "c", "-1.1327165,-2.9517", \     "-1.9996959,-5.44247", "-1.926621,-5.53505", "0.073075,-0.0926", \     "3.957119,-0.67937", "8.63121,-1.30398", "C", "51.148046,111.46463", \     "75.614452,102.94", "87.948536,91.308267", "L", "93.5,86.072926", \     "68.309017,86.036463", "c", "-13.855041,-0.02005", \     "-25.421756,0.336936", "-25.703812,0.793312", "-0.282056,0.456376", \     "1.914958,3.227403", "4.882253,6.157839", "l", "5.395081,5.328064", \     "-4.191269,3.372522", "-4.19127,3.37251", "-5.633788,-6.202247", \     "-5.633788,-6.202251", "-8.192543,4.262229", "c", \     "-4.505899,2.344227", "-8.454026,4.000749", "-8.773616,3.681159", \     "-0.31959,-0.31959", "-1.579212,-2.234924", "-2.79916,-4.256295", \     "l", "-2.218088,-3.675221", "7.125491,-3.411753", "c", \     "9.721447,-4.65472", "21.775439,-12.818376", "29.827634,-20.200987", \     "l", "6.702143,-6.144822", "4.047857,2.065063", "C", \     "61.178464,66.111369", "63,67.351969", "63,67.732472", "c", \     "0,0.380504", "-1.893694,2.621358", "-4.208208,4.979676", "L", \     "54.583584,77", "80.791792,77", "107,77", "l", "0,4.300463", "c", \     "0,3.602014", "-0.69025,5.119122", "-4.25,9.341089", "C", \     "92.980914,102.22798", "77.402299,111.67795", "57,118.39344", "c", \     "-11.332786,3.73023", "-30.101934,8.14519", "-39.071725,9.19063", \     "l", "-5.571726,0.64939", "-2.059484,-5.36673", "z"      how the data is managed is described in this link, so, It there any good way to get a bezier function out of this data?


Conditionally formatting elements in a list

I have a list `{{a1, a2, a3},{b1, b2, b3}, ...}` and I want to replace the numbers less than 10 by `0x` (just insert a 0 before the element, so that `2 -> 02`, `3 -> 03`, etc). How can I do that? To clarify, I will later export this table and run it through a program that will upload it to a database. These number are identifications for different objects, and for some reason the list needs to be all aligned. If I just export it as it is, I would get something like > >     1  2  3 >     20  40  55 >   which the program can't read.


How to scale Histogram counts with the value of bin center?

I am analyzing some variates from a steeply falling power-law distribution (approximately with a power index -4) using               Histogram[data, Automatic, "PDF"]      While the option `ScalingFunctions->{"Log", "Log"}` helps a lot in keeping the results in perspective, I cannot really see small deviations from the power law since the dominant trend in the log-log view will be a linear function with approximate slope -4. The usual trick in such studies is to scale the resulting pdf by dividing it with the approximate trend, i.e. for the bin entries I want something like               ScalingFunctions->{"Log", Function[{count, center}, Log[center^4 count]]}      instead of only `Function[x, Log[x]]` which I get with the `"Log"` option. Unfortunately `Histogram` seems to call this function with only one argument which is the corresponding bin count (or pdf value in my case), unlike e.g. `Plot` which calls `RegionFunction` with all the coordinates and similarly other plotting functions in Mathematica. Is there a way to convince Mathematica to call the scaling functions not only with the bin value but also with the bin center or location of bin edges?


Sorting an Array with words in different languages

Array consists of words of different languages. I need to sort elements in reverse alphabetical order and make a list of elements, which consist of english letters. Example of array which consist of english and russian words:               m = {"computer", "экзамен", "elephant", "стол", "bread", "телефон",         "exception", "desktop", "best", "колонка", "zoom", "saphire",         "ярость"};      Sorting with `Reverse@Sort[m]` and `Sort[m]` work with english words only. `Select[m, LetterQ]` can make a list of english words. Problem is a different language (Russian in this e.g.)


Can I run calculations on an external ssh server that doesn't have Mathematica installed?

I am currently running some rather compilex _Mathematica_ calculations on my laptop and sometimes run into an out-of-memory errors. However, I have access to some larger simulation servers via ssh, but they don't have _Mathematica_ installed on them. Is there a possibility I can use this additional calculation-power for my calculations? (I already found ConnectToARemoteKernel but if I understand correctly this only works, if _Mathematica_ is installed on both systems.)


Volumetric Rendering of cylinder symmetric radial image

I would like to render a cylinder symmetric radial cross-section with Image3D. As an example one could use the propagation of a Bessel Beam through a Lens: ![Bessel Beam Focusing](http://i.stack.imgur.com/C6VOD.png) Here the cylinder axis is the bottom of the image and the radial coordinate is along the vertical direction of the image. A 3D volumetric rendering would show the resulting focus ring at a radius of 1mm very nicely. My solution is very slow and uses a tomographical approach by generating array plots of rotated image rows and stacking them together in Image3D.               inpdata =        ImageData[        Import[NotebookDirectory[] <> "<Filename of image to rotate>.png"]][[;; , ;; , 1]];     outdata =        Monitor[Table[tint = Interpolation[Reverse[1 - inpdata[[;; , i]]]];          Image[ArrayPlot[           Table[Piecewise[{{tint[Sqrt[x^2 + y^2]],                Sqrt[x^2 + y^2] < Length[inpdata]}},              0], {x, -Length[inpdata],              Length[inpdata]}, {y, -Length[inpdata], Length[inpdata]}],            Frame -> False, ImageMargins -> None,            ColorFunctionScaling -> False]], {i, 1, Dimensions[inpdata][[2]], 1}], i];     Image3D[outdata]      I hope that there is a more efficient way to do this in _Mathematica_...


NIntegrate issue to do with unknown types

I have a numerical function zz:               zz[s_ ? NumericQ] := so3toE3[Inverse[yn[s]].ND[yn[k], k, s]];      The other functions involved have 2 pages of code defining them so I will leave it at that for now unless asked to give more detail               Print[A0];     Print[ND[zz[kk], kk, 1]];     Print["J1 A=0 ", NIntegrate[Norm[ND[zz[kk], kk, tt] ], {tt, 0, 1}, Method -> {"TrapezoidalRule", "Points" -> 100}, MaxRecursion -> 0, PrecisionGoal -> 3]]     Print["J1 A only ", NIntegrate[Norm[A0], {tt, 0, 1}, Method -> {"TrapezoidalRule", "Points" -> 100}, MaxRecursion -> 0, PrecisionGoal -> 3]];     Print["J1 ", NIntegrate[Norm[ND[zz[kk], kk, tt] - A0], {tt, 0, 1}, Method ->{"TrapezoidalRule", "Points" -> 100}, MaxRecursion -> 0,  PrecisionGoal -> 3]];      The output of the preceding statements are:               {0.5,-0.1,0.}     {-1.57106,4.25392,-0.435128}     J1 A=0 4.21996     J1 A only 0.509902      These are as expected. The problem happens when I then try and subtract A0 from the other expression:               NIntegrate::inum: Integrand Sqrt[Abs[-0.5+1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0. +1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0.1 +1/63 (Times[<<2>>]+Times[<<2>>])]^2] is not numerical at {tt} = {0.}. >>     NIntegrate::inum: Integrand Sqrt[Abs[-0.5+1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0. +1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0.1 +1/63 (Times[<<2>>]+Times[<<2>>])]^2] is not numerical at {tt} = {0.}. >>     J1 NIntegrate[Norm[ND[zz$1746189[kk],kk,tt]-A0$1746189],{tt,0,1},Method->{TrapezoidalRule,Points->100},MaxRecursion->0,PrecisionGoal->3]      Why is subtracting `A0` from `ND[zz[kk], kk, tt]` causing a problem even though I know they are both vectors of the same dimension? Is there a way of 'declaring' that `zz` is a vector of `Length[]` equal to 3? Thanks.


Dynamic ListLinePlot

I have a list of lists looking like this: `{{{x1, y1}, {x2, y2}}, {x1, y1},...}}`. Furthermore I have defined a legend, which is taken from the filenames. Now I want to plot this data dynamically, add/remove sub-lists in a `ListLinePlot`, e.g. with a `Checkbox`. This is the part of the code I have so far: Importing the data:               files = FileNames["*.dat"];     data = Import[#, "Data"] & /@ files;     legend = StringReplace[files, ".dat" -> ""];      So far I have made the plot like this:               plot1 = ListLinePlot[data[[1]], PlotLegends -> legend[[1]]];     plot2 = ListLinePlot[data[[2]], PlotLegends -> legend[[2]]];          Manipulate[     Show[       If[x1 == True, plot1, Sequence @@ {}],       If[x2 == True, plot2, Sequence @@ {}],       {{x1, True, "plot1"}, {True, False}}, {{x2, True, "plot2"}]      Is there maybe a more elegent way of realizing this, maybe automatically, for list of sub-lists?


How to enumerate multisets?

Given the eight-element set `{1,2,3,4,5,6,7,8}`, I would like to enumerate all multisets (subsets with repetition) of size `n`, where `n >= 3`. For example, with `n = 3`, the sets `{1,1,1}, {1,1,2}, ..., {8,8,7}, {8,8,8}` would all be found. Ideally, I would like to be able iterate through each set, rather than create one gigantic program-crashing list, so that I can use each set at the time it is found. Since `Binomial[n, k]` only works for values of `k <= n`, I'm not sure how to best go about this.


Mathematica output in ASCII or larger text size for the output?

I am trying to read the output of this code that has crosses, circles and spaces. For some reason, the output is in very-very small alphabets so I would like to get it in ASCII and/or in larger alphabets to be more easily readable. ![enter image description here](http://i.stack.imgur.com/1JSgH.png) So >   1. how can I get Mathematica output in ASCII let say with the earlier > style table having only crosses, circles and spaces? > >   2. is there some setting to control the output formatting to specify the > size of writing such as the crosses, circles and errs? Are there environment > variables to adjust the size of the writing? > >


Unexpected behavior of Unevaluated

_Maybe it is about time I read some proper text about the main loop. Maybe I should not care (so much) about Unevaluated (as Leonid suggests). But I think this is an interesting question anyway._ This question of mine got a bit ruined by the fact that I got a bit confused. I hope this separate question will take away this confusion. My confusion was that I found it strange that we have, for               x = 3;     g[_Symbol] := "yay"      that as expected               g[Unevaluated[x]]      -> "yay" but               g[_Symbol] := "yay"     g[Sequence[Unevaluated[x]]]      -> g[Unevaluated[x]] and even               With[{yyyy = g[Sequence[Unevaluated[x]]]}, Identity[yyyy]]      -> g[Unevaluated[x]] The strange thing here is that even though `g[Unevaluated[x]]` is not in its "final form" (at a fixed point), in the sense that a rule can be applied to this as we can see above, Mathematica stops evaluating. I show the third example in which With occurs, because one might have thought that the behavior occurs because Mathematica assumes that rules for g have already been applied or something. But even when we use With (or in fact, Identity, With is really not necessary) to start a "clean evaluation", Mathematica refuses to do the last step. For a little while, I had the following question/hypothesis about this: "Does Mathematica remember if an expression has been fully evaluated?". Using that I found another similar example. We have               Clear[h, somethingElse, something]     h[something, something = somethingElse]      -> h[something, somethingElse] even though, if we evaluate the resulting expression again, we have               h[something, somethingElse]      -> h[somethingElse,somethingElse] But this time, we have               Clear[h, somethingElse, something]     Identity[h[something, something = somethingElse]]      -> h[somethingElse, somethingElse] So that Mathematica does continue evaluation in this case. The same happens for a user-defined Identity. Note that the following does not result in a "fixed point" (expression that is left unchanged by the rules).               Clear[h, somethingElse, something]     List[h[something, something = somethingElse]]      -> {h[something, somethingElse]} Which probably makes sense. I guess Identity is defined in terms of a rule, and after a rule we have to evaluate again. However, if we put something in a list, we can assume that the thing inside the list was evaluated correctly so we don't have to evaluate again. Little tentative conclusion: It is not true that Mathematica repeatedly evaluates an expression until it does not change anymore. It seems to be a little more subtle than that. The question is: Is it a bug that               g[_Symbol] := "yay"     Identity[g[Sequence[Unevaluated[x]]]]      Evaluates to               g[Unevaluated[x]]      ?


Expanding Matrix Expressions

I want Mathematica to recognize that               A.(-B.C)+A.B.C = 0      Yet FullSimplify and the like leaves the expression as it is. How do I get around this?


User-defined DistanceFunction for RegionNearest

In the function `Nearest` , I can define my custom function using the `DistanceFunction` option. e.g:               dist[{u_, v_}, {x_, y_}] := 3 Abs[u - x] + 2 Abs[v - y]      Which I can use like this               Nearest[{ {1.5, .6}, {2, 0}, {1.25, 1.25}}, {0, 0}, DistanceFunction -> dist]      Is it possible to give a user-defined `DistanceFunction` for `RegionNearest` in **V10**? I don't see how to do this.


How to model shocks to parameter in a dynamic system?

My simple model is:               m[t_] := m[t] = m[t - 1]*p + 2     m[0] = 0     p = 0.5      I can plot the system as:               DiscretePlot[m[t], {t, 0, 50}]      Now, I would like to shock `p` for a short period, say, from 10 to 13 during which it would be 0.8 and then recovering its original value, 0.5, afterwards. Would `Insert` do this?


Why are PlotLegends not combined with Plots?

I'm using `PlotLegends` in v9. It seems that in the documentation examples, plots and legends are combined into one graphic: Here's an example from `LineLegend` in the documentation:               Plot[{Sin[x], Cos[x]}, {x, 0, 5}, PlotLegends -> LineLegend["Expressions"]]      Which outputs this (notice how the legend is selected within the graph): ![enter image description here](http://i.stack.imgur.com/FHJK6.jpg) However, if this same line is evaluated by me, it becomes this: ![enter image description here](http://i.stack.imgur.com/qHYSu.jpg) Is this default behavior? Did Wolfram put graphics in place of output for their documentation? If this is default behavior, can they be combined without creating a rasterized image? **UPDATE:** It turns out that _Mathematica_ documentation sometimes contain rasterized images for output which was causing the initial confusion. The main point of the question is the behavior of the `Legended` (and related) function and exporting images with it included. The context menu and `Export` command treat this different.


How can I convert colors to grayscale?

![](http://i.stack.imgur.com/wtlqF.jpg) I want to change the above colored plot into a grayscale plot. I have tried this:               CCGray[pic_?ImageQ] := Module[{}, ColorConvert[pic, "GrayScale"]];      but it doesn't give me the degree of differentiation I would like.


Know the degree of the equation with the radicals expanded

I have an equation with radicals. I would like to know what would be the degree of the polynomials if I'd move the terms and square the equation a number of times sufficient to remove all the radicals. How could I achieve this in Mathematica? Practically, in the following equation nu12==0 I would like to know the degree of t once all the radicals are removed               C1 := c1*Cos[phi + xi1] - b*Cos[psi1] - ox1     D1 := c1*Sin[phi + xi1] - b*Sin[psi1] - oy1     oneToTwo := {c1 -> c2, xi1 -> xi2, psi1 -> psi2, ox1 -> ox2, oy1 -> oy2}     C2 := C1 /. oneToTwo     D2 := D1 /. oneToTwo     hcd = (C2^2 - C1^2 - D1^2 + D2^2)/(2*(D1 - D2))     numcd = TrigExpand[     Numerator[Together[Simplify[C1^2 + (hcd + D1)^2 - a^2]]]]     cogamma = c2*Sin[psi1]*Cos[phi + xi2] - c1*Sin[psi1 - phi - xi1]     sigamma = c2*Sin[phi + xi2]*Sin[psi1]     Weier := {Sin[phi] -> (2 t)/(1 + t^2), Cos[phi] -> (1 - t^2)/(1 + t^2)}     nu12 = TrigExpand[Numerator[Together[      numcd /. {Sin[psi2] -> sigamma/Sqrt[sigamma^2 + cogamma^2],         Cos[psi2] -> cogamma/Sqrt[sigamma^2 + cogamma^2]}]]] /. Weier


Solving an equation involving a determinant

I have a matrix which doesn't include numerical values. There are four variables in it. It is defined by               M1 = ({           {κ0  BesselJ[m, κ0 R],            q BesselI[m, q*R],             q1 BesselK[m, q1*R],            q2 BesselK[m, q2*R]},           {((F1 /. L -> L1) - E1 + N1*κ0^2)*BesselJ[(m + 1), κ0*R],            ((F1 /. L -> L1) - E1 - N1*q^2)*BesselI[(m + 1), q*R],            -((F1 /. L -> L2) - E1 - N1*q1^2)*BesselK[(m + 1), q1*R],            -((F1 /. L -> L2) - E1 - N1*q2^2)*BesselK[(m + 1), q2*R]},           {κ0^2 BesselJ[(m + 1),            κ0*R], -q^2 BesselI[m + 1, q*R],            q1^2 BesselK[(m + 1),            q1*R], q2^2 BesselK[(m + 1), q2*R]},           {((F1 /. L -> L1) - E1 + N1*κ0^2) κ0*BesselJ[m, κ0*R],            ((F1 /. L -> L1) - E1 - N1*q^2) q*BesselI[m, q*R],            ((F1 /. L -> L2) - E1 - N1*q1^2) q1*BesselK[m, q1*R],            ((F1 /. L -> L2) - E1 - N1*q2^2) q2*BesselK[m, q2*R]}          });          Det[M1] = 0      I want to get the formula for E1 in terms of the other variables and constants. I used `Solve`, but it didn't work. Can anyone please help me? Really appreciated.


Linear equation with complex numbers

I have to solve an equation of the type $$a z+b \overline{z}=c$$ with $a,b,c\in\mathbb{C}$. My approach is to set $F(z)=a z+b \overline{z}-c$ transform $z$ to $x+i y$ and then get a real linear system by assuming $x,y\in\mathbb{R}$ and solve $$\frac{F(x+i y)+\overline{F(x+i y)}}{2}=0$$ $$\frac{F(x+i y)-\overline{F(x+i y)}}{2i}=0.$$ My problem is that this has to happen a lot for a program that I am writing and I was wondering if there is a faster way to do that. It would be ideal if mathematica can solve these linear systems directly.


octopress plugin for CDF reader?

I am looking for a way to embed CDFs in octopress blogs. Looks like there are a lot of moving parts such as Jekyll, Liquid, and Pygments. I'd be grateful for a native trailguide through the jungle.


What's a non-trivial Mathematica program involving conscious choice of stack vs. queue data structure?

In a typical computer science algorithms course, much attention is given to the discussion of queues vs. stacks as a data structure programmers need to consciously choose from to achieve algorithmic performance. What's a good Mathematica program example that also involves (explicitly) choosing data structures? Most of these "implementation details" or algorithmic design tactics is automated in a black box fashion by Mathematica's Automatic idiosyncrasy.


RowReduce: Solving for the resource vector (a, b, c) in Augmented Matrix

Here are two examples:               RowReduce[{{3, 1, a}, {2, 1, b}}]      evaluates to               {{1, 0, a - b}, {0, 1, -2 a + 3 b}}      but               RowReduce[{{1, 2, 3, a}, {4, 5, 6, b}, {7, 8, 9, c}}]      evaluates to               {{1, 0, -1, 0}, {0, 1, 2, 0}, {0, 0, 0, 1}}      The result is independent of `a`, `b` and `c`. Since I want to know the steps of reduction, I add `a`, `b` and `c` for bookkeeping. But it does not work in the second example. Is anything wrong or is any way to keep track of the steps of reduction?


Can't simplify Abs[a*Cos[x]]^2

Why doesn't               FullSimplify[ Abs[a*Cos[x]]^2, Assumptions -> {{a, x} ∈ Reals}]      simplify to               (a*Cos[x])^2      but this query               Simplify[ (a*Cos[x])^2 == Abs[a*Cos[x]]^2, Assumptions -> {{a, x} ∈ Reals}]      yields True? I'm using _Mathematica 8.0_.


Non-descending Tuples

I want to get all the non-descending tuples of a list with given length, for example:               f[{1,2,3,4},{3}]      > > > {{1,1,1},{1,1,2},{1,1,3},{1,1,4},{1,2,2},{1,2,3},{1,2,4},{1,3,3},{1,3,4},{1,4,4}, >      {2,2,2},……,{4,4,4}} >   A function lies between `Tuples` and `Subsets` to some degree. Is the an efficient way to achieve this? (It should be general for all kind of elements, like `Tuples`, not specifically for `Integers`.)


Interactively Manipulate SparseArrays or Lists

I'd love to use `SparseArray`or `List` to group a set of parameters together in a function.               params[a] = 5;     params[b] = 6;          AFunction[p_] := p[a] * p[b]      If I however want to create a manipulatable entry in the array, it doesn't work:               Manipulate[params[c], {params[c], 0, 50}]     Manipulate::vsform: "Manipulate argument {params[c],0,50} does not have the correct form for a variable specification."      The same thing for a "normal" value works as intended:               Manipulate[c, {c, 0, 50}]      The Mathematica 10.0 documentation states, that Manipulate should be able to interactively transform any expression. I also tried it with `With`, which leads to the same error. Is this straight not possible, or am I doing something wrong. How do you handle big manipulatable parameter sets?


Computing the minimum number of terms required in a Fourier series to achieve a particular upper bound on the error

In a Fourier series, the maximum error bound is the difference of the function and the partial sum of its Fourier series. Within an interval, as we increase the number of terms of partial sums, the error decreases. $$e(x) = \left|f(x) − s(x)\right|$$ How can I determine the number of terms needed to calculate the partial sum so as to have a specific maximum error bound? For e.g $|e(x)| ≤ 0.01$ or $|e(x)| ≤ 0.001$ For example in a typical question, $f(x)$ defined as $$f (x) = \begin{cases} 0 &−3 \leq x \leq 0\\\ x^2(3 − x) & 0 < x < 3 \end{cases}$$ is a periodic function with period $6$ i.e., $f (x + 6) = f (x)$   * Plot $|e(x)|$ versus $x$ for $0 ≤ x ≤ 3$ for several values of $m$.   * Find the smallest value of $m$ for which $|e(x)| ≤ 0.1$ for all $x$. Constructing the Fourier series for this periodic function and plotting $|e(x)|$ versus $x$ for several partial sums like $m = 5, 10, 20$ is easy. It can be accomplished by `DiscretePlot`. How can I find the smallest value of $m$ (i.e., the number of terms needed in the partial sum to achieve a specific error bound)? I use Mathematica 6 and 7.


Reduce/Solve an equation with symbols in powers

I am trying to solve the following equation with respect to `x`.               eqn = x^z + y == a;      But when I do               Reduce[eqn,x]      mathematica doesn't solve at all. I guess this is because of symbolic expression in powers. If I replace `z` into some numeric values, mathematica works immediately. I was wondering what I am missing with this.


When running Mathematica from a Linux terminal, how can I prevent a script from terminating upon logout?

I am running Mathematica on a remote Linux cluster, by the terminal, using the `math` command. (I do not have access to a terminal GUI. For example, when I type the command `mathematica`, I get this error message: `Can't open display ""`.) I write Mathematica code in a text file (e.g., `test.txt`) and pass it to `math` using either the command               math < test.txt      or the command               math -script test.txt      Both of these methods work fine for starting a Mathematica job. However, when I log out of the terminal -- or even when a brief loss of internet connection interrupts my connection to the remote cluster -- the Mathematica script is terminated. When I log back in the terminal, no Mathematica processes (i.e., `MathKernel`) are running. To prevent this termination upon logout, I have tried using the standard Linux program `nohup`, which is a command telling the terminal to ignore the `HUP` (hangup) signal; output is redirected to a file `nohup.out`. I use `nohup` with any of the following commands:               nohup math < test.txt      or               nohup math < test.txt &      or               nohup math -script test.txt      or               nohup math -script test.txt &      These commands **all** _start_ the Mathematica job fine, but when I logout and log back in to the terminal, no `MathKernel` or similar processes are running (as verified by `ps` and by `ps -u myusername`). The situation is the same regardless of whether my job is a single kernel job or a parallel, multikernel job. Since the jobs _start_ fine -- including those ending with the `&` symbol to force the job to the background -- I do not think that I am having the same "background job suspension" problem as in this question. Do you have any thoughts on how I can prevent the terminal from terminating jobs when I logout or my connection is briefly interrupted? The `nohup` method above works for me with other programs, but for some reason not with Mathematica. (A toy test example is `Table[Length[FactorInteger[10^50 + n]], {n, 50}]`, which takes about 30 seconds on the terminal.)


Custom mesh in ListPlot3D

I have the following data:               bData = {{0.05, 0, 3.0198054316361485}, {0.05, 0.55,       1.1092237487369552}, {0.05, 1., 0.835126287487935}, {0.05, 1.61,       0.3647962208597364}, {0.1, 0, 2.991741037155516}, {0.1, 0.55,       1.1270688044265789}, {0.1, 1., 0.8493688576645464}, {0.1, 1.61,       0.5932718812318991}, {0.15, 0, 2.8183386248853517}, {0.15, 0.55,       1.6096377385996246}, {0.15, 1., 1.1088595437185633}, {0.15, 1.61,       0.5368907021939747}}      I plot my data as follows:               p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]]     p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None,        Mesh -> All, InterpolationOrder -> 1(*,ClippingStyle\[Rule]None*),        PlotRange -> All]     Show[{p1, p2}]      What I want to achieve with this is to show the data points clearly and also connect them in the x and y direction with simple lines. I have done the following ![Output1](http://i.stack.imgur.com/sORYG.png) ![Output 2](http://i.stack.imgur.com/Xus1d.png) ![Output 3](http://i.stack.imgur.com/6auV6.png) I would like to remove all the diagonal lines and just connect the points in the x and y directions. If I do `Mesh->Full`, I get the following: ![Output 4](http://i.stack.imgur.com/D7C66.png) Is there also a way of marking the vertices, without having to superpose two different plots? That complicates the labelling and legending I also want.


How to catch an interrupt (Control-C) in a script?

If a user hits Control-C when a script is running, they get an `Interrupt>` prompt, where they have to type `exit` or `quit` to return to the shell. I'd like to have the interpreter exit immediately when Control-C is hit. To this end, I'd like to catch the interrupt and run `Exit`. Is there a way to do this? Or is there a better option?


LocatorPane, selecting multiple Locators

Consider the following snippet                 pts = RandomReal[1, {3, 2}]       g = Graphics[{Polygon[Dynamic[pts]]}, PlotRegion -> {{0, 0}, {2, 2}}];       Panel[LocatorPane[Dynamic[pts], g]]      I would like to be able to drag the triangle as a whole. I found none and assume this has to be added via code, i.e. `EventHandler` but found no examples of this. **Question: How can I select, and act upon multiple locators, i.e. drag, scale, apply a transformation to the points?**


Restrict Locator to a certain graphic inside Manipulate

I would like to restrict the Locator inside Manipulate to a certain graphic. For example if I display two graphs, I would like to be able to click on the right one and use this information in other places (for example in the title and the left graph). By design, `Manipulate` assigns the `Locator` to the **first** graphic object that it displays (see under Details and Options). How can this be overcome? Here is an example snippet:               Manipulate[      sin =       Plot[Sin[x], {x, -5, 5}, ImageSize -> Medium,         Epilog -> {Red, PointSize[Large], Point[p]}];      cos = Plot[Cos[x], {x, -5, 5},         PlotLabel -> "I would like to have the locator on this graph!",         ImageSize -> Medium, Epilog -> {Green, PointSize[Large], Point[p]}];      Column[{Style[StringForm["Title `1`", p], Large],        Row[{sin, cos}]}, Center],      {{p, {0, 0}}, {-5, -5}, {5, 5}, ControlType -> Locator}]      ![example output](http://i.stack.imgur.com/6lJCR.png) I know this can be done using `Dynamic`, but then I loose some features of manipulate, such as "Paste Snapshoot", "Make Bookmark" and `SaveDefinitions`


xkcdConvert routines perform slower in Mathematica 9

I am experiencing some rather large performance decreases in _Mathematica_ version 9.0 using the _xkcd-styled_ plotting routines. I had used the `xkcdConvert` code from Simon Woods as seen here (also described/annotated by Vitaliy Kaurov, as seen here) a few months back under version 8.0.4. This code worked great under version 8.0.4 and ran the following sample code in about **1.68 seconds** :               f1[x_] := 5 + 50 (1 + Erf[x - 5]);     f2[x_] := 20 + 30 (1 - Erf[x - 5]);     xkcdConvert[       Plot[{f1[x], f2[x]}, {x, 0, 10},         Epilog ->          xkcdLabel /@ {{"Label 1", {1, f1[1]}, {1, 30}}, {"Label 2", {8,              f2[8]}, {0, 30}}},         Ticks -> {{{3.5, "1st Event"}, {7, "2nd Event"}},           Automatic}]] // AbsoluteTiming      This code will produce a simple xkcd-styled plot as given by Simon Woods example. When I run the same code under version 9.0, the output takes **~17.0 seconds** to produce!? I'm not sure why the performance degradation is happening in version 9.0. I was hoping to produce a number of comic styled plots for a meeting. I have produced the desired plots, but all the plot-rendering took a really long time (one plot took ~8 minutes to render). I welcome insight on how to improve the rendering performance under version 9.0 for future rendering efforts!


Why do NDSolve and OutputResponse not evaluate non-analytic functions numerically?

test = OutputResponse[TransferFunctionModel[1/(1 + s), s], Exp[-(1/t)], {t, 0, 10}]      does not evaluate. If `Exp[-(1/t)]` is replaced by `Exp[-t]`, it's fine. Starting the numerical evaluation at `t>0` does not help, either. (v9.0.1.0 on Mac OS). Thanks. The same issue occurs with NDSolve:               NDSolve[{y'[t] + y[t] == Exp[-1/t], y[0] == 0}, y, {t, 0, 10}]      does not generate an interpolating function. Replacing `Exp[-(1/t)]` by `Exp[-t]` does.


Can some one explain perplexing behavior of arbitrary precision arithmetic?

I was exploring the problem presented by another question, when I ran into some behavior of _Mathematica_ 's arbitrary precision arithmetic engine that perplexes me. Here is what I was doing               poly = 64 x^7 - 112 x^5 - 8 x^4 + 56 x^3 + 8 x^2 - 7 x - 1;     solns = Solve[poly == 0, x, Reals]      > {{x -> -(1/2)}, {x -> 1},   >  {x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 1]},   >  {x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 2]},   >  {x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 3]},   >  {x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 4]},   >  {x -> Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5]}}               root[n_] := Cos[2 n Pi/11];     poly == 0 /. x -> root[1]      > True               N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] == root[1], 20]      > True               N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] - root[1], 20]      > N::meprec: Internal precision limit $MaxExtraPrecision = 50.` reached while > evaluating -Cos[(2 [Pi])/11]+Root[1+6 #1-12 #1^2-32 #1^3+16 #1^4+32 > #1^5&,5,0]. > > 0.*10^-70               PossibleZeroQ[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] -  root[1]]      > PossibleZeroQ::ztest1: "Unable to decide whether numeric quantity > -Cos[(2\\[Pi])/11]+Root[1+6\ #1-12\ #1^2-32\ #1^3+16\ #1^4+32\ #1^5&,5,0] is > equal to zero. Assuming it is." > > True It would appear that Mathematica can compare the values of `Root[1+6 #1+..+32 #1^5&,5]` and `root[1]` more easily than it can determine their difference. I realize differences lose precision very rapidly, but I still find this perplexing. Finally I tried raising the value of `$MaxExtraPrecision`, but still no joy.               Block[{$MaxExtraPrecision = 10000},        N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] - root[1], 20]]        > N::meprec: "Internal precision limit $MaxExtraPrecision = 10000.` reached > while evaluating -Cos[(2\\[Pi])/11]+Root[1+6\ #1-12\ #1^2-32\ #1^3+16\ > #1^4+32\ #1^5&,5,0]" > > 0.*10^-10020 Larger values of `$MaxExtraPrecision` only made the computation take longer before it failed. Could there be something wrong with the algorithm used to compute a difference to high precision in the case where the two terms are essentially the identical? ### Edit From the first answer posted, I realize I should ask my question more carefully. I am not sure how _Mathematica_ estimates the precision of very small numbers, which can be a tricky business. Perhaps, that's my problem. For a difference that is expected to be zero or very close, should I be asking for evaluation in terms of accuracy rather than precision? I note that               N[Root[1 + 6 #1 - 12 #1^2 - 32 #1^3 + 16 #1^4 + 32 #1^5 &, 5] - root[1], {∞, 1000}]        returns `0.*10^-1001` with no error message. For this return value, I get               Accuracy[0.*10^-1001]      > 1000.               Precision[0.*10^-1001]      > 0. This is consistent with the behavior that bothers me, but why is the precision zero? WRI defines precision and accuracy as follows: > Precision[x]: the total number of significant decimal digits in x > > Accuracy[x]: the number of significant decimal digits to the right of the > decimal point in x In my mind, these definitions are not consistent with the accuracy and precision values shown above. The definitions imply that accuracy will always be less than precision.


How to deploy a Manipulate object to the cloud that enables SynchronousUpdating?

Is it possible to deploy a Manipulate object in the cloud that enables the SynchronousUpdating, which response immediately ? For example, to make something like this in one of the Wolfram's blog ![enter image description here](http://i.stack.imgur.com/f1qQA.gif)


Hatched Filling for ListPlot

I am plotting to data curves using ListLinePlot. I like the look of Filling, but this is going to be printed, so I want something both black and white friendly, but giving more definition and separation than changing the opacity of the filling. Ideally, I would either have one hatched and the other filled solid gray, or both hatched in opposite directions or something such that they can be identified separately. This is what I have so far that I may just use if I can't find anything better:               data1 = exPDMIABSA[[1]];     data2 = exPDMIAwater[[1]];     ListLinePlot[{data1, data2},       PlotStyle -> {Black, Directive[Dashed, Black]},       Filling -> Axis,       FillingStyle -> Directive[Opacity[0.7], Gray]]      ![enter image description here](http://i.stack.imgur.com/bCvyV.png) Three related questions I've found are RegionPlot (or FillingStyle) using hash lines? and Filling a polygon with a pattern of insets and How can I make hatching filling of plot but none seems to address this situation. They seem to be dealing with shapes and (region)plots and not ListPlots. While it is entirely possible that they are very closely related, I'm not sure how to use any of those answers for my situation. Thanks


Incompatible Changes since Mathematica Version 7?

There is documentation of the incompatible changes made to _Mathematica_ with each major release:   * Incompatible Changes since Mathematica Version 1 Unfortunately that documentation simply stopped with version 7. Therefore I ask: ## What incompatible changes have been made since _Mathematica_ 7? There are other questions on the subject but I wish to make this an exhaustive index for easy reference.


Timeline plotting: horizontal bars of time intervals

This text file logs the time that a process (identified by a number) changes state ("Brown", "Blue" etc.")               2014-08-29 03:59:52 , 27273 , Brown     2014-08-29 03:59:53 , 27276 , Green     2014-08-29 03:59:55 , 27276 , Brown     2014-08-29 03:59:57 , 27303 , Red     2014-08-29 03:59:58 , 27303 , Green     2014-08-29 03:59:59 , 27303 , Brown     2014-08-29 04:00:04 , 27317 , Brown     2014-08-29 04:00:07 , 27331 , Blue     2014-08-29 04:00:07 , 27334 , Blue     2014-08-29 04:00:08 , 27331 , Red     2014-08-29 04:00:08 , 27334 , Cyan      What I try to do is to plot horizontal bars as time intervals, colored according to the third column, where x-axis is time, y-axis is process id number. One of the colors (probably Cyan) should not be displayed, as it marks the interval end. It is actually a timeline of many parallel events. DatePlot does not seem to help. Any suggestions?


Reduce Cannot Solve Complicated Function

As per the answer to this question: SolveAlways rejects inequality, I tried the following commands:               Clear[f, x]     D[Erf[x  f[x]], x]     Reduce[D[Erf[x  f[x]], x] <= 0, Reals]      Which gives the following output: > (2 E^(-x^2 f[x]^2) (f[x] + x f'[x]))/Sqrt[[Pi]] > > Reduce::nsmet: This system cannot be solved with the methods available to > Reduce. >> I would like to use the relation `D[Erf[x f[x]], x] <= 0` to find a relation between `f[x]` and `f'[x]` over the domain `x >= 0`. I know that `x` is positive and real, and that `f[x]` is a function from Reals to Reals, and that it is positive, continuous, and differentiable, but the exact form of the function is unknown. In this case, it is clear that the derivative will be less than or equal to zero whenever `f[x] <= -x f'[x]` but I can't get Mathematica to work with me. Any ideas on how I can use Mathematica to find the relation `f[x] <= -x f'[x]`?


Representing second derivatives with a double overdot

I would like to express a second derivative with two dots above the variable. You can do this with a first derivative by saying:               f[x_] := OverDot[x];     Print[HoldForm[f[x]], " == ", f[x]]      Is there a possible syntax to do this with the second derivative?


How does LocationTest choose its "AutomaticTest"?

Is there a way of determining how `LocationTest` chooses its `"AutomaticTest"`? Sometimes it's clear from the `VerifyTestAssumptions` option               sample = BlockRandom[SeedRandom[7];RandomVariate[SkewNormalDistribution@2, 10]];          {LocationTest[sample, Automatic, "AutomaticTest", VerifyTestAssumptions ->{"Normality"}],     LocationTest[sample, Automatic, "AutomaticTest", VerifyTestAssumptions -> "Normality" -> True]}      > {SignedRank, T} other times less so               {LocationTest[sample, Automatic, "AutomaticTest", SignificanceLevel -> 0.05],      LocationTest[sample, Automatic, "AutomaticTest", SignificanceLevel -> 0.0005]}      > {SignedRank, T} ( i.e. how can the level of the apriori-decided "burden of proof" affect the resulting sampling distribution? ) **Update 1:** Following on from the comments - Perhaps the setting for the significance level is somehow being inherited in checks for normality i.e.               {DistributionFitTest[sample, NormalDistribution[],"ShortTestConclusion", SignificanceLevel -> 0.05],      DistributionFitTest[sample, NormalDistribution[],"ShortTestConclusion", SignificanceLevel -> 0.0005],     DistributionFitTest[sample, NormalDistribution[], "PValue"]}      > {Reject,Do not reject,0.00836514} The critical point is not around the previous p-value instead appearing just after 0.03               Plot[If[LocationTest[sample, Automatic, "AutomaticTest", SignificanceLevel -> x] === "T", 1, 0], {x, 0.01, 0.05}]      ![enter image description here](http://i.stack.imgur.com/D9p5d.jpg) If so, perhaps some sort of Bonferroni correction is taking place? **Update 2:** From the answer from Andy Ross, the relevant test is not                DistributionFitTest[sample, NormalDistribution[]]          (*0.00836514*)      but rather                DistributionFitTest[sample]          (*0.0307822*)      indicating that indeed this significance level is being filtered down. This doesn't however, provide a systematic answer to determining _how_ this choice is made in general. In this case, the logic used by `LocationTest` can be deduced because it is a standard example but applying NHST can be a bit of an art that depends heavily on circumstance for its ultimate interpretation. Hence, having a black box for this logic seems limiting in perhaps a far more consequential way than say for other "more deterministic" and clear-cut algorithms. Also, what is the rationale behind this inheritance? - in NHST machinery, the significance level has a specific meaning in relation to Type 1/Type 2 errors, power, experimental context etc with the theory being predicated on a test's conditions being apriori satisfied _without_ concession to their own uncertainty (e.g. despite a p-value being returned, is an error message for a failed test of normality in say TTest invocations counted as a false negative/positive in defining a Type 1/Type2 error?).               sample2 = {6.1, -8.4, 1, 2, 0.75, 2.9, 3.5, 5.1, 1.8, 3.6, 7., 3, 9.4,         7.5, -6};     TTest@sample2          (* TTest::nortst: At least one of the p-values in {0.0903246}, resulting from a test for     normality, is below 0.05`. The tests in {T} require that the data is normally distributed. >> *)          (* 0.0498525 *)      The warning above doesn't seem to fit since 0.0903246 is not below 0.05 but explicitly set the significance level to the default 5% however, and the warning message disappears?               TTest[sample2, SignificanceLevel -> 0.05]          (* 0.0498525 *)      At any rate, in general it is quite conceivable that a different significance level for the overarching test might be needed in comparison with the significant level required for an apriori test checking the data's normality, symmetry, heterogeneity etc (n.b. also how are all these combined from the initial setting?) **Update 3:** To be a little more systematic: Define a function `ShowSignificanceLevelThresholds` to show those significant levels at which `LocationTest` changes its choice of `"AutomaticTest"` (the `"HighlightAutomaticTest"` option highlights this choice - both are defined at the post's end).               LocationTest[sample2, Automatic, {"TestDataTable", All},"HighlightAutomaticTest" -> True]     // ShowSignificanceLevelThresholds      ![enter image description here](http://i.stack.imgur.com/AhLwx.jpg) As deduced, the first transition appears due to the Koglomorov-Smirnof test of normality and its p-value of 0.09.               DistributionFitTest[sample2, Automatic, {"TestDataTable", All},      "HighlightAutomaticTest" -> True]      ![enter image description here](http://i.stack.imgur.com/F93E6.jpg) The second transition at a significance level 0.604 would appear to involve the violation of a symmetry assumption (observable by manual setting the `"Symmetry"` and `"Normality"` options to in the `"VerifyTestAssumption"` option) so that a related question becomes what Test is used by default to test for symmetry? While a high significance level of 0.604 is unlikely to have much practical significance in this particular case, this may not apply more generally. Again, the unknown effects of passing a significance level down to diagnostic tests is not straightforward and suggests caution in applying `LocationTest` and its ilk together with scope for further improvements (discussed in more detail here).               (*Needs to be evaluated twice*)     ALocationTest[sample_, x_, {tableType_, All}, y___ : OptionsPattern] /;     TrueQ@("HighlightAutomaticTest" /. {y}) :=      With[{\[ScriptCapitalH]2 =       LocationTest[sample, x, "HypothesisTestData",        FilterRules[{y}, Except["HighlightAutomaticTest"]]]},      Module[{AT = \[ScriptCapitalH]2["AutomaticTest"],       AllTests = \[ScriptCapitalH]2["AllTests"],       TableDataType = StringDrop[tableType, -5],(*Dropping "Table"*)      pos, Headers, grid, TableData},      TableData = \[ScriptCapitalH]2[{TableDataType, All}];     pos = 1 + Position[AllTests, AT][[1, 1]];     Headers =       Switch[TableDataType, "TestData", {"  ", "Statistic", "P-Value"},        "TestStatistic", {"  ", "Statistic"},        "PValue", {"  ", "P-Value"}];     Grid[{Headers,         Sequence @@          MapThread[          Flatten[Join[{#1}, {#2}]] &, {AllTests, TableData}]},        Alignment -> Left,        Background -> {Automatic, pos -> GrayLevel@0.9},        Dividers -> {2 -> True, 2 -> True},        FrameStyle -> Directive[GrayLevel@.7]] // Text]];          Unprotect@LocationTest;     PrependTo[DownValues@LocationTest,      DownValues[ALocationTest] /. ALocationTest -> LocationTest];     Protect@LocationTest;          AVarianceTest[sample_, x_, {tableType_, All}, y___ : OptionsPattern] /;     TrueQ@("HighlightAutomaticTest" /. {y}) :=      With[{\[ScriptCapitalH]2 =       VarianceTest[sample, x, "HypothesisTestData",        FilterRules[{y}, Except["HighlightAutomaticTest"]]]},      Module[{AT = \[ScriptCapitalH]2["AutomaticTest"],       AllTests = \[ScriptCapitalH]2["AllTests"],       TableDataType = StringDrop[tableType, -5],(*Dropping "Table"*)      pos, Headers, grid, TableData},      TableData = \[ScriptCapitalH]2[{TableDataType, All}];     pos = 1 + Position[AllTests, AT][[1, 1]];     Headers =       Switch[TableDataType, "TestData", {"  ", "Statistic", "P-Value"},        "TestStatistic", {"  ", "Statistic"},        "PValue", {"  ", "P-Value"}];     Grid[{Headers,         Sequence @@          MapThread[          Flatten[Join[{#1}, {#2}]] &, {AllTests, TableData}]},        Alignment -> Left,        Background -> {Automatic, pos -> GrayLevel@0.9},        Dividers -> {2 -> True, 2 -> True},        FrameStyle -> Directive[GrayLevel@.7]] // Text]];          Unprotect@VarianceTest;     PrependTo[DownValues@VarianceTest,      DownValues[AVarianceTest] /. AVarianceTest -> VarianceTest];     Protect@VarianceTest;          ADistributionFitTest[sample_, x_, {tableType_, All},      y___ : OptionsPattern] /;      TrueQ@("HighlightAutomaticTest" /. {y}) :=          With[{\[ScriptCapitalH]2 =       DistributionFitTest[sample, x, "HypothesisTestData",        FilterRules[{y}, Except["HighlightAutomaticTest"]]]},     Module[     {AT = \[ScriptCapitalH]2["AutomaticTest"],      AllTests = \[ScriptCapitalH]2["AllTests"],      TableDataType = StringDrop[tableType, -5],      (* Dropping "Table" *)      pos, Headers, grid, TableData      },     TableData = \[ScriptCapitalH]2[{TableDataType, All}];     pos = 1 + Position[AllTests, AT][[1, 1]];     Headers = Switch[TableDataType,       "TestData", {"  ", "Statistic", "P-Value"},       "TestStatistic", {"  ", "Statistic"},       "PValue", {"  ", "P-Value"}       ];     Grid[{        Headers,        Sequence @@          MapThread[Flatten[Join[{#1}, {#2}]] &, {AllTests, TableData}]        }, Alignment -> Left,        Background -> {Automatic, pos -> GrayLevel@0.9},        Dividers -> {2 -> True, 2 -> True},        FrameStyle -> Directive[GrayLevel@.7]] // Text     ]];          Unprotect@DistributionFitTest;     PrependTo[DownValues@DistributionFitTest,      DownValues[ADistributionFitTest] /.      ADistributionFitTest -> DistributionFitTest];     Protect@DistributionFitTest;               SetAttributes[SignificanceLevelThresholds, HoldFirst];     SetAttributes[ShowSignificanceLevelThresholds, HoldFirst];           SignificanceLevelThresholds[test_[A__]] :=       With[{firstTest = test[A, SignificanceLevel -> 0.0001]},       Last /@       Split[Table[{i, test[A, SignificanceLevel -> i]}, {i, 0.001, .999,         0.001}], Last@#1 === Last@#2 &]];          ShowSignificanceLevelThresholds[test_[A__]] :=      Module[{NForm},      NForm[n_] := If[MemberQ[{0, 1}, n], n, NumberForm[n, {4, 3}]];     With[{SLT = SignificanceLevelThresholds[test[A]]},      With[{intervals =        StringForm[          "`1` < \[FilledSquare] < `2`", #[[1]] // NForm, #[[2]] //            NForm] & /@         Partition[Prepend[SLT[[All, 1]] /. .999 -> 1, 0], 2, 1],       TestOutputs = SLT[[All, 2]]},      Grid[{{HoldForm@          test[A, SignificanceLevel -> \[SelectionPlaceholder]] //          Style[#, Bold] &,         Sequence @@ ConstantArray[SpanFromLeft, Length@SLT - 1]},        intervals, TestOutputs},       Spacings -> {2, {1 -> 2, 2 -> 2, 3 -> 1, 4 -> 1}},       Background -> {None, 2 -> LightBlue},       ItemStyle -> {None, 2 -> Directive[15]},       Dividers -> {{True, True, 3, 4}, {True, True, False, True}},       ItemSize -> 16, Frame -> True]]]]


How to define and use a linear function

I have the following equation $T = -800n + 12000$. I know that this is a linear function and that the two points $(0, 12000)$ and $(15,0)$ lie on the line. When I have 2 other values of n between 0 and 15, how is it possible to determine their corresponding T-values with Mathematica.


I failed to solve a set of one-dimension fluid mechanics PDEs with NDSolve

@DNA The fluid here has been assumed as single component perfect gas i.e. it obeys the equation P=ρRT, the thermal conductivity is assumed as a constant, so the equation is:               NDSolve[{D[ρg[t, x], t] + D[ρg[t, x] u[t, x], x] == 0,                   ρg[t, x] D[u[t, x], t] + ρg[t, x] u[t, x] D[u[t, x],x]                == -D[ρg[t, x] te[t, x], x],                   ρg[t, x] D[te[t, x], t] + ρg[t, x] u[t, x] D[te[t, x],x]               == -ρg[t, x] te[t, x] D[u[t, x], x] + D[te[t, x], x, x],                   te[0, x] == 298, te[t, -0.5] == 298, te[t, 0.5] == 298,                   ρg[0, x] == (1 - x^2),                   u[0, x] == 0, u[t, -0.5] == 0, u[t, 0.5] == 0},                  {ρg[t, x], te[t, x], u[t, x]}, {t, 0, 1}, {x, -0.5, 0.5}]      After I ran the code, I only got the warning message NDSolve::ndsz and NDSolve::eerr, I've checked the the equations for times and I think they are correct, and the initial and boundary conditions are also simple and seems to be reasonable (at least from the perspective of physics). So…What's wrong with it?…Well, to tell you the truth, what I really want to ask is, does NDSolve lack the ability to solve system of partial differential equations? Oh, someone may feel strange that there's no boundary condition for `ρg[t, x]`, that's because, I found that only four boundary conditions are necessary for the solving of the equations though I don't know the exact reason (I found it in times of trial when I set `ρg[0, x]` as a constant ).


Table in a Legend

Calculated data:               data= {{3.54216*10^6, 5.43391*10^6}, {3.5422*10^6,            5.43392*10^6}, {3.54224*10^6, 5.43393*10^6}, {3.54215*10^6,            5.43395*10^6}, {3.54219*10^6, 5.43396*10^6}, {3.54223*10^6,            5.43397*10^6}, {3.54214*10^6, 5.43399*10^6}, {3.54218*10^6,            5.434*10^6}, {3.54222*10^6, 5.43401*10^6}, {3.54213*10^6,            5.43403*10^6}, {3.54217*10^6, 5.43404*10^6}, {3.54221*10^6,            5.43405*10^6}, {3.54212*10^6, 5.43407*10^6}, {3.54216*10^6,            5.43408*10^6}, {3.5422*10^6, 5.43409*10^6}};      How can I present these data as an Table {i,x[i],y[i]} next to a graphic as a legend? I tried this finally with:               e = data &;     legends = AccountingForm /@ e[x];          legend = Overlay[{legendMaker[legends]}, Alignment -> {-.5, -.8},        ImageSize -> 400]      using the function legendMaker but I am not happy with my result. The best way would be to have it as an excel-like table. Thanks a lot.


Partitioning a list of numbers the Mathematica way

I have two sorted lists, one list will be called the "fences" and the other the "values" Fences could be: $\\{1, 5, 9, 14\\}$ Values could be $\\{-1, 1, 3, 4, 6, 9, 10, 13, 14, 15\\}$ I want to partition the values list using the equivalence relation that they are between the same fence values. ($f_i \leq v < f_{i+1})$ With the example above, I would get the partition: $$\\{\\{-1\\}, \\{1,3,4\\}, \\{6\\}, \\{9, 10, 13\\}, \\{14,15\\}\\}$$ This partitioning is quite easy using to implement using a for loop but I can't help but feel there is a better way to do it using some of the inbuilt Mathematica functions. I am not asking anyone to write the algorithm for me but to suggest which functions I should be aware of in order to do this elegantly.


How to avoid this kind of numerical error caused by extreme parameters when using NDSolve?

Here I use a one-dimensional heat conduction equation as the example. I found that when the thermal diffusion coefficient is small enough, Mathematica will give a result against the second law of thermodynamics:               fun[k_] := (a = NDSolve[{D[tes[t, x], t] == k D[tes[t, x], x, x],      　　　　　　　　　　    　　tes[t, 0] == t, tes[t, 1] == 0, tes[0, x] == 0},      　　　　　　　　　　   　　{tes[t, x]}, {t, 0, 1}, {x, 0, 1}];      　　　　　　Plot[(tes[t, x] /. a) /. t -> 1, {x, 0, 1}, PlotRange -> All]);     fun[1]     fun[10^-3]     fun[10^-6]      Here's the result: _Graph 1_ ![Graph 1](http://i.stack.imgur.com/NZ1w6.jpg) _Graph 2_ ![Graph 2](http://i.stack.imgur.com/J4Wkz.jpg) _Graph 3_ ![Graph 3](http://i.stack.imgur.com/c76JQ.jpg) The circled part in Graph 3 is the crux: this wave is unreasonable in the view of physics. So, how to avoid this if I have to use this kind of parameters?


How can I get the value of a at "t=2.4985352432136567" in the following expression?

By running the following code:               a = Sin[y[t]];     sol = NDSolve[{Derivative[2][y][t] + 0.1*Derivative[1][y][t] + Sin[y[t]] == 0,      Derivative[1][y][0] == 0, y[0] == 1}, y,      {t, 0, 10}, Method -> {"EventLocator", "Event" -> Derivative[1][y][t] - y[t]}]      we can obtain that the `"Event"` happens at `t = 2.4985352432136567` . The value of `y[2.4985352432136567]` can be obtained by using `y[2.4985352432136567] /. sol`, which appears to be `-0.589753`. However, when I apply this method to `a` for `a[2.4985352432136567] /. sol`, the results appear to be `{Sin[InterpolatingFunction[{{0., 2.49854}}, <>][t]][2.49854]}`, and no specific value is obtained. My question is, how can I get the specific value of `a` at `t = 2.4985352432136567`?


Suspend spacing between Repeated and number

The spacing of the first expression includes extra space before the `5`. I would like to have the same spacing as the second line.               HoldForm[4 .. 5]     HoldForm[a .. b]      Is there a way to suspend Mathematica's spacing, perhaps with a `StyleBox`?


Symbolic Integration of Special Functions

Sorry in advance if this formatting comes out strange, this is my first question! I can't find a way to integrate, e.g., a function of the Hermite polynomials for general (still integer) order. For example,               Integrate[E^-x^2 HermiteH[m,x] x HermiteH[n,x ], {x, -\[Infinity], \[Infinity]},          Assumptions->{m \[Element] Integers, n \[Element] Integers, m >= 0, n >= 0]      will not calculate. But if I give specific m and n,               Integrate[E^-x^2 HermiteH[m,x] x HermiteH[n,x ]/.{m->2,n->1}, {x, -\[Infinity], \[Infinity]}]      the answer comes right out. I know there is a general rule for certain classes of these integrals, and have often come across situations where I end up having to do them by hand. Does anyone know how to make Mathematica recognize/do these integrals? Thanks in advance.


Error message from NDSolve using WhenEvent

I am working with the following `NDSolve` expression:               sol =        NDSolve[{           (x[r] (0.9628102243099506` + (20 r^3 y''[r])/y[r]))/r^4 == (5 x''[r])/r,            1000 (2 (x'[r])^2 + 2 x[r] x''[r]) + 250 (2 (y'[r])^2 + 2 y[r] y''[r]) ==              -(17.65185212647424`/r),            x[1] == 0, y[1] == 0.25435588063893033`,            y'[1] == -0.011618552862714042`, x'[1] == 21/128,           WhenEvent[y[r] == 0, end = r; "StopIntegration"]},         {x, y}, {r, 1, 2.381047528519592`}]      I can plot `x[r]`, `y[r]`, but I get the message: > Power::infy: Infinite expression 1/0. encountered. >> If I delete the `WhenEvent` expression in the original code, I can numerically solve the equation without any error message. When I look at the plots with and without the `WhenEvent` expression, the two plots are exactly the same within the region that they share. Why am I getting the error message? can I ignore it, since the plot looks perfect.


Unexpected behaviour of Solve applied to two equations in two variables

I have a simple _Mathematica_ expression               Solve[{a(a-1)Sqrt[1+a^2+b^2] == b(a^3-1), b(b-1)Sqrt[1+a^2+b^2] == a(b^3-1)}]      which returns (on version 8.0, and also version 9.0) > >     {{b -> -(a/(1 + a))}, {a -> 1, b -> -I}, {a -> 1, b -> I}, {a -> 1, b -> > 1}, >      {b -> 0, a -> 0}, {b -> I, a -> I}, {b -> 1, a -> -I}, {b -> 1, a -> > I}} >   The first of these solutions does not seem correct. For example, putting `a=2, b=-2/3` does not satisfy either of the equations. On the other hand, if I add the `"VerifySolutions"` option to `Solve` I get the right answer:               Solve[{a(a-1)Sqrt[1+a^2+b^2] == b(a^3-1), b(b-1)Sqrt[1+a^2+b^2] == a(b^3-1)}           , VerifySolutions -> True]      returns > >     {{a -> 1, b -> -I}, {a -> 1, b -> I}, {a -> 1, b -> 1}, {b -> 0, a -> > 0}, >      {b -> I, a -> I}, {b -> 1, a -> -I}, {b -> 1, a -> I}} >   Is this the expected behaviour? It seems a bit odd to have to add an option to `Solve` to make it check that the solution returned actually satisfies the original equations.


Is wavelet a Nonlinear transform, or Not?   specifically, continuous wavelet transform with morlet function. I am studying behavior of a dynamic system, and it has nonlinear behaviour. can I employ wavelet transform?


numerical precision in output file

I want to write the numerical results of a computation to a file which is to be read in Fortran. The data looks like:               oswf0={1/(E^(25/2) \[Pi]^(1/4)), 1/(E^(81/8) \[Pi]^(1/4)), 1/( E^8 \[Pi]^(1/4)), 1/(E^(49/8) \[Pi]^(1/4)), 1/(E^(9/2) \[Pi]^(1/4))}      and I write it out with               Export["oscillatorwf_n0.dat", N[oswf0, 50]]      but the ouput file looks like               2.79918439290959673893721788332716676696872559106e-6     0.000030094068318430211211425128144825612558205505948023     0.00025197454903091461102445530088385078965019945670456     0.0016430804571573454314321054224416885379324057884235     0.008344251073246413703289360250294637268362678784284      All of them have clearly different precisions (>50). Why is mathematica not consistent here? What am I overlooking? How can I get 50 digits of precision consistently? Thanks a lot


Implementing a 100%-Mathematica http server

I would like to dedicate a small machine to exclusively running a Mathematica kernel and use that kernel to read http requests arriving on port 80, treat them and send http responses back **without any web server or extra software of any kind**. Requests are to be treated in sequence (only 1 connection shall be supported at a time). Clearly webMathematica is an overkill here. Any ideas?


Numerically solving systems of (first order) linear delay differential equations

I was wondering, how to solve such a system with mathematica? I found the NDsolve function, but in the reference is not mentioned if it is possible to solve a system of equations.


Automatically dealing with "disable dynamic updating"

I'm programmatically creating notebooks containing dynamic content. When a new notebook is being created, a window pops up: ![enter image description here](http://i.stack.imgur.com/LmUiP.png) I then manually click on "Continue" and it will create the notebook. The same steps happen for each notebook being created. How to automatically deal with this?


Plot Natural Log and Derivative Help

h[x_] := Log[2 x + xSin[x]]          h'[x_] := (2 + Sin[x] + xCos[x])/(2 x + xSin[x])          Plot[{h[x], h'[x]}, {x, 0, 10}]      Whenever I try to plot these two functions the plot turns up blank with two axes. Please halp.


How to color objects from a single .obj file?

How to paint the dolphin, shark and the box with different colors after loading the .obj file into Mathematica?               gr = Import["c:\\DolphinSharkBox.obj" ];     Graphics3D[gr[[1]]]      Link for the .obj file. ![enter image description here](http://i.stack.imgur.com/TBq4n.jpg)


Highlighting or coloring certain words / substrings appearing in a larger string

I have one longer string, `longString`, and a set $S$ of shorter strings `{ss1,ss2,ss3,...}`. I'd like to print out `longString` but where the positions of the shorter strings are indicated in some nice way. For example, perhaps we could color the characters in the longer string with a specific specified color for each shorter string. I.e. where would would have an array like `{{ss1,'Red'},{ss2,'Green'},{ss3,'Blue'},...}` and would then color words appearing in `longString` `Red` if the word is `ss1`, `Blue` if the word is `ss2`, and so forth. The idea would be to shade `Brown` / etc. overlap regions if they occur. Is this possible? One can use `StringPosition` to return the first and last character position for a set of substrings or words appearing in a larger string, for example:               StringPosition["TheBrownFox", {"Brown","Fox"}]          out: {{4, 8}, {9, 11}}      Now, one of the more interesting parts of this question, IMO, is how we handle overlaps between substrings / words (i.e. `ss1`, `ss2`, `ss3`, etc.). For example, if we add the nonsense word "wnFo" to the previous example, we have overlapping words:               testString = TheBrownFox;     StringPosition[testString, {"Brown","Fox","wnFo"}]          out: {{4, 8}, {7, 10}, {9, 11}}      So we need to do a kind of "surgery" on the output list for `StringPosition` s.t. there is never a situation where we have `{..., {integerOne, intTwo}, {intThree, intFour}, ...}` where it is NOT the case that `intOne < intTwo < intThree < intFour`. Update: Please see Kuba's very slick answer to my question concerning how one might do this: Identifying and isolating sections of overlap in a set of integer intervals * * * I am inspired by this example https://reference.wolfram.com/mathematica/example/HighlightWordsOfAGivenLength.html where words of a certain length are highlighted and bolded.


Returning lists of pixels connected through their Moore neighborhoods

I have a binarized image in Mathematica 9, and I would like to generate a list of coordinates for clusters of pixels connected through their Moore neighborhoods, e.g. $((c_{1,1},c_{1,2},...),(c_{2,1},c_{2,2},...),...)$ where some $c_{n,k}$ is the coordinate for the $k$th pixel in the $N$th set of pixels connected through their Moore neighborhoods. Is there a simple way to proceed with Mathematica 9's image analysis tool set?


Issue using the Cases function when forming a function of parameters

This is my code so far:               k = Import["all.txt.", "Table"]          Cases[k, {name_, G_, H_, S_, Cp_, V_, a1a_, a2b_, a3c_,a4d_, c1e_, c2f_, omegalan_, cT_}           /; name == "compoundname" -> {Cp, G, S}]      (The contents of `all.txt` can be found here.) This imports a table of 2000 different compounds, each having 12 different numerical values. Right now when I alter `"compoundname"` to for instance `"water"` the values I desire (here `Cp`, `G` and `S`) will appear for water. I am trying to alter this to make it so I can type the desired name into a simple function instead by attempting something like this:               HKFparameters[compoundname_] :=        Cases[k, {name_, G_, H_, S_, Cp_, V_, a1a_, a2b_, a3c_, a4d_, c1e_, c2f_, omegalan_, cT_} /;              name == "compoundname" -> {Cp, G, S}]      I have tried modifying this line in multiple ways but I cannot figure out how to do it.


Identifying and isolating sections of overlap in a set of integer intervals

I have a very large array like the following:               {{1,10},{8,9},{9,20},{34,40},{41,42},{43,50},{47,53},...};      Now, imagine that every element in the array corresponds to an integer interval. I'd like to delete elements in the array that fall within a larger interval, and whenever there is an interval-interval overlap, I'd like to shrink the intersecting intervals to eliminate the overlap and then add the former section where the overlap occurred as a new element to a separate array (here I'm calling this `overlapArray`). Perhaps this is best explained by example. Looking at the smaller case:               {{1,10},{8,9},{9,20},{34,40}...}      We notice that there is an overlap between the first three elements of the array, and that the element `{8,9}` falls entirely in this overlap section. So we this array becomes the following after our procedure:               {{1,7},{11,20},{34,40}...}          overlapArray = {{8,10}};      Now for the full example, this:               {{1,10},{8,9},{9,20},{34,40},{41,42},{43,50},{47,53},...};      Becomes:               {{1,7},{11,20},{34,40},{41,42},{43,46},{51,53}          overlapArray = {{8,10},{47,50}};      Is there an elegant way to do this with list operations in Mathematica v9?


Error message NDSolve::conarg: The arguments should be ordered consistently

Here is my code, i'm trying to make a simulation of the double pendulum               eq10 = 1.;     eq20 = 2.;     l1 = 5.;     l2 = 5.;     m1 = 5.;     m2 = 5.;     g = 9.81;     tMax = 10;          sol = NDSolve[{            l1 (m1 (g*Sin[P[t]] + l1*P''[t]) +               m2 (g*Sin[P[t]] + l1*P''[t] +               l2 (Sin[P[t] - Q[t]] Q'[t]^2 + cos[P[t] - Q[t]] Q''[t]))) == 0,             l2 m2 (g*Sin[P[t]] +               l1 (-Sin[P[t] - Q[t]] P'[t]^2 + Cos[Q[t] - Q[t]] P''[t]) +               l2 Q''[t]) == 0,             P[0] == eq10, Q [0] == eq20, P'[0] == 0., Q'[0] == 0.},             P[t], Q[t], {t, 0, tMax}]      > NDSolve::conarg: The arguments should be ordered consistently


How to fix the number and length of vectors when using ListVectorPLot

I want to plot only the vectors that I specify in my list of vectors, and no more. ListVectorPlot plots many of them, namely plots the field extrapolating from my four vectors.I would also like to have the length I give them, that is, if my list is the following: list = {{{-1, -1},{2, -2}}, {{1, -1},{2, 2}}, {{1, 1},{-2,2}}, {{-1, 1},{-2,-2}}}; I would like to have just four vectors at sites {-1,-1},{1,-1},{1,1} and {-1,1} of length Sqrt[2²+2²]. Does anybody know how to do this?


Collect pattern (Log's)

Is it possible to apply "Collect" command (to put Log's in particular combination) to factor out (pattern) a particular form from the full expression. For example, consider the following expression:               Log[a] + Log[b] - Log[c] + Log[d] - Log[f]      And I need to get a               Log[ab/c] - Log[f/d]      How one can do it?? Thanks in advance!! A. **EDIT** My concrete example is: Given this expression:               -(1/2) Log[(     \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)      \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(     \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)      \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\))] (Log[(         Subscript[t, 1] Subscript[t, 3])/(     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\) μ^2)] - 1/ϵ)      and applying ExpanAll[PowerExpand[%]] leads to               Log[     \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)]/(2 ϵ) +       Log[μ] Log[     \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] + Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)]/(2 ϵ) +       Log[μ] Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] + 1/2 Log[     \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] + 1/2 Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)]^2 - Log[     \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)]/(2 ϵ) -       Log[μ] Log[     \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] - 1/2 Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[     \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] - Log[     \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)]/(2 ϵ) -       Log[μ] Log[     \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] - 1/2 Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[     \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] - 1/2 Log[     \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[Subscript[t, 1]] -       1/2 Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[Subscript[t, 1]] +       1/2 Log[     \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] Log[Subscript[t, 1]] +       1/2 Log[     \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] Log[Subscript[t, 1]] -       1/2 Log[     \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[Subscript[t, 3]] -       1/2 Log[     \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[Subscript[t, 3]] +       1/2 Log[     \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] Log[Subscript[t, 3]] +       1/2 Log[     \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] Log[Subscript[t, 3]]      How to get from the last expression (a very long) the first (combined) one? I know, that I need to factor out this factor               Log[(     \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)      \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(     \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)      \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\))]      Naively:               Collect[expression, Log[(         \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)          \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(         \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)          \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\))] ]


simplifying equations

I have a question that seems easy but I can't solve it. I have an equation like:               eqgama = -8.33208*10^56 g1 + 8.18264*10^56 g1^2 == -1.42093*10^56      I use the following statements to find its discriminant:               poly = (eqgama[[1]] - eqgama[[2]]) // Simplify;     Discriminant[poly, g1];      The answer is: 2.29158*10^113 In another program mathematica itself simplifies eqgama to the following equation:               -1.97163*10^54 g1 + 1.93627*10^54 g1 ^2 == -3.36235*10^53      and so the discriminant becomes: 1.28315*10^108. I have a loop and I want to plot discriminants versus a definite parameter, but in this loop sometimes Mathematica simplifies equations and sometimes not. So the plot fluctuates. What should I do?


Why can I edit only one character of the output of a Dynamic expression?

Try this:               DynamicModule[{foo = \[Placeholder]}, foo]      Note how we're able to edit the placeholder in the output, _e.g._ replace it with 42:     ![enter image description here](http://i.stack.imgur.com/4BquZ.png) Now, try this:               DynamicModule[{foo = \[Placeholder]}, Dynamic@foo]      This time, I'm only able to edit _one_ character:     ![enter image description here](http://i.stack.imgur.com/1ZrG9.png) **What's going on internally, that explains this behavior?** At first, I thought maybe upon the first "touching" of a Dynamic portion of an output expression, the entire expression somehow "locks up." But, that can't be the case—I can edit that "4" as much as I'd like—I just can't remove or add any characters. Next, I compared the two expressions' `FullForm`s, keeping in mind that the very act of typing the first `/` in the output cell might have an effect on the expression:     ![enter image description here](http://i.stack.imgur.com/PXOMv.png) But I'm not sure what to make of the difference. Does it have something to do with `ImageSizeCache`? Still, why and how would something enforce the presence of a strictly one-character atom? I'm on $Mathematica$ 9.0.1.0.


Adding Lines to Sparklines (plots w/o frames, axes, etc.)

I have been working with Sparklines, thanks to some code found here. Here is what I am using:               sparkline[data_] :=      DateListPlot[data, {1997},        FrameTicks -> {{Automatic, Automatic}, {{{2007, 1, 15}, Red}},          None}, Axes -> False, Frame -> False, Joined -> True,        PlotRange -> All, Filling -> Bottom, AspectRatio -> 0.2,        ImageSize -> 120]      Here is my data:               data={{0, 0.00342768669164354`, 0.00503464769633257`, 0, 0.000187`, 0, 0,            0, 0, 0, 0, 0, 0, 0}, {0.0415627991238424`, 0.0545451018506565`,            0.0395873926886832`, 0.0284671754269643`, 0.0390903566779343`,            0.0344695110117644`, 0.0326128167712641`, 0.0380630684019641`,            0.0358499768032886`, 0.0241216221583061`, 0.0421644617338612`,            0.013010650199335`, 0.0249861212092993`, 0.0052690153372215`}};      I have been arranging them in charts, like so:               Grid[{{"Topic No.", "Sparkline"}, {"1", sparkline[data[[1]]]}, {"2",         sparkline[data[[2]]]}}, Frame -> All,       Background -> {None, {LightGray}}]      ![enter image description here](http://i.stack.imgur.com/Ov1CR.png) What I am trying to do, so far unsuccessful, is find options to put lines within the Sparkline to indicate a specific date. i.e. is there a way that I could add a line for the year '2005' in the example above? The beauty of the Sparkline lies in having no frame or printed axes, but most of the Mathematica commands that come to mind rely on those. My end goal would be to have something like this (where the line is at 2005, although this is just a mock up): ![enter image description here](http://i.stack.imgur.com/h1zlc.png)


Function that is a good fit to the plot made with SmoothHistogram

How can I find a function that fits the plot from the SmoothHistogram function? For instance if I have data like this and plot a Smooth Histogram, how can I get a function that fits the plot?               data = {4, 4, 4, 4, 1, 1, 4, 1, 5, 5, 5, 5, 5};     SmoothHistogram[data]      ![plot](http://i.stack.imgur.com/m1Kcg.png)


How to get the dimensions of a rectangle?

Suppose I create a Rectangle of dimensions 1 and 3. Is there any function in Mathematica that I can use to recover the dimensions of the original rectangle? If there is no such a function, is there a way of recovering the dimensions?


How to use and input audio wav file into a Wolfram demonstration

I am trying to send a Wolfram demo, which contains a sound wav file. `sound = Import["C:/myfile.wav", "Data"]; snd := sound[[1]]; or snd = sound[[1]];` Is it possible to convert the wav file into the data set,- and in this form to insert in the demonstration? Or is there a problem with my Internet connection when uploading the demo? In what form do you have to prepare audio *.wav files for use in Wolfram demonstrations? What kind of audio compression is needed for this purpose?


Changing the data indices for a large dataset plotted with ContourPlot

I have a large (square) dataset that I am plotting with ListContourPlot ... The data is 128x128 -- without coordinates for each point. I.e. - {{0,0,1,0,...,0},{0,2,1,1,...,1},...{3,1,1,1,...,2}} So the default contour plot uses the axis range 0->128 - for both x and y since there are 128 sets of 128 points. However, how can I remap the axis such that I plot this data with axis ranges of {-150,150}?? I realize that Rescale will give the formula to remap 128 points to the range -150,150 (e.g. - X/128 * 300 - 150), but how do I tell ListContourPlot to use those indices for the data (and hence those tick marks)? Thx, Rick