title: How to reverse the direction of the y axes on Graphics

text: Question related to this one, except I need the same for the Graphics. Lets say I have the following drawings:               Graphics[{         Line[{ Q, P, V }] ,       Arrow[{P, P + v }] ,       Arrow[{P, P + vx }] ,       Arrow[{P, P + vy}] ,            {Dashed,         Line[{Q + (dir1*d1), P + v,  V + (dir2*d2)}]        },            FontSize -> 16, Background -> RGBColor[1, 1, 1, 1],       Text["Q", Q],       Text["P", P],       Text["V", V],       }, Axes -> True]      But on my drawing sysytem (this drawing should illustrate part of it work), the screen coordinates goes from top to bottom (in reverse order). So I want to reverse it somehow.


title: Numeric values from transform

text: How would I create a table of values from a transformation? eg:               r1 = 1; r2 = 1000; primorial[n_] := Times @@ Prime[Range[n]];     plot = ListLinePlot[Table[N[Log[primorial[n]]], {n, r1, r2}]];     plot /. L_Line :> {GeometricTransformation[L, ReflectionTransform[{-1, 1}]]}      How could I convert the transform of 'plot' into a list of numeric values?


title: Why do Permute and PermutationReplace not invert one another?

text: Why do `Permute` and `PermutationReplace` not invert one another, as stated in the documentation? If we have an identity permutation list (a list of the form `Range[n]`)               In[1]:= list1 = {1, 2, 3};      then `Permute` and `PermutationReplace` invert one another:               In[2]:= cycle = Cycles[{{1, 2, 3}}];             Permute[PermutationReplace[list1, cycle], cycle] == list1     Out[3]= True          In[4]:= PermutationReplace[Permute[list1, cycle], cycle] == list1     Out[4]= True      But this does not necessarily hold for lists not of the form `Range[n]`:               In[5]:= list2 = {3, 2, 1};             PermutationReplace[Permute[list2, cycle], cycle] == list2     Out[6]= False          In[7]:= Permute[PermutationReplace[list2, cycle], cycle] == list2     Out[7]= False      Why is this so?


title: Plot The Cornu Parametric Spiral

text: How to plot the Cornu parametric Spiral in 3D With Mathematica. The 2D is quite easy. Thx. For more details you need to be familiar with the Cornu statement. $$\begin{cases} x(t)=\int_{0}^{t}cos(u^{2})du\\\ y(t)=\int_{0}^{t}sin(u^{2})du. \end{cases}$$


title: Variable widths on BoxWhiskerChart

text: BoxWhiskerChart automatically uses the same width for each of the boxes in a plot. I would like to force it to use a list of widths (with each width corresponding to a box). I'm working with time series data, and would like to have the width of each box depend on the duration over which its dataset was collected, regardless of the sampling rate. (For example, a box containing data collected over 2 hours would be twice as wide as that with data over 1 hour). One way to get a variable width is to use Method and BoxWidth as below. The box widths then scale according to the number of points in each dataset.               data = {{1, 4, 3, 5, 1, 2}, {1, 5, 4, 3, 3, 4, 4, 2, 3, 2, 8}}     durations = {180, 60}          BoxWhiskerChart[data,Method->{"BoxWidth"->"Scaled"}]      But since my sampling rates are variable, this width doesn't reflect the duration of the measurement. Is it possible to apply a list of durations to BoxWidth somehow? Many thanks!


title: Animated matrix will not work?

text: I want to export a list of matrices as a gif so that they will appear one after another 2 seconds apart. Ive tried the following but when I open it up it only does the first two matrices, I have 10 altogether.               list = MatrixForm /@ {{{0.3333, 0, 0}, {0, 0.3333, 0}, {0, 0,0.3333}}, {{0.04466, 0, 0}, {0, 0.3333, 0}, {0, 0, 0.622}}, {{0.05954, 0, 0}, {0, 0.8293, 0}, {0, 0,0.1111}}, {{0.1163, 0, 0}, {0, 0.8681, 0}, {0, 0,0.01558}}, {{0.01707, 0, 0}, {0, 0.9511, 0}, {0, 0, 0.03185}}, {{0.01707, 0, 0}, {0, 0.9511, 0}, {0, 0, 0.03185}}, {{0.001264, 0, 0}, {0, 0.9811, 0}, {0, 0, 0.01761}}, {{0.0006892, 0, 0}, {0, 0.998, 0}, {0, 0, 0.001286}}, {{0.0006901, 0, 0}, {0, 0.9993, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 1, 0}, {0, 0, 0}}};          Export["N://presentation28.gif", list, "DisplayDurations" -> 3]


title: why doesn't NSolve find all the solutions that Solve finds?

text: Define               d[p1_, p2_] := (p1 - p2).(p1 - p2)      to be the square of the distance between two points. I am trying to solve equations like:               Solve[{d[{p1, q1}, {0, 0}] == 1, d[{p2, q2}, {0, 0}] == 1, d[{p1, q1}, {p2, q2}] == 1,      d[{p2, q2}, {x, x}] == 1, d[{p1, q1}, {x, x}] == 1}, {p1, q1, p2, q2, x}]      I get 12 solutions. But when I approximate these solutions with:               NSolve[{d[{p1, q1}, {0, 0}] == 1, d[{p2, q2}, {0, 0}] == 1, d[{p1, q1}, {p2, q2}] == 1,      d[{p2, q2}, {x, x}] == 1, d[{p1, q1}, {x, x}] == 1}, {p1, q1, p2, q2, x}]      I only get 4 of the solutions. What gives? For larger number of equations, it takes too long to use Solve[ ] and then N[ ] the result. Erich


title: NIntegrate::slwcon Problem

