Excel Headers --> Mathematica

I have a large Excel .xls file. Miniature version shown below: (formatting should appear as two columns...)               Test1   Test2     75        64     58        85     81        55     64        63     70        94     88        90     78        96     96        98     54        97     75        61      I would like to do some statistical analysis on the file in Mathematica 8.0.4. Additionally I am using Mathematica Link for Excel 3.5. The issue I'm now attempting to address concerns the "headers," or "column labels." I need to tell Mathematica to disregard the headers. I want to use each respective header, however, as the name for the "variable stream" (Mathematica-speak for each column of data.) What might be the best ways of dealing with such headers? ===== Additional edit: The "one-liner" version seems to work just fine. Thank you Vitaliy. Follow-up Question: If the Excel .xls spreadsheet being imported is rather large -- 200 columns, 5000 rows -- will that present a problem with the Mathematica "one-liner" approach Vitaliy has suggested? i.e., memory inadequacy, inability to make subsequent steps? What I mean here is, is it completely okay to import an entire large Excel .xls all at once? Or is it far better to ONLY import "columns" as needed, that will immediately be used in subsequent Mathematica steps? I'd prefer to import all at once -- using Vitaliy's method -- if that's totally acceptable.


PDE Solving in mathematica

I'd like to ask how I might go about solving this equation: # $\frac{\partial Ci}{\partial t} + \frac{1}{r^2}\frac{\partial (r^2 Ci)}{\partial r} = D\frac{1}{r^2}\frac{\partial}{\partial r}(r^2\frac{\partial Ci}{\partial r})$ as suggested a simplification # $\frac{\partial Ci}{\partial t} + \frac{1}{r}2Ci +\frac{1}{r^2}\frac{\partial Ci}{\partial r} = D(\frac{2}{r}\frac{\partial Ci}{\partial r} +\frac{\partial^2 Ci}{\partial r^2})$ $r = 0, t = 0 \rightarrow Ci = 0$   $r = 1, t = 0 \rightarrow Ci = 0$ I am fairly new to Mathematica and I don't really know how to go about this; I've also tried the steps outlined in this post here but while I understood what to do I get recursion limit reached errors (using the code provided). Could you please help me out on how to solve this equation? a partial and first attempt on solving this taking in account the notes of the posted link is the following:               Clear[y];     f1[r_ /; r > 0] := 1;     f1[r_ /; r == 0] := 2;     f2[r_ /; r > 0] := 1/r^2;     f2[r_ /; r == 0] := 0;     f3[r_ /; r > 0] := 1/r;     f3[r_ /; r == 0] := 0;          eqns = {         Derivative[0, 0, 1][y][t, r, z] +         f3[r]*2*y[t, r, z] +       f2*Derivative[0, 1, 0][y][t, r, z] -       2*f3[r]*Derivative[0, 1, 0][y][t, r, z] -       Derivative[0, 2, 0][y][t, r, z] == Derivative[1, 0, 0][y][t, r, z],       y[t, 0, z] == 0,       y[t, r, 0] == 0,       Derivative[0, 1, 0][y][t, 0, z] == 0,       Derivative[0, 0, 1][y][t, r, 0] == 0,       y[0, r, z] == (1 - r^2)*(1 - z^2)}           $RecursionLimit = 1536           y[t_, r_, z_] =           y[t, r, z] /.                First[NDSolve[eqns, y[t, r, z], {t, 0, 1}, {r, 0, 1}, {z, 0, 1},                Method -> {"MethodOfLines", Method -> "StiffnessSwitching",                "DifferentiateBoundaryConditions" -> {True,                "ScaleFactor" -> 1}}]];      This gives me a lot of errors but the first one is the following: ![partial error output](http://i.stack.imgur.com/xZT5s.png)


The correct way to linearize colorspace before resizing, blurring etc

There was an interesting discussion on MathGroups dealing with the fact that image-processing functions in _Mathematica_ (and many other software, including Adobe Photoshop) work with RGB, Grayscale etc. intensity values as if they would be linear and additive while in fact these values are powers of the _physical_ intensity values and consequently must be linearized before making additive operations on them. This topic is expanded in the linked article where examples of incorrect default image resizing and blurring are given along with the general explanation of the correct algorithm and images generated with it. Matthias Odisio (Wolfram Research) replied: > This genuine issue will be properly addressed in a future release of > Mathematica. So, _Mathematica_ 9 is released. But I cannot find any example in the Documentation on how to linearize a colorspace correctly. Obviously, the linearization algorithm must depend on the colorspace used. The question is: is there efficient and straightforward way to linearize a colorspace in _Mathematica_ correctly? ## UPDATE Here is an excerpt from the documentation for Adobe After Effects which highlights some benefits of linear color space: > By performing operations in a linear color space, you can prevent certain > edge and halo artifacts, such as the fringing that appears when high- > contrast, saturated colors are blended together. Many color operations > benefit from working in a linear color space, including those operations > involved in image resampling, blending between layers with blending modes, > motion blur, and anti-aliasing. > > <...> > > _Note: A linearized working color space works best with higher color > depths—16 bpc and 32 bpc—and is not recommended for 8-bpc color._ Also, good explanation of the difference between linear RGB and sRGB color spaces can be found here.


A lot of matrix multiplication

So I have a set of 15 $4\times 4$ matrices which I call $X_i, (i=1,2..15)$ and a set of 6 $4\times 4$ matrices which I call $y_j, (j=1,2...6)$. Now I have to calculate $(X_i y_j)-(y_j X_i^*)$ for different values of $i$ and $j$, where $*$ stands for Complex conjugate. Is there a simple command (with perhaps loops) in mathematica using which I can calculate all the 90 results instead of multiplying these matrices individually 90 times?


Running out of memory when partitioning an image with ImagePartition

I have an `Image3D` object of image type _"Bit16"_ with the dimensions 1472 x 1472 x 1472 that I would like to split into small image cubes of dimension 64 x 64 x 64 which would give me a total of 23^3 = 12167 small `Image3D` objects. I want to apply an adaptive thresholding algorithm I already implemented which computes separate thresholds for each image block and then interpolates the computed threshold values (adaptive thresholding). For this purpose I use the function `ImagePartition`. The following code illustrates the partitioning:               croppped = ImageCrop[image, {1472, 1472, 1472}];     parts = ImagePartition[cropped, {64, 64, 64}];      I use `ImageCrop` to add a border to the original image which results in the mentioned `Image3D` object of dimensions 1472 x 1472 x 1472. If I try to run the partitioning my _Mathematica_ kernel crashes with an out of memory error. I have 96 GB RAM installed on my machine. I'm not sure, but the memory should be a sufficient amount of memory available to do the partitioning. What surprised me is that i can create multiple huge `Image3D` objects and the kernel doesn't crash, but when I partition an `Image3D`, using ImagePartition it does. See the following code for the memory usage when I create another `Image3D` object:               MemoryInUse[]     cropped2 = ImageCrop[image, {1472, 1472, 1472}];     MemoryInUse[]      > 14461079560 > > 20840097904 Questions:   1. Is there a simple explanation for this problem?   2. What would be a suitable workaround in order to perform the splitting? **Edit (08/01/2014)** First of all thanks very much UDB for this nice solution you posted. I now had the time to try out the function `MyImagePartition` on my data and here are the results I obtained so far. First, to get a feeling for the timings and memory usage I created the same test volume and partitioned it on my machine. I then checked whether the original volume can be assembled again to give the volume again.               volume = Image3D[RandomInteger[{0, 255}, {8, 9, 10}*64], "Byte"];     First@AbsoluteTiming[ip = ImagePartition[volume, {64, 64, 64}]]      > 10.899000               MaxMemoryUsed[]         First@AbsoluteTiming[mip = MyImagePartition[volume, {64, 64, 64}]]     MaxMemoryUsed[]      > 248907056 1.505000 542529936               Image3D[ImageAssemble@ip] == volume      > True               Image3D[ImageAssemble@mip] == volume      > True Then I tested the function `MyImagePartition` on a real image I have. In between the partitioning of the test volume and the real data i quit the kernel to get a fresh Mathematica session. Fortunately, the function is very fast in partitioning my data and memory consumption seems to be no issue. When reassembling it again I checked for the image dimensions of the assembled image.               ImageDimensions@testImage      > {458, 403, 202}               MaxMemoryUsed[]     First@AbsoluteTiming[mip = MyImagePartition[testImage, {64, 64, 64}]]     MaxMemoryUsed[]      > 249027112 0.278000 542635024               ImageDimensions@Image3D[ImageAssemble@mip]      > {448, 384, 192} Obviously the dimensions of the reassembled image do not match the original image dimensions. I have to admit that I didn't fully understand the usage of the second parameter 'dwdh'. Is it the option for image padding such that the image matches up with the partitioning block size? I tried several options but failed continuously ;) Besides that issue, would it be possible to add the functionality to create an overlapping partitioning of the image (e.g. give the overlap of the blocks in voxels as an additional parameter). With the built-in function `ImagePartition` this works quite good as follows:               parts = ImagePartition[spheroid3d, {64, 64, 64}, {60, 60, 60},         Padding -> 0];


Color of a plane in Contourplot3D