text: I have a problem with numerical integration of this function. Integral value is zero, but `NIntegrate[]` needs a lot of time to calculate this. Is there any way to speed up this calculation? Input:               function[s_, t_] :=100 (-2160 (1 - 2 s)^4 t^3 (-2 + 5 t) +       96 (1 - 2 s) t^3 (25 (-1 + 2 s) t^2 (-3 + 5 t) +          5/4 (-1 + 2 s)^3 (-1 + 5 t)) -       24 (-1 + 2 s)^3 t (5 (-1 + 2 s) t^2 (-3 + 5 t) +          25/4 (-1 + 2 s)^3 (-1 + 5 t)));          AbsoluteTiming[NIntegrate[function[s, t], {t, 0, 1/2}, {s, 0, 1/2}]]     AbsoluteTiming[Integrate[function[s, t], {t, 0, 1/2}, {s, 0, 1/2}]]      Output: > During evaluation of In[4]:= NIntegrate::slwcon: Numerical integration > converging too slowly; suspect one of the following: singularity, value of > the integration is 0, highly oscillatory integrand, or WorkingPrecision too > small. >> > > During evaluation of In[4]:= NIntegrate::eincr: The global error of the > strategy GlobalAdaptive has increased more than 2000 times. The global error > is expected to decrease monotonically after a number of integrand > evaluations. Suspect one of the following: the working precision is > insufficient for the specified precision goal; the integrand is highly > oscillatory or it is not a (piecewise) smooth function; or the true value of > the integral is 0. Increasing the value of the GlobalAdaptive option > MaxErrorIncreases might lead to a convergent numerical integration. > NIntegrate obtained -1.49243*10^-14 and 1.0093478121591215`*^-12 for the > integral and error estimates. >> >   >   >     Out[5]= {43.421484, -1.49243*10^-14} >   >     Out[6]= {3.963227, 0} >


title: Connect Frontend to Kernel Started by JVM via JLink

text: I have a MathKernel started and controlled via JLink from a JVM. The $CommandLine for this kernel is:               $CommandLine     (* {"C:/Program Files/Wolfram Research/Mathematica/10.0/mathkernel.exe", "-mathlink", "-linkprotocol", "", "-linkmode", "connect", "-linkname", "h7r_shm"} *)      I can open a Frontend from this kernel by sending it the following string for evaluation:               Needs["JLink`"];     FrontEndLaunchCommand = mmaFrontEndPath;     ConnectToFrontEnd[]      and this string to actually open a window with a notebook               UseFrontEnd[       nbObj = CreateWindow[                  DocumentNotebook[                     {TextCell["Launched by JVM Kernel", "Title"]}],                   Visible -> True ]                  ]      I'd like to be able to set this notebook to use the JVM's kernel for evaluation (rather than its own) so I can use the notebook for easier debugging of the JVM launched kernel. I've tried creating a link on the JVM's kernel using               feMathLink = LinkCreate["feMathLink"]          and then attempting to connect to this in the Notebook using                jvmLink = LinkConnect["feMathLink"]      I get True from LinkReadyQ[jvmLink] but attempts to read from it using LinkRead[jvmLink] just hang. I've also tried just setting the Notebook's evaluation kernel to "feMathLink" using               SetOptions[EvaluationNotebook[], Evaluator -> "feMathLink"]       but this also just hangs. Apologies in advance if this really is in the manual but it is not obvious. This all comes from a small test program here that seemed too large to post. **Update - Clarification** As suggested by halirutan, I've simplified the question by taking Java/Groovy out of the question and focusing just on the kernel to frontend connection issue. If you run the following code from a kernel (call it kernel A) in "terminal mode" then it will launch a frontend which is connected to this kernel but has its own kernel (call it kernel B) for evaluation. That is, kernel A can send commands to the frontend via UseFrontEnd[] but this frontend doesn't use kernel A for evaluation.                Needs["JLink`"]      (* this is the program the JLink will use to launch a FrontEnd *)      $FrontEndLaunchCommand = FileNameJoin[{$InstallationDirectory, "Mathematica.exe"}]      (* this connects the kernel to a FrontEnd launched via JLink *)      ConnectToFrontEnd[]      (* at this point, FrontEnd is not visible, it is available only for processing some commands via UseFrontEnd[] *)      (* this uses UseFrontEnd[] to open a new Notebook in a Window making the FrontEnd visible *)      UseFrontEnd[          nbObj = CreateWindow[                 DocumentNotebook[{TextCell["Launched by JVM Kernel", "Title"]}],                  Visible -> True ]          ]     (* you should now see an unnamed notebook with first cell as a Title "Launched by JVM Kernel" *)                  I'd like to set the evaluation kernel (currently Kernel B) to be Kernel A, the initializing kernel. The objective is to use the frontend as a debugging tool for a kernel launch via JVM (or terminal in this case). As noted above, I've tried creating a math link in Kernel A using:               feMathLink = LinkCreate["feMathLink"]       and setting the frontend's evaluation kernel to this link using:               jvmLink = LinkConnect["feMathLink"]     SetOptions[EvaluationNotebook[], Evaluator -> "feMathLink"]       I've also tried reading and writing from this link but it always hangs on me. I've put a windows batch file and a simple .m file with all of this here. This should enable you to replicate the issue on any standard windows setup without much effort, none if you have version 10 installed in the standard place - just run the runIt.bat in a cmd or Powershell terminal. Many thanks again to halirutan for suggestions to clarify the question. It really isn't a JVM question at all, although UseFrontEnd[] is a JLink function.


title: Subscripts and Simple Forumlas giving unexpected answer

text: I trying to do a tensor problem but for simplification I'll only ask for assistance with one simple part. I set my variables using subscripts like so.. $Subscript[y, 1] = - .23556;$ But when I try to do a simple exponential like this $(Subscript[y, 1])^2$ I get as an output $(-0.23556 + TextCell[""])^2$ I have no clue why this problem persists but I can't seem to figure out the solution. Sorry if this has a simple solution, this is the first time I have used mathematica like so.


title: Recurrence equations with periodic coefficient

text: Suppose I have the following recurrence equation: $$ F_{i+1}P_{i+1}+F_iP_i-P_{i+1}+P_i=2J\,, \quad\textrm{with}\quad F_{i+L}=F_i,P_{i+L}=P_i\,. $$ $J$ is constant, $\\{P_i\\}$ are probabilities with normalization $\sum_{i=1}^LP_i=1$. Now I want to use `RSolve` to solve for $\\{P_i\\}$ (or is it possible?), but I don't know how to set `RSolve` up for such periodic relations.


title: Simplify equation using conditions/inequalities

text: If I have an equation like               f[x](1 + a)==0      I'd like to be able to tell Mathematica that 1+a doesn't vanish in general, and get back               f[x]==0      I've come up with               Reduce[f[x](1 + a)==0 && (1 + a) != 0, f[t]][[1]]      But it's not clear to me this is the best solution. EDIT: The reason this isn't ideal to me is that it seems sometimes the part that I want isn't always the first part of the output, so it doesn't generalize well. Sometimes I need to take [[1]], other times [[3]], etc.


title: Replace symbols with values without evaluation

text: If I have assigned values to `a`, `b` and `c`:               a=7;     b=5;     c=6;      and I select the expression:               (a+b)/c      and I press `cmd + enter` in the Mathematica frontend, the expression will be replaced by `2`. I would like to do something similar which would fill in the values of the symbols without evaluating the result. So `(a+b)/c` would be replaced by `(7+5)/6`. Is there a way of doing this? If so, can you also assign this to a keyboard shortcut that would replace the selected expression? **Note:** Assume you don't know the values or the names of the variables. Inputting `(a+b)/c` to a function, should be able to produce something like `(7+5)/6` without having to input `a`, `b` and `c` or `7`, `5` and `6`.


title: Digital filter of image in Fourier space

text: Consider the contour plot below, of a function f(x,y) - which is calculated numerically by solving some equations. If one looks carefully, one can observe two types of waves, to the left and right of the depression at (0,0). To the right we see waves of long wavelength (only two crests are visible actually). The waves to the left, on the other hand, are much more closely spaced and much less intense, but one can still distinguish them. Let us ignore the vertical stripes, which are of no interest. ![real-space image](http://i.stack.imgur.com/odQqs.png) Now if we take the 2D Fourier transform of the data, we get a picture like this: ![fourier](http://i.stack.imgur.com/4L96t.png) The very small circle in the center corresponds to the waves of large separation, and the other 2 circles correspond to the washed out, closely- spaced waves. My question is, what type of manipulation can I do (some filtering/convolution comes to mind) in order to give more weight to the washed-out waves to the left (make them more visible)? **Edit:** Just to clarify the above. I am not interested in any of the parallel vertical lines in the real-space plot, either to the right or to the left. What I am interested in are the very small parabolic waves very close to the center of the image, on the left side. I try to point them out in the zoom below, because they might be hard to spot in the original plot. ![zoom](http://i.stack.imgur.com/2G9az.png) **Edit 2:** I would prefer a way of selecting just the waves which correspond to a certain ring in the Fourier transformed image, something like a band pass filter which selects one ring. That is because I suspect that the close-spaced waves on the left of the center correspond to one particular ring only (the one pointed to by the blue arrow in the fourier plot). The main motivation for doing things like this is that then I want to apply the same method to the problem below:               data = Import["http://pastebin.com/raw.php?i=ieiLy8AD"];     img = Image[Rescale[data], ImageSize -> 400]      ![space-mat](http://i.stack.imgur.com/aIFO0.png) In this image, the washed out waves to the left of the dark central point are even weaker. My gut feeling is that they can be best brought out by filtering in Fourier space. However, I am willing to accept any answer that can **transform this last image to one where the small ripples are seen clearly** and then **make a cut of that 2D plot to calculate their wavelength** (along the y=0 axis for instance).


title: Arbitrary precision spline interpolation

text: Current implementation of `Interpolation` does not allow arbitrary precision spline interpolation. Yu-Sung Chang say here that "it is not hard to implement it manually for arbitrary precision using `BSplineBasis`." I am new to splines and not familiar with `BSplineBasis`. **What is the best way to implement arbitrary precision spline interpolation in _Mathematica_?** I am interested primarily in an analog of the `Method -> "Spline"` of `Interpolation` which I investigated in this answer (btw, what are the names of such spline and of this kind of parametrization?). Also Ｊ. Ｍ. gives in this answer interesting implementation of a spline with centripetal parametrization but it is not clear how to use it for interpolation. P.S. I need an implementation where the degree of a spline is arbitrary. At the moment I am more interested in even-degree splines.


title: Counting Events in a moving date range

text: I want to count the number of times events take place in a date range. The counting is done over a window of e.g. 28 days where the goal is to have between 11 and 13 events in the time window. The date range for the counting is e.g. from last October until now. My current solution seems to be inefficient, both timing wise (it takes almost 63 seconds for this small, sample test data) and from an intuitive way of thinking about the problem (with no repeated recounting of values). My question is: **How can I solve this problem in a more efficient and elegant way?** Here is my version               sumEventsInRange[targetDate_, eventlist_, minDiff_, maxDiff_] :=        Length[Select[         eventlist, (minDiff < DateDifference[Part[#, 2], targetDate] <             maxDiff) & ] ];          dvHITS = Drop[        Last[Import[          "https://docs.google.com/spreadsheet/ccc?key=\     0AstJzCCxOXH1dDdBaDRHMW5FMFFFVzhPRnpTUXlrU1E&usp=sharing", "Data"]],         1];          DateListPlot[      Transpose[{DateRange[{2013, 10, 1},          now], (sumEventsInRange[#, dvHITS, 0, 28] &) /@          DateRange[{2013, 10, 1}, now]}],       PlotRange -> {{{2013, 10, 1}, now}, {0, 20}},       GridLines -> {Automatic, {11, 13}}, Joined -> True]      Which generates the following plot ![Counted events in range](http://i.stack.imgur.com/ZQcrI.png)


title: Using StringCases and treating certain phrases as single words

text: My question is about `StringCases`. When I use this function, each word is separated by a `,`. But I want some noun phrases like names of a ministry to be considered single words. For example, I would like to count the number of words in the next two sentences.               text= "The Ministry of Infrastructure and Environment is      committed to improving quality of life,access and mobility in a      clean,safe and sustainable environment.The Ministry strives to create      an efficient network of roads,railways,waterways and      airways,effective water management to protect against flooding,and      improved air and water quality"          StringCases[text, WordCharacter ..]      The result of this function is:               {"The", "Ministry", "of", "Infrastructure", "and", "Environment",      "is", "committed", "to", "improving", "quality", "of", "life",      "access", "and", "mobility", "in", "a", "clean", "safe", "and",      "sustainable", "environment", "The", "Ministry", "strives", "to",      "create", "an", "efficient", "network", "of", "roads", "railways",      "waterways", "and", "airways", "effective", "water", "management",      "to", "protect", "against", "flooding", "and", "improved", "air",      "and", "water", "quality"}      Each word is separated by a ','. When I count the number of words I get 50, but there are four noun phrases I want to be considered single words:               "Ministry of Infrastructure and Environment"     "quality of life"     "network of roads"     "water management"      So the word count I would like to get is 41. I can create a reference table with all possible combinations of words. Is there a solution for this problem?


title: NIntegrate inside NSum

text: Consider the following function with a numerical integration:               BDMAF[n_, \[Gamma]_, x_, c_] :=       Module[{K1 = EllipticK[1/Sqrt[1 + \[Gamma]^2]],         E1 = EllipticE[1/Sqrt[1 + \[Gamma]^2]], y0},       y0 = ((\[Pi]^2 (IntegerPart[x + 1] - x + n))/(2 K1 E1))^(1/2);       Exp[-y0^2] NIntegrate[         Exp[y^2] Sin[(n + IntegerPart[x + 1])/2 \[Pi] + c y]^2, {y, 0, y0}]       ]      that works perfectly if all parameters are explicitly defined:               BDMAF[1, 1, 1, 1]      > 0.0391914 I need to calculate the infinite sum over n. Naive approach gives               NSum[BDMAF[n, 1, 1, 1], {n, 0, \[Infinity]}]      > NIntegrate::nlim: y = 1.38268 Sqrt[1. +n] is not a valid limit of > integration. >> Following the answer to the question about nested NIntegrate, I tried to redefine BDMAF as follows:               BDMAF[n_?NumericQ, \[Gamma]_, x_, c_] := BDMAF[n, \[Gamma], x, c] =        Module[{K1 = EllipticK[1/Sqrt[1 + \[Gamma]^2]],          E1 = EllipticE[1/Sqrt[1 + \[Gamma]^2]], y0},        y0 = ((\[Pi]^2 (IntegerPart[x + 1] - x + n))/(2 K1 E1))^(1/2);        Exp[-y0^2] NIntegrate[          Exp[y^2] Sin[(n + IntegerPart[x + 1])/2 \[Pi] + c y]^2, {y, 0, y0}]        ]      The problem remains, but I receive another error message:               NSum[BDMAF[n, 1, 1, 1], {n, 0, \[Infinity]}]      > NIntegrate::inumr: The integrand BDMAF(n,1,1,1) has evaluated to non- > numerical values for all sampling points in the region with boundaries (15. > 4.64782*10^14). >> How BDMAF function should be defined?


title: How to decouple a first order ODE system by eliminating coupled functions

text: Let's see an example of a first order ODE system : $$\begin{align*} y_1'&=a_{11}\cdot y_1+a_{12}\cdot y_2 \qquad(1)\\\ y_2'&=a_{21}\cdot y_1+a_{22}\cdot y_2 \qquad(2) \end{align*}$$ where $y_1$ and $y_2$ are functions we are to solve, and $a_{11},\; a_{12},\; a_{21},\; a_{22}$ are constants. I know 2 methods to solve this, one is to eliminate $y_1$ or $y_2$ by replacing, and then we will get 2 decoupled second order ODEs $$ y_1''-(a_{11}+a_{22})y_1'+(a_{11}a_{22}-a_{12}a_{21})y_1=0 $$ the other ODE is similar. The other method: Try to calculate the eigenvalues and eigenvectors of the coefficient matrix $\\{\\{a_{11},a_{12}\\},\\{a_{21},a_{22}\\}\\} $, and then get the general solutions for system of $y_1$ and $y_2$ simultaneously. Though the second method is more popular in the textbooks, I like the first one more. **So my question is: Which function in _Mathematica_ can decouple the ODE system by the _first_ method automatically?**


title: How would I plot the volume element in cylindrical coordinates?

text: I have this graph: ![http://i.stack.imgur.com/nag9x.png](http://i.stack.imgur.com/nag9x.png) But it doesn't have a function so I can't just plugin in a function into wolfram or mathematica to plot it. I have these coordinates to make it however:               (1, 0, 1)  (2, 0, 1)  (1, 0, 2)  (2, 0, 2)  (1, Pi/6, 1)  (2, Pi/6, 1)  (1, Pi/6, 2)  (2, Pi/6, 2)      How would I enter this in wolfram or mathematica to plot it? I am trying to download the STL file for it to print it in 3D.


title: How can I plot a function and its partial sums?

text: > **Possible Duplicate:**   >  How to Plot an Infinite Series   >  Coding mistake? I have _Mathematica_ v9.0 and I am a newbie to _Mathematica_. I am trying to plot a function $f(x)=x$ over the interval $(-\pi,\pi)$. Together on the same plot, I want two partial sums, $S_{4}$ and $S_{8}$. I have tried to plot $S_{4}$ and $f(x)$, but can't seem to get it right. Can anyone show me how to do it? Here is my code:               f[x_] = x     s[n_, x_] := Sum[((-1)^(n + 1)) (2/n) (Sin[nx]), {n, 1, Infinity}]      partialsums = Table[s[n, x], {n, 1, 4}];      Plot[Evaluate[f[x], partialsums], {x, -3, 3}]      Is there anything wrong with my code? Hope someone can shed light on this.


title: Coding mistake?

text: I have just started using _Mathematica_ with v9.0. I am trying to follow a computation from a book on Fourier series with the function $f(x)=x$ on the interval $-\pi < x < \pi$. Here is the code I have tried:               f[x_] = x;      a[0] = 1/2 Pi Integrate[f[x], {x, -Pi, Pi}]     a[n] = 1/Pi Integrate[f[x] Cos (nx), {x, -Pi, Pi}]     b[n] = 1/Pi Integrate[f[x] Sin (nx), {x, -Pi, Pi}]      I got the same result for a[0] and a[n] as per the book; for b[n] the answer generate by _Mathematica_ is 0, but the answer in the book is $\frac{2}{n}(-1)^{n+1}$. Can someone explain why is this the case? Note: I found a post here Fourier Coefficients in Mathematica but I can't seem to follow it.


title: Fourier Coefficients in Mathematica

text: I'm calculating Fourier Coefficients by hand and trying to verify them in Mathematica. However, in Mathematica I get them wrong by a factor of 2. Is there some part of the Mathematica functions I'm missing or am I doing something else wrong? What almost makes me think there is something wrong with Mathematica is that $c_0$ should be equal to $1/2 a_0$. When computing by hand $c_0$ is indeed $1/4$ but $a_0$ should be $1/2$ (as I get by hand) and not 1 as Mathematica tells me. Here is my code:               g[x_] := Piecewise[{{0, -Pi < x < 0}, {1, 0 < x < Pi/2}, {0,          Pi/2 < x < Pi}}]          makeper[f_, L_, offset_] := f[Mod[#, L, offset]] &          gTest = makeper[g, 2*Pi, -Pi]          Plot[gTest[x], {x, -4*Pi, 4*Pi}, PlotRange -> {0, 1},       Ticks -> {{-4 Pi, -3 Pi, -2 Pi, -Pi, 0, Pi, 2 Pi, 3 Pi, 4 Pi}, {-1,          0, 1}}, Filling -> Axis]          FourierCoefficient[gTest[x], x, n]          FourierCoefficient[gTest[x], x, 0]          FourierSinCoefficient[gTest[x], x, n]          FourierCosCoefficient[gTest[x], x, n]          FourierCosCoefficient[gTest[x], x, 0]      Any help would be appreciated!


title: Google speech API . Speech to text recognition with Mathematica

text: Has anyone tried to use the Google speech API with Mathematica? This would open up exciting possibilities when combined with the free form input already available in Mathematica and with the recently announced "Wolfram Language everywhere" strategy.


title: Increase 3D Graph thickness for 3D printing in Mathematica?

text: My code:               Plot3D[{(2*x*y)/(x^2 + y^2)}, {x, -2, 2}, {y, -2, 2}]      Output: ![enter image description here](http://i.stack.imgur.com/BAZKH.png) And now I can export this to STL by using the export STL command, however, when I try to print this on the MakerBot 3D printer there is a problem because the width of the graph is too thin. I need to increase the thickness of the width of the graph, can I do this in Mathematica?


title: Combining Rasterize with ParametricPlot

text: The goal is to create an image like the one below ![Desired output](http://i.stack.imgur.com/kjFI3.png) which was created using               ParametricPlot[{t, t^2}, {t, 0, 1}, Epilog -> Disk[{0.5, 0.5}, 0.09]]      but instead of using the Graphics primitive I want to use a Rasterized version of Disk. Using the commands below, how can I duplicate the result?               bkgd = Rasterize[Disk[{0, 0}, 0.09]];     pplot = ParametricPlot[{t, t^2}, {t, 0, 1}];      It is important that ParametricPlot remain un-Rasterized.


title: How to use Notation package with TraditionalForm

text: I know that I can use the `Notation` package to define my own custom notation. This works great for `StandardForm` output, but I would like the notation to apply when I convert it to TraditionalForm`. For example:               Notation[△ θ_ ⟸ △[θ_]]      This tells _Mathematica_ that if it finds a laplacian operator, mathematica should display it without the brackets. This works fine in `StandardForm`. However, if I use `TraditionalForm`, then _Mathematica_ inserts parentheses instead of following the rule. How can I make the rule apply to `TraditionalForm`?