I have the following code example:               cylinder = ContourPlot3D[y^2 + z^2 == 32, {x, 0, 5}, {y, -6, 6}, {z, -8, 8},                               Mesh -> 1, ContourStyle -> FaceForm[{White, Red}, Opacity[0.0]],                               AxesLabel -> {"x", "y", "z"}];     areaR = ContourPlot3D[{1, 0, 0}.({x, y, z} - {0, 1.5, 1.5}) == 0,                            {x, 0, 5}, {y, -6, 8}, {z, -6, 8},                            ContourStyle -> Directive[White], Mesh -> False];     Show[cylinder, areaR]      ![enter image description here](http://i.stack.imgur.com/69IX9.png) Can anyone tell me how I get the plane `areaR` to be `White`?


Manipulate and Turning Expressions into Functions

I've been trying to use Manipulate to do interactive plotting, but I've been running into a few problems with saved expressions. I have an expression saved as "func" and I want to work with it and then plot it later. But I can't seem to get it to work. For example, this works fine               Manipulate[Plot[Sin[a x + b], {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]      while this does not               func = Sin[a x + b];     Manipulate[Plot[func, {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]      I assume that this has something to do with when expressions are evaluated and the difference between expressions and functions, but I'm new to Mathematica and and I'm not sure on on the difference between the two. I have tried other things like the following. For example, this works               Manipulate[Plot[Function[{a, b, x}, Sin[a x + b]][a, b, x], {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]      and this works               func2 = Function[{a, b, x}, Sin[a x + b]]     Manipulate[Plot[func2[a, b, x], {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]      but this does not               func = Sin[a x + b];         func2 = Function[{a, b, x}, func];     Manipulate[Plot[func2[a, b, x], {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]      How could I fix this and why doesn't it work the way I have it written?


Computing the mean difference between elements in a list with index $i$ and the closest elements with index $(i+1)$

I have a list that looks like this:               preprocessedList = {{1,5.3},{1,5.566},{1,1.4322},{2,3.443543},{2,3.444},{3,0.1223},{4,1.3243},{4,1.554343}}      Each element in the list is of the form $(i,j_k)$, where $i = 1,2,3,...,N$ is an integer index (which may be degenerate, i.e. there may be multiple list entries with the same $i$ value), and $j_k$ is some value associated with each list item. I want to create a new list $L$ where, for each index starting with $i = 2$, we compute the median or mean of the difference between elements with the index $(i-1)$ and the nearest elements with index $i$ (in terms of one- dimensional Euclidean distance). Using the about example list: Starting with $i = 2$, we first take {1,5.3}, we compute that {2,3.444} is closest since the different between 3.444 and 5.3 is the minimum for all items with the index $i=2$. We compute this difference as $(3.444 - 5.3) = -1.856$. We then move on to {1,5.566}, notice again that {2,3.444} is closest to {1,5.3}, and compute this difference as $(3.444 - 5.566) = -2.122$. Finally, we move on to {1,1.4322}, notice that this is closest to {2,3.443543}, and compute the difference $(3.443543 - 1.4322) = 2.011343$. We then average these differences: $(-1.856 + -2.122 + 2.011343) / 3 = -0.6555...$ and place this at position $(i-1)$ in $L$. So we have $L = (-0.6555..., ...)$ thus far. We then move on to $i = 3$ and so forth. Note that if there is no $i = 3$ elements, we'd just enter $0$ at that position in $L$. Is there a fast and slick way to do this with a large initial preprocessedList? Here's the naive (very slow) way to do this:               preprocessedList = {{1, 5.3}, {1, 5.566}, {1, 1.4322}, {2, 3.443543}, {2, 3.444}, {3, 0.1223}, {4, 1.3243}, {4, 1.554343}};          L = Array[0 &, Max[preprocessedList[[All, 1]]] - (Min[preprocessedList[[All, 1]]])];          counter = 0;     For[i = Min[preprocessedList[[All, 1]]] + 1,        i <= Max[preprocessedList[[All, 1]]], i++,            counter += 1;            highIndexList = Select[preprocessedList, #[[1]] == i &];       lowIndexList = Select[preprocessedList, #[[1]] == (i - 1) &];            If[Length[highIndexList] > 0 && Length[lowIndexList] > 0,                differenceArray = Array[0 &, Length[lowIndexList]];           For[k = 1, k <= Length[lowIndexList], k++,            differenceArray[[k]] =               Nearest[highIndexList[[All, 2]], lowIndexList[[k, 2]]] - lowIndexList[[k, 2]];           ];       L[[counter]] = {i, Mean[Flatten[differenceArray]]};       ,       L[[counter]] = 0;       ];           ];      The output is:               L = {{2, -0.655552}, {3, -3.32147}, {4, 1.202}};      Perhaps there's a way to compile this?


How to check if a Polynomial has a specific form

I have a polynomial `F[x]`, for example `F[x] = 1 - 2x + x^2`. I wanna check whether F[x] has the form of `(1 + kx)^n`. For the example above, `k = -1` and `n = 2`. I have searched on several documents but found nowhere has the answer. So can I do this on Mathematica? If yes, how can I get k and n?


FinancialData property value at a given date

I was trying to get the volatility value of a specific equity on a given day. Based on the _Mathematica_ Help, the syntax is > `FinancialData["name","prop",{start,end,...}]` gives a list of dates and > values of a property for a sequence of dates or periods. So I tried this with the specific request.               FinancialData["SPY", "Volatility20Day", {{2012, 10, 11}, {2012, 10, 11}}]      which generates a long error message that starts with `DatePlus::date: Argument {{2012,10,11},{2012,10,11}} cannot be interpreted as a date. >>` By the way, the syntax does work with other properties such as close, open, return, etc. Is there any specific syntax that is different for `Volatility20Day`?


How to stop a single function to be evaluated?

See this example:               AA = {x} \[Function] Normalize[x]     BB = {x} \[Function] Evaluate[AA[x]*5]      I need BB to be Normalize[x]*5. Some context:I call evaluate because I'm using CForm later to do some optimizations, so my functions need not to call other user-defined functions which would translate into something that is not really valid C code. Normalize though just evaluates to a version which makes some sense only for complex numbers, this is not what the definition of Normalize does... Also, afaik Evaluate doesn't take assumptions, so I don't know how to "hint" it not to incorrectly expand Normalize... I've tried various hold/replace/single step evaluate tricks, all not working. Any ideas?


Preserving a bijection between arrays when shuffling elements in one array

Imagine I have two lists of elements like the following:               listOne = RandomReal[{0,2}, {100,2}];     listTwo = RandomReal[{0,2}, {100,2}];      Let $f: X \to Y$ be a bijection or one-to-one correspondence between the elements in `listOne` and the elements in `listTwo`. I can shuffle the elements in `listOne` as follows:               listOne = RandomSample[listOne, Length[listOne]];      However, is there a way for me to perform the above shuffling operation while preserving the bijection $f$? In other words, can I shuffle the elements in `listOne` and `listTwo` in precisely the same manner?


Is this the expected behaviour from Partition when padding is inserted at the start of the list?

The documentation for `Partition` shows an example of partitioning without padding, so that no elements are dropped, but the last sublist can be shorter.               Partition[Range[50], 8, 8, 1, {}]     (* {{1, 2, 3, 4, 5, 6, 7, 8}, {9, 10, 11, 12, 13, 14, 15, 16}, {17, 18,         19, 20, 21, 22, 23, 24}, {25, 26, 27, 28, 29, 30, 31, 32}, {33, 34,         35, 36, 37, 38, 39, 40}, {41, 42, 43, 44, 45, 46, 47, 48}, {49, 50}} *)      The documentation for `Partition` in the Wolfram Language documentation (and presumably for the forthcoming version 10) has an additional example, where the partitioning starts from the end, and the first list is the shorter one. A similar example (but with actual padding not an empty list) is in the version 9 documentation under the _Padding Alignment_ section of the documentation page. However, partitioning from the end does not seem to result in all elements of the original list being preserved, regardless of whether padding is used or not. Notice that the last value (50) is missing from the result. (Output from version 9, but I have reason to believe that the behaviour from the current version of the Wolfram Language is similar.)               Partition[Range[50], 8, 8, -1, x]        (* {{x, x, x, x, x, x, x, 1}, {2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13,        14, 15, 16, 17}, {18, 19, 20, 21, 22, 23, 24, 25}, {26, 27, 28, 29,        30, 31, 32, 33}, {34, 35, 36, 37, 38, 39, 40, 41}, {42, 43, 44, 45,        46, 47, 48, 49}} *)     Partition[Range[50], 8, 8, -1, {}]     (* {{1}, {2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16, 17}, {18,        19, 20, 21, 22, 23, 24, 25}, {26, 27, 28, 29, 30, 31, 32, 33}, {34,        35, 36, 37, 38, 39, 40, 41}, {42, 43, 44, 45, 46, 47, 48, 49}} *)      Is this a bug? Is there a way to ensure that partitioning from the end preserves all original elements of the list? The context for this question is that I'm trying to create a little function that implements local shuffling, for inclusion in a little genealogical simulation I'm writing (on the theory that people in bygone eras were more likely to marry people form nearby than people from far away, but didn't systematically always marry the person next door).               localshuffle[list_List, window1_Integer?Positive, window2_Integer?Positive] /;        Length[list] > window2 && window2 > window1 :=      Flatten[RandomSample /@         Partition[ Flatten[RandomSample /@ Partition[list, window1, window1, 1, {}],           1], window2, window2, -1, {}], 1]      The number of elements should be the same as in the input but it is not. It does work if the `-1` in the outer `Partition` is replaced with `1`.               test = localshuffle[Range[50], 5, 8]     (* {3, 8, 6, 1, 4, 5, 2, 10, 7, 14, 13, 11, 12, 9, 18, 17, 15, 19, 22, \     16, 24, 20, 21, 23, 25, 32, 27, 29, 28, 33, 30, 31, 26, 41, 38, 39, \     36, 37, 40, 34, 35, 48, 50, 46, 49, 43, 45, 44, 42} *)          Length[test]     49


Writing NDSolve-like functions

I've been using _Mathematica_ for a while now, and there are multiple common tasks that I end up doing. I'd like to learn how to convert them into functions so that I can store them in some file and load them at startup. Most of these common tasks involve taking a set of equations and doing something with them. Thing is, I don't want to fix the variables the equations are written in, and would like behavior similar to `NDSolve` where one can specify the functions as well as which variable is which. For example, take this task:               Pd = ParametricNDSolve[{v'[t] == (v[t] - v[t]^3/3 - ω[t])/0.2,             ω'[t] == (1 + v[t])/0.2,             ω[0] == b, v[0] == a}, {v[t], ω[t]},              {t, 0, 20}, {a, b}];     PVec[x_, y_] := {D[(v[t] /. Pd) [x, y], t] /. t -> 0,                       D[(ω[t] /. Pd) [x, y], t] /. t -> 0};     VectorPlot[PVec[x, y], {x, -2, 1}, {y, -1.2, 0.5}]      Here, I'm parametrically solving the pair of equations $$ \begin{align} v'(t)&=\frac{-\frac{1}{3} v(t)^3+v(t)-\omega (t)}{0.2}\\\ \omega'(t)&=\frac{v(t)+1}{0.2} \end{align} $$ with the parameters being the initial state of $v$ and $\omega$. Now, I take the vector field of their derivatives at $t=0$, and vector plot it. Basically, I want to get a quick map of how the initial trajectories ($(v'(t),\omega'(t))$) change for different initial conditions without having to open `EquationTrekker` and do things manually. * * * So now, I want to take this task and write it as a function akin to `TrajectoryMap[{eqn1,eqn2},{{var1,varmin,varmax},{var2,varmin,varmax}},{{timevar,timepoint},tmin,tmax,tpoint}]` where this particular code would run as               TrajectoryMap[{v'[t] == (v[t] - v[t]^3/3 - ω[t])/0.2,          ω'[t] == (1 + v[t])/0.2}, {{v[t],-2,1}, {ω[t],-1.2,0.5}}, {{t,0},0,20}]      (or something similar) Here, `timepoint` is the value of `t` for which the derivative of the interpolating function is calculated. I can tell that this will probably need some combination of `Hold`s and `Evaluate`s, but I can't seem to get the right one. How should I go about converting this code (or any arbitrary code of a similar type) into a custom function?


Find Lists with intersecting sublists

I have a list of the following form:               l = {{"label1", {1, 2, 3}}, {"label2", {4, 5}},            {"label3", {3, 6, 9, 8}}, {"label4", {11, 25, 24, 14}}, {"lable5", {4, 5}}}      I would like to retrieve only those labels whose corresponding list has an intersection with the corresponding list of another label, along with the intersecting elements. So, for `l` I would get               {{"label1", "label2", "label3", "label4"}, {3, 4, 5}}      (I'll add my answer, but I'd like to see if someone can come up with a simpler one)


Bound on number of function evalulations in FindMinimum

I am minimizing a nonlinear constrained problem using `FindMinimum`. The problem involves about 200 variables and the function is a black-box which cannot be compiled/optimized (I have set the Method as Automatic). During evaluations, I collect the value of the objective function at intermediate evaluations using `EvaluationMonitor` option. I have a `Monitor` statement enclosing the `FindMinimum` which plots the objectiveFunction against the number of function evaluations. This was the picture. ![objective_fn_against_num_of_fn_evals](http://i.stack.imgur.com/Juk0H.jpg) Is there an option to **(gracefully) terminate** the `FindMinimum` after `nMax` number of function evaluations, returning the best solution of those so far evaluated (like position 25 in the image)? ( `MaxIterations` does not achieve it, since it is a bound on the number of **steps taken** and not the function evaluations).


Finding roots of nontrivial equation

I am trying to solve the following nontrivial equation:                   fun[z_] := (Log[Gamma[n]] + n Log[Gamma[z + 1]] + z n Log[n] - Log[Gamma[n (z + 1)]])/n         fun[z] /. n -> 8         m = Table[i, {i, -1, 1, 0.1}]          sols = Table[FindRoot[fun'[z] + 0.5 == m[[i]], {z, 1}], {i, Length[m]}]         sols2 = Table[FindRoot[fun'[z] + 0.5 == m[[i]], {z, sols[[j]]}], {i, Length[m]},              {j,   Length[sols]}]      Basically, I get roots from the equation that are stored in `sols`. However, I also need all values from `sols` as starting values for the next iteration that will be executed in `sols2`. However, this doesn't work and produce the following errors:                   {{FindRoot[\!\(\*SuperscriptBox["fun", "\[Prime]",MultilineFunction->None]\)[z] +0.5 == m[[i]], {z, sols[[j]]}],          FindRoot[\!\(\*SuperscriptBox["fun", "\[Prime]",MultilineFunction->None]\)[z] + 0.5 == m[[i]], {z, sols[[j]]}],          FindRoot[\!\(\*SuperscriptBox["fun", "\[Prime]", MultilineFunction->None]\)[z] + 0.5 == m[[i]], {z, sols[[j]]}],          ....      Any suggestion on how to fix this?


MathLink and CDF

So far I have read that some things are not supported in CDFs. Istvan-zachar mentioned very useful things in his post. Unfortunately he mentioned that > MathLink operations, including J/Link and .NET/Link, are not supported. This is taken straight from wolfram.com under the "Interactivity in .cdf Files" section. In the past I was messing around with MathLink because I wanted to create functions that would execute faster. For an example of a complete MathLink program look at this old post of mine. In there I created an interactive program that uses the MathLink program. The question now, regardless of what wolfram says about no support for MathLink operations is, Has anyone been able to export this type of programs? Is it possible to embed the MathLink program in the cdf file? If not, can we make the cdf file create the link to the MathLink program? I suppose that we need to be aware that if this is possible then it would only work in computers running the same operating system that compiled the MathLink program. That is, if I compiled in Mac OS X, then the CDF would not run properly under Windows. # Update: Thanks to Mark McClure now I know how to make the function available to the cdf document. The problem now is that I get this: ![Non-working CDF](http://i.stack.imgur.com/iocMC.png) Only after I click on Enable Dynamics the desired result: ![Working CDF](http://i.stack.imgur.com/z1tNH.png) This tells me that the CDF was able to load the MathLink program but it will not let it run. I'm aware that this is do to security. I was reading here about the trusted path. Well, instead of adding a path I moved the cdf file and the MathLink program to a trusted directory. If I open it with Mathematica then it opens with no problem. But, if I were to open it with the CDF Player then I run into the issue I just mentioned. It requires me to click on the "Enable Dynamics" button. I believe this is what makes the CDF not being able to be displayed online. Any thoughts?


ListPolarPlot Labelling Points on the Plot

I have created a ListPolarPlot using the code below. I need to label the lines that extend from the centre to the outer ring. I do not want to label them with the values that these lines represent but rather with the values 1 to 7. I have tried LabelingFunction and some other things but these options don't work for ListPolarPlot. Can anyone help me with this ? As a second best solution I could just label the plotted points themselves from 1 to 7 (starting at the right hand horizontal and working anticlockwise).               ListPolarPlot[      Tooltip /@ {0.01422, 0.3425217, 0.30036, 0.013, 0.152, 0.3762,         0.122}, Joined -> True,       PlotMarkers -> Graphics@Disk[{0, 0}, Scaled[0.025]],       Axes -> {True, False}, PolarAxes -> Automatic,       PolarGridLines -> {{0.897, 0.897*2, 0.897*3, 0.897*4, 0.897*5,          0.897*6, 0.897*7}, {0.1, 0.2, 0.3}}, PolarTicks -> None,       AspectRatio -> 1/1, ImageSize -> {300, 300}]


Assumptions seem not to be considered

In the following `a`,`b` is a probability distribution, i.e. `a+b==1` with `a`,`b` real, and in the interval `[0,1]`. If we try to maximize the Shannon entropy over this distribution using Mathematica, we can either set `b=1-a`, or state the total probability condition as an assumptions. Maximizing using `b=1-a` works as expected. This input `Maximize[{-Log[2, a]*a - Log[2, 1 - a]*(1 - a), a <= 1 && a >= 0}, a, Reals]` yields `{1, {a -> 1/2}}`. However, when we give `Maximize[{-Log[2, a]*a - Log[2, b]*b, a + b == 1 && a >= 0 && a <= 1 && b >= 0 && b <= 1}, {a, b}, Reals]` as input, Mathematica does not find the solution. Any suggestions how the later input can be altered to find the correct solution?


Start Mathematica without the menu bar?

Is there any way to start Mathematica without the main menu bar? To be precise: ![what is the menu bar](http://i.stack.imgur.com/qizbK.png) Sometimes I make standalone mini-applications that I would like to just have in their own little windows without the cognitive weight of the entire Mathematica system bearing down upon my little one-off uses.


Pass an empty list object into a function and dynamically generate its list elements

I have another question on passing a list which needs to be generated dynamically. (Sorry for posting two questions in one day...) I did some search and found a similar post here, but I think it was for a fixed-length list. I hope I didn't misunderstand it... Here is my code:               FindRootsOfResult[i_, points_] := Module[{a, c},         Result = 2 E^(2 I \[Pi] w x) (2 + E^(I \[Pi] w x)) ((-100 + 0.55 I) + w)^3 /. x -> i;         a = FindRoot[Result == 0, {w, j}] // Hold;         c = ParallelTable[{Re[(a // ReleaseHold)[[1, 2]] - 100], Im[(a // ReleaseHold)[[1, 2]]]}, {j, 100 - 6, 100 + 6, 0.001}];         c = DeleteDuplicates[c, (Abs[#1[[2]] - #2[[2]]] < 10^-2 &) || Abs[#1[[1]] - #2[[1]]] < 10^-8 &];         points = Join[points, c];     ]      What I'm trying to do is to assign a value for the variable x and to pass a list into the `FindRootsOfResult` function, and then compute the corresponding roots of the function of w in a certain region. Finally I get rid of duplicate roots and save the roots in the list I passed in for further calculation. Since the number of roots in the given region changes for different x, the length of the list should be dynamically changed as well. I use `Join` in the last line because I'd like to assign many different x, compute the roots, and save all of them in the same list. A simple example would be               FindRootsOfResult[1/100, ans]      and I expect `ans` contains all the roots for x=1/100. However Mathematica gives me many error messages like               $RecursionLimit::reclim: Recursion depth of 256 exceeded. >>     Join::heads: Heads Join and List at positions 1 and 2 are expected to be the same. >>      and the list `ans` has nothing useful inside. Then I think, OK maybe Mathematica doesn't know that `ans` should be a list object, so I make `ans` be an empty list and do it again:               ans = {};     FindRootsOfResult[1/100, ans]      but I still get error messages               Set::shape: Lists {} and {{-1.82878*10^-6,-0.55},{-1.81874*10^-6,-0.55},{-1.80871*10^-6,-0.55},{-1.79868*10^-6,-0.55},{-1.78866*10^-6,-0.55},{-1.77864*10^-6,-0.55},{-1.76862*10^-6,-0.55},<<38>>,{-2.06832*10^-6,-0.55},{-2.05815*10^-6,-0.55},{-2.04798*10^-6,-0.55},{-2.03781*10^-6,-0.55},{-2.02765*10^-6,-0.55},<<344>>} are not the same shape. >>      Now I really don't know why I can't pass a list as I expected. If I execute the commands in `FindRootsOfResult` line by line manually, it works perfectly. I guess I don't really understand how Mathematica passes list objects. If anyone could give me a brief explanation or any previous discussion, I would so appreciate it!


Using Outer with Compiled functions that accept more than 2 arguments

How does one use `Outer` with a compiled function that accepts 3 or more arguments. Alternatively, how does one create a compiled function with 3 or more arguments that can be used with `Outer`? I am trying to use the following function:               minimumImagePD =  Compile[{{x, _Real, 1}, {y, _Real, 1}, {z, _Real}},                       Total[( (x - y) - z * Round [ (x - y) / z]) ^ 2]]      This function compiles just fine but you can't use it with `Outer`. Trying the following doesn't work because `Compile` does not "see" the argument 'z':               minimumImagePD2[z_Real] =  Compile[{{x, _Real, 1}, {y, _Real, 1}},                       Total[((x - y) - z * Round[ (x - y)/z] ) ^ 2]]              Outer[minimumImagePD2[3.2], {{2.1, 3.2, 4.3}}, {{3.2, 4.3, 2.8},                                 {1.1, 2.2, 3.3},   {3.4, 2.0, 6.5}}, 1].      Now, If I replace `z` in `minimumImagePD` with a number as follows:               minimumImagePD3 =  Compile[{{x, _Real, 1}, {y, _Real, 1}},        Total[((x - y) - 3.25026*Round[(x - y)/3.25026])^2]]      The function compiles and works fine as with the following example:               Outer[minimumImagePD3, {{2.3, 4.3, 6.5}}, {{2.1, 4.8, 7.3}, {2.2,         1.1, 4.3}, {2.1, 3.3, 4.7}}, 1] // Flatten      Which gives:               {0.93, 1.11557, 3.14325}      As noted by Oleksandr R. below, using set-delayed in `minimumImagePD2` solves the problem.


Dynamically Updating Function

I use Mathematica 8 and am working with DynamicModule. I'm trying to enter a function in an InputField then later apply it to two values entered in subsequent Input Fields. The function just does not seem to be dynamically applying to the new values I input. The issue probably lies in my definition of the function.                    DynamicModule[{dydx = Null, xi = Null, yi = Null},            Deploy[            Panel[             Grid[Transpose[{{"Differential equation: (dy/dx)=", "x:", "y:",              "slope:"}, {InputField[Dynamic[dydx]], InputField[Dynamic[xi]],             InputField[Dynamic[yi]],              InputField[               Dynamic[Function[{x, y}, Dynamic[dydx]][Dynamic[xi],                 Dynamic[yi]]], Enabled -> False]}}]]]]]


Showing the empty space in a Graphics3D plot

I would like to be able to visualize the empty space in a Graphics3D plot. For example, if I plot hexagonally close packed spheres using something like:               Show[Graphics3D[Sphere[#, Sqrt[2]/2] & /@ Select[Tuples[{-1, 0, 1}, 3],      Mod[Total[#], 2] == 0 &], Boxed -> False]]      ![Mathematica graphics](http://i.stack.imgur.com/XZzVA.png) Then how would I show the space between the spheres? That is, I would like the space occupied by the spheres to be empty and the space between them to be filled in.


"Show" with Manipulate runs fine normally, but gives errors as a CDF

I've simplified my code to what can reproduce my error. Basically, I have two lines:                spherePoint[x_] := Graphics3D[Sphere[{x, 0, 0}, 1]];       Manipulate[Show[spherePoint[m]], {{m, 1}, -Pi/2, Pi/2}]      This runs perfectly fine when I evaluate it in a mathematica notebook, but when I do a CDF preview (or export), it gives me the error               Show::gtype: spherePoint is not a type of graphics. >>      What gives?! Show should accept Graphics3D, and spherePoint is a graphics 3D object! (I'm not sure about the last part of that sentence, because it's a function that gives a graphics 3d object, but I don't know what that implies for the program) What am I doing wrong?


Manual CellGrouping option causes crash at cell evaluation

**Update: Try to reproduce this behaviour with`CellGrouping` set to manual**. To do that:   * either evaluate `SetOptions[$FrontEnd, CellGrouping -> Manual]`,   * or hit `CTRL`+`SHIFT`+`O` to bring up the **Option Inspector** window, **Lookup** (among **Global preferences** ) the option `CellGrouping` and set it to `Manual`.  Please test whether the phenomen is reproducible for you with the changed setting. You can reset cell grouping to its default behaviour by:               SetOptions[$FrontEnd, CellGrouping -> Automatic]      * * * Strangest bug ever. Copy the following piece of code to the same notebook **two times** , below each other, as two identical cells. Be sure to run a fresh kernel.               DynamicModule[{x}, Print[1]; Dynamic@x, Initialization :> Print[2]]      Now evaluate the **second cell**. Fine, it returns and prints stuff. ![Mathematica graphics](http://i.stack.imgur.com/a3nBf.png) And now, without quitting the kernel, **evaluate the first cell**. It crashes _Mathematica_. Every time, and only when the first cell is evaluated. If (after a restart) I only evaluate the first cell, _Mathematica_ crashes again. **How come that the outcome of evaluating two identical cells depends on whether the cell is the last one or not?** Furthermore, this one causes a crash on its own:               DynamicModule[{x}, Dynamic@x, Initialization :> Print[2]]      * * * _Mathematica_ 9.0.1.0 Windows 7 (64-bit), no packages, problem persists after full reboot, suggestion bar is turned off.


Run kernel script in cygwin without window popping up

I'm calling mathematica scripts running kernels through a cygwin terminal, which are again executed from c++ code. When I do this a window pops up, prints warnings and errors if there are any, and then disappears when the computation is done. This gets annoing because the window automatically opens on top of whatever else I'm doing. I've tried to find solutions without any luck - for example this thread gives the answer for some other situations but wouldn't work from cygwin I think. Any ideas? EDIT: To clarify: I'm trying to run a Mathematica script from the cygwin terminal without a Mathematica window popping up. That is, I'm running a command in cygwin with something like `./MathKernel -script myScript.m 45 3` where 45 and 3 are parameters in the computation. Everything works fine but a Mathematica window pops up un top of everything and disappears after a little while, something I'd like to avoid.


Evaluating the tensor product many times for a given list

I need to evaluate the tensor product 10 times in a given list( {g,e,r}) Here I have evaluated for 3 times...               #\[TensorProduct]#\[TensorProduct]#&[{g,e,r}]     ..     ..      Evaluated for 6 times...               #\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#&[{g,e,r}] (*n=6*)      Each time I need to include the tensor product on the list. Is there any better way to do this for large no.?


Aborting from inside a ScheduledTask

If you have an `Abort[]` inside a `ScheduledTask` expression, what does it abort? The scheduled task evaluation, or any main kernel evaluation that is ongoing?


Image levels: how to alter 'exposure' of dark and light areas?

I was working with some less than ideal photographs, and wanted to adjust them before continuing. I wanted to raise the levels of the very dark areas and lower the levels of the very light areas. I couldn't find a function in Mathematica 8 that would allow me to do this. As a quick work-round, I wrote a function that quickly adjusted the levels. It looks terrible in this simplified example (I had more levels going, for one thing), but you get the idea (I hope!).               image1 = Image[         ReliefPlot[            Table[i - 3 Sin[i^2 + j^2],                 {i, -4, 4, .03},                 {j, -4, 4, .03}]]];      tweakC = Compile[{pixel}, Module[{ p = pixel},        m = Mean[p];        Which[             m < 0.3, p = pixel * 1.5,                 m > 0.85, p = pixel * 0.8 ,                 m > 0, p = p ]]];     image2 = ImageAdjust[ImageApply[tweakC, image1]];     ImageAssemble[{image1, image2}]      ![before and after](http://i.stack.imgur.com/8vYOs.png): What's the best way to do this? I don't think `ImageAdjust` or `ImageClip` do what I want.


How to map an image to get an illusion of 3D

I would like to distort or map a given jpg so it looks 3D as in the following youtube video: http://www.youtube.com/watch?v=IfCCUd8mFtg. I usually use conformal mapping (a complex function) to do my distortions. Can you help me with figuring out which function to use for this?


Write numbers to a file

I want create file with some text (and numbers). This is my code.               str=OpenWrite["f:\\1.txt",PageWidth->Infinity, FormatType->StandardForm,NumberMarks->True];     Write[str, "a = ", 0.123456789];     Close[str]      The problem is there is rounded number (0.123457) in the output file. but I actually want file with text               a = 0.123456789      **Explaining** : I want parse a test suite files (*.mt) with data for check. Rows looks like               dataAcc = {{1.865987700, 1.920469000, 1.811506300, ...},...}     Get[childTestLocation<>"nameOfChildTest.mt"]      I have a numbers for dataAcc list. But when i create testfile numbers becomes rounded.


step by step interactive indefinite integral

WolframAlpha can give step by step solution for indefinite integral. There seems to be similar question but for derivatives. Is there a way that I can generate my own step by step solution for indefinite integrals (for simple integrals having closed form)? Sorry, if the question is inappropriate.


How do I plot points on a sphere using spherical coordinates?

Currently, I have a matrix containing a list of spherical coordinates. Column 1 is r; r=1 for all points. Column 2 is theta and column 3 is phi. Each row is an ordered triple (r,theta,phi). Is there a function that I can get to operate on this matrix and plot these points on a sphere of radius 1? Thank you! -Chase


Manipulate is evaluated slowly

I have this function:               f[k_, θ_, ϕ_] := Cos[k*Cos[θ]*x + k*Sin[θ]*y - ϕ]      I want to change the parameters $\theta, \phi,$ and $k$ to see the effects on the function. I use the command below to achieve that:               Manipulate[       ContourPlot[f[k, θ, ϕ], {x, 0, 50}, {y, 0, 50}, PlotLegends -> Automatic],     {k, 0, 10}, {θ, 0, 2*Pi}, {ϕ,0, 2*Pi}]      The problem is that when I change one of the parameters, say $\theta$, continuously the plot is evaluated slowly so that during the running you cannot see the actual graph. How can I change those parameters and see the real evaluated result immediately?


Why doesn't a Composition[] hold its arguments and what can be done about it?

Now that `Composition` (also `RightComposition`) has shorthand syntax I am more inclined to use it, however what I feel _should_ be one of its best advantages over the plain `foo @ bar @ ## &` doesn't exist: **held arguments.** For example I wish for the following behavior:               Composition[ToString, HoldForm][2 + 2]          (* desired output: "2 + 2" *)      I am aware that the form `head[a__][b__]` doesn't normally allow holding of arguments `b` but this has always seemed like a place an exception should have been made. ~~Unless the first head applied has hold Attributes this would not alter behavior.~~ Does anyone regularly make use of the evaluation of arguments that I am seeing as undesirable? Presumptuously assuming that others find desirable the behavior that I want I see this as a sorely missed opportunity:   * the shorthand forms `foo @* bar` and `foo /* bar` could have been made to parse as `LeftComposition` (hypothetical) and `RightComposition`   * these new operators could have been made to hold arguments as I describe without breaking backwards-compatibility with `Composition` in past versions. I wonder what can now be done to improve the situation.   1. I suppose it is too late to get such changes made to natively. Has such a change _ever_ been made to _Mathematica_ (or Wolfram Langauge) after an initial release?   2. I am tempted to try to force this behavior myself using one of the methods available. All public code except what I see as edge cases would work on my machine but my own code would fail on others.   3. Sadly it is not possible to define custom compound operators so there is no true alternative, but I could define e.g. `comp[fn1, fn2]` to work as I desire. My questions therefore: **Is there some reason _not_ to have a `Composition` expression hold its arguments?** **Is there another option that I am failing to consider?** **How can one robustly implement option #2 or #3?**


Problem When Trying to Export Graphics with Transparency to SVG

I'm trying to export a graph as a graphic to an SVG file with transparent background. When the background is specified as a color (or unspecified), it works just fine. When the background is specified as `None`, it offsets the graphic down and to the right a bit and ends of cutting off part of the graphic.               g = CompleteGraph[7];     g = GraphicsGrid[{{g}}];     Export["good.svg", g, Background -> Pink];     Export["bad.svg", g, Background -> None];      Transparency works perfectly as expected when the graphic is exported to PNG. Is this a bug, or am I just missing something here? I'm running Mathematica 9.0.0.0 on Linux 64-bit. Here's a screenshot of what I am seeing when I open the bad.svg in the gnome image viewer (with some style changes made to the graph for visibility). Note that the image is cut off on the bottom and on the right. When I open bad.svg in chromium or in firefox, it appears fine. ![1](http://i.imgur.com/tAkcEye.png)


V10's Operator Forms - what are they good for?

V10 introduces an operator form for several functions perhaps primarily due to their role in queries as part of introducing data science functionality. At first pass it seems a lot of effort to add some syntactic sugar (given an equivalent pure functional form only ever requires an extra couple of symbols - (`#`, `&`) )? For example,`Map[f,#]&[{a,b,c}]`can now be shortened to `Map[f][{a,b,c}]`, - slightly more compact but then again perhaps not such an improvement on an existing operator (short) form - `f/@{a,b,c}`. So, are there some compelling examples that illustrate the rationale behind the introduction of this new construct? **Conclusion** To summarize the points made in all the informative responses:   * In addition to avoiding the symbols (`(#&)`) operator forms can eliminate the need for `Function` in nested definitions.   * The gains of using operator form are cumulative as they are chained together either in postfix, prefix or for some, infix form.   * While not necessarily restricted to this area the motivation and applicability of operator forms stems from the need to provide functions as arguments in `Dataset`.   * Many operator forms are built-in but when not they can be readily defined.   * The pure and operator forms are not always semantically equivalent (natively or user-defined) with, for example, `Query` using their different patterns to interpret differently.   * They can potentially be used to improve efficiency not just via code's reduced leaf-count but in reduced algorithmic complexity.   * They are potentially a rich source of language improvement from mimicking natural language patterns, code refactoring, debugging or automated and non-deterministic parsing via corpus-derived context.


Plotting confidence intervals

The documentation for PDF has an example for plotting a confidence interval of a standard normal distribution:               pdf = PDF[NormalDistribution[], x]     Show[Plot[pdf, {x, -1.7, -1}, Filling -> Axis, FillingStyle -> Green],       Plot[pdf, {x, -1, 1}] ,       Plot[pdf, {x, 1, 1.7}, Filling -> Axis, FillingStyle -> Green],       PlotRange -> {0, 0.4}, AxesOrigin -> {0, 0.1},       Ticks -> {Automatic, None}]      The plot range is set such that this code would not work in a generalized case for `NormalDistribution[u,s]`. **What is the appropriate format for {x, xmin, xmax} in the`Plot` function above for the general case of a normal distribution with mean = u and standard deviation = s?**


smooth kernel distribution

I just want to know what is "x" in a code line like "SmoothKernelDistribution[Data,x], when it is a real number?!! when it is integer I know that it is the number of bins but what is this factor when it is something like "0.5"?


How to force the RegionPlot to shade a narrow region?

I have an interactive demonstration, which (very simplified to leave out unnecessary details) looks as follows:                   Manipulate[      Show[{        Plot[{x, a*x}, {x, -1, 1}, PlotRange -> {-1, 1}],        RegionPlot[x < y < a*x, {x, -1, 1}, {y, -1, 1}]        }], {a, 0.5, 1.5}]      On the screen I see this: ![enter image description here](http://i.stack.imgur.com/Q8NIX.jpg). I draw the arrow to point out a defect in the shading: the shading does not cover a narrow triangle in the vicinity of the coordinates origin, though it should. More than that. The degree of shading varies as I move the slider. I could, of course, use the option "Filling" in the Plot statement and remove the RegionPlot at all. I need, however, the filling to show the region where one of the lines is above the other. It seemed that the RegionPlot is in this case a more natural choice. Can you imagine a workaround with the RegionPlot, or I should inevitably go to Filling in the Plot statement?


Linearized Einstein Equations with Mathematica

I need to compute the linearised Einstein Equations around a fixed metric $g_{\mu \nu}$ which is not the flat metric. Someone knows some Mathematica package or some review that can help me?


How to load FORTRAN libraries through Librarylink

First, the main reference is the thread Linking FORTRAN with Librarylink, which teaches how to make the link between a FORTRAN subroutine and a Mathematica code, by using Librarylink. This must done through a C code, from where the FORTRAN subroutine is called. The C code is, then, compiled via Mathematica. I have studied the examples and tried them myself. My doubt is on how to load FORTRAN libraries, e.g. for using the FORTRAN command `open` within the subroutine. Whenever I try to call a subroutine that contains `open`, I read an error message on the screen. Read below my minimal example. **FORTRAN subroutine** The subroutine reads `a,b,c` and stores `a+b+c` into the variable `sum`. Additionally it open,reads and close `file.dat`.                   !fadd.f90         subroutine add(a,b,c,sum)               implicit none               integer a,b,c,sum               sum=a+b+c               open(1,file='file.dat')               read(1,*)               close(1)               return         end subroutine      `file.dat` only contains the number `1`, for the minimal example. This value is not used anywhere, for simplification. My actual code would use dat files to make complicated computations. **Calling the subroutine from C**               //MMA.cc     //Link directly to fortran object file     #include "WolframLibrary.h"          DLLEXPORT mint WolframLibrary_getVersion(){         return WolframLibraryVersion;}     DLLEXPORT int WolframLibrary_initialize(WolframLibraryData libData){         return 0;}          //declare fortran subroutine     extern "C" { void add_(mint* a, mint* b, mint* c, mint* sum);}           EXTERN_C DLLEXPORT int add(WolframLibraryData libData, mint Argc, MArgument *Args, MArgument Res){         mint I0 = MArgument_getInteger(Args[0]);         mint I1 = MArgument_getInteger(Args[1]);         mint I2 = MArgument_getInteger(Args[2]);         mint sum;         add_(&I0,&I1,&I2,&sum);//call fortran subroutine         MArgument_setInteger(Res,sum);         return LIBRARY_NO_ERROR;     }      **Mathematica: create library and load library function**               Needs["CCompilerDriver`"];     CreateLibrary[{"MMA.cc", "fadd.o"}, "myadd", "Debug" -> True, "TargetDirectory" -> "."]          funcadd = LibraryFunctionLoad["./myadd", "add", {Integer, Integer, Integer}, Integer]          Print[ funcadd[2,2,2] ]     Exit[]      **ERROR** (Running Mathematica 8 through Linux terminal)               (*   /optifi/Wolfram/Mathematica/8.0.4/SystemFiles/Kernel/Binaries/Linux-x86-64/MathKernel: symbol lookup error: (...)/myadd.so: undefined symbol: _gfortran_st_open   *)      For compiling the FORTRAN code, I have run on LINUX terminal               gfortran -c -fPIC fadd.f90      where `-fPIC` has been added as requested by an error message telling `recompile with -fPIC`.


Image3D and Graphics3D

also I guess that the topic was tackled in Combining Image3D and Graphics3D. My question is quite similar: How do I match the coordinate Systems of Graphics3D and Image3D? Here some code:               z = 1;     p = RandomInteger[100, {z, 3}];     r = RandomInteger[10, {z}];     spheres = MapThread[RotateLeft[DiskMatrix[#1, {100, 100, 100}], #2] &, {r, p}];     i = Image3D[Plus @@ spheres, Axes -> True, AxesLabel -> {"x", "y", "z"}]     obj = GraphicsComplex[p, Sphere[Range[z], r]];     gr = Graphics3D[obj,                     Axes -> True,                     AxesLabel -> {"x", "y", "z"},                     PlotRange -> {{0, 100}, {0, 100}, {0, 100}}]     Show[i, gr, Axes -> True]      Can anyone explain to me how to match the coordinate systems, that the spheres match? Thanks in advance!


How do I define an argument pattern for a Head of NOT a given value?

I want to define a function f with an argument that matches only when an argument Head is NOT of a given value. I know I can define a pattern that matches the Head for an argument:               f[a_Integer] := 2 a      Now, how do I define a version that matches only when argument a is NOT an Integer?               f[a_NotAnInteger] := <something else>


Mathematica Version 9.0.1 EPS Format Improvements

Is it just me or has the ability to make high quality EPS graphics increased greatly in version 9.0.1 compared to 9.0.0? I've always found it difficult to get plots that I make in Mathematica to print nicely in Microsoft Word. Mathematica does a terrific job of converting whole notebooks to a pdf but in my experience, it does a much poorer job of saving individual cells or graphics to a pdf. So I've started saving a given notebook as a pdf. From there I open it up in Adobe Acrobat 11 and crop the figure I want. Then I save the resulting pdf as a .eps which I then import in word. Here's the kicker though, do this with version 9.0.0 and your likely to have issues with the misplacement of text in your figures (or the text may even be missing completely) upon importing the .eps in word. Do this in version 9.0.1 and you'll get beautiful, crystal clear graphics upon the printing of the word document. Did Wolfram Research acknowledge that changes in this area were made with this update? I know we don't like to post too many questions all at once but I was annoyed with the fact that I ended up having to uninstall 9.0.0 from my system in favor of 9.0.1. Why doesn't Mathematica update automatically from version x.a to version x.b? Thanks


Unpacked eigenvectors of complex matrices

**Edit:** This bug is fixed in _Mathematica_ 10.0.0 I want to calculate eigenvectors of a Hermitian matrix. For example               $HistoryLength = 0;     n = 3000;     mat = # + ConjugateTranspose[#] &@RandomComplex[{0, 1 + I}, {n, n}];     evec = Eigenvectors[mat];      However, `evec` is unpacked!               evec // Developer`PackedArrayQ      > False System monitor shows ![enter image description here](http://i.stack.imgur.com/1GrDX.png) It seems that the result was unpacked in the end of evaluation. I think the problem is that the last element of each eigenvector is real instead of complex               evec[[All, -1]]      > >     -0.100012, -0.059244, -0.0723702, ... >                 evec[[All, -2]]      > >     -0.0994738 - 0.00136552 I, -0.0527357 - 0.0532419 I, 0.158174 + > 0.0341157 I, ... >   With real matrices everything is fine               n = 5000;     mat = # + Transpose[#] &@RandomReal[1, {n, n}];     evec = Eigenvectors[mat];     evec // Developer`PackedArrayQ      > True ![enter image description here](http://i.stack.imgur.com/R9cEy.png) My current workaround consist in packing the result immediately after `Eigenvectors`               evec = Developer`ToPackedArray[0.0 I + Eigenvectors[mat]];      Now `evec` is packed but there is a very big peak in the memory usage ![enter image description here](http://i.stack.imgur.com/lNBEQ.png) It is not a problem for a small matrices, but if matrix `mat` is ~30GB then I need ~300GB memory. It is quite a lot even for the swap space! It seems that this is a very simple question, but I could not find anything. P.S. I use _Mathematica_ 9.0.1 and Linux. _Mathematica_ 8 has the same problem. **Update** halirutan's answer solves this problem completely! Now memory profile is much better ![enter image description here](http://i.stack.imgur.com/NJ9DS.png) Some notes: You need 11 version of MKL. In Gentoo it is available in science overlay. I compile the library with the command               gcc -shared -fPIC -o PackedEigenvectors.so -I /usr/local/Wolfram/Mathematica/9.0/SystemFiles/IncludeFiles/C/ -I /opt/intel/composerxe-2013.0.080/mkl/include/ PackedEigenvectors.c      Helpful links: 1, 2


A question about definite integrals and timing

I need to integrate the expression `G` given below:               R = {Rx, Ry, Rz};     b = {bx, by, bz};     r = Sqrt[(s*b - R).(s*b - R)];     K = Exp[-r/L]/r;     G = Simplify[-K*(1/r + 1/L)*1/r*b.(s*b - R)];      If I use:               Integrate[G,{s,0,1}]      it takes quite a long time; instead if I use:               int = Integrate[G, s]     Simplify[(int /. s -> 1) - (int /. s -> 0)]      it takes less than a second. Why is it so?


How to convert TableForm to proper LaTex and why is "\" not replaced by StringReplace?

I'm trying to optimize the teXForm output of a table because the standard output ist not satisfying:               badLatex = TeXForm[TableForm[{     {"nm", "E1", "E2"},     {500.`, -0.001`, -0.001`},     {499.`, -0.001`, 0.`},     {498.`, 0.`, -0.001`}}]]      I get this output               \begin{array}{ccc}          \text{nm} & \text{E} & \text{E} \\          500. & -0.001 & -0.001 \\          499. & -0.001 & 0. \\          498. & 0. & -0.001 \\         \end{array}      No I want to replace the decimal points with commas, change the environment and eliminate the "\text" command. The last doesn't work for me.               goodLatex = StringReplace[ToString[badLatex],         {"array" -> "tabular","." -> "," ,  "\text" -> ""}]      I get the following result:                   \begin{tabular}{ccc}              \text{nm} & \text{E1} & \text{E2} \\              500, & -0,001 & -0,001 \\              499, & -0,001 & 0, \\              498, & 0, & -0,001 \\         \end{tabular}      As you can see, the expression "\text" is still there. Why is "\" not replaced by StringReplace? Do you have a better idea how to convert tables to proper LaTex code? Thanks in advance for your help! Michael


Is LinearSolve the most robust way to solve the equation $Ax=b$?

I want to solve the equation $Ax=b$, where $A$ is an $n\times n$ matrix, and $x$ and $b$ are $n\times 1$ column vectors. Here $n=124$. `LinearSolve[A,b]` I got the following warning message: `LinearSolve::luc: Result for LinearSolve of badly conditioned matrix {{2075.28,-2527.91,633.713,-282.942,160.179,-103.364,72.5099,-53.9143,41.8539,-33.5945,27.6963,-23.3423,20.0412,-17.4831,15.4647,-13.8482,12.5376,<<17>>,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,<<74>>},<<49>>,<<74>>} may contain significant numerical errors. >>` The determinant of the matrix $A$ in this case is about $10^{282}$. I also used Matlab to solve the same problem; there is no warning massage and the result is consistent with the Mathematica result. This is only a small part of a program, and it can be checked that the final result is correct despite the warning message. But it is disturbing that the precision may not be good enough. What is the best way to solve the equation $Ax=b$ when the matrix $A$ is large? How can we increase the precision or control the precision?


Multiple swapping of rows and columns

m={{a, b, c, p}, {d, e, f, x}, {g, h, k, z}, {u, v, w, y}};      I want to swap 1st and 2nd rows by 4th and 3rd rows respectively. And then, swap 1st and 2nd columns by 4th and 3rd columns.


Constrain Fit to make a fit that remains positive over the range of my independent variable

For example, say I have the following data.               {{100, 1.5157*10^-3}, {200, 1.4556*10^-4}, {300, 2.8538*10^-5},       {400, 7.5323*10^-6}, {500, 2.3853*10^-6}, {600, 8.3798*10^-7}}      When I attempt to use the `Fit` command (to any order of x) the result always allows for the y value to be negative at some x. Is there anyway I can add a constraint that will prevent this from happening?


nested use of Apply/Map/MapThread in pure functions

**1\. My main question** I have a function with two argument slots. I wan't to apply this function to 2 lists with different length's. I thought in this solution:               Map[Map[f[# &, #], b] &, c]      But it doesn't work. Why is that? **Example**               f[x_, y_] := Sin[x y]                 b = {1, 2}       c = {1, 2, 3}      The output seems pretty close of what i wanted but not close enough:               {{Sin[#1 &][1], Sin[#1 &][2]}, {Sin[2 (#1 &)][1],        Sin[2 (#1 &)][2]}, {Sin[3 (#1 &)][1], Sin[3 (#1 &)][2]}}      **2.** It seems that i only need to take the &'s out of the square brackets. **a)** Is it so? Why? **b)** how can i do that? Thanks


Exporting Dynamic@Graphic with Mathematica and Player Pro

Why does               DynamicModule[{grf, x},       Panel[{Button["Export", Export["test.png", grf]],         Slider[Dynamic[x], {1, 4}],         grf = Dynamic[Graphics[{Line[{{1, x}, {x, 1}, {3, 2}}]}]]}]]      export properly in Mathematica but not Player Pro and               DynamicModule[{grf, x},       Panel[{Button["Export", Export["test.png", grf]],         Slider[Dynamic[x], {1, 4}],         Dynamic[grf = Graphics[{Line[{{1, x}, {x, 1}, {3, 2}}]}]]}]]      export properly in both? Thanks in advance.


How to specify VertexCoordinates as geographic coordinates of cities?

I have been very busy these days with giving the `VertexCoordinates` of the cities the geographic coordinates from `CityData["CityName","Coordinates"]` of the cities. Could somebody please help me on writing algorithm?               Graph[{"Uppsala" -> "Marsta", "Marsta" -> "Uppsala",        "UpplandsVasby" -> "Sollentuna", "Sollentuna" -> "UpplandsVasby",        "UpplandsVasby" -> "Marsta", "Marsta" -> "UpplandsVasby",        "Stockholm" -> "Boo", "Boo" -> "Stockholm",        "Stockholm" -> "Lidingo", "Lidingo" -> "Stockholm",        "Stockholm" -> "Sollentuna", "Sollentuna" -> "Stockholm",        "Stockholm" -> "Taby", "Taby" -> "Stockholm"},       VertexLabels -> "Name"]


on simplifying an expression

After some integration process, I ended up with the following expression:               (1/(b (-1 + E^b) Re[b]))E^-Re[b](  b E^b - b + E^Re[b] Re[b] - E^(b + Re[b]) Re[b]                                      + E^Re[b] Sqrt[E^(-2 b) (-1 + E^b)^2] Re[b]                                      + b E^(b + Re[b]) Sqrt[E^(-2b)(-1 + E^b)^2] Re[b] )      all is good, but this expression is supposed to be equal to               1 + (2/b) e^(-b) - 1/b      via simple numerical trials, i can confirm that they are equal. But, it would be great if I can actually make _Mathematica_ simplify that nasty expression into this innocent form. I tried, `Fullsimplify`, it does not work. Does anyone have any suggestion?


Table/Tree of values

**My question:** Is there a way to create a tree of values? Something like the output of the command TreeForm, but with values in the nodes? **Why do I want this?** I'm trying to do a complete program to analyse the output of my labs classes. Each column of data has a symbol assigned. In general, each column is meaningful: it's not just a pile of diferent variables. What i want to say is that in general,calculations are done "column wise".My problem is when i need a to do a calculation that needs a more envolved "horziontal" structure : Assigning the variables to columns lacks "horizontal flexibility" . (In a way,this is the kind of problems that are solved in Excel with the `$$` and array formulas) let me ilustrate with an example:               y={1,2,3,4,5,6,7,8,9};     x={-1,-2,-3};      I want to associate the 1;;3, 4;;8, 9;;9 parts of y to each element of x. What i mean by associating is that for some calculation the input of the function will have as argument each of this sets. I'm aware of functions like Map, Apply, Thread and MapThread. I've been using them to solve this kind of problems, but sometimes it gets a little confusing. I'm also aware of Partition, wich would solve my problem if i wanted to separate y in subarrays of the same length. As i say in my question, what i want is to construct something like a net/tree that "archives" the structure of the arguments in each step of my calculations. Something like in networking theorys, when each node as an associated list of it's connections to the rest of the network. Notice that this list should not contains the values but some kind of coordinates of the connected nodes **Example:** Calculate the mean and the mean square deviation of the irregular partition of lenghts `n={3,2,5}` of the list                y={3,5,8,7,9,4,6,2,1,5};      **My very conceptual aproach:** The first column of my Table/Tree will be the data y. To refer to some value on some column, I will use a pair of coordinates i,j: i stands for the column and j stands for the internal position. I will assign to y the coordinate i=1. For the means calculation, what kind of "calculating conections" i have?               Yav=F1[y]=Mean[y]      The column of the means, Xav i=2, will have 3 elements. To each one I assign a list of conections to y: (Conection of "" is rerpesent with a C"")                   CYav[[1]]: {1,{1,2,3}}         CYav[[2]]: {1,{4,5}};         CYav[[3]]: {1,{6,7,8,9,10}}      The connection are written in the form {i,{j's of the elements of i}} Now, let's calculate the mean squared deviation. That is ,                  Ymsd=F2[y,Yav]=Mean[(y-Yav)^2]      This column as `i=3` and also 3 elements. For this calculation, i want to use the columns i=1,2. The calculating connections to y are the same that the ones used to calculate Yav. But now, i need to connect Ymsd to Yav.                   CYmsd[[1]]: {{1,{1,2,3}},{2,1}}         CYmsd[[2]]: {{1,{4,5}},{2,2}}         CYmsd[[3]]: {{1,{6,7,8,9,10}},{2,3}}      Now the conections are a pair of conections of the former type, one to each column connected. After assigning the conections, i would use a function that would fetch the correct values, guided by the map created, and apply the F1,F2. Thanks


Eliminate doesn't work in Mathematica

Hello Mathematica users, I have problems trying to eliminate variable $Q(x,y)$ froma PDE, but Mathematica output is just `True`. The problem is that I already found how to eliminate it. We can apply $d/dx$ on the second equation and then from the first equation we can determine and substitute $dQ[x,y]/dx$ in the second. Why can't Mathematica do that? My output is in that case a PDE of fourth order, but I don't have `Q[x,y]`, which is the aim, and I solved it by hand.                Eliminate[{A0*D[w[x,y],{y,2}]-B0*D[w[x,y],{x,2}]-        C0*D[Q[x,y],{x,1}]+C0*D[w[x,y],{x,2}]==0,        E0*D[Q[x,y],{y,2}]-FF0*D[Q[x,y],{x,2}]-CC0*D[w[x,y],{x,1}]-Q[x,y]==0},         {(Q^(0,2))[x,y],(Q^(1,0))[x,y],Q[x,y]}]


MathKernel and MathLM interaction

If one restarts MathLM on a Linux server, will that restart mathkernel as well? In other words, will restarting MathLM affect the current jobs running that use MathKernels? Thanks.


Why does $Path change when I examine it in new cell after I just changed it?

This is really driving me crazy. In one cell, I change `$Path` by removing from it un-needed paths that I do not want for the duration of a computation I will be doing. Immediatly after, in new cell, I type $Path and see it was changed ok. Now, I open a new cell, and do the same. I type $Path again, and now I see some of the Paths I removed are back again! Here is a screen shot from my notebook now ![enter image description here](http://i.stack.imgur.com/Isyws.png) You can see the variable $Path now has changed, on its own. This is what I type               $Path =DeleteCases[$Path, "C:\\Users\\me"];     $Path =DeleteCases[$Path, "."];     $Path =DeleteCases[$Path,"C:\\Program Files\\Wolfram Research\\Mathematica\\8.0.4\\AddOns\\LegacyPackages"];     $Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Autoload"];     $Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Kernel"];     $Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Applications"];     $Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Applications"];     $Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Autoload"];     $Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Kernel"];     $Path=DeleteCases[$Path,"C:\\Program Files\\Wolfram     Research\\Mathematica\\8.0.4\\Documentation\\English\\System"];      Then in new cell               $Path      Then in new cell the same. And now the $Path has been reset. I noticed this when I was calling Leonid function he posted, and in it, it uses `$Path`, but I noticed I was getting packages that should not show up since I changed the $Path before calling it. This is really strange. I am using V 8.0.4 on windows 7 **edit** Just installed version 9. Not able to reproduce this. Using the same PC, same notebook, same steps. So it looks like, whatever it was, is fixed in Version 9.


How do I keep the right ordering of eigenvalues using Eigensystem?

I'm having an issue with the `Eigensystem` command. I need to diagonalize a bunch of 3 by 3 complex valued matrices, but more importantly, I need to keep the exact ordering of their eigenvalues once brought to their diagonal form. For example, if               A = { {1.999, 0.000428712*I, 0} , {-0.000428712*I, 2.00072, 0} , {0, 0, -4.00057} }      then `Eigensystem[A]` returns the three eigenvalues (with their corresponding eigenvectors) listed in order of decreasing magnitude (absolute value). What is even more annoying is if my loop runs into an already diagonal 3 by 3 matrix such as `B = {{2,0,0},{0,-3,0},{0,0,2}}`, it will reorder the eigenvalues as `{-3,2,2}`. Is there a command that gives me the eigenvalue without re-sorting them?


Global precision setting

Coming from Maple I do not understand how the precision for numerical computations in Mathematica is specified. I understand that there are various options to commands such as `WorkingPrecision` and `PrecisionGoal`. But I would like to use the same precision (above machine precision) for a number of computations including matrix operations and the `FindRoot` command outside and inside of routines. Also I would like to specify the precision of the output.


Formatting ANOVA table and/or ParameterTable without using Grid?

Does anyone know if there is an option or function that can automatically format the output of `ANOVATable` and `ParameterTable`, but without using the `Grid` function ?


Distances between points in periodic cube

How can one implement more efficiently/elegantly/memory savvily the following function which returns a matrix of all Euclidian distances between points in 3D within a cube of width `size`, while accounting for the periodicity of the cube?               Clear[PeriodicDistance];     PeriodicDistance[x_, size_: 1] := Module[{xm, ym, zm},     xm = {Outer[EuclideanDistance, x[[;; , 1]], x[[;; , 1]]],      size - Outer[EuclideanDistance, x[[;; , 1]], x[[;; , 1]]]};     xm = Map[Min[Abs[#]] &, Transpose[xm, {3, 1, 2}], {2}];     ym = {Outer[EuclideanDistance, x[[;; , 2]], x[[;; , 2]]],      size - Outer[EuclideanDistance, x[[;; , 2]], x[[;; , 2]]]};     ym = Map[Min[Abs[#]] &, Transpose[ym, {3, 1, 2}], {2}];     zm = {Outer[EuclideanDistance, x[[;; , 3]], x[[;; , 3]]],      size - Outer[EuclideanDistance, x[[;; , 3]], x[[;; , 3]]]};     zm = Map[Min[Abs[#]] &, Transpose[zm, {3, 1, 2}], {2}];     Sqrt[xm^2 + ym^2 + zm^2]     ]      As a side question, is it possible to carry out such computation within mathematica using e.g. octree so that it could be scaled up to millions on points? Thanks for your help


Invisible characters being inserted into the output from FindMaximum

I have been using _Mathematica_ for quite some time but I have never seen anything like this. It started without warning and I am not sure how to fix this. Please have a look at the following example https://dl.dropboxusercontent.com/u/23383252/bugs_editor.nb The notebook exemplifies my problem. Before you run it to check it, please read through it as I have explained every step of the problem. I am using a dropbox link to my notebook, since I have no idea how to attach a file (or if it is possible at all!) to this message. In short, the problem is as follows: there is an issue with `FindMaximum` (could be other built in functions as well, but so far this is where it started) where, the editor changes the output from `{maximum, {xx -> maximum position}}` to `{maximum(extra invisible characters), {(xx -> maximum position)(some more invisible characters)}}`. This has a huge impact on the rest of the variable types that are calculated with either element of the `FindMaximum` output (see the notebook for an example with `ListPlot`). Has anyone seen this and how did they fix it. P.S.: I tried to google this problem but I had no success since I don't really know what generates it. Update: As discussed below, I have modified the shared notebook to make it simpler. Got rid of all the unnecessary parameters and replicated the problem on my computer. Now, as rasher said, the issue could arise due to the excessive use of comments. This seems to be the case, because I copy and pasted the first cell where function nx is defined, into a new notebook and same thing happened. Again the problem was fixed if I wrote the function in a new cell. I will try to add the code to this message together with the output for `Va=2`:               nx[Va_] := Block[     {WmaxL},     WmaxL = FindMaximum[{rr^2 - 10 rr + Va - 1/rr, rr > 0}, {rr, 1}];     WmaxL     ] ;      This is the original function. Please note the extra spaces between the last `]` and `;` (this was a surprise for me too as is not evident in my notebook!). The output for this function is as not what you would expect from `FindMaximum`:               Out[15]= {-5.221174649 TextCell[""], {(rr -> 0.3271088) TextCell[""]}}      More surprises! This is what I get when I copy from the _Mathematica_ notebook and paste it here! What is this `TextCell` in the output? It is obvious for me why the rest of the notebook is not working as it should, but I have no idea why are these invisible characters inserted in my expressions. I hope this clarifies the issue a bit more, and allows you to check it on your machines too. P.P.S.: the modified notebook can be found at the same link.


Derive a smooth circle with cusp from an image

![enter image description here](http://i.stack.imgur.com/3VEuj.jpg) ## question 1 get the center * * * ( _sample data_ ) `sample` is the black circle with cusp.                (*Input 1 ==< *)      sample = Binarize[Import["http://i.stack.imgur.com/z7isS.png"]]      > >     (*Output CellExpression, You can copy to Notebook or just Skip*) > > \!\(\*GraphicsBox[TagBox[RasterBox[CompressedData["1:eJztnc1u1DAUhR3Egh079jwKPEJ5glaCLVJBQn17mpnpNImPnTj+ude+51OpVI1jn/v5ZzLTqfj69Pvh1wfn3J9Pr98eHv99e35+fPnx8fWH7y9/fz7ND32enPvy+m9qhpuJPz65W7MFq8fHw+1ouT0cszKmmGm9YtbVX782Le+tt44Gw6/0bsUZtLLdGP7PsfaDSilhRSZ4VfatrMse3AraCrsFwotG8kMrK4pXM4QbWtlSN32vbirnXvbdh5ZG89jZZmqUtWMrFdP2Y6V5zi7UtM+o3YrgtCk2I7mYlVoRny2VB4x4JFrZC6DCiqI0iszoSbJ8eSSYRdHcvLF871MqgkIr0om0CXlHMhmtaBs7jlAyhQfKGpGAtKJiyFO0TUkrsmPl0i4qrYSH6UDJG7SCqJ3XdWuldv9dCblSOXWnVnY/65vdd4dOZuolp5VAv30qmerN6BhWSlcwhpXCvTa4Q6zK+41W0Sp6t1L8NVHPTz4LaAVSUkuHr3wClKyEVmr3JUuxSuo8n4lBK4gytQyl5Ep+RWMtlCvFrBRLpIH8mR7RSm5VI+6fmby6aKX81XrJqGuwG5U1p2ujlciFNTKp4JwYI1aSPq088vZ5I73C8Z3kWBnZS7IVA/sn/ZSwcKqctlI1kwbSvNBKpHXlTPLQCiLFihEl0+J3zwfuQOxYSXkNbNHKzmKxcaty5+BacWaO2gtHrVhycoFWEEdOFmtOjp2ktBJs0yyRBvatGBNygVYQe1bMbZ4btIKgFUR8D9FK6NHGgVSwb8WmmNiLRFrxirerZKIVDK0gaAVBKwGwF1qhFR9oJXp7ZwFkJXJvZ4SIFbFM8tAKglYQtIKgFUTQytCfrt3Dt8KVQisYWoGErJj24n+ciU5iVix74VrB0AqCVhDb5xxamUFWRAOpgFYQKyvcPjdoBUErCFpB0Apidc9PK3doBUErPjxXELSCoBUErSCcW3ihlRu0gqAVBM8VBK0gaAVDKwha8eEOQqysTHyP/wqtIGgFQSsIWkEgKxRDKwhaQdAKglYQWwu0MkMrCFpB0AoCWRGMowRaQXAHIWgFQSsIWvHxHdAKrWBoBQEc0Aq8Z6OVoBXTXmgFQSsIWvHB5Zu3El0rRr0EiqcVvFVM7yBaQcStWNWyY8WkFheunVZia8Wgl8iCiAgbnZiV2PYamWjVzupiiVdt7H86vLNXtc3VslewRSeHrVjycqhcWgk2ohXUyJKWg9Wa0nK4WFrJajgCqVZseKEVREqpVqykLQBayW/dK87Rio/jWgGkrhUbXtJrpJXoNdUyCXNy2mml4GW9cLI4WolcRivosjF/73x+ytNvcvoho7JhrWTVRSuVrtdIfk0Dni1FKhrTSpFOaAV1Qiuok3HEFKuEViIdjWClYB20Eu+tby/FZ5dWoh0W6k+ECidB916qFEArTbttQ7XsI1ip8mZrr2Iq5na0ItF7JarP5vszfkdeqkemlZ0hevHSJCytRIfpQEzbpLSyN2CT0U6wMtIqZVdWmqXsy4rIsO0GPUrqx4vLDaxZi5gVoa17ANlctHIkgMD4HioCqQixREUgFSGWiO8ebUGc05LET6Mlh7QVkEh4eAVCZqRTSY8fpkCyU9dux9XkhFYwtBIkJ2H6db4QfUZyU45q5crZrCnXgDH0CrlAK2FQ7kjylNZ9CrlAKyGwGa+GQLODSBSWxVkrSZ4kCsvirJU0JCrL5WSNAxuZqWml+7+zPjXzKW27hFZihJ5fpHPJkmFlXHXBexHpYIqgDIRuK/8B+/IYOQ=="], > {{0, 271}, {278, 0}}, {0, > 1},ColorFunction->GrayLevel],BoxForm`ImageTag["Bit", ColorSpace -> > Automatic, Interleaving -> > None],Selectable->False],BaseStyle->"ImageGraphics",ImageSizeRaw->{278, > 271},PlotRange->{{0, 278}, {0, 271}}]\) >                  (*Input 2 ==< *)     pts0 = PrincipalComponents@N@Position[ImageData[sample], 0];     {length = pts0 // Length,      radius = EuclideanDistance[#, {0, 0}] & /@ pts0 // Mean,     center = Mean@pts0 // N // Chop,      g1 = Graphics[{Point[pts0], {Red, Thick, circleNew = Circle[center, radius]}}]     }      > >     Output result see picture ==> :)@@ >   I do not like this, I' d like the red circle overlap the black circle. ## question 2 get the cusp. * * * Thought 1: Put one locator in the cusp and drag it to along the diameter (from cusp point to center), and the `circleNew` will go to the center. Maybe need interpolation, ie something `BezierCurve` or `BSplineCurve.`. Thought 2: Go on ImageProcessing, directly make `circleNew` (smooth except the place of cusp) overlap the balck circle. Maybe here we can directly `Fit` one curve with one function?                (*Input 3 ==< *)      Pruning[Thinning[ColorNegate[Erosion[sample, 1]]]]      > >     (*Output CellExpression, You can copy to Notebook or just Skip*) > > \!\(\*GraphicsBox[TagBox[RasterBox[CompressedData["1:eJztnMtu00AYhWcQC3bs2PMo8AjlCVoJtkgFCfXtSVtTcjm2ZzyX/3Y+qRfXdnLOZ8/ISZp8fvh59+NdSunXh9O3u/s/Xx4f75++vT8tfH36/f3hedXHnNKn0xcxQH5DOokezl3Qy0LeXIxCvuJmvUQoAd76l00dZ7IczzT55peivRY1PrU0H22HWnqMAFejqOP1h5uLmREdjHsZdlztehl7qhsdSONDm9My50gam3unJrWhZfrhs3C6SERUr0UmoGYtgnOf3mlXOpb0/QM0HCsFES5RkkdJjAU1aRTNL2qCvKIijTInSYUWBRFuEM8kHgAifP7qlJJEveibUs4QyqbaSRLSotxJEkmoX8r8jNpHz8LUS10jTl6ZlNWUk1lWbDlJcwKbk8KXplYYHdqklNGpbUoZnNuqlKHJ7UoZmN2ylGHpbUuhFcyQ/NalDGlgX8qADh6kdG/hQ0rnHl6k9G1CK2NvSpp+VRxJ6VfGlZRedZxJ6VPInZQelRxKae/kUUp7K59WWms5tdLWy6uUpmZ+pTR08yzlcDvfUg728y7lWENa6bWPMeorBpBS3zGClPqWtNK+uVnqekaxUvmxQaNSaKOmaBgpNU3jSKnoGklKeVtaOb6ZF2gFUtQ3mpSyxvGsFFQOKGW/c0Qpu6VDStlrHVPKTu2gUrZ7R5VCK5it5nGtbFWnlep1vqEVCIcQZLV7ZCmr5UNLoRUIrUBW6ge3stI/uhUoILwUWoHQCgIYoBRagdAKglYQtIK4VUAptIK5cUApiVYwHEEIWkHQCoLzCoJWINcWaOWFvLEUF1pB5NWFyOSV32NDKwhaQdAKglYQtIKgFQStIGgFQSsIWkHQCoJWELSCoBUErSBoBUErCFpB0AqCVhB8jh9BKwhaQdAKgq+oImgFkTcXo0IrCFpB0AqA/wGGoBUErSBoBUErCFpB0AqCVhC0AuC7GwB8exCCVhC0AuA73xH89BUAFhBdC60gaAVBK4CV+rRS9fcY0AqCVhCr7UNroRXAendaqVvjn43ucbVsNQ9rZbN4VCvbvWnlyGqn7LYOqWW/dEAtBZXjWSlpHM5KWeFoWgr7xtJS2pZW2jb0AK0gystG0kIrgJqqcbRUNY2ipa4nrfTY3Cq0AqhuGUJLfckAWg5U9G/lUEPvWg72863laDta6bmfCY6X86yloZtfLS3NvFrJbcV8amlu5VFLh07+tHRp5E1Lpz7OtNAKoFsbV1r6lXGkpWMVP1a6NvGipXMPJ1p613ChpXsJD1YGdLCvZUgD61oG5betZVh6y1oGZrerZWhyo1oan5Dcv/2xNz+G8aENapkRefTZ2J1JeW1pmZbWkpaJWQ1pmRnVipbJk6ANLdNTWtAikFG9FplLCOVapOKp1iIXTq8W0QtwrVqEc2WNj4o0ZFIQ4RIdgXSdL4rCMAlESxgtORZUxFE0ehYUBFIQ4YYsOuvK3vs2YsHUGnlB4pBpPk3+w+e/MDOfQTYjZWJWQ06eOeQl58o5wpiUdOThUb74UXIPlXegg7pP8Xjbumw3o07SMiQKN73YreB2j2ZSQlH+q402S5s38kLem0XRyrXN7Z8ll6y2wSvyOanArVFWGpUU9ajjH+hYO65bwfWYkM6jCwohhATjL3IdCrM="], > {{0, 271}, {278, 0}}, {0, > 1},ColorFunction->GrayLevel],BoxForm`ImageTag["Bit", ColorSpace -> > Automatic, Interleaving -> > None],Selectable->False],BaseStyle->"ImageGraphics",ImageSizeRaw->{278, > 271},PlotRange->{{0, 278}, {0, 271}}]\) >   ![enter image description here](http://i.stack.imgur.com/thEyK.png)


Pick with nested list

I have a list of pairs of values. Some of those pairs are invalid based on another list. I would like to select only the valid pairs.               list1 = {"abc", "def", "ghi", "jkl", "mno"};     list2 = {{"abc", 1}, {"def", 2}, {"ghi", 3}, {"jkl", 4}, {"mno", 5}};     sel = {{2}, {}, {4}, {1}, {7}};     Pick[list1, sel, {_}]     Pick[list2, sel, {_}]      list1 is a sample of what I would like. list2 is similar to my actual case. sel is the result of `Position` where I'm checking a corresponding list against valid cases. When the result of `Position` is an empty list, I do not want the values in list1 or list2. The output from the above code is: ![enter image description here](http://i.stack.imgur.com/2hmRU.jpg) I see from the documentation that what I'm doing with list2 is not valid. My question is what is a good way to do this? I want my original list2, but without {"def",2}. Everything I can think of is pretty messy.


How to export to .html .nb file together with links «in» and «out»

If use «File > Save As > HTML» lines «in» and «out» are lost To save a document without loss of these lines/links? ![enter image description here](http://i.stack.imgur.com/RGetT.png) ![enter image description here](http://i.stack.imgur.com/1gMzf.png)


How to modify font for all text fields?

I know that one can modify the StandardForm style so that all input and output codes (and maybe other things too) follow that style. This makes it tricky to make input code different from output code (though this problem has been solved here) because the StandardForm is the overriding style for both inputs and outputs. Here I have an opposite problem with formatting texts. I want all text fields in my notebook to have the same font, and that includes the style of Title, Subtitle, Sections, Text, Item, Subitem, and so on. Of course I could set all of them to be the same font in my stylesheet, but I'm wondering if there's a style that I could change and that would apply that change to all texts. That way if I want to change the font of my texts in the future, I could just change that one style instead of changing all text styles one by one. In other words, is there any equivalence to StandardForm for text fields?


Replace matrix with conditions

I want to replace the values of 1. in `slot` under the condition that the year and month in `basevalue` and `slot` have to be matched Here are my matrices: `basevalue = {{{2012, 9}, 0.2819}, {{2012, 10}, 1.01406}, {{2012, 11}, 1.06447}, {{2012, 12}, 0.929704}, {{2013, 1}, 1.11471}, {{2013, 2}, 1.08585}}` `slot = {{{2012, 3}, 1.}, {{2012, 4}, 1.}, {{2012, 5}, 1.}, {{2012, 6}, 1.}, {{2012, 7}, 1.}, {{2012, 8}, 1.}, {{2012, 9}, 1.}, {{2012, 10}, 1.}, {{2012, 11}, 1.}, {{2012, 12}, 1.}, {{2013, 1}, 1.}, {{2013, 2}, 1.}}` I have tried the following code by my own `Map[Function[arg, ReplacePart[arg, 2 -> Select[basevalue, #[[1]] == arg[[1]] &][[All, -1]] ]], slot]` , but it returned me different from what I want. I think I still do not fully understand how to use `function` :( Any helps or suggestions would be appreciated Thank you


Partitioning a numerical integral: need to integrate spectra

I am trying to integrate a spectrum I obtained from a fourier transform infrared spectroscopy experiment, in order to determine the global warming potential of green house gases. In order to do this, I would like to integrate the spectrum that I have in chunks of 10 wave numbers (x axis is wave numbers). IE, I would like to generate a list that has the integral from 525 - 535 in the first slot, 535-545 in the next slot Here is a link to my data: https://drive.google.com/file/d/0B5gGZ4-SD7-ZZDRoNE5XMzFnYnM/edit?usp=sharing               data = Import["/home/marco/Documents/Mathematica/GlobalWarming/nitrogenforMathematicaTest.csv"]     spectraInterp = Interpolation[data, InterpolationOrder->3] (* Here we  create an interpolation function to represent our data *)               ListPlot[data]     Plot[spectraInterp[x], {x,525,1400}, PlotRange->{{525, 1400}, {0, 0.3}}]     NIntegrate[spectraInterp[x], {x,600,1400}]


Calculate the algebraic multiplicity of known eigenvalues of a large, sparse matrix

I have a large (and sparse) matrix with size 1000x1000 -- 10000x10000. I believe i know all eigenvalues for the matrices. All entries are integers and so are the eigenvalues. I want to check this by calculating the algebraic multiplicity of the eigenvalues and see if they sum up to the dimension my matrix implying I have all the eigenvalues. I know the matrices to be non-diagonalizable, which makes it non-sufficient to calculate the dimension of each corresponding nullspace. I also need to do the calculations symbolically (numerically I seem to have found them all at least within error margin). I have tried calculation the characteristic polynomial but this seems to be very slow. Once I have the characteristic polynomial checking multiplicity would have been a simple task. Anyone have any ideas? I guess the question simplifies to: How do i find the algebraic multiplicity of a known eigenvalue when the matrix is large and sparse?


ListPlot of lists with specified x coordinate

I want to do:               ListPlot[{{x1, y1}, {x2, y2}, ...}]      each y being not a number but a list of numbers. I tried:               ListPlot[{{x1, {y1}}, {x2, {y2}}, ...}]       but it does not work. Does anybody now how to do this? Thanks a lot!


How can I compile this function

I want to simplify my function `f1` to `f2`, but `f2` can't be compiled. How can I make it compilable?               f1 = Compile[{{arr, _Real, 2}},        Module[{a, b, c, d}, {a, b, c, d} = arr;         {{a, (a + b)/2, (a + c)/2, (a + d)/2}, {(a + b)/2, b, (b + c)/2, (           b + d)/2}, {(a + c)/2, (b + c)/2, c, (c + d)/2}, {(a + d)/2, (           b + d)/2, (c + d)/2, d}}         ], RuntimeAttributes -> {Listable}];          v = {{{0, 0, .6}, {-.3, -.5, -.2}, {-.3, .5, -.2}, {.6, 0, -.2}}};     n = 3;     p = Nest[f1, v, n]~Flatten~n;     Graphics3D[Tetrahedron /@ p]               f2 = Compile[{{arr, _Real, 2}},        Module[{a, b, c, d}, {a, b, c, d} = arr;         With[{t = Evaluate@Map[Mean, Partition[Tuples[{a, b, c, d}, 2], 4], {2}]},          t          ]         ], RuntimeAttributes -> {Listable}];      ![enter image description here](http://i.stack.imgur.com/w2mH7.png)


Simplify system functions

Consider the code defining two constants:               a=Cos[t]     b=Sin[t]      Suppose that we have another value in terms of `Cos[t]` and `Sin[t]`, for example,               c=2*Cos[t]+Sin[t]^2      How to show the result of `c` in terms of `a` and `b`, that is, instead of the line above I'd like my computations being showed as               c=2*a+b^2      In other words, how to ask Mathematica to recognize `Cos[t]` as `a`?


Options which require RuleDelayed

For some functions in _Mathematica_ it is important to use `RuleDelayed`. One prominent example is the `EvaluationMonitor` for functions like `NMinimize`               NMinimize[x^4 - 3 x^2 - x, x, EvaluationMonitor :> Print[x]]      Here it is inevitable to use `RuleDelayed` because otherwise `Print[x]` would be evaluated too soon. **Question:** Is there a comprehensive list of options which require `RuleDelayed`? Btw, the reason why I need this list is to support this correctly in the IntelliJ Plugin for Mathematica: ![enter image description here](http://i.stack.imgur.com/zJ1rv.gif)


Having used Mathematica as a "gateway" language, where to from here?

I have been using _Mathematica_ for about a year. It is the first language that I have attempted to learn. I'm still very much a newbie, but there are moments I feel more like I am waving than drowning. As with many addictions, at first it left an unpleasant taste, but with time, using _Mathematica_ started to open up new possibilities and I have come to depend on it. It has occurred to me that there are a number of reasons why at some stage I would like to learn some new language(s) to complement _Mathematica_ and further nurture my 'coding brain'. At times I feel slightly handicapped by not really understanding the capabilities/pitfalls of, for example, `Do` loops and other constructs that seem common in many languages. Indeed, it would be nice to be able to understand/relate to programmers that don't use _Mathematica_. Although a lot of coding paradigms can be used in _Mathematica_ , I feel it would be instructive to spend some time learning strictly procedural, object- oriented, etc. programming styles in the context of another language. Which other programming languages should a _Mathematica_ -only user be interested in, so as to appreciate the underlying programming principles and constructs that one takes for granted with _Mathematica_? Alternatively, I understand that there are a number of languages that can be implemented or interfaced from within _Mathematica_. Would it be a worthwhile trying to learn other languages/coding styles without leaving the notebook environment?


Is it possible to Import urls not type ""

These days I often copy urls from Internet Explorer's address bar. When I paste the url into a Mathematica cell it is neither a string nor a expression. Import@http://mathematica.stackexchange.com/search?q=load+file I always manually add " " to get                Import@"http://mathematica.stackexchange.com/search?q=load+file"      Another method is to use `InputString[]` sometimes, I don't like the pop-up dialog. Is there any more lazy way to make               Import@http://mathematica.stackexchange.com/search?q=load+file      successful, maybe by using a button, or InputField, or other setting, or some styled-cell?


How can I shade specific regions between two curves in a Plot?

From               Plot[{       ((0.707106 Sqrt[1 - 1.5 s13^2] + 0.5 s13)^2)/(1 - s13^2),        ((0.707106 Sqrt[1 - 1.5 s13^2] - 0.5 s13)^2)/(1 - s13^2)},        {s13, 0.0, 0.23},       PlotRange -> {{0.0, 0.23}, {0.35, 0.67}}, Frame -> True,       FrameLabel -> {FrameLabel -> {sin13, sin223}},       PlotStyle -> {{Gray, Thick}, {Brown,Thick}},       LabelStyle -> Directive[Black, Bold], Filling -> True,       FillingStyle -> Directive[Opacity[.19], Green]     ]      I obtained this ![enter image description here](http://i.stack.imgur.com/Bna4b.gif) * * * But I want to shade definite regions of the axes with different colors. Like ![\(\)](http://i.stack.imgur.com/Tf3cc.png) sorry for poor quality of the 2nd picture


notebooks not opening in mathematica 10

I`m a guest here, and thought I could just ask you guys. `I've tried filling in mathematica's support form on their website, but all I got was an e-mail telling me to use their support form!` \- and I'm not phoning them! - I live in Scotland! My problem is that I have downloaded mathematica 10 upgrade, and have opened new notebooks, closed them, and when I try to open them again, a message comes up with something about the book having potentially damaging "dynamic content" - which it doesn`t! - tried it with just saving a notebook with a simple quadratic equation in it! If I press the "enable dynamic content - nothing happens, and I have to create blank documents in mathematica 8 that will successfully open in version 10. What can I do about this myself, if anything? * * * I've given up using it and I'm just using my laptop with mathematica 9 the exact message is: " this notebook contains potentially harmfull dynamic content. Do you still wish to open?"


Constraint in a 2D plot with Legend

I have the following plot:               Plot[Table[C*r^2 + 2 C, {C, {25, 100, 150, 300}}] // Evaluate,          {r, 0, 1000},           PlotLegends ->LineLegend[{25, 100, 150, 300}, LegendLabel -> C,                  LabelStyle -> {GrayLevel[0.2], Bold, 10}, LegendFunction -> "Frame"],           AxesLabel -> {r, Plot},           PlotLabel -> "Plot"]      But I need to include a constraint: `r >= C.` So when `C` is `300`, the plot should show only for `r = 300` to `r = 1000`. How should I modify this code?


Numerically Integrating to find a Maximum using NDSolve

I am trying to numerically find an equilibrium (maximum) of a function using its differential. The following is a simplified version.               myEquilibrium[p_]:=Last[{myPreviousStep=1;NDSolve[{s'[t]==p-s[t],s[0]==myPreviousStep,WhenEvent[s[t]-myPreviousStep<10^-4||s[t]<10^-4,"StopIntegration"]},{s},{t,0,Infinity},StepMonitor:>(myPreviousStep=s[t])];myPreviousStep}]      myEquilibrium[.5] // 0.5 which is correct The function should be constrained to positive s, which is why I included the `s[t]<10^-4` requirement. However this does not seem to work. myEquilibrium[-.5] // -0.5 but should be 10^-4 The NDSolve should also not go to `0` exactly, as the real, non-simplified version contains a `1/s[t]` in the differential. That's another reason I want the procedure to stop at `s[t]=10^-4`, before `s[t]=0`. myEquilibrium[0] // 0. but should be 10^-4 Finally, I often get `NDSolve::mxst: Maximum number of 10000 steps reached at the point t == 6.57563031118913721074693815431*^4952. >>` and `NDSolve::ndsz: At t == 1.79769313486*^308, step size is effectively zero; singularity or stiff system suspected. >>`. What would typically solve this issue? Thanks.


AssociationMap to query Dataset across levels?

Is there a way to operate on Dataset across levels to apply a function `f` to a `key -> value` pair in an Association as follows:               pivotApply[f_, key_ -> value_] :=  key -> f[key, value]      For example, take the Titanic dataset and pivot up "class":               titanicClass = titanic[GroupBy[Key@"class"], KeyDrop[Key@"class"]];      For this problem, assume only titanicClass. `"class"` key has been deleted and so can't referenced. The motivation is tree-structured data where it would be inefficient to insert the keys `{"1st"...}` at the deeper level. Here `foo` represents a "client" function to be applied to deeper level data but depenent on class values. **EDIT // #age >= 18 &**               foo["1st", data_] := Dataset[data][All, #age >= 18 &];     foo["2nd", data_] := Dataset[data][All, "sex"];     foo["3rd", data_] := Dataset[data][All, "survived"];      Is there a way to avoid inefficient downcasting to Normal and back to Dataset to use AssociationMap? Also note there are Datasets nested in a larger one, which should also be cast to Lists (since there is an outer Dataset).               AssociationMap[pivotApply[foo, #] &, titanicClass // Normal] // Dataset      ![enter image description here](http://i.stack.imgur.com/L4Rik.jpg) Is there a way to query Datasets across levels like this? This seems extremely roundabout, but haven't figured an implementation using, say Keys and Values and related Dataset operators.


Finding Symmetries of Points on a Sphere

Currently, I am working on a project where I would like to find symmetries of points plotted on a sphere. One example would be to rotate the sphere 180 degrees about the x-axis and the picture would look the same. I am looking through many different formations of points and am wondering whether or not there is a way to speed it up and to increase the accuracy. Is there a function to find rotational symmetries about different axes (as they are not limited to x,y, and z)? If relevant, my points are currently in cartesian form, but I also have them available as spherical coordinates. Thanks! -Chase


A few specific questions on a number of plots in a do loop

I have created the picture displayed below, with the following line of code:               Colors = List[Brown, Red, Orange, Yellow, Green, Blue, Pink, Purple, Black];         Show[Table[            Plot[Part[list, i, 2]*Prob[Part[list, i, 2]*n] /. {y -> a,               z -> Part[list, i, 3]}, {n, 0, 3},             PlotStyle -> {Thick, Part[Colors, i]}], {i, Length[list]}],           PlotRange -> {All, {0, 1.2}}]      The array list just contains sum numbers of the form { {a,b,c}, {c,d,e}, ...} and Prob is just some function, with constants y and z which I specify in the above. There are a few questions I have concerning this code: -Note that the axis of the graph appears to lie above zero. I would like to make a graph with its x axis really at y=0. How to do this? -I would like to give every graph in the picture a different label, which is stored in Part[list, i,2]. However, I have two problems: PlotLegends gives an error and I only know how to include text between " ", not a number which is determined by the running of the do loop.  Any help is very much appreciated! ![enter image description here](http://i.stack.imgur.com/iInR3.png)


Recursive function with if-statement

I am trying to represent the following function definition in Mathematica: $$\begin{align*} f(1)&=1 \\\ f(2n)&= \begin{cases}f(n) & \text{if}\space n\equiv0\pmod{2} \\\ 2f(n) & \text{if}\space n\equiv1\pmod{2}\end{cases} \\\ f(2n+1)&=\begin{cases}2f(n)+1 & \text{if}\space n\equiv0\pmod{2} \\\ f(n) & \text{if}\space n\equiv1\pmod{2}\end{cases} \end{align*}$$ I have tried both the following definitions, but both of them return `f[2011]` as their output when I input `f[2011]` into the kernel. Using _if-statements_ :               f[1] := 1     f[2 n_] := If[Mod[n, 2] == 0, f[n], 2 f[n]]     f[2 n_ + 1] := If[Mod[n, 2] == 0, 2 f[n] + 1, f[n]]      And using _switch-statements_ :               f[1] := 1     f[2 n_] := Switch[Mod[n, 2], 0, Evaluate[f[n]], 1, 2 Evaluate[f[n]]]     f[2 n_ + 1] := Switch[Mod[n, 2], 0, 2 Evaluate[f[n]] + 1, 1, Evaluate[f[n]]]      Neither of these definitions seem to give me what I'm after, so I'd appreciate any help.


ParallelTable running on outermost index only

I need to run a simple `ParallelTable`:               ParallelTable[       {tab1[[i1]], tab2[[i2]], tab3[[i3]], tab4[[i4]],        fun[tab1[[i1]],tab2[[i2]],tab3[[i3]],tab4[[i4]]]       },        {i1, 1, n1}, {i2, 1, n2}, {i3, 1,n3}, {i4, 1, n4}     ]      The computation, however, is parallelized only on the outermost index `i1` and not on all of them. The problem is that I have more cores than `n1` and so I'm not computing this table as fast as I had hoped. Is there a simple way to run on as many cores as possible without having to rewrite the table in a flattened version?


Can not Import PDF

I try to import PDF and extract text from it               Import["D:\\Vegetarian MS.pdf", {"PDF", "Plaintext"}]      but with some files I have a problem like this               Import::general: Unimplemented operator ' encountered >>          Import::general: Could not draw page 1 stream 0 >>          Import::general: Could not draw page 1 >>      How can I solve this? Thank you link to file http://dl.dropbox.com/u/15137276/Vegetarian%20MS.pdf