title: Cannot evaluate differential in Mathematica

text: I have a small toy script in Mathematica that I am trying to use to evaluate the pdf of $Y$ where $Y=X^2$, and $X$ is uniformly distributed in $[0,a]$. The script is,               assum = {a > 0};      Subscript[P, X][x_] := If[Inequality[0, Less, x, LessEqual, a], 1/a, 0];          Y[x_] := x^2          Subscript[F, Y][y_] := Integrate[If[Y[x] <= y, 1, 0]*Subscript[P, X][x],         {x, -Infinity, Infinity}]          Subscript[P, Y][y_] := D[Subscript[F, Y][y], y]      It shows the correct form of the pdf:               In[192]:=     Simplify[Subscript[P, Y][y], assum]          Out[192]=     Piecewise[{{1/(2*a*Sqrt[y]), y > 0 && a^2 >= y}}, 0]      However, it doesn't evaluate the expression correctly:               In[194]:=     Simplify[Subscript[P, Y][a*(a/2)], assum]          During evaluation of In[194]:= General::ivar:a^2/2 is not a valid variable. >>          Out[194]=     D[1/Sqrt[2], a^2/2]      The session, in pretty printing looks like this: ![enter image description here](http://i.stack.imgur.com/i1Wqj.png)


title: How to know if a number is the square of a rational?

text: I'm pretty new with Mathematica and I was looking for a way to know whether a number is a square of a rational. I thought of               Head[Sqrt[myNumber]] == Rational      where `myNumber` came from replacing some variables with rational and integer numbers in a polynomial equation. Is there a better way to do it for large numbers, perhaps without computing the square root?


title: Hankel Transform integrals won't work in Mathematica

text: I'm trying to do this integral, which is shown on the Wikipedia page on the Hankel transformation: $$\int_0^{2\pi}\mathrm d\varphi\;e^{\mathrm im\varphi}e^{\mathrm ikr\cos(\varphi)}$$ The answer is supposed to be $$2\pi\mathrm i^m J_m(kr)$$ Mathematica cannot seem to do this integral; it simply gives me the input back:               Integrate[         Exp[I m phi] Exp[I k r Cos[phi]],         {phi, 0, 2 Pi},         Assumptions -> Element[m, Integers]     ]      Why can't this be done? It can do it for explicit values of m = 0 and m = 1, but after that it begins reporting the answer in terms of polynomials times a zero-order Bessel function or something similar. Perhaps I'm expecting too much of the software, but I'd expect it to be able to verify integrals listed on Wikipedia pages. Is there something I'm overlooking?


title: Mathematica to swf / fla

text: Is it possible to export an interactive (in terms of mouse clicks) _Mathematica_ manipulation / animation as an interactive swf file, including converted actionscript? I realise this is probably not possible from inside _Mathematica_ , but just wondering if there was a 3rd part program that did it?


title: Embed CDF into an Apple iBook?

text: **Edit** From the comments I received and verifying the information about CDF at wolfram.com, it appears that it is presently impossible to embed CDF into iBooks. WRI does not appear to be happy with this state of affairs, and promises to provide updates if and when CDF for the iPad is supported by Apple. * * * My question is related to an earlier question, How can I embed a Manipulate...in my website using CDF?. Has anyone had success in getting CDF to work in Apple iBooks? There are some lovely examples of how to use Computable Document Format (CDF) to embed Mathematica applets into electronic textbooks in Pearson's Calculus: Early Transcendentals textbook. See also Eric Schulz's Sharing Wisdom Gained in Publishing a CDF ebook and a video by him here. Apple's iBooks Author does not currently accept code such as that shown in the Vornoi diagram example. It does have an Author widget, called HTML, for accepting HTML in DashCode. Before learning to use DashCode (or seeking out someone who does) I'd like to know whether this is a promising option for publishing CDF applets in ebooks. Any help would be appreciated.


title: About an elementary limit

text: Here we have an elementary limit that Mathematica simply doesn't want to compute it.   What solutions might I have to fix that? Could you help here? As you can easily guess,   the limit is precisely $0$. Below you may find the code I used               N[Limit[Integrate[Sin[t^n], {t, 0, Pi/2}], n -> Infinity, Assumptions -> n \[Element] Integers]]


title: Cluster analysis returns questionable results

text: A few weeks ago I ran a cluster analysis on some economic data and (unfortunately only) now I found out that some results do not make sense. For instance I analyzed the development of unemployment rates form end-2005 to mid-2011 for 32 countries. One cluster contained among others Germany (Figure 1) and Spain (Figure 2) and another cluster among others Estonia (Figure 3). I couldn't understand why _Mathematica_ would put Germany and Spain together in one cluster, instead of Estonia and Spain. I just calculated the `EuclideanDistance` between Germany and Spain (17.3) as well as Spain and Estonia (9.1). These results underline my doubts on my cluster-analysis- results. ![Germany](http://i.stack.imgur.com/HpQQP.png)![Spain](http://i.stack.imgur.com/niVez.png)![Estonia](http://i.stack.imgur.com/wQiRv.png) Here is the code with which I worked: First I generate a random sample (n=1200) of the original data, to minimize the effect of the input-order in `FindClusters` (Note from Mathematica- Documentation: "The order of elements can have an effect on the clusters found")               data;  (*see below*)     Table[DeleteDuplicates[             Table[RandomSample[DeleteCases[data[[j]], {}]], {i, 1200}]], {j,Length[data]}];      Then I run `FindCluster` for the first time to determine the commonest length of each cluster.               ClustersUnSorted[list_]:=Table[Map[FindClusters,list[[i]]],{i, Length[list]}]      In my next step I say, that if the previous step found less than four clusters, I would like Mathematica instead to set the minimum number of clusters to 4.               ClusterLength[list_]:=Table[If[         Commonest[Map[Length,list[[i]]]][[1]]<4,         4, Commonest[Map[Length, list[[i]]]][[1]]],     {i, Length[list]}]      Then I run `FindClusters` again on the basis of the previously determined number of clusters.               ClustersUnSortedFixLength[list_,Flatten[ClusterLength_]]:=         Table[Map[FindClusters[#,ClusterLength[[i]]] &, list[[i]]], {i, Length[list]}]      The last two steps are there to get rid of duplicates as for each indicator I generated a random sample (see step 1).               ClustersSorted[list_] := Table[Table[         Sort[Map[Sort, list[[j]][[i]]]], {i, Length[list[[j]]]}],      {j, Length[list]}]          CommonestCluster[list_] := Map[Commonest, list]      The last two steps can be easily comprehended by the following example (instead of `RandomSample` I could use `Permutations[{1, 5, 3, 10, 100}]` for a much more reliable result but since `Permutations` is limited to input with length less than 11 it is not applicable to my data.):               Table[RandomSample[{1, 5, 3, 10, 100}], {i, 1200}];     Map[FindClusters, %];     Table[Map[Sort, %[[i]]], {i, Length[%]}];     Map[Sort, %];     Commonest[%]      exemplary data (Note: the time series are not always of the same length.):               Country1GDP = Join[{{"Country1", "GDP"}}, RandomReal[{-1, 1}, {6}]];     Country2GDP = Join[{{"Country2", "GDP"}}, RandomReal[{-1, 1}, {6}]];     Country3GDP = Join[{{"Country3", "GDP"}}, RandomReal[{-1, 1}, {6}]];     Country4GDP = Join[{{"Country4", "GDP"}}, RandomReal[{-1, 1}, {5}]];     Country5GDP = Join[{{"Country5", "GDP"}}, RandomReal[{-1, 1}, {6}]];          Country1Imports =        Join[{{"Country1", "Imports"}}, RandomReal[{-1, 1}, {6}]];     Country2Imports =        Join[{{"Country2", "Imports"}}, RandomReal[{-1, 1}, {5}]];     Country3Imports =        Join[{{"Country3", "Imports"}}, RandomReal[{-1, 1}, {6}]];     Country4Imports =        Join[{{"Country4", "Imports"}}, RandomReal[{-1, 1}, {6}]];     Country5Imports =        Join[{{"Country5", "Imports"}}, RandomReal[{-1, 1}, {6}]];          CompleteGDP = {Country1GDP, Country2GDP, Country3GDP, Country4GDP,         Country5GDP};     CompleteImports = {Country1Imports, Country2Imports, Country3Imports,         Country4Imports, Country5Imports};          data = {CompleteGDP, CompleteImports};


title: In a Function, how to Ensure Code Runs Prior to an Abort

text: Is there a way to set aside some code in a function that will be triggered to run if the evaluation of the function is aborted by a user? Specifically, I have a function that has to open a log file to write to, but the algorithm in the function in many cases doesn't finish so it has to be aborted:               f[]:= Module[{},         logstream = OpenWrite["logfile.txt"];         (*  algorithm that often doesn't finish  *)         Close[logstream];     ];      Is there some way to ensure within the function that the `Close[logstream]` gets run even if the function gets manually aborted in the loop? (Or is there some other mechanism to achieve the same thing?) I've come across `AbortProtect[]` which seems like it should be useful here, but I don't think it's applicable in this situation.


title: Symbolic Optimisation

text: I'm trying to solve symbolically the following optimisation: $$ \min_{q_uu}\ \Biggl[ q_u q_{uu}\psi B_{uu} + q_u q_{ud}\psi B_{ud} + q_d q_{du}\psi B_{ud} + q_d q_{dd}\psi B_{dd} $$ $$ \+ \eta_s \left ( q_u \log \frac{q_u}{p_u} + q_d \log \frac{q_d}{p_d} \right ) $$ $$ \eta_p q_u \left ( q_{uu} \log \frac{q_{uu}}{p_{uu}} + q_{ud} \log \frac{q_{ud}}{p_{ud}} \right ) \+ \eta_p q_d \left ( q_{du} \log \frac{q_{du}}{p_{du}} + q_{dd} \log \frac{q_{dd}}{p_{dd}} \right ) \Biggr] $$ subject to $$ q_u + q_d = 1\ ,\ p_u + p_d = 1\ ,\ q_{uu} + q_{dd} = 1\ ,\ p_{uu} + p_{dd} = 1 $$ is there an elegant method for solving such a problem? My approach has been to substitute in the constraints , define the resulting objective as a function , and then differentiate. Unfortunately I get a strange output with 'pattern' coming in for some reason. Apologies if this is trivial - I'm new to mathematica...               f[qu_, quu_, qdu_, \[Psi]_] := (qu*quu*\[Psi]*Buu + qu*(1 - quu)*\[Psi]*Bud      + (1 - qu)*qdu*\[Psi]*Bud + (1 - qu)*(1 - qdu)*\[Psi]*Bdd) +      \[Eta]s*(qu*log[qu/pu] + (1 - qu)*log[(1 - qu)/pd]) +      \[Eta]d*qu*(quu*log[quu/puu] + (1 - quu)*log[(1 - quu)/pud]) + \[Eta]d*(1 - qu)*           (qdu*log[qdu/pdu] + (1 - qdu)*log[(1 - qdu)/pdd]);      Then ,               FOC = D[f[qu_, quu_, qud_, \[Psi]_], quu]      but I get a strange answer ?               -Bud qu_ \[Psi]_ (Pattern^(1,0))[quu,_]+Buu qu_ \[Psi]_ (Pattern^(1,0))[quu,_]+qu_          Subscript[\[Eta], d] (-log[(1-quu_)/pud] (Pattern^(1,0))[quu,_]+log[quu_/puu]      (Pattern^(1,0))[quu,_]-((1-quu_) (log^\[Prime])[(1-quu_)/pud] (Pattern^(1,0))     [quu,_])/pud+(quu_ (log^\[Prime])[quu_/puu] (Pattern^(1,0))[quu,_])/puu)


title: How make AddMenuCommands work in an init.m

text: I want to add some items to the Mathematica 8.0.4 Help menu (under Mac OS X). In                [$UserBaseDirectory]/Autoload/FrontEnd/init.m      I have the following cell:                 FrontEnd`AddMenuCommands["OpenHelpLink",{Delimiter,       Item["Installed Add-Ons",FrontEndExecute[FrontEnd`FrontEndToken["OpenHelpLink",                {"guide/InstalledAddOns",Automatic}]]],       Item["Standard Extra Packages",FrontEndExecute[FrontEnd`FrontEndToken["OpenHelpLink",              {"guide/StandardExtraPackages",Automatic}]]],       Delimiter}]      but the items are not added to the Help menu when I start Mathematica. Do I have the syntax wrong, or should this go in some other init.m?


title: How to hide inline Cells

text: By giving a cell the simple option `CellOpen -> False`, it can be hidden from view. But for inline cells (cell within a cell) this does not work. An option `Visible -> False` only seems to exist for notebooks, not for cells. What to do?


title: Mathematica code for Bifurcation Diagram

text: At the moment I am trying to construct a bifurcation diagram of the iterative function $f(x)=$ $ax-1.1975x^3$. I've scoured the internet for pre-made bifurcation diagrams and found many (mostly of the logistic map). However, as the code is quite complicated I am not sure how to edit the code so that it deals with my function instead of the logistic one. Would anyone have a general template for the code to create a bifurcation diagram of a function? Ideally, I would like to have $a$ on the x-axis and equilibrium values on the y-axis.


title: Preventing Numerical value from being evaluated

text: I have searched stackoverflow (and comparable pages) for quite a while now (got redirected from there to this specialized stack), and I surrender. I am trying to evaluate an expression that is small in the end numerically.   Example:               Log[Log[Log[6^5^4^3^2^1]]]=12.9525...        WolframAlpha has no problem evaluating these values for (any/a very high) amount of exponents (I tried it up to 20). I guess it is possible to achieve this in Mathematica aswell? I tried Hold, Defer etc, as described in   http://stackoverflow.com/questions/1616592/mathematica-unevaluated-vs-defer- vs-hold-vs-holdform-vs-holdallcomplete-vs-etc   Hoever none of these did what I hoped for. Is it a matter of explaining Mathematica the rules of logarithms?               FullSimplify[Log[x^b], x>0 && b>0] expands it nicely, however that is not what I want (I have explicit numbers). Is there any way to perform the calculations WolframAlpha performs with mathematica (obviously avoiding the WolframAlpha Output Operator ;)) ? Is there some Option/Assumption etc I have overlooked? * * * For this specific question there is a recursive algebraic solution: $$ n^{(n-1)^{...^1}}=e^{\log(n)*(n-1)^{...^1}} $$ and so on, remove a bunch of e-s at the end. I guess Wolfram|Alpha uses this. I would still like to know if theres a true Mathematica solution to this.


title: What exactly does GenerateConditions do?

text: Consider for example this strange behavior:               Integrate[1/x, {x, 0, Infinity}, GenerateConditions -> False]     (*0*)      I'd also like to know the difference between `GenerateConditions -> Automatic` and `GenerateConditions -> True`.


title: Solving a system of nonlinear equations self-consistently

text: I am trying to solve a set of three non-linear equations in _Mathematica_. I need help with them. The _Mathematica_ code (in plain text format) is attached below. If you copy & paste the code below into a Notebook the actual input will become clear. It is too complicated to be typed up, hence I am displaying it in this way. I cannot seem to converge to a solution which is correct. I can get answers but I don't think that makes sense based on the problem that I am doing. Neither χ nor Δ should go to zero. * * * Defining the functions first (copy & paste in a Notebook) * * *               tχfn[x_?NumericQ,y_?NumericQ,μ_?NumericQ,χ_?NumericQ,Δ_?NumericQ] :=       (Cos[x]+Cos[x/2+Sqrt[3]/2 y]+Cos[x/2-Sqrt[3]/2 y]-μ)^2/Sqrt[4 χ^2 (Cos[x]+        Cos[x/2+Sqrt[3]/2 y]+Cos[x/2-Sqrt[3]/2 y]-μ)^2+4 Δ^2 (Cos[x]+Cos[x/2+Sqrt[3]/2 y]+        Cos[x/2-Sqrt[3]/2 y])^2]          tΔfn[x_?NumericQ,y_?NumericQ,μ_?NumericQ,χ_?NumericQ,Δ_?NumericQ] :=       (Cos[x]+Cos[x/2+Sqrt[3]/2 y]+Cos[x/2-Sqrt[3]/2 y])^2/Sqrt[4 χ^2 (Cos[x]+        Cos[x/2+Sqrt[3]/2 y]+Cos[x/2-Sqrt[3]/2 y]-μ)^2+4 Δ^2 (Cos[x]+Cos[x/2+Sqrt[3]/2 y]+        Cos[x/2-Sqrt[3]/2 y])^2]          tμfn[x_?NumericQ,y_?NumericQ,μ_?NumericQ,χ_?NumericQ,Δ_?NumericQ] :=       (χ^2 (Cos[x]+Cos[x/2+Sqrt[3]/2 y]+Cos[x/2-Sqrt[3]/2 y]-μ))/Sqrt[4 χ^2 (Cos[x]+        Cos[x/2+Sqrt[3]/2 y]+Cos[x/2-Sqrt[3]/2 y]-μ)^2+4 Δ^2 (Cos[x]+Cos[x/2+Sqrt[3]/2 y]+        Cos[x/2-Sqrt[3]/2 y])^2]      * * * Setting up the non-linear solution (copy paste in a notebook) * * *               FindRoot[      {       NIntegrate[tχfn[x, y, μ, χ, Δ], {x, (4*Pi)/3, (10*Pi)/3}, {y, 0, (4*Pi)/Sqrt[3]},                  Method -> "MultiPeriodic"] == 1.5,       NIntegrate[tΔfn[x, y, μ, χ, Δ], {x, (4*Pi)/3, (10*Pi)/3}, {y, 0, (4*Pi)/Sqrt[3]},                  Method -> "MultiPeriodic"] == 1.5,       NIntegrate[tμfn[x, y, μ, χ, Δ], {x, (4*Pi)/3, (10*Pi)/3}, {y, 0, (4*Pi)/Sqrt[3]},                  Method -> "MultiPeriodic"] == 0.125      },      {{μ, 0.02}, {χ, 1.}, {Δ, 1.}},      Evaluated -> False     ]      * * * I have tried without the `"MultiPeriodic"` option, with `"MonteCarlo"` option, and even used the basic default option.


title: Making a screen icon by Mathematica

text: Is it possible to make within Mathematica an image file to be used as a screen icon? Could you kindly give an example?


title: Why can't Mathematica solve this system of equations?

text: I am trying to solve the following system of equations for three unknowns _Theta, Nu,_ and _K_. All the other parameters are constants. The third argument in `Solve`, { _ub, uc, pm_ }, is to be eliminated: i.e. I don't want the solution to contain _ub, uc,_ or _pm_.               system = { Subscript[p,m] == K (Pi (c + uc)^2 - Pi (b + ub)^2)/(Pi c^2 - Pi b^2) ,      ub == (b (-2 a^2 Subscript[p,i] + (-b^2 (-1 + ν) + a^2 (1 + ν))     Subscript[p,m]))/((a^2 - b^2) θ) ,     uc == (c ((c^2 (-1 + ν) - d^2 (1 + ν)) Subscript[p,m] + 2 d^2      Subscript[p,o]))/((c^2 - d^2) θ) } // FullSimplify          Solve[system, {θ, ν, K}, {ub, uc, Subscript[p,m]}]      With the code as it stands, my Mathematica 9 just hangs. I have also tried `Reduce`. Could you please help me find what's wrong with my Mathematica code or identify the fault with the logic of how I posed the question? Thank you very much.


title: Using implicit function theorem to examine the relation between variables

text: I have an implicit function with seven variables defined as follows: $F(g,a,b,c,d,e,f)=2g^5 (1+g)^{-(2+a+b)} \Big(f(c-1)(e-1)(1+g)^a - (d-1)(1+g)^b \big(1+ef+(c-1)(1+f)(1+g)^a\big)\Big)=0$ All variables are subject to certain restrictions: $-1<g<1$, $0<b<a$ and $0<c,d,e,f<1$. Now I would like to examine how changes in each of $a,b,c,d,e,f$ affect $g$. Maybe I should use an implicit function theorem: $\frac{\partial g}{\partial a}=-\frac{\frac{\partial F}{\partial a}}{\frac{\partial F}{\partial g}}$ and see if this expression is positive or negative. It is most probable that it will not be a clear-cut positive/negative but will be positive/negative 'under certain conditions'. Anyway, for this, I have first coded the implicit function:               F[g_,a_,b_,c_,d_,e_,f_] := 2g^5 * (1 + g)^(- 2 - b - a) * (f * (c - 1) * (e - 1) * (1 + g)^a - (d - 1) * (1 + g)^b * (1 + e * f + (c - 1) * (f + 1) * (1 + g)^a )))      And the partial derivatives are coded as:               D[F[g,a,b,c,d,e,f],a]     D[F[g,a,b,c,d,e,f],g]      These produce very scary results which do not allow to see if positive or negative. Is there any way to check these with Mathematica? Or, is this the right way to proceed at all?


title: Is there no documentation for Method in Eigensystem?

text: There does not appear to be any documentation on how to use `Method` in `Eigensystem`, or at least not in Version 9.0.1 of Mathematica (unless I'm looking in the wrong place). The documentation page for `Eigensystem` just gives a single example of using an Arnoldi shift as               Method -> {"Arnoldi", Shift -> -4}      and the internal implementation page at `tutorial/SomeNotesOnInternalImplementation#5107` just says that `Eigensystem` uses an ARPACK Arnoldi solver for iterative computing of the first $k$ eigenvectors. The documentation page on `Method` likewise makes no mention of what options are available for use in eigendecomposition problems. Is there any documentation on what possible syntax options are available for `Method` in the context of `Eigensystem`?


title: Ordering for Pattern matching in Subscripts

text: I have some transformation rules acting on subscripted variables. When I match the a product the order matters.               Subscript[Z, 2, 1] Subscript[Z, 3, 1] /.       Subscript[Z, l_, m_] Subscript[Z, k_, n_] -> {{l, m}, {k, n}}     Subscript[Z, 3, 1] Subscript[Z, 2, 1] /.       Subscript[Z, l_, m_] Subscript[Z, k_, n_] -> {{l, m}, {k, n}}      both cases yield               {{3, 1}, {2, 1}}.      It seems k,n always get assigned the subscripts with the smaller first value. Why is this and how can I influence this?


title: Using lists as optimization parameters

text: > **Possible Duplicate:**   >  Minimizing a function of many coordinates Suppose that the function $F[\vec{x}]$ computes a certain polynomial of the elements of the list $\vec{x}$. How can I use `Nminimize` or `FindMinimum` to find the vector $\vec{x}$ which minimizes the function $F[\vec{x}]$ ? Edit: I found this question Minimizing a function of many coordinates which asks about the same thing. The answer offered there using arrays, worked for my problem as well.


title: Image processing: extracting ordered contour

text: Continuing the question How to extract the edge from a set of points and its answer by Simon Woods, I would like to ask if there is a way to extract the boundary of ![enter image description here](http://i.stack.imgur.com/h2Ewf.png) obtained as               ToExpression@Import@"http://pastebin.com/raw.php?i=741qaDt2";     boundary = Complement[spiel, Intersection @@          Outer[Plus, {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}, spiel, 1]];      ordered in such a way that               ListPlot[boundary,Joined->True]      would give a polygon outlining the shape? The points extracted the way they are in the answer are not ordered along the boundary: ![not ordered points](http://i.stack.imgur.com/vY31D.png) It would be even better to know if it is possible with `MorphometricComponents[]`, because images I am working on look like that: ![typical image](http://i.stack.imgur.com/tmKw2.png) With `MorphometricComponents[]` one can extract perimeter lenghts, baricenters and whatever he likes for the components, but not the ordered perimeter points themselves. So the question is if there is a way to do that? Just to be clear: for each region in the picture, I would like to have the ordered coordinates of the points of the boundary `boundary={{x1,y1},{x2,y2},...}` such that `ListPlot[boundary,Joined->True]` would give polygons outlining the shapes.


title: Combining Plot and ListPlot in a manipulation

text: I have a plot of data points using `ListPlot` and another plot using a function. I want the function to look like the data points. I am able to use `Manipulate` to change the variables in the function when plotting, but it's annoying to then have to compare this to a `ListPlot` each time.   Is there a way to combine a `Plot` and a `ListPlot` while still giving me the ability to manipulate variables in the plot? Here's an example that's similar but simplified:               function = x^2 + a + b + c          Manipulate[       Show[         Plot[function, {x, 0, 1}],          ListPlot[{{0, 0}, {1, 1}, {2, 2}}],         PlotRange -> All],       {a, -1, 1},       {b, -1, 1},       {c, -1, 1}]      It works if I plug in the function, but not by defining the function.


title: How to draw a spring?

text: I am new to _Mathematica_ and have recently been exploring graphical animations. So I was experimenting with simple concepts in periodic motion and hence wondered how can I draw a simple spring? Is there an easier/better way to do this? The solution I arrived at was a simple function to draw a spring between two $x$ and $y$ coordinates.               hspring[a0_, x10_, x20_] :=       Module[{a = a0, x1 = x10, x2 = x20, n = 100},       h = (x2 - x1)/n;       xvalues = Table[k, {k, x1, x2, h}];       yvalues = Table[a Sin[m Pi/2], {m, 0, n}];       Line[Transpose @ {xvalues, yvalues}]      ];          vspring[a0_, y10_, y20_] :=       Module[{a = a0, y1 = y10, y2 = y20, n = 100},       h = (y2 - y1)/n;       yvalues = Table[k, {k, y1, y2, h}];       xvalues = Table[a Sin[m Pi/2], {m, 0, n}];       Line[Transpose @ {xvalues, yvalues}]      ];          Manipulate[      Graphics[{hspring[0.2, 0, Abs[2 Sin[x]]], Red, PointSize[0.03],         Point[{Abs[2 Sin[x]], 0}]}, PlotRange -> {{0, 3}, {-1, 1}}],        {x, 0.01, 2 Pi, 0.1}]      ![Horizontal spring](http://i.stack.imgur.com/LmdOY.gif) ![Vertical Spring](http://i.stack.imgur.com/9x9xb.gif)


title: How can I conveniently call igraph through RLink?

text: Mathematica has lots of functions for working with graphs, but this functionality is not yet as mature as the igraph library. It is useful to have access to igraph from Mathematica, both for accessing functionality that Mathematica does not have and for verification. Calling igraph through its C interface is possible, but not convenient. How can we use RLink to call it more conveniently?


title: WordData for other languages

text: _Mathematica_ already includes dictionaries for a lot of languages. What I am looking for is a handy semantic/grammatic database for Hungarian, just like `WordData` for English. Is it available in any form? Does Wolfram intend to include other languages into _Mathematica_ in the future? Does anyone know anything about the trajectory WRI aims for concerning languages?


title: Plotting large datasets

text: I have a lot of data (e.g., 64x8192), to plot and it consumes too much memory (more than 2 GB) causing Mathematica to return "no memory available". For example,               lst = Table[Sin[x^2 + y^2], {x, 2^7}, {y, 2^13}];     ListDensityPlot[lst]      Is there any way to cope with it?


title: Efficiently generating 3D histograms for large sets 2D coordinates

text: I'm attempting to generate a 3D histogram for a large set of two-dimensional coordinates ($\approx 10^7$). the x- and y-components of each coordinate are rounded to the nearest integer, and these rounded values are used as indices in a histogram matrix counting the number of coordinates rounded to the same integer values. For example, if we have some list of elements:               ElementList={{102.2134124213,101.2421321312},{500.2,2761.7},{102.542423,101.344}}      We would add $+2$ to position {102, 101} in the histogram matrix, and $+1$ to the position {500, 2761}. Here's the piece of code I'm running:               ElementList = Table[{RandomReal[{1, 2000}], RandomReal[{1, 2000}]}, {x, 1, 10^7}];          HistogramDimX = 2000;     HistogramDimY = HistogramDimX;          ImageMatrix = Array[0 &, Length[ElementList]];     ImageMatrixHistogram = Array[0 &, {HistogramDimX, HistogramDimY}];          For[i = 1, i <= Length[ElementList], i++,          RoundedCoordinate = Round[ElementList[[i]]];     ImageMatrixHistogram[[Round[RoundedCoordinate[[1]]],      Round[RoundedCoordinate[[2]]]]] += 1;          ];          MatrixPlot[ImageMatrixHistogram, ColorFunctionScaling -> True, MaxPlotPoints -> 10^12]      This takes 94.7 seconds to run on a single X5690 3.47 GHz Intel Xeon(R) CPU. Is there a way to significantly speed this process up, and use a more efficient data structure that scales proportionally with the number of elements in ElementList rather than the dimensions of the histogram matrix (i.e. HistogramDimX & HistogramDimY)? I suppose I'd very much like the output to look something like the output of MatrixPlot in the above example. Directly applying MatrixPlot to the data works terribly, which I suppose is due to some auto-interpolation occurring.


title: Making a "cached" version of `Manipulate[]`?

text: I have a function that is a bit too slow for `Manipulate[]`. Right now I plan to cache outputs outside the manipulation and just have the manipulator select among cached outputs, but I am wondering if some better version of that trick exists. Basically, I am creating a CDF presentation in which I intend to show the effect of different values for a correlation parameter $\rho$ in Monte Carlo simulations to the audience using `Manipulate[]` to show the resulting sample histograms. The simulation process is too slow to make for a good user experience as a live function, so one way or another I will have to cache some things. It seems that if I am clever about writing a `Module` as an argument to `Manipulate` I should be able to make it cache, say, 199 different output sets corresponding to the various % correlations between -0.99 and +0.99.


title: Most efficient way to obtain samples from high-dimensional multivariate distributions?

text: Is `MultinormalDistribution[]` efficient and easy to use for high dimensions? I have a variable $n$ representing the dimension of a Monte Carlo integration I do on a multivariate Gaussian copula, where typical values of $n$ are near 100. I am using a simple correlation matrix made from `ConstantArray[ρ, {n,m}]` (except on the diagonal). For now I simply wrote a function that calls `RandomVariate[NormalDistribution[0,1], {n,m}]`, generates the correlation matrix, calculates its Cholesky decomposition, and then multiplies to obtain the correlated multivariate normal samples. It works fine and was easy to code and understand. However, generating correlated multivariate $t$ samples is more involved, so it would be convenient to just drop in a call to `MultivariateTDistribution[]`. That leaves me with two issues:   1. Setting up `MultinormalDistribution[]` with an arbitrary variable count is hard because it seems to want variable names, which I am having trouble generating programmatically.   2. I am not sure that the internals of `RandomVariate` on `MultinormalDistribution[]` and `MultivariateTDistribution[]` are set up to efficiently obtain high-dimensional sample sets. If the efficiency is not expected to be that great I will stick with my current approach. Otherwise I would appreciate advice on using `MultinormalDistribution` in this high-dimensional context, since it would be worth investing the time in this more elegant and Mathematica-like approach.


title: How to integrate functions of linearly interpolated data?

text: At first, consider integration of pure `InterpolatingFunction`. Importing some data (works in v.9, for earlier versions one can use this link to download zipped `M` file which can be imported by `data=Import["data.zip", "data.m"]`):               data = First@        Import["http://webbook.nist.gov/cgi/cbook.cgi?JCAMP=C67561&Index=17&Type=IR"];      Transforming the data according to an integrand:               integrand[ww_, k_] := k/ww     dataF = {#1, integrand[#1, #2]} & @@@ data;       Now interpolation and integration:               In[13]:= int = Interpolation[dataF, InterpolationOrder -> 1];     ni = NIntegrate[int[ww], {ww, dataF[[1, 1]], dataF[[-1, 1]]}]      > >     During evaluation of In[13]:= NIntegrate::ncvb: NIntegrate failed to >     converge to prescribed accuracy after 9 recursive bisections in ww >     near {ww} = {1053.057940138439}. NIntegrate obtained > 0.000035786622823277624 >     and 1.6106181332828143*^-6 for the integral and error estimates. >> >   >     Out[14]= 0.0000357866 >   I am confused by unexpectedly high absolute error (see next) and strange error `Message` generated by `NIntegrate` when integrating function of linearly interpolated data. Note that `NIntegrate` fails to converge on linear (!) piece of the polyline:               In[15]:= Nearest[dataF[[All, 1]], 1053.057940138439`, 2]      > >     Out[15]= {1053.0705299372542, 1053.010264968627} >   `Integrate` is able to integrate pure `InterpolatingFunction`s:               i = Integrate[int[ww], {ww, dataF[[1, 1]], dataF[[-1, 1]]}]      > >     0.00003537589327711996 >   We can check it by direct integration:               exactSum =       MovingAverage[dataF[[All, 2]], 2].Differences[dataF[[All, 1]]]      > >     0.00003537589420603186 >   The differences:               {ni, i} - exactSum      > >     {4.10729*10^-7, -9.28912*10^-13} >   One can see the large error for `NIntegate` output. Increasing `PrecisionGoal` and `MaxRecursion` does not give much:               ni = NIntegrate[int[ww], {ww, dataF[[1, 1]], dataF[[-1, 1]]},         MaxRecursion -> 25, PrecisionGoal -> 16] // Quiet     exactSum - ni      > >     0.000035342690008474926 >   >     3.32042*10^-8 >   At this point my questions are:   1. Why `NIntegrate` fails to converge when interpolating the polyline? Why it has biggest trouble not even on a node but on a linear piece of the polyline?    2. Is it possible to achieve for `NIntegrate` at least the same precision as it is for `Integrate`? Or, better, as it is for direct summation? Now I wish to integrate a function of linearly interpolated data:               int2 = Interpolation[data, InterpolationOrder -> 1];     ni2 = NIntegrate[int2[ww]/ww, {ww, data[[1, 1]], data[[-1, 1]]},         MaxRecursion -> 22, PrecisionGoal -> 19] // Quiet      > >     0.000035342690032342044 >   `Integrate` cannot work with functions of interpolated data at all. Direct summation gives:               area[{w1_, k1_}, {w2_, k2_}] =        Integrate[(a + b ww)/ww, {ww, w1, w2}, PrincipalValue -> True] /.          First@Solve[a + b w1 == k1 && a + b w2 == k2, {a, b}] // Simplify;     exactSum = Total[area @@@ Partition[data, 2, 1]]          exactSum - ni2      > >     0.000035375894186915904 >   >     3.32042*10^-8 >   Again, I get very large error. It is not always possible to get closed-form formula for direct summation. So the final question is: **what is the best way to integrate smooth functions of linearly interpolated data with high precision?**


title: Mathematica Import functions fails for data download from website

text: I am trying to download some data from a website that uses "java enabling" to tell me that I cannot download the data. Using               Import[ "website...", "Data"]       I get               {....."You need Javascript enabled to view live scores. Loading... Loading... ..}      Do I have to use something like squid to change requester_id so it shows up as a web-browser rather than Mathematica ? I have now fixed this problem. The second problem is that Mathematica does not support iframe. Does it ? Is there a way around this issue ?


title: $InputFileName backwards compatibility

text: What would be a good replacement for `$InputFileName` (which has been added recently to Mathematica 8) to achieve backwards compatibility with let's say M6 and M7? I am using it for loading auxiliary data from a package file and found that it is a convenient way to use relative paths for this purpose. However, I am not sure how to achieve this in M6 and M7. For example,               $PackageDir=DirectoryName[$InputFileName];     svgParser=XML`Parser`InitializeXMLParser["svg",          FileNameJoin[{$PackageDir,"Cache/svg10.dtd"}]]


title: Why does piecewise plot have a discontinuity when the function, first and second derivatives are equal?

text: There were some related questions to this one, but in this case we have the function value, the first derivative and the second derivative all equal (that was actually the problem I was solving). We have:               f[x_] := Piecewise[{{3 x^2 - 3 x + 1, x >= 1}, {x^3, x < 1}}]     Plot[f[x], {x, 0, 1.5}]      The answer in those other questions was to use "Exclusions -> None" and it can be used here, but why is this happening since we are good in all derivative information? **Update** Some examples of the related questions are:   * Why does Plot leave gaps in the graph of a continuous function?   * Plot showing discontinuity where it shouldn't   * Mathematica plots a discontinuity in piecewise function that does not exist


title: CountryData et al. and associated InputStream

text: **Quick update** I found a way to solve this in webMathematica, using `CollectStreams`. But still, below problem leaves me puzzled, I would very much like to learn how this works. **Original** This question is motivated by the fact that I started to used webMathematica and observed a (to me) strange behavior there. I tried to isolate the problem, in plain Mathematica. I think it is rather closely related to this question, so I hope it is not considered a duplicate. **Setup** We start with a fresh kernel and check the `Streams`:               Quit[]     Streams[]      > `{OutputStream["stdout", 1], OutputStream["stderr", 2]}` Next, we load some `CountryData` related info, such as:               CountryData["CH", "Population"]      > `7.595*10^6` Checking `Streams` again:               Streams[]      > `{OutputStream["stdout", 1], OutputStream["stderr", 2], InputStream[ > "/Users/myusername/Library/Mathematica/Paclets/Repository/\ > CountryData-8.0.62/Data/CountryData.wdx", 111]}` Ok, `CountryaData` opened a new stream to read the info from. All good. Now we `Close` that stream manually:               Close[Last@Streams[]]      so we're back to               Streams[]      > `{OutputStream["stdout", 1], OutputStream["stderr", 2]}` and then we try to get the population a _different_ country:               CountryData["FR", "Population"]      > General::openx: > InputStream[/Users/myusername/Library/Mathematica/Paclets/Repository/CountryData-8.0.62/Data/CountryData.wdx,111] > is not open. >> > > BinaryRead::openx: > InputStream[/Users/myusername/Library/Mathematica/Paclets/Repository/CountryData-8.0.62/Data/CountryData.wdx,112] > is not open. >> > > `$Failed and interestingly, this still works:               CountryData["CH", "Population"]      **My Conclusion** It seems to me that on a fresh kernel, the first time we call `CountryData` (and e.g. `ElementData`, ...) it opens a stream and subsequently remembers that it has (should have) an open stream and tries to read from it. If that stream gets closed (which seems to happen in webMathematica, e.g. on reload of a page), you get `$Failed`. **My Question** Do you know where `CountryData` stores the stream it is associated with, in the open session? Is there a way to "reset" `CountryData` without quitting the kernel? Or can I add the lost stream manually? I tried various possiblities, such as:               OpenRead["/Users/myusername/Library/Mathematica/        Paclets/Repository/CountryData-8.0.62/Data/CountryData.wdx"]      but I got the wrong serial number - and `CountryData` was still referring to the previous one (`111` in above example). **Note** Please let me know if the webMathematica code I used to play with is of interest (how to replicate etc)


title: Resolve a conditional expression including exists and forall

text: I don't know the `Resolve` function exactly, especially when involved with `Exists` and `ForAll`, could you please help me in the following example? > $\forall C$, can we find some $x>0$, such that $$ > c(x)=(C+2x)x^2+C^2x+2Cx^2+C\geq0, $$ and $$ C<-2x $$ holds at the sametime?


title: Why does the shape of my function change when plotted alongside another function?

text: I wanted to investigate the periodicity of functions so I tried to `Plot` them on Mathematica using the `Plot` function. The particular function was $\cos(\cos(x))+\cos(\sin(x))$. What I did was first plot them individually, then together. Individual results were as follows:               Plot[Cos[Cos[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}],     {1.530, 1.535, 1.540}}, AspectRatio -> .1]      ![diagram 1](http://i.stack.imgur.com/3JnEb.png)               Plot[Cos[Sin[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}],      {1.530, 1.535, 1.540}}, AspectRatio -> .1]      ![diagram 2](http://i.stack.imgur.com/qAXoE.png)               Plot[Cos[Cos[x]] + Cos[Sin[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}],     {1.530, 1.535, 1.540}}, AspectRatio -> .1]      ![diagram 3](http://i.stack.imgur.com/ncTVa.png) Now all together:               Plot[{Cos[Cos[x]], Cos[Sin[x]], Cos[Cos[x]] + Cos[Sin[x]]}, {x, -Pi, Pi}, Ticks ->     {Table[x*Pi, {x, -1, 1, 1/2}]}, AspectRatio -> 1/2]      ![diagram 4](http://i.stack.imgur.com/wJsrL.png) See the yellow plot? That's supposed to be my original function but the individual function plot seems to be very different. Why is that so? Is it some system error or is it my fault?


title: NotebookFind and String Pattern Expressions

text: Is there a way that `NotebookFind` can be used to match string pattern expressions rather than just strings? The documentation for `NotebookFind` states that only a string, box expression or complete cell can be used as the search term so my question is really whether or not pattern matching can be achieved through writing some additional code that wraps or replaces `NotebookFind`. One obvious strategy would be to convert the notebook to a text representation using `NotebookGet` and then perform the pattern matching search on the text representation, but this is not ideal for my intended application because I would like any match that is found to be highlighted (by selecting it) much like `NotebookFind` already does. Eventually I would like to build a replacement for Mathematica's built-in Search and Replace functionality. Two key enhancements that I hope to provide are:   1. the ability to search and replace across all open notebooks in the front-end or all notebooks in a selected directory (which is not too difficult to accomplish) and    2. the ability to search and replace using string pattern expressions.  I realize that Workbench already offers these features. My goal is to enable users who prefer the notebook interface (rather than the .m editor promoted by Workbench) to continue developing complex multi-notebook packages from within the front-end. **Edit:** Celtschk proposes a strategy below in the comments that may provide a partial solution. One of the issues that is still not clear however is how to deal with _surrounding context_ in a pattern match when returning to `NotebookFind`. Perhaps the following example will help clarify the potential problem. Without digressing into the theory of formal grammars, let's say that we want our string pattern language to be powerful enough to express not just wildcard patterns but also surrounding context. Imagine in particular that we want to find each occurrence of the string pattern "foo?" in some notebook that is enclosed by a pair of parentheses (not necessarily immediately surrounding the "foo?" pattern). We can do that easily using standard Mathematica string pattern expressions by operating on the string representation of the notebook. Let's now assume that there is one occurrence of "foo1" and two occurrences of "foo2" in the notebook, the latter of which is not surrounded at any distance by a pair of parentheses. How would we then exclude the second "foo2" from being found when we return to `NotebookFind` to search for "foo1" and "foo2"? Of course we could have matched the entire string plus surrounding context (which in this case would include the surrounding pair of parentheses) when searching the string representation for parentheses-enclosed instances of "foo?" -- but this is not really what we want, and in certain instances could be quite inconvenient in a tool designed to assist the user in refactoring a large body of Mathematica code.


title: Manipulate Evaluation Order Problem

text: I seem to be getting some unintended results from a nested `Manipulate` that I have not been able to resolve. I boiled down the problem I'm having to a simplified version. I can not seem to get the evaluation order of `Manipulate` correct.               Manipulate[      Manipulate[       Print[{Parity, n}];       {Parity, n},       {n, Select[Range[1, 10, 1], Parity]}      ],      {Parity, {OddQ, EvenQ}}     ]      ![Mathematica graphics](http://i.stack.imgur.com/2l52K.png) The problem isn't what it shows in the window, it is with what the Print statement outputs. For instance, if it is in the state EvenQ,2 and I click on OddQ, the Print output will read:               {OddQ,2}      Despite the fact that it shows {OddQ,1} in the window. Why is this, and how can I fix it? In this boiled-down example it doesn't matter, but in my real life one, an error is issued every time I switch the outer manipulate.


title: Representing a value in an output as a self defined variable

text: I'm trying to find a way to have Mathematica always represent a numerical value as a self defined variable that I define using `lhs=rhs`. For example, if I execute               In[1]:=Solve[x^3 - 1 == 0, x]     Out[1]:={{x -> 1}, {x -> -(-1)^(1/3)}, {x -> (-1)^(2/3)}}      What I'd like is to define a variable `rho=(-1)^(1/3)` so that when I execute the above I get out something like               In[1]:=Solve[x^3 - 1 == 0, x]     Out[1]:={{x -> 1}, {x -> -rho}, {x -> rho^2}}      Is this possible? I'm basically trying to get mathematica to always represent an $n$th root of unity as a given symbol to clean up inputs and outputs.


title: Path queries for tree-structured data

text: Can anyone suggest documentation or tutorials for developing path queries and indices for (XML-like) tree-structured data? Suppose data is organized hierarchically in key->value pairs, eg:               In[220]:= data = {row1 -> {key1 -> value1, key2 -> value2},                        row2 -> {key1 -> value3, key2 -> value4}}          Out[220]= {row1 -> {key1 -> value1, key2 -> value2},                 row2 -> {key1 -> value3, key2 -> value4}}          In[221]:= row1 /. data          Out[221]= {key1 -> value1, key2 -> value2}          In[222]:= key2 /. (row1 /. data)          Out[222]= value2      This is a primitive form of tree-structured data that enables building up basic path queries out of `Rule` and `ReplaceAll`. However, it's desirable to also have wildcard functionality (e.g. like `All`) and range-like queries (e.g. like `Span`), but again where query parameters are named entities rather than Position expressions as in more common in relational data structures.


title: Composition: how to make a day and night world map?

text: Given the following world images:               day   = Import["http://eoimages.gsfc.nasa.gov/images/imagerecords/55000/55167/earth_lights_lrg.jpg"]     night = Import["http://eoimages.gsfc.nasa.gov/images/imagerecords/57000/57752/land_shallow_topo_2048.tif"]      ![enter image description here](http://i.stack.imgur.com/npmJ1.png) how would you use Mathematica to create an accurate “day and night map” (examples here and there) of the Earth for a given date and time?


title: FindRoot errors

text: I'm trying to solve a system of two equations in two variables for some range of parameter values. I use `ContourPlot` to see where I should look for a solutions and then I use `FindRoot` to get the solutions. However, I am getting some "you need more than machine precision.." errors and sometimes when I rescale the function the error goes away. But I never thought to plug the solution back into the main expression to confirm that I get 0 until a few moments back and unfortunately I am not getting zeros. My function is hyper sensitive to the values and the solutions I get from this `FindRoot` I want to use to compute other things later. So I am worried about picking up non-solutions. What are some good practices I can use in these conditions? How can I ensure that I do have a solution? Is `ContourPlot` reliable in terms of where to look? Here is the exact problem I am solving: My parameter is `c0`. I am looking to solve the system for "small" `c0`. The example below has `c0=0.004` and I am looking to see how small I could push it between `0.01 > c0 >0.0001` The variables I am solving for are `H0S` and `H0D`.                f1 = (-1.906273202485612` + 891.8237204611049` c0) H0D^1.7049946543060779` -    10.246354837464178` H0D^1.8549946543060778` - 0.3513303329336004` H0D^2.704994654306078` + (50.83395206628298` - 891.8237204611049` c0) H0S^1.7049946543060779` +   10.246354837464178` H0S^1.8549946543060778` - .0702660665867201` H0S^2.704994654306078`;          f2 = (-1.093726797514388` + 511.6850514687195` c0)/H0D^2.9716613209727445` - 6.736078957579072`/H0D^2.821661320972744` - 0.4820030003997329`/H0D^1.9716613209727445` + (   29.166047933717014` - 511.6850514687195` c0)/H0S^2.9716613209727445` + 6.736078957579072`/H0S^2.821661320972744` - 0.09640060007994662`/H0S^1.9716613209727445`;                c0 = 0.004      sub = 1088.96;      slb = 1088.94;      dub = 2.1774212*10^(-6);      dlb = 2.177421*10^(-6);           ContourPlot[{f1, f2}, {H0S, slb, sub}, {H0D, dlb, dub}]      This is what the `ContourPlot` looks like: ![enter image description here](http://i.stack.imgur.com/ojTi0.jpg) Then I try to find solutions:               {hs, hd, c0} = {H0S, H0D, c0} /. FindRoot[{f1 == 0, f2 == 0}, {H0S, (slb + sub)/2, slb,      sub}, {H0D, (dlb + dub)/2, dlb, dub}, MaxIterations -> Infinity]          {1088.95, 2.17742*10^-6, 0.004}          Scale1 = f1 /. {H0S -> 2000, H0D -> 0.000001};     Scale2 = f2 /. {H0S -> 2000, H0D -> 0.000001};          {hs, hd, c0} = {H0S, H0D, c0} /. FindRoot[{(f1)/Scale1 == 0, (f2)/Scale2 == 0}, {H0S, (slb + sub)/2,      slb, sub}, {H0D, (dlb + dub)/2, dlb, dub}, MaxIterations -> Infinity]          {1088.95, 2.17742*10^-6, 0.004}      When I do `FindRoot` without the scale, I get an error message about "..more than machine precision.." but when I do the `FindRoot` with the scale then I don't get any errors. But the solutions are the same. However, when I do this:                 f1 /. {H0S -> hs, H0D -> hd}       f2 /. {H0S -> hs, H0D -> hd}       (f1/Scale1) /. {H0S -> hs, H0D -> hd}       (f2/Scale2) /. {H0S -> hs, H0D -> hd}      I get:               4.6912*10^-11     -15.7874     -1.80356*10^-18     -2.22429*10^-16      My `f2=-15` at the proposed solution. So what's going on? Can I reliably use this solution going forward? How do I get it to give me the solution that makes `f1` and `f2` small..like zero... the solution `ContourPlot` seems to indicate that exists. **EDIT to include problems with** ``Rationalize` and `Rationalize[..,0]`               fa=-1.90627 H0D^1.70499 + 52.3946 f H0D^1.70499 - 10.2464 H0D^1.85499 -0.35133 H0D^2.70499 + 11.1478 f H0S^1.70499 + 10.2464 H0S^1.85499 - 0.0702661 H0S^2.70499 + (0.523946 (9. + 100. f - 1. H0D) H0D^1.70499 H0S^1.70499 (877653. - 1. H0S^2.97166) (877653. - 0.000389055 H0S^4.67666))/((-877653. + H0S^2.97166) (877653. H0S^1.70499 - 1. H0S^4.67666 + H0D^4.67666 (1 - 0.000389055 H0S^1.70499) + H0D^1.70499 (-877653. + 0.000389055 H0S^4.67666))) + (0.523946 (9. + 100. f - 1. H0D) H0D^3.40999 (877653. -      1. H0S^2.97166) (-877653. + 0.000389055 H0S^4.67666))/((-877653. + H0S^2.97166) (877653. H0S^1.70499 - 1. H0S^4.67666 + H0D^4.67666 (1 - 0.000389055 H0S^1.70499) +      H0D^1.70499 (-877653. + 0.000389055 H0S^4.67666)))          fb=    (30.0615 f)/H0D^2.97166 - 1.09373/H0D^2.97166 + (-0.857219 -        0.280427 H0D^0.85)/H0D^2.82166 - 5.87886/H0D^2.82166 - \     0.201576/H0D^1.97166 + (6.39606 f)/H0S^2.97166 + (      0.857219 -        0.0560854 H0S^0.85)/H0S^2.82166 + 5.87886/H0S^2.82166 - \     0.0403152/H0S^1.97166 + (      0.300615 (9. + 100. f - 1. H0D) (877653. -       1. H0S^2.97166) (-877653. + 0.000389055 H0S^4.67666))/(      H0D^1.26667 (-877653. + H0S^2.97166) (877653. H0S^1.70499 -         1. H0S^4.67666 + H0D^4.67666 (1 - 0.000389055 H0S^1.70499) +         H0D^1.70499 (-877653. + 0.000389055 H0S^4.67666))) - (      0.300615 (9. + 100. f - 1. H0D) H0D^1.70499 (877653. -        1. H0S^2.97166) (-877653. + 0.000389055 H0S^4.67666))/(      H0S^2.97166 (-877653. + H0S^2.97166) (877653. H0S^1.70499 -        1. H0S^4.67666 + H0D^4.67666 (1 - 0.000389055 H0S^1.70499) +        H0D^1.70499 (-877653. + 0.000389055 H0S^4.67666)))          f = 0.3     ContourPlot[{fa == 0, fb == 0}, {H0S, 405, 408}, {H0D, 0.1, 3}]      ![enter image description here](http://i.stack.imgur.com/otnVT.jpg) According to `ContourPlot` the solution is near `(406,1.50)`               far = Rationalize[fa, 10^-16];     fbr = Rationalize[fa, 10^-16];     fa0 = Rationalize[fa, 0];     fb0 = Rationalize[fa, 0];     Clear[f]           In[21]:= {hsr, hdr} = {H0S, H0D} /.        FindRoot[{far == 0, fbr == 0} /. {f -> 0.3}, {H0S, 410, 360.5,          420}, {H0D, 1, 0.0001, 5}, MaxIterations -> Infinity]          Out[21]= {406.678, 0.316565}          In[434]:= {hs, hd} = {H0S, H0D} /.FindRoot[{fa == 0, fb == 0} /. {f -> 0.3}, {H0S, 400,    360.5, 420}, {H0D, 1, 0.0001, 5}, MaxIterations -> Infinity]          Out[434]= {406.43, 1.54421}               In[12]:= {hs0, hd0} = {H0S, H0D} /.       FindRoot[{fa0 == 0, fb0 == 0} /. {f -> 0.3}, {H0S, 400, 360.5,       420}, {H0D, 1, 0.0001, 5}, MaxIterations -> Infinity]          Out[12]= {406.175, 2.32183}      The solutions I get using rationalize are clearly incorrect if `ContourPlot` is to be believed. Now I will substitute these solutions in the expression below:                exp=117.218 - 1754.39 f (0.047 + (0.00047 (9. + 100 f - H0D) (877653. -         H0S^2.97166) (-(877653./H0S^1.70499) + 0.000389055 H0S^2.97166))/(f (-877653. + H0S^2.97166) (877653./H0D^1.70499 - 0.000389055 H0D^2.97166 - 877653./H0S^1.70499 + H0D^2.97166/H0S^1.70499 + 0.000389055 H0S^2.97166 - H0S^2.97166/        H0D^1.70499))) + 877653. ((30.0615 f)/H0D^2.97166 - (0.336512 (0.833333 + 2.54737/H0D^0.85))/H0D^1.97166 - (0.122684 (2.97166 (3. + 16.9824 H0D^0.15 +          0.833333 H0D) H0D^1.97166 - (0.833333 + 2.54737/H0D^0.85) H0D^2.97166))/H0D^4.94332 + (     0.300615 (9. + 100 f - H0D) (877653. - H0S^2.97166) (-(877653./H0S^1.70499) +         0.000389055 H0S^2.97166))/(H0D^2.97166 (-877653. + H0S^2.97166) (877653./H0D^1.70499 - 0.000389055 H0D^2.97166 - 877653./H0S^1.70499 + H0D^2.97166/H0S^1.70499 + 0.000389055 H0S^2.97166 - H0S^2.97166/H0D^1.70499))) + 0.000389055 (52.3946 f H0D^1.70499 - (    0.213828 (2.97166 (3. + 16.9824 H0D^0.15 + 0.833333 H0D) H0D^1.97166 - (0.833333 + 2.54737/           H0D^0.85) H0D^2.97166))/H0D^0.266667 + (0.523946 (9. + 100 f - H0D) H0D^1.70499 (877653. - H0S^2.97166) (-(877653./H0S^1.70499) + 0.000389055 H0S^2.97166))/((-877653. + H0S^2.97166) (877653./H0D^1.70499 - 0.000389055 H0D^2.97166 - 877653./H0S^1.70499 +         H0D^2.97166/H0S^1.70499 + 0.000389055 H0S^2.97166 - H0S^2.97166/H0D^1.70499)))                         In[22]:= exp /. {H0S -> hs, H0D -> hd, f -> 0.3}              exp /. {H0S -> hs0, H0D -> hd0, f -> 0.3}              exp /. {H0S -> hsr, H0D -> hdr, f -> 0.3}          Out[22]= 99.0462          Out[23]= -58748.5           Out[24]= 5.63457*10^7      99 is around where the answer should be whereas -58752 and 5*10^7 are just absurdly wrong. This is making me real hesitant about using `Rationalize`. At least in this instance I knew what the answer was gonna look like. For many other expressions I don't have a good idea and I could introduce errors and things could go wildly wrong as the errors compound. Any help will be greatly appreciated.


title: Trying to plot this probability

text: Can anyone help me plot this? log P(X >= x) = alpha logx x=0.001 + k(0.001) k= 0, ..., 100 I can't figure out the coding for this.. I've been trying this for a while, and can't seem to figure it out. I believe this is a stable distribution, but the built in function doesn't seem to have x^(alpha) so it's making me extra confused. Can anyone help me out? Thank you.


title: Operator and VariationalMethods

text: I'm trying to get the variational derivative $\delta E$ respect to $\Phi$ of this functional $$ E[\Phi] = \int d^3r\ \left[ -\frac{\hbar^2}{2m}\nabla^2\Phi + V(\vec{r})\Phi^*\Phi + \frac{1}{2}g\Phi^{*2}\Phi^2 \right] $$ I've to check if my hand-calculus are corrects. I've defined the differential operator $H$ in this way               H[x_, y_, z_] = -(\[HBar]^2/(2 m)) Laplacian[#, {x, y, z}] + U[x, y, z] Abs[#]^2 + g/2 Abs[#]^4 &      and then i tried to calculate the variational derivative throw               g[x_, y_, z_] = H[x, y, z][f[x, y, z]]     VariationalD[g, f[x, y, z], {x, y, z}]      But the result is 0. Why? Trying to get the Euler Equation i get an error               EulerEquations[g, f[x, y, z], {x, y, z}]     EulerEquations::args: EulerEquations takes a single integrand, a function or list of functions, and a list of variables as input. >>


title: Probability in a knock-out tournament

text: Maths newbie so please go gently. Imagine if you would: 4 teams in the semi-final of a soccer tournament A,B,C,D. A,B and C all have 20% chance of winning the tournament. D however, is the favourite with a 40% chance of winning. The lunch time game is between A and B where A wins? So...the question is how do I calculate the new probabilities of B,C or D now winning before the evening semi between C and D Second question if I can? what the probabilities after D wins the evenings semi match? Thanks in advance.


title: Is there a way to do conditional matrix loop using 'continue'

text: ![enter image description here](http://i.stack.imgur.com/H2l9N.png)I have the following:               n = 3;     m = 5;     ww = RandomReal[{0, 0.1}, {n, n}];     uu = RandomReal[{0, 1}, {m, n}];     pp = RandomReal[{0, 1}, {n, n}];     ss = RandomInteger[{0, 5}, {m, n}];     Grid[{{"ww", "uu", "pp", "ss"}, {ww // TableForm, uu // TableForm,         pp // TableForm, ss // TableForm}}, Spacings -> {5, 2},       Dividers -> All]      where I would like to look at every element of matrix `ss` and produce a matrix `tt`, with zeroes at the locations in `ss` which have zeroes, and in all other positions do the following:               tt = (-1/Subscript[ww, m]) Log[(1 - uu)/(Subscript[pp, m - 1])],       where `Subscript[ww, m]` is the value at `index` of `ww` matrix and where `Subscript[pp, m - 1]` is the value at `index-1` of `pp` matrix. So for example if the first value ever read from matrix `ss` happens to be 2, then value taken from matrix `ww` would be from the row 2, but from `pp` would be from row 1. Also how to tell difference between a 0 as a valid value from within the matrix elements to end of matrix if I do not know the actual size of the matrix beforehand? Given the data as above, tt matrix would be like this: ![enter image description here](http://i.stack.imgur.com/hoL7h.png)


title: Wald–Wolfowitz Runs Test

text: Does Mathematica 8 implement Wald–Wolfowitz runs test for randomness? I can't find it in the documentation. I would like to test some fit residuals.


title: obtaining random element of a set given by multiple inequalities

text: I try to obtain random elements from a set given by multiple inequalities. This is of general interest to me, but let me present one example here: I have multiple inequalities specifying half spaces in 2D given by:               Eta[a_] := {Cos[a], Sin[a]}     NI[a_] := {Cos[a], Sin[a]}     Table[Dot[{Phi1, Phi2}, Eta[b]]] <= Norm[NI[Pi] - Eta[b]]^2 + 2, {b, 0, 2 Pi, 2 Pi/10}]      The set I am interested in is the intersection of all these inequalities (half spaces). Here is a `RegionPlot` of the set:               RegionPlot[And @@ Table[Dot[{Phi1, Phi2}, Eta[b]]] <= Norm[NI[Pi] - Eta[b]]^2 + 2, {b, 0, 2 Pi, 2 Pi/10}], {Phi1, -7, 7}, {Phi2, -7, 7}]      ![enter image description here](http://i.stack.imgur.com/Q0e61.png) Now I want to pick random vectors (elements) from this set. My current approach is to define an indicator function for the set like this:               set[x1_,x2_] = And@@Table[Dot[{Phi1, Phi2}, Eta[b]]] <= Norm[NI[Pi] - Eta[b]]^2 + 2, {b, 0, 2 Pi, 2 Pi/10}]/.{Phi1->x1,Phi2->x2}      Then use a Random number generator for `x1` and `x2` with appropriate bounds, that I get from inspecting the `RegionPlot` of the set to obtain a function that gives me `n` "random" elements from my set:               randomVector[n_] := Module[{list = {}, vector, i = 0},       While[i < n,        vector = {RandomReal[{-3, 6}], RandomReal[{-5, 5}]};        If[set[Sequence @@ vector], i++; AppendTo[list, vector];];        ];       Return[list];       ]      **Do you know of a more elegant way to do this?**


title: Why the coloring in Block construct?

text: I want a function that works like in the following example: it gets an expression which contains a variable var and evaluate it setting setting var = value. I used `Block` to avoid expr being evaluated if variable var holds a value in the notebook. It seems that my function works correctly - I made also a trace - but I get var inside block coloured red and I think it's a warning from _Mathematica_. Can you explain to me why I obtain it? Is my code wrong? Is there a better way to obtain the desired behavior?               SetAttributes[myFunc, HoldFirst];          myFunc[{expr_, var_}, value_] :=       Block[{var}, expr /. var :> value]      ![picture](http://i.stack.imgur.com/GYvIn.png)


title: How to deal with units in logarithms?

text: I'm trying to take a formula, take it's integral which yields a formula with logarithms, and then directly plug in values with units and get an answer. However if the units go into any of the logarithms I get conditional expressions. Is it possible to set up the equations so I can just plug in units? Here's my code:               Pideal[n_, T_, V_] := (n*R*T)/V     PvdW[n_, T_, V_, a_: a, b_: b] := (n*R*T)/(V - n*b) - (n^2*a)/V^2     W[V1_, V2_, P_] := Integrate[P, {V, V1, V2}]     Wideal[V1_, V2_, n_: n, T_: T] = W[V1, V2, Pideal[n, T, V]]      Here's the problem spot:               Wideal[5 Liters, 10 Liters, 1 Mols, 298 Kelvins]      I can work around this fairly easily, just leave out the Liters because they cancel out anyway. (`Liters = Quantity["Liters"]`, etc) However when I get to a more complicated equation that doesn't work so easily without making sure to put back in what I leave out.               WvdW[V1_, V2_, n_: n, T_: T, a_: a, b_: b] =          W[V1, V2, PvdW[n, T, V, a, b]]     WvdW[5*Liters, 10*Liters, 1 Mols, 298 Kelvins, 0, 0]      This doesn't work for the same reason, even though the Liters cancel out Mathematica doesn't assume that. However if I leave them out, I still have problems with the Mols, which appear in and outside of Logarithms, even though they're multiplied by 0.               WvdW[5, 10, 1 Mols, 298 Kelvins, 0, 0]      Finally, I haven't even gotten to using b which also appears in the logarithm, and even though the volumes add up and cancel out, Mathematica doesn't assume so.               WvdW[V1*Liters, V2*Liters, 1 Mols, 298 Kelvins, 0, 0 Mols Liters^(-1)]


title: WolframAlpha Selective SubPod Content

text: I am sending queries to Wolfram | Alpha from _Mathematica_ V9 and and importing the results back into _Mathematica_ , but I am running into a challenge in formatting the request. Specifically, I would like a listing of all of the departing flights from LAX for the current day and, then, I want to select only those flights using Airbus A380 aircraft (there should be about 5 per day). When I query for LAX departures it returns a subpod of the 680+/- departures for the current 24 hour window, but I am not able to retrieve the aircraft type. If I search for a specific flight, such as "American Airlines flight 1867", Wolfram | Alpha returns a subpod with the aircraft/equipment details. I checked Wolfram | Alpha's sources; both queries are going to the FAA ASDI database, so the data should be available. Any suggestions? One other question: The subpod of LAX departures displays five results, but indicates 680 or so results are returned. Is there a way in _Mathematica_ to tell Wolfram | Alpha to return all results without having to code "More" repeatedly? See the `PodStates` option below in the code.               WolframAlpha["Flights departing LAX",        {{"FlightsBetween:Scheduled:From:FlightData", 1}, "Content"},        PodStates ->            {"FlightsBetween:Scheduled:From:FlightData__More",             "FlightsBetween:Scheduled:From:FlightData__More",             "FlightsBetween:Scheduled:From:FlightData__More"}]


title: Embedding hidden information in styled text

text: I would like to convert a collection of digitized documents to Mathematica notebooks. They are formatted as XML, divided into pages. The XML contains formatting I would like to preserve, but I do not want to display page divisions, in other words I would like the text to flow like a typical notebook. However, I would like to use a docked cell to display the page range of any text that is selected. A text selection could come from a single page or multiple pages. My question is, what is the best way to represent this data? I imagine StyleBoxes and TagBoxes (to hold page numbers) but I don't have a clear understanding of how these interact. When I try to nest one inside the other (TaxBox[StyleBox[...]] or StyleBox[TagBox[...]]) I end up with cells that just print as expressions. I also imagine I could use InterpretationBoxes to store the formatted text and then a hidden duplicate copy with the page information added, but that is so inefficient I have to believe there is a better way. Here's an example. What would be a good way to represent this text? Say it spans pages 1-2, divided at ///. > A sentence **that spans two** /// **_pages_** and has some mixed formatting. **EDIT:** The following code almost works, but the way it behaves when I try to select text with my mouse is off.               Cell[BoxData@RowBox[{      TagBox[RowBox[{         StyleBox["A sentence", "Text"],         StyleBox["that spans two", "Text", FontWeight -> "Bold"]         }], "Page1"],      TagBox[RowBox[{         StyleBox["pages", "Text", FontWeight -> "Bold",           FontSlant -> "Italic"],         StyleBox["and has some mixed formatting.", "Text"]         }], "Page2"]      }]] // CellPrint      If I place the cursor on the left side of this sentence and drag toward the right, once I pass "two" the entire right-side box becomes selected. So, for example, I cannot select "two pages" using my cursor. I understand this is related to the hierarchical nature of the underlying expressions; is there something that can be done about it? Or is there an alternative representation that will avoid this problem?


title: Creating new graphics primitive (EdgeForm, FaceForm)

text: My question is strongly related to this question, nevertheless I would like to bring it to every ones attention. Lets say I want to create a new graphics primitive `Boing` which should look like this               Boing[] :=       Polygon[Join[#1, Reverse[#2]] & @@@         Partition[         Table[{2 x/Pi, y/2*Cos[x]}, {x, -Pi/2, Pi/2,            Pi/10}, {y, {-1, 1}}], 2, 1]]          Graphics[{Opacity[0.3, Blue], Boing[]},       AspectRatio -> Automatic]      > ![Mathematica graphics](http://i.stack.imgur.com/i1eeX.png) As new primitive, it should clearly work like other primitives like `Disk`, `Rectangle`, etc. When I define a `FaceForm` and `EdgeForm` one sees that this does not work because the settings are applied to the underlying `Polygons`               Graphics[{EdgeForm[Black], FaceForm[Opacity[0.3, Blue]],        Boing[]}, AspectRatio -> Automatic]      > ![Mathematica graphics](http://i.stack.imgur.com/FPabS.png) In this case one could slightly re-arrange the points and create one overall polygon to circumvent the issue               Boing[] :=       Polygon[Join[#1, Reverse[#2]] & @@         Transpose[         Table[{2 x/Pi, y/2*Cos[x]}, {x, -Pi/2, Pi/2,            Pi/10}, {y, {-1, 1}}]]]     Graphics[{EdgeForm[Black], FaceForm[Opacity[0.3, Blue]], Boing[]},       AspectRatio -> Automatic]      > ![Mathematica graphics](http://i.stack.imgur.com/S3oK3.png) When I am not mistaken, then this is in general not possible without having access to the current values of `FaceForm` and `EdgeForm`. Consider the following example where I don't see a direct way > ![Mathematica graphics](http://i.stack.imgur.com/yeSDQ.png) ### Question: What is the most simple solution to create a new graphics primitive which works like e.g. a polygon? To clarify: I want to be able to manually construct a new primitive and define how the settings of the current graphics state like `FaceForm` or `EdgeForm` (`Texture`, `Specularity` or `Lighting` are further examples which change the state of the graphics engine) are handled. # Update: The answer of rm-rf was promising but unfortunately, `Graphics`Mesh`PolygonCombine` seems to make more or less the same what I have already shown above. This means, that for my target application it will not work. Consider the following example               points[r1_, r2_, n_] :=       With[{dphi = 2.0 Pi/(n - 1)},        Table[r {Cos[phi], Sin[phi]}, {phi, 0, 2 Pi, dphi}, {r, {r1, r2}}]        ];          Graphics@{EdgeForm[{Black, Thick}], FaceForm[Opacity[0.3, Red]],       Polygon[        Function[{p1, p2}, Join[p1, Reverse[p2]]] @@@          Partition[points[0.3, 0.7, 30], 2, 1]]}      > ![Mathematica graphics](http://i.stack.imgur.com/nH8AG.png) And with `Graphics`Mesh`PolygonCombine` we get > ![Mathematica graphics](http://i.stack.imgur.com/VtaaD.png)


title: Styling individual bars in a BarChart with grouped data

text: Consider the following:               fakedata = RandomReal[{4, 9}, {5, 10}];     BarChart[fakedata, BarSpacing -> {0, 0.4},       ChartBaseStyle -> EdgeForm[],       ChartStyle -> {{Magenta, Blue, Red, Orange, Green}, Opacity[#] & /@ Range[0.1, 1, 0.1]}]      ![enter image description here](http://i.stack.imgur.com/lhaDD.png) This is all well and good, but what I really want is the following, but grouped, so that the bars are opaque, the ticks come out how I want them, and the little space in between the groups (from the `BarSpacing` option) shows up:               BarChart[Flatten@fakedata, BarSpacing -> {0, 0.4},       ChartBaseStyle -> EdgeForm[],       ChartStyle ->        Flatten@Outer[Blend[{{0, White}, {0.7, #1}, {1.1, Black}}, #2] &, {Magenta,           Blue, Red, Orange, Green}, Range[0.1, 1, 0.1]]]      ![enter image description here](http://i.stack.imgur.com/dpcx6.png) Unfortunately if I create a "matrix" of colours as the value of the `ChartStyle` option, only the second list is picked up, and I get this:               BarChart[fakedata, BarSpacing -> {0, 0.4},       ChartBaseStyle -> EdgeForm[],       ChartStyle -> Outer[Blend[{{0, White}, {0.7, #1}, {1.1, Black}}, #2] &, {Magenta,          Blue, Red, Orange, Green}, Range[0.1, 1, 0.1]]]      ![enter image description here](http://i.stack.imgur.com/0bB92.png) How can I style my bars individually like in the second example, when the data are grouped?


title: Animate curve parametric plot on a surface

text: I have a surface               s = Plot3D[{x,y,F[x,y]},{x,-1,1},{y,-1,1}]      with $F$ predefined, and a curve               c = ParametricPlot3D[{g1[t],g2[t],F[g1[t],g2[t]]},{t,0,1}]      with $g1,g2$ predefined. $c$ is therefore a curve on the surface $s$. If I want to show both the objects together I can use               Show[s,c]      but how can I animate the trajectory described by the curve $c$ on the surface $s$?


title: Editing preset schemes

text: _Mathematica_ has many preset schemes, for example `"DarkRainbow"` and `"FadingRectangle"`:               Histogram[RandomVariate[NormalDistribution[1, 0.2], 100],       ChartStyle -> "DarkRainbow",      ChartElementFunction -> "FadingRectangle"]      ![test](http://i.stack.imgur.com/Ocv73.png) How can I get _Mathematica_ to tell me the source code for these schemes? I want to reproduce `"FadingRectangle"`, with some modifications of my own.