Merging (combining) tables of graph relationships (2-mode to 1-mode network)

I have some data of corporate board members in Australia in excel format here (Dropbox public link). It is the data behind this graph. The first worksheet is of all the vertexes (directors and companies with a unique ID for each, and a market capitalisation to use for weighting the size of vertexes in displayed graphs). The second worksheet is the relationship between companies and directors (edges). The edges table looks a bit like this               {{"Source", "Target"}, {"BHP BILLITON",        "Mr Alberto Calderon"}, {"BHP BILLITON",        "Mr Andrew Mackenzie"}, {"BHP BILLITON",        "Mr Brendan Harris"}, {"BHP BILLITON",        "Mr Carlos Cordeiro"}, {"BHP BILLITON",        "Ms Carolyn Hewson"}, {"BHP BILLITON",        "Mr David Crawford, AO"}, {"BHP BILLITON",        "Mr Graham Kerr"}, {"BHP BILLITON",        "Mr Jac Nasser, AO"}, {"BHP BILLITON",        "Dr John Buchanan"}, {"BHP BILLITON",        "Dr John Schubert, AO"}, {"BHP BILLITON",        "Ms Karen Wood"}, {"BHP BILLITON",        "Mr Keith Rumble"}, {"BHP BILLITON", "Mr Lindsay Maxsted"}...       What I ultimately want is a graph of that eliminates the companies, with undirected edges between only directors who are on boards together.                   ASXdata =            Import["https://dl.dropbox.com/u/3997716/ASXdata.xls"];         ASXvertexes = Take[ASXdata[[2]]];         ASXedges = Take[ASXdata[[1]]];     graphFunc = Function[{u, v}, v \[UndirectedEdge] u];     twoMode = graphFunc @@@ ASXvertexes;     twoModeGraph = Graph[twoMode, ImageSize -> 500]      The above code gets me the below 2-mode graph (includes company and director vertexes). ![enter image description here](http://i.stack.imgur.com/tZjm2.png) Somehow I want a function that assigns all the possible undirected edges between the directors that have the same company in the first column. I should then see a graph that looks a bit like the below snippet (my previous function can turn it into an undirected graph).               {{Mr ALberto Calderon,Mr Andrew Mackenzie},{Mr Alberto Calderon, Mr Brendan Harris}...      Obviously the graph will be much bigger because of all the extra edges required - eg. for the 21 directors in BHP there will now be 210 edges between them, instead of the previous 21 between the company and each director. Ideally I could also create a network for just companies, with edges where they share a common board member. I literally have no idea how to even start, but assume I could apply whatever function someone can come up with to the columns in reverse for this.               {{BHP BILLITON, ASCIANO},{ANZ,TELSTRA}...      I guess the other main question, since I intend to be doing this sort of stuff quite a bit, is whether I first map the unique numerical vertex IDs from the first worksheet in the spreadsheet before doing these type of operations and before working with the resulting graph (measuring centrality, components, clusters, paths etc). **UPDATE** I have been able to divide the edges list by company. I figured that I would take the director name list for each company that comes from this, them make a complete graph of each, then combine them. However CompleteGraph doesn't seem to like the list input                  ASXvertexes = Take[ASXdata[[1]]];     ASXedges = Take[ASXdata[[2]]];     tASXedges = Transpose[ASXedges];     graphFunc = Function[{u, v}, v \[UndirectedEdge] u];     twoMode = graphFunc @@@ ASXedges;     twoModeGraph = Graph[twoMode, ImageSize -> 500];     compnames = Union[Transpose[ASXedges][[1]]];     directornames = Union[Transpose[ASXedges][[2]]];          t = Split[Rest@tASXedges[[1, All]]];          match = Table[       Cases[ASXedges, {n_, __} /; n == compnames[[b]]], {b, 1,         Length[compnames]}]     c1 = Flatten[Take[Flatten[Take[match, 1], 1], All, -1]]     CompleteGraph[c1]      Which gives as output               CompleteGraph[{"Mr Bill Bartlett", "Mr Rod De Aboitiz",        "Mr Malcolm G Irving", "Mr John M Thame", "Dr Frank M Wolf",        "Mr David Bastian", "Mr Ellis Varejes", "Mrs Myra Salkinder",        "Mr Neil Summerfield"}]      **UPDATE 2** With a bit of help from @kguler I can assign unique IDs to the names, and do a bit of sorting. But for some reason the Graph function won't accept what I give it (it looks like a reasonably constructed graph to me). I get the error message "Graph::supp : Mixed graphs and multi graphs are not supported>>" I've had this problem before, but I though the filtering of Union, DeleteCases etc would have done it. Here's the current code               ASXdata =        Import["https://dl.dropbox.com/u/3997716/ASXdata.xls"];     ASXvertexes = Take[ASXdata[[1]]];     ASXedges = Drop[Take[ASXdata[[2]]], 1];     graphFunc = Function[{u, v}, v \[UndirectedEdge] u];     compnames = Union[Transpose[ASXedges][[1]]];     directornames = Union[Transpose[ASXedges][[2]]];     edges = ArrayComponents[ASXedges];     blist = Flatten[Take[edges, All, 1]];          match = Table[Cases[edges, {n_, __} /; n == b], {b, blist}];     directorgroups =        Union[Table[Part[match, i, All, 2], {i, 1, Length[match]}]];          example =      Sort[       Flatten[        Table[         DeleteCases[          Union[           Tuples[directorgroups[[i]]            , 2],           SameTest -> (First[#1] == Last[#2] &)]          , _List?(Equal @@ # &)]         , {i, 1, Length[directorgroups]}]        , 1]       ]          testdirectorgraph = graphFunc @@@ example;     Graph[testdirectorgraph]      Many thanks again.


RSolve fails on a two-equation non-linear system

I have a system of just two recurrence equations, I need to solve them and so I use `RSolve`:               RSolve[{H[n + 1] == (1 + (7 h[n])/10) H[n],              h[n + 1] == 1 - (1 + (7 h[n])/10) H[n]},             {H[n], h[n]}, n]       But this just returns my code, without any errors: > >     RSolve[{H[1 + n] == (1 + (7 h[n])/10) H[n], >             h[1 + n] == 1 - (1 + (7 h[n])/10) H[n]}, >            {H[n], h[n]}, n] >   Where am I going wrong? Why am I not even seeing any errors? Additional Info:   * I am modelling the frequency of two variants, H and h, through discrete time (n)   * Total frequency in the population: h + H = 1   * The two variant's frequencies depend on each other as you can see in the above code


Substituting a function in the output

I have to calculate the derivatives of the function `K` defined in the code:               << VectorAnalysis`     K = δ[t]*Exp[-(r/L)]/r;     SetCoordinates[Cartesian[x, y, z]];          r = Sqrt[(x - x0)^2 + (y - y0)^2 + (z - z0)^2];     Hes = D[K, {{x, y, z}, 2}];     der = Grad[K];     FullSimplify[der[[1]]]     FullSimplify[Hes[[1, 2]]]     FullSimplify[Hes[[1, 1]]]      This is part the output just for `FullSimplify[der[[1]]]`: > >     -((E^(-(Sqrt[(x - x0)^2 + (y - y0)^2 + (z - z0)^2]/ L)) (x - x0) (L + >         Sqrt[(x - x0)^2 + (y - y0)^2 + (z - z0)^2]) δ[t])/( L ((x - x0)^2 + > (y - y0)^2 + >       (z - z0)^2)^(3/2))) >   I would like the function `K` to appear in the result instead of that "mess": is it possible to do it?


Is it possible for me to explicitly specify a point list for SpatialGraphDistribution?

The function `RandomGraph[SpatialGraphDistribution[n, r]]` generates a random geometric graph over $[0,1]^2$ where vertices are connected if they are within a distance $r$ of one-another. How would I explicitly specify a list of points for generating a random geometric graph using this function? Specifically, I need to enforce a minimum threshold distance between points. Clarification: My point list is going to come from a Random Sequential Adsorption (RSA) simulation of circles on a plane. So I mean that no two points should be closer than some minimum threshold distance set by the radius of the circles being deposited, not that two points shouldn't share an edge if they are closer than the threshold distance.


Reducing mesh details while exporting to vector format SVG

I am trying to export a simple cuboid into .SVG format. In the output file, the cuboid is finely meshed, which increases the file size. How to remove this detailed mesh?                Export[FileNameJoin[{NotebookDirectory[], "trial.svg"}], Graphics3D[Cuboid[]]]      ![enter image description here](http://i.stack.imgur.com/UHBws.png)


Evaluate integral of a series

I want to evaluate this integral, but it won't work. Does anyone knows why?               Remove["Global`*"]          dm = (M/(2 π a)) a ;          i[ϵ_] = 1/(a Sqrt[1 - 2 (ϵ) Cos[θ] + (ϵ)^2]);     i1[ϵ_] = Series[i[ϵ], {ϵ, 0, 1}];     invertdist[r_] = i1[a/r];          ϕ[r_] = -Integrate[G dm invertdist[r], {θ, 0, 2  π}]


SplicedDistribution - different definition across Mathematica 9?

I am having troubles with my notebook. I succesfully defined Asymmetric Laplace Distribution at school using `SplicedDistribution` function, and _Mathematica_ was able to compute (about 30sec) `Mean`, `Variance`, `Skewness` and `Kurtosis`.   Now, I am at home and _Mathematica_ can compute only `Mean`?! I am running _Mathematica 9.0.1.0 Student Edition_. Where is the problem during switching machines? I can make upload of notebook if needed. ![SplicedDistribution problem](http://i.stack.imgur.com/BHUqR.png)               AsymmetricLaplaceDistribution[ θ_, τ_, κ_] =        SplicedDistribution[{ κ, 1/κ},{ -∞, θ, ∞},{ LaplaceDistribution[ θ, τ κ],                                                   LaplaceDistribution[ θ, τ/κ]}];      and then               ALD = AsymmetricLaplaceDistribution[ θ, τ, κ];      and after               { Mean[ALD], Variance[ALD], Skewness[ALD], Kurtosis[ALD]}      yields (but only @ school computers? why?)               { θ + τ/κ - κ τ, ((1 + κ^4) τ^2)/κ^2,       -(( 2 (-1 + κ^6) τ^3)/(κ^3 (((1 + κ^4) τ^2)/κ^2)^(3/2))),       (9 + 6 κ^4 + 9 κ^8)/(1 + κ^4)^2}      **Edit** : I just find `Moment[ dist, r]` works fine up to `r = 10` what I tested. But still, `Variance` does not.


How to distribute PermutationProduct over the sum

Assuming I have two elements of the permutation group algebra $a_1$, $a_2$ such that $a_i=\sum_{p\in S_n}\alpha_pp$, I want to define a linear product $\odot$ that distributes over the sum and pulls out scalars: $a_1\odot a_2=\sum_{p\in S_n}\sum_{q\in S_n}\alpha_p\alpha_qp\odot q$, where $p\odot q\equiv PermutationProduct[p,q]$. If I try for example               Distribute[PermutationProduct[Cycles[{{}}] + Cycles[{{1, 2}}], Cycles[{{}}] - Cycles[{{1, 2}}]]}      The result is               Cycles[{}] +PermutationProduct[Cycles[{{1, 2}}],(-Cycles[{{1, 2}}])]      but I'm not sure how to make it take "constants" outside the product.


Inconsistent behavior of Assuming[] in combination with Simplify[]

The following integral gives the correct result               Assuming[{n, m} \[Element] Integers,      Integrate[     2/W Sin[(n Pi z)/W] D[Sin[(m Pi z)/W], {z}], {z, 0, W}] //      Simplify]          (2 (-1+(-1)^(m+n)) m n)/((m^2-n^2) W)      However, the following expression returns `0`, which is, i.g., wrong (for `m=n=1` this should give `1`)               Assuming[{n, m} \[Element] Integers,      Integrate[2/W Sin[(n Pi z)/W] D[Sin[(m Pi z)/W], {z, 0}], {z, 0, W}]//     Simplify]      Edit: To make the disaster clearer:               Assuming[{m, n} \[Element] Integers,      Integrate[2 Sin[n \[Pi] z] Sin[m \[Pi] z], {z, 0, 1}]//Simplify]      returns 0!


Conjugating symbolic expression

I am trying to conjugate a symbolic expression, and I have explicitly stated the real terms. However, I simply can't get it to work:               Conjugate[      ComplexExpand[       I Cos[z] Sin[y] + Sin[z] +         A (Cos[z] - I Sin[y] Sin[z]), {z \[Element] Reals,         A \[Element] Reals, y \[Element] Reals}]]      What am I doing wrong here?


Importing RSS to Notebook: How to get images instead of long ugly links?

This question on importing news headlines via a RSS feed reminded me of an old question I've been meaning to ask. Past attempts at finding a use for Mathematica's RSS to Notebook capabilities were frustrated by the fact that images within a given post always get parsed as a long ugly link to the image, rather than importing the image itself. Consider the following blog:               NotebookPut[Import["http://gregmankiw.blogspot.com/feeds/posts/default?alt=rss", "RSS"]];      Scrolling down to one of the posts containing an simple image (along with a tiny snipped of text that correctly hyperlinks to a WSJ article), one often sees something like: ![enter image description here](http://i.stack.imgur.com/6o3ce.png) **Request 1:** Instead of the messy html text---that is a working hyperlink to the actual image---I'd rather see an actual image. Many posts also contain embedded video clips for sites like YouTube, etc. Instead of seeing an messy link, as in: ![enter image description here](http://i.stack.imgur.com/aL2W3.png) **Request 2:** Can you instead display a static video image (and make that image a hyperlink to the actual YouTube video---and feel free to strip out the tracking crap...)? I realize this may require some knowledge of how YouTube embedded links actually work. Dunno if it's easy, or even possible, to request a static 'placeholder' image from YouTube.


Differentiating space curves

I'm trying to do some very basic differential geometry of space curves. For example, a space curve $\gamma:\mathbb R\to\mathbb R^3$ has unit tangent and normal vectors given by $$t(s)=\frac{\gamma'(s)}{\lVert\gamma'(s)\rVert},\\\ n(s)=\frac{t'(s)}{\lVert t'(s)\rVert}.$$ I want to define functions that would compute the tangent and normal vectors of an arbitrary curve at any $s$. I tried it in a higher-order functional style, like in say Haskell:               norm[x_] := Sqrt[x.x]     tangent[γ_] := Function[s, γ'[s]/norm[γ'[s]]]     normal[γ_] := Function[s, tangent[γ]'[s]/norm[tangent[γ]'[s]]]      (I need to define my own `norm` because Mathematica doesn't like to differentiate `Norm`.) Unfortunately, this doesn't work. Let `γ[s_] := {Cos[s], Sin[s], 0}` be our test curve, a circle. Then `normal[γ][1] // N` does not return a vector, but instead a bizarre expression involving the dot product of `1.` and a vector. I have no idea how to begin figuring out what's going on. I can do it in a less elegant way as               tangent[γ_, s_] := γ'[s]/norm[γ'[s]]     normal[γ_, s_] := D[tangent[γ, ss], ss]/norm[D[tangent[γ, ss], ss]] /. ss -> s      but this requires the use of a dummy variable and the not-so-pretty `D[tangent[γ, ss], ss]` construction. Why does my original implementation not work, and is there a simple way to fix it?


Faster way to compute the distance from a point to a surface in 3D

I am trying to compute the shortest distance between a point and a triangle in 3D               distance[point_, {p1_, p2_, p3_}] := Module[{p, s, t, sol},       p = s*p1 + (1 - s)*(t*p2 + (1 - t)*p3);       MinValue[{(point - p).(point - p),        0 <= s <= 1, 0 <= t <= 1}, {s, t}]];      but it seems to be quite slow, is there any way to make it faster?


Numerically solving a PDE with dependance on a fixed grid point

I am trying to solve partial differential equations of the type $y^{(1,0)}(t,x) = f(y^{(0,1)}(t,x), y(t,x_0))$ where $x_0$ is a fixed point. For example, when pluging this into Mathematica :               NDSolve[{D[y[t, x], t] == D[y[t, x], x] + y[t, 1], y[0, x] == Cos[x]}, y, {x, 0, 2}, {t, 0, 2}]      I get the error message               NDSolve::delpde: Delay partial differential equations are not currently supported by NDSolve. >>      The problem is cured by replacing `y[t, 1]` by `y[t, x] DiscreteDelta[x-1]` ; however I do not find this trick very elegant. Do you know of a better way to circumvent this problem?


Why is my compiled function slower than a regular function?

I have the following functions:               Block[{n, diag},      snake`diag[n_] = Ceiling[1/2 (-1 + Sqrt[1 + 8 n])];      snake`alongdiag[n_, diag_] = {0, diag + 1} + (n - diag (diag - 1)/2) {1, -1};      snake[n_] = snake`alongdiag[n, snake`diag[n]];]     (*A003986 on OEIS, http://oeis.org/A003986*)     A003986[n_] := BitOr @@ (snake[n] - {1, 1})     A003986c =       Compile[{{n, _Integer}}, A003986[n], CompilationTarget -> "C",        RuntimeAttributes -> {Listable}, RuntimeOptions -> "Speed"]      The functions seem very "compilable" in that they're just numerical computations. However, the compiled function performs as badly or worse:               Table[{x, A003986 /@ Range@(10^x); // Timing // First,           A003986c[Range@(10^x)]; // Timing // First}, {x, 5}]~       Prepend~{"Func", "ME", "Comp"} // TableForm      ![enter image description here](http://i.stack.imgur.com/MmQLV.png) Fine - perhaps the function does "too little" and the overhead from running the C code is costing too much. But then altering my code to fix that doesn't help things:               A003986l =        Compile[{{n, _Integer}}, A003986 /@ Range[n],          CompilationTarget -> "C", RuntimeOptions -> "Speed"];     Table[{x, A003986 /@ Range@(10^x); // Timing // First,           A003986l[(10^x)]; // Timing // First}, {x, 5}]~       Prepend~{"Func", "ME", "Comp"} // TableForm      ![enter image description here](http://i.stack.imgur.com/iaKNG.png) Both functions are approximately linear, so everything seems to be working as expected in an algorithmic regard, but this is very slow for a couple of formulas and `BitOr`! What is going wrong?


Visualizing vectors

How to visualize a set of vectors with 3 coordinates $(x,y,z)$, e.g.,$(1,1,1), (1,-1,-1),(-1,1,-1),(-1,-1,1)$? In fact there are many of them. I try the function "Graphic3D" with the following code               Graphics3D[{Arrow[{{0, 0, 0}, {1, 1, 1}}], Arrow[{{0, 0, 0}, {1, -1, -1}}]},      {Arrow[{{0, 0, 0}, {-1, 1, -1}}], Arrow[{{0, 0, 0}, {1, -1, -1}}]},     Axes -> True, Boxed -> True]      However, it seems it can only give me the first two vectors in the plot. How can I visualize all of them at the same time? And is there any other way to visualize them? ![enter image description here](http://i.stack.imgur.com/L0Bb1.jpg)


Symbolic Definite Integration

How do I perform               Integrate[Sin[x]^2/(z^2 + R^2 - 2 zRCos[x])^(3/2), {x, 0, Pi}]      where `z` and `R` are constants. I would like if possible the result in terms of `z` and `R`.


Parallelize[Mapindexed[]], level={-1}? Sal Mangano's 《Cookbook》

It is easy to **Parallelize[]** Map[] & MapIndexed[], as having been shown in MMA9 Help for ParallelMap[] and Parallelize[]. For MapIndexed[], the default **levelspec** is {1}. However there are many cases when we need mapping to deeper levels such as {-1}, for example with image data (2D array). I have tried Parallelize[] and found it FAILED and switched to **sequential evaluation** whenever **levelspec** is explicitly specified, actually even when **levelspec={1}** ! ![enter image description here](http://i.stack.imgur.com/qlBlE.png) In page 652 of Sal Mangano's _Mathematica Cookbook_, he seems to have written functions which   1. use Parallelize[] on MapIndexed[]   2. able to specify **levelSpec** ![enter image description here](http://i.stack.imgur.com/LIkHH.png) I don't know how he achieved that, and his example was not detailed enough to see the intended effect. I actually suspect that: with the default levelspec={1}, Parallelize[] could conveniently distribute the elements on the first level of the list across different kernels (like **breadth-first search** on level 1, using a **queue** in C); however if we need to go deeper with MapIndexed[]'s **depth-first** (see help) search, then the parallel implementation would be very difficult. So is it true that **Parallelize[Mapindexed[]]** only works with default/implicit levelSpec={1}, not others? Is Mr. Sal Mangano on this forum? Could he also comment?


Wrapping a data selection in Mathematica

I was wondering what would be the most efficient way to add brackets to given elements in my data set in order to change it's form from {{a,b},{c,d}} to {{{a},b},{{c},d}}. I took a look through a few questions within the exchange database but couldn't find an answer which would output data in that form. I found an example for strings here, however,the output is a string which I can't manipulate as data (if that makes any sense). My example data is as follows:               List = {{0.343051, 48.3831}, {0.331855, 81.4873}, {0.323979, 101.01}, {0.317126, 108.65}, {0.310429, 106.103}, {0.303265, 95.0686}, {0.294876, 77.2432}, {0.283812, 54.3249}, {0.265673, 28.0113}, {0., 0.00176955}, {-0.265673, 28.0113}, {-0.283812, 54.3249}, {-0.294876, 77.2433}, {-0.303265, 95.0686}, {-0.310429, 106.103}, {-0.317126, 108.65}, {-0.323979, 101.01}, {-0.331855, 81.4882}, {-0.343051, 48.3836}}      (I'm not looking for it to be done for a specific dataset of just this size, but rather for the more general case initially suggested) My current method looks a bit like this:               Transpose@{Partition[List[[All,1]],1],List[[All,2]]}      where I separate the list into two and use partition to wrap all the first elements of list in a set of brackets and then transpose. As the list size increases the timing becomes a bit too nonsensical. Could someone suggest a faster method please or possibly direct me to the answer? Thanks in advance


Minimize failing on a polynomial

Calling:               Minimize[{-0.4877 - 0.1190 r^2 - 0.1885 r^4 + 2.9703 z - 0.5531 z^2,               0 <= z <= 3.5 ∧ 0 <= r <= 1.75}, {r, z}]      returns `{1.00051, {r -> 1.75, z -> 3.5}}`, when it's obvious that simply setting `r` and `z` to `0` yields `-0.4877`. Is this an issue of numerical instability? Is there anything that can be done about it?


Fast Spherical Linear Interpolation of list of quaternions

An accurate way to interpolate between two quaternions is to use Spherical Linear Interpolation (Slerp) because it preserves the unit length, whereas straightforward linear interpolation does not, as shown by this example:               Clear[slerp];     slerp[q1_, q2_, f_] := Module[{omega},       omega = ArcCos[Dot[Normalize@q1, Normalize@q2]]];       If[PossibleZeroQ[omega],          q1,         (Sin[(1 - f) omega] q1 + Sin[f omega] q2)/Sin[omega]       ]     ]          q1 = {1,0,0,0};     q2 = {0,1,0,0};     q3 = {0,0,1,0};          (* Linear interpolation using Interpolation *)     qint = Interpolation[{{0,q1},{1,q2}},InterpolationOrder->1];          Plot[{Norm@qint[t], Norm@slerp[{1, 0, 0, 0}, {0, 1, 0, 0}, t]}, {t, 0, 1},        AxesLabel -> {"time", "length"}, PlotRange -> {0.7, 1.01},        PlotStyle -> {Automatic, Dashed},        Epilog -> {Text["Linear Interpolation", {0.5, 0.75}],        Text["Spherical Linear Interpolation", {0.5, 0.98}]}     ]      ![Mathematica graphics](http://i.stack.imgur.com/SkKgL.png) What's nice thing about `Interpolation`, however, is that it is easy to give it a list of vectors to get an interpolating function valid over the specified range, and it works fast:               Interpolation[{{0,q1},{1,q2},{2,q3}},InterpolationOrder->1]      > InterpolatingFunction[{{0,2}},<>] How can I create something like an `InterpolatingFunction` that preserves the unit-length property? This is what I came up with, but it seems kludgy and it is very slow (this code does not check input bounds):               Clear[slerpInterpolation];      slerpInterpolation[q_List] := Function[{t},        Module[{times, quaternions, pos, u, dt},         times = q[[All, 1]];         quaternions = q[[All, 2]];         pos = Last@Flatten@Position[t - times, x_ /; x >= 0];         dt = times[[pos + 1]] - times[[pos]];         u = (t - times[[pos]])/dt;         slerp[quaternions[[pos]], quaternions[[pos + 1]], u]       ]     ]      It is too slow in practice, giving about 10 evaluations per second on my laptop. Compare that with regular interpolation:               qlist = Transpose[{Range[100000] - 1, Normalize /@ RandomReal[{-1, 1}, {100000, 4}]}];     sint = slerpInterpolation[qlist];     lint = Interpolation[qlist, InterpolationOrder -> 1];          AbsoluteTiming[Do[sint[541.236], {10}]][[1]]/10      > 0.0967707               AbsoluteTiming[Do[lint[541.236], {10000}]][[1]]/10000      > 7.2522*10^-6


How to write a UTF-8 file?

s = OpenWrite[ofile, CharacterEncoding -> "UTF8"]     Export[s, "∂f/∂t"]     Close[s]      did not successfully write `∂` into the file. Instead, it writes the `InputForm`. How to let it write `∂`?


FindRoot inside Table

**(MWE at the end of the post)** I need to solve a non-linear equation $f(y;x_1,x_2,..,x_5)$ in one variable $y$ and then compute 4 new output expressions, for over 60 different initial parameter inputs of $x_i$. The 4 output variables which are as follows: $g_m(y,x_1,..,x_5) \; \forall m$ The main equation will solve for the variable $y(i)$: $f(y(i),x_1(i),x_2(i),...,x_5(i))=0 \; \forall \; i \in \\{1,60\\}$ Now my $f(y(i),x_1(i),x_2(i),...,x_5(i))=A1(y,x_1,..,x_5)*y^{k_1} + B1(y,x_1,..,x_5)*y^{k_2}-c1(x_1,..,x_5)$ I define variables               A1=A1(y,x1,..,x5);     B1=B1(y,x1,..,x5);     c1=c1(x1,..,x5);      g1=g1(y,x1,..,x5);     g2=g2(y,x1,..,x5);     g3=g3(y,x1,..,x5);     g4=g4(x1,..,x5);      I have data for $x_1(i),..,x_5(i)$ in a CSV file that I Import and Table straight into the variable names making them into lists.               datatemp = Import["C:\\Documents\\2012U26G0.csv"];     j = Dimensions[datatemp][[1]]     kk=2     x1 = Table[datatemp[[i, 3]], {i, kk, j}]     x2 = Table[datatemp[[i, 4]], {i, kk, j}]     x3 = Table[datatemp[[i, 5]], {i, kk, j}]     x4 = Table[datatemp[[i, 6]], {i, kk, j}]     x5 = Table[datatemp[[i, 7]], {i, kk, j}]      I think this automatically makes my earlier defined formulae for $A1$,$B1$ and $g_m$ into a list of formulae with the only unknown being $y$ and it makes $c1$ into a list of constants since $c1$ was only dependent on $x_i$. Now, what I would like to be able to do is the following. Give some initial search point for my FindRoot for $i=1$               sol={1,1,1,1,120}      As you will see in a second, I only care about               sol[[5]]      Due to continuity, the roots move monotonically with $i$ so once I find one root, I can get a sense of where to look for the next one so I substitute the previous solution into the search for the next one. Also, in one shot I compute the 4 output variables I need. So when the Table is run, in one shot I have all the output data I want.               outputdata=Table[sol={g1,g2,g3,g4,y} /. FindRoot[ A1[[i]]*(y[[i]])^(k1) + B1[[i]]*(y[[i]])^(k2)==c[[i]] , {y, sol[[5]]+10, sol[[5]], sol[[5]]+20}], {i,1, 60}]      This process worked for a charm for little while but for a certain parameter space (by parameter I don't mean the $x_i$ I used earlier but a host of $\gamma$s and$\beta$s in my equations that I have suppressed so far), it has started giving me errors, 1/0 infinity type stuff, because of some assignment issues. Is there a clean and correct/good way to do this? I wanna be able to import a ton of data, Table my findroot to compute a whole bunch of data and Export it real fast. Please please please help! _**MWE_**               f = y^(3.1276)*(A1) + y^(-0.5875)*(B1) + (c1)^2;     A1 = x1/y + x2*y + 3*x3;     B1 = x1*x3 + 1/(y*x2);     c1 = x1^3 + x2^5 - x3;     g1 = y^(x1) - x3*x2;     g2 = x1/y;      Imported Data Below:               x1 = {89, 88, 87}     x2 = {0.048334203`, 0.048515211`, 0.048707816`}     x3 = {-19486.2273`, -19742.04035`, -20016.22863`}      When I do this, I can see what the curves look like:                Plot[Table[y^(3.1276)*(A1[[i]]) + y^(-0.5875)*(B1[[i]]) + (c1[[i]])^2, {i, 1,       3}], {y, 150, 180}]      ![enter image description here](http://i.stack.imgur.com/EBvBq.jpg) This is what I want to do. To be able to Table a whole bunch of output in one shot:               dataoutput=Table[{g1[[i]], g2[[i]], y} /. FindRoot[y^(3.1276)*(A1[[i]]) +      y^(-0.5875)*(B1[[i]]) + (c1[[i]])^2, {y, 165, 150, 170}], {i, 1,      3}]      This is the result that I get, with some errors about accuracygoal and precisiongoal.               {{1623.03, -6.88842*10^19, 167.181}, {1530.37, -5.38632*10^19,       163.049}, {1431., -4.18019*10^19, 158.952}}      My MWE is working, just like my actual problem worked for a certain parameter space but now I am running into trouble. Is there a good way to Import a ton of Data, Table my FindRoot and generate a ton of output using Table and then Export my results? Thanks.


Contexts after Cell Grouping

I'm trying to separate my document into cell groups, each with their own context (much like the style of code isolation described by the answer here: Localizing variables within a Manipulate), but the I can't get the grouped cells to share a context, even though Notebook's Default Context is set as "Unique to each cell group." I have a simple example. The linked notebook appears as a single cell group (when I look at the grouping bars along the right side of the window), but multiple calls of `Print[$Context]` yield different results. It seems like, once a cell has been created, it's context doesn't change even if I adjust the grouping. What is going on in the simple example I posted, and is there a way to fix these weird context differences/prevent them from happening? Thanks!


How to populate a table using a rule replacement

I am trying to populate the rows and columns of a table by using a rule replacment. To generate a table that looks like this ![enter image description here](http://i.stack.imgur.com/asCQa.jpg) For example Sc would be row 1, column 1. An example of a record looks like this                rawData = Import["H:\\allresults.json"]               record = {19, 60, "Ag", "Ag", "19Ag@60Ag_npo: -186.503305 by solar
 \     19Ag@60Ag_bnp: -180.812004 by solar
 O_sng:-8.032213 by \     marco
", "-1.675194475", "Binding Energy", "solar"}      Then I extract the relevant entries with some functions (there is probably a more elegant way to to do this)               getRow[resultVector_] := resultVector[[3]];     getColumn[resultVector_] := resultVector[[4]];     getResult[resultVector_] := resultVector[[5]];     getResultType[resultVector_] := resultVector[[7]];      For example               getRow[record]      gives               Out[41] = Ag      I have a list of replacemnt rules               elementList = {"Sc" -> 1, "Ti" -> 2, "V" -> 3, "Cr" -> 4, "Mn" -> 5,        "Fe" -> 6, "Co" -> 7, "Ni" -> 8, "Cu" -> 9, "Zn" -> 10, "Y" -> 11,        "Zr" -> 12, "Nb" -> 13, "Mo" -> 14, "Tc" -> 15, "Ru" -> 16,        "Rh" -> 17, "Pd" -> 18, "Ag" -> 19, "Cd" -> 20, "Lu" -> 21,        "Hf" -> 22, "Ta" -> 23, "W" -> 24, "Re" -> 25, "Os" -> 26,        "Ir" -> 27, "Pt" -> 28, "Au" -> 29, "Hg" -> 30}      I would like to build a table where the location in the table gets identified, and the corresponding result gets put into that location of the table. For example Ag, Ag (row, column) should put "-1.675194475" in location (19,19) (row, column) of a table. Is there a better way to do this than with replacement rules? * * * Update: Here is my current implementation to see all my data:               elementList = {"Sc" -> 1, "Ti" -> 2, "V" -> 3, "Cr" -> 4, "Mn" -> 5,       "Fe" -> 6, "Co" -> 7, "Ni" -> 8, "Cu" -> 9, "Zn" -> 10, "Y" -> 11,        "Zr" -> 12, "Nb" -> 13, "Mo" -> 14, "Tc" -> 15, "Ru" -> 16,        "Rh" -> 17, "Pd" -> 18, "Ag" -> 19, "Cd" -> 20, "Lu" -> 21,        "Hf" -> 22, "Ta" -> 23, "W" -> 24, "Re" -> 25, "Os" -> 26,        "Ir" -> 27, "Pt" -> 28, "Au" -> 29, "Hg" -> 30};      I create lists of data for different particle sizes and energy types               data = Import["H:\\allresults.json"];     atoms32 = Select[data, StringCases[#[[1]], "32"] != {} &];     atoms79 = Select[data, StringCases[#[[1]], "60"] != {} &];     atoms32Binding =        Select[atoms32, StringCases[#[[1]], "Binding"] != {} &];     atoms32Cohesive =        Select[atoms32, StringCases[#[[1]], "Cohesive"] != {} &] ;     atoms79Binding =        Select[atoms79, StringCases[#[[1]], "Binding"] != {} &];     atoms79Cohesive =        Select[atoms79, StringCases[#[[1]], "Cohesive"] != {} &];     mat = Outer[List, elements, elements];      Is there a more elegant way to do this? I intend to do more energy calculations of different types in the future (vacancy formation energy etc). Is it possible to write it such that the data is automatically partitioned out into lists for each size and type?               rules79Binding =        Cases[atoms79Binding, {__, "M1" -> e1_, "M2" -> e2_, __,           "result" -> val_, __} :> {e1, e2} ->           ToExpression@val, \[Infinity]];     rules79Cohesive =        Cases[atoms79Cohesive, {__, "M1" -> e1_, "M2" -> e2_, __,           "result" -> val_, __} :> {e1, e2} ->           ToExpression@val, \[Infinity]];     rules32Binding =        Cases[atoms32Binding, {__, "M1" -> e1_, "M2" -> e2_, __,           "result" -> val_, __} :> {e1, e2} ->           ToExpression@val, \[Infinity]];     rules32Cohesive =        Cases[atoms32Cohesive, {__, "M1" -> e1_, "M2" -> e2_, __,           "result" -> val_, __} :> {e1, e2} ->           ToExpression@val, \[Infinity]];       This also suffers from exactly the same repetitive line with the only thing that changes between the lines is the list. Finally I plot all the data               ArrayPlot[mat /. rules79Binding /. {_, _} -> 0,       ColorFunction -> (Blend[{Blue, Red}, #] &),       ColorRules -> {0 -> White}, Mesh -> True, Frame -> True,       FrameTicks -> ({#, #} &@Transpose@{Range@Length@elements, elements}),       PlotRangePadding -> None, ImageSize -> 500,       PlotLabel -> "19M1@60M2 Binding Energy"]     ArrayPlot[mat /. rules79Cohesive /. {_, _} -> 0,       ColorFunction -> (Blend[{Blue, Red}, #] &),       ColorRules -> {0 -> White}, Mesh -> True, Frame -> True,       FrameTicks -> ({#, #} &@Transpose@{Range@Length@elements, elements}),       PlotRangePadding -> None, ImageSize -> 500,       PlotLabel -> "19M1@60M2 Cohesive Energy"]     ArrayPlot[mat /. rules32Binding /. {_, _} -> 0,       ColorFunction -> (Blend[{Blue, Red}, #] &),       ColorRules -> {0 -> White}, Mesh -> True, Frame -> True,       FrameTicks -> ({#, #} &@Transpose@{Range@Length@elements, elements}),       PlotRangePadding -> None, ImageSize -> 500,       PlotLabel -> "6M1@32M2 Binding Energy"]     ArrayPlot[mat /. rules32Cohesive /. {_, _} -> 0,       ColorFunction -> (Blend[{Blue, Red}, #] &),       ColorRules -> {0 -> White}, Mesh -> True, Frame -> True,       FrameTicks -> ({#, #} &@Transpose@{Range@Length@elements, elements}),       PlotRangePadding -> None, ImageSize -> 500,       PlotLabel -> "6M1@32M2 Cohesive Energy"]      I have not put pictures up of each plot so that I do not make the post too long. Also, How can I map specific numerical values over color gradients. For example, for the binding energies, {-1,-2} blends through green. {-2,-3} blends through yellow {-3,-5}, blends through orange, {-5, -10} blends through red, and {-10, infinity} is black.


How to replace plus sign by comma

I want to replace plus by comma and the order of numbers in the list should be in increasing order. Example:               a1 + a10 + a11 + a13 + a2 + a27 + a28      In this expression, I want to replace plus sign by comma and delete "a". To get a list of numbers and the order should be               {1,2,10,11,13,27,28}      I have tried this, but it's not convenient...               StringReplace["a1 + a 10 + a 11 + a 13 + a2 + a27 + a28" , "+ a" -> ","]


Why don't I get numeric values from this Solve?

Solve[ a^2 + b^2 == c^2 && a < 100 && b < 100 && c < 100, {a, b, c}, Integers]      gives me this result > >     {{c -> ConditionalExpression[-Sqrt[ a^2 + b^2], >              ((a | b | c) ∈ Integers &&  Sqrt[10000 - a^2] - b > 0  && -99 > <= a <= -1) || >              ((a | b | c) ∈ Integers &&  Sqrt[10000 - a^2] - b > 0  &&   1 > <= a <= 99) || >              ((a | b | c) ∈ Integers &&  Sqrt[10000 - a^2] + b <= 0 && -99 > <= a <= -1) || >              ((a | b | c) ∈ Integers &&  Sqrt[10000 - a^2] + b <= 0 &&   1 > <= a <= 99) || >                   ...           ] },   ...  } >   where I would expect something like > >     {{x -> 3, y -> 4, z -> 5}, {x -> 4, y -> 3, z -> 5}, {x -> 5, y -> 12, z > -> 13},...} >   What am I doing wrong?


Extracting the coordinate of a particular point of interest from a ListPlot

Is there a way to obtain the coordinate of a point of interest in a `ListPlot`? As an example, I have a list containing many sets of 2D coordinates and the plot drawn is discontinuous at one point (the first derivative is not continuous and the gradient increases suddenly). Can I extract the location of that point interactively? Otherwise, I have to search through the list of data myself to determine the change of gradient, which defeats the whole purpose of drawing a plot. Also, using the Get Coordinates function from the right click menu does not give very accurate results.


Associating symbol pages with symbols (Workbench)

Normally when you have symbol Abc, WorkBench creates a symbol page named _Abc_. Then when you make a build, type Abc and then press the F1 key, you are sent to the Abc symbol page. Suppose however that you want to type a string , say _xyz_ , but on pressing F1 you want to go to symbol page Abc or, at least, be given Abc page among the search results. Is this possible? I think it might be. For example, type the exclamation mark (!) and then F1. You are given the choice between the _Factorial_ , _Not_ and _Run_ pages. How were these associations made? In other words: is it possible to intercept the F1 action? Or somehow indicate for a symbol page which search strings are appropriate? Or use some other hack to obtain this effect?


Attaching a legend to BallAndStick picture

I am looking for a way to add a legend showing the identity of various atoms (with different colours) to this picture. Any Clues?               Import["ExampleData/1PPT.pdb", "Rendering" -> "BallAndStick"]      ![enter image description here](http://i.stack.imgur.com/FSFoH.png)


How to create a Table of Tables with indexed variables

I want to use concise code to generate a table of values that list the addition of a set of vectors. What I am looking for is essentially a Table of Tables. I will show here the kind of lists I want, which I am able to generate individually. First, let's define a set of say 6 vectors (an ordered pair):               H = Table[{Cos[n*Pi/3], Sin[n*Pi/3]}, {n, 0, 5, 1}];      This will be our first Table. Next, I want to get all vectors that result from adding any two vectors in H together:               H2 = Table[H[[i1]] + H[[i2]], {i1, 1, 6, 1}, {i2, 1, 6, 1}];      Now we create another Table, but this time with all vectors that result from choosing three vectors from the set H and adding them together:               H3 = Table[H[[i1]] + H[[i2]] + H[[i3]], {i1, 1, 6, 1}, {i2, 1, 6, 1}, {i3, 1, 6, 1}];      Suppose we were to continue creating tables like this with arbitrarily many sums of this type. How can I create one single Table that would combine them all? I am aware that I can use some function like Append to join them all together after each one has been generated, but I am looking for something more efficient that can be done a single cell. I have something in mind along the following lines (note that this is not properly functioning code, but I am writing it for illustrative purposes). It would be nice to be able to generalize these Tables using something like this, where I've attempted to index the variables (incorrectly?):               H[N_] =      Table[     Sum[ H[[i_j]] , {j, 1, N, 1}],     {i_1, 1, 6, 1}, {i_2, 1, 6, 1}, ... {i_N, 1, 6, 1}] ;      Then I could create a single table with say 10 iterations using:               Table[ H[N],{N,1,10,1}]      Unfortunately, I am unable to index variables in this way because Mathematica tells me the variable names are "Protected". How can I get around this?


How to order legend in Show?

I've asked this question in Wolfram community and have not received a response. I am wondering why when I use `Show` to combine 6 plots, the plot legend does not show in order? The order should be 150, 250, 350, 450, 550, 650. However when I step through `Show` adding one plot at a time, I notice that _Mathematica_ does something weird with the order of the legend, and in the end the order is 650, 150, 250, 350, 450, 550. How can I get the order of the Legend or Show to be correct, such that there is a logical sequence of the label? I have attached some code below to show what's happening:                data = {          {0., 23.1628, 15., 12., 5., 2., .75, 0.0},          {0., 53.611, 100., 83.27448, 40., 33., 25., 10.0},          {0., 71.7055, 100., 79, 72.996, 30.76314, 17., 15.},          {0., 71.92428, 100., 100, 83.35182, 41.09816, 35., 10.0},          {0., 75.87498, 100., 100., 88.65755, 87.0691, 34.27131, 20.},          {0., 100., 100., 100., 88.65755, 87.0691, 80.4311, 39.40}          } // TableForm;          time = {0., 120., 300., 600., 900., 1200., 1500., 1800.};          activity = Table[Transpose[{time, data[[1, i]]}], {i, 1, 6}];          tickSpecs = {{{0, "0"}, {120, "2"}, {300, "5"}, {600, "10"}, {900,          "15"}, {1200, "20"}, {1500, "25"}, {1800, "30"}}, Automatic};          label = {"150 ", "250 ", "350 ", "450 ", "550 ", "650 "};     colors = {Black, Red, Orange, Green, Blue, Purple, Magenta};               Plots = Table[          ListPlot[activity[[i]],              PlotRange -> All,              PlotStyle -> {Darker[colors[[i]]], Dashing[{0.05}], Thick,           AbsolutePointSize[12]},         Joined -> True,         Mesh -> All,         Ticks -> {Automatic, None},         FrameTicks -> tickSpecs,         Frame -> {Left, Bottom},         FrameStyle -> Thick,         Axes -> False,         LabelStyle -> {FontSize -> 20, FormatType -> Bold},         ImageSize -> 450,         PlotLegends ->          LineLegend[{label[[i]]},           LabelStyle -> Directive[Bold, 15],           LegendMarkerSize -> Automatic]],     {i, 1, 6}];          Show[Plots]


RegionPlot giving an "invalid comparison" error

I am trying to use `RegionPlot` in _Mathematica_ and I am stuck because I am getting an invalid comparison error. I am trying to evaluate the following code:                   Manipulate[      RegionPlot[{(         X Log[((-8 + X (8 + γ) + Sqrt[              64 - 128 X + X^2 (64 + γ^2)]) (-8 (-1 + X) y0 +               X z0 (-8 + 8 X - X γ + Sqrt[                 64 - 128 X + X^2 (64 + γ^2)])))/((8 -               X (8 + γ) + Sqrt[              64 - 128 X + X^2 (64 + γ^2)]) (8 (-1 + X) y0 +               X z0 (8 + X (-8 + γ) + Sqrt[                 64 - 128 X + X^2 (64 + γ^2)])))])/Sqrt[         64 - 128 X + X^2 (64 + γ^2)] >          0, ((-8 + X (8 + γ) + Sqrt[            64 (-1 + X)^2 + X^2 γ^2])^2 (-8 (-1 + X) y0 +             X z0 (-8 - X (-8 + γ) + Sqrt[               64 (-1 + X)^2 + X^2 γ^2])))/((8 - X (8 + γ) +             Sqrt[64 - 128 X + X^2 (64 + γ^2)])^2 (8 (-1 + X) y0 +             X z0 (8 + X (-8 + γ) + Sqrt[               64 (-1 + X)^2 + X^2 γ^2]))) >          Exp[-(8 - 8/X + γ)*(           X Log[((-8 + X (8 + γ) + Sqrt[                64 - 128 X + X^2 (64 + γ^2)]) (-8 (-1 + X) y0 +                 X z0 (-8 + 8 X - X γ + Sqrt[                   64 - 128 X + X^2 (64 + γ^2)])))/((8 -                 X (8 + γ) + Sqrt[                64 - 128 X + X^2 (64 + γ^2)]) (8 (-1 + X) y0 +                 X z0 (8 + X (-8 + γ) + Sqrt[                   64 - 128 X + X^2 (64 + γ^2)])))])/Sqrt[           64 - 128 X + X^2 (64 + γ^2)]]}, {z0, -(1 - X^-1),         2*(1 - X^-1)}, {y0, -(X - 1), 2*(X - 1)}, Frame -> True,        FrameTicks -> Automatic, BaseStyle -> {FontSize -> 30},        PlotStyle -> {Directive[Orange, Opacity[0.4]],          Directive[Green, Opacity[0.4]], Directive[Blue, Opacity[0.4]]},        Evaluated -> True], {X, 1.01, 10, Appearance -> "Open"}, {γ,        0.1, 100, Appearance -> "Open"}]          I want to evaluate the second inequality only if the first equality is satisfied, or something like that, so the code will evaluate without producing an error message.


Finding similar expressions in list

I have a function that returns to me lists of expressions, like:               I (a^2 + b^2) (* 1 *)     a (I b + e)   (* 2 *)     b (I a + d)   (* 3 *)     b (I a + f)   (* 4 *)     a b           (* 5 *)     a (I b + f)   (* 6 *)     I (b^2 + c^2) (* 7 *)      The expressions can become arbitrary complex. Now I want a function that returns to me that expression 2,3,4,6 as well as 1,7 are similar, because one can just rename the variables. I have absolutly no idea how to solve this problem, and would be very happy for any hint in the right direction. **Update on _similarity-criterion_** Similar means:                a -> b, c, d, e, f, ... zzzz, SomeVar1, ...      (If it is simpler, for the moment one can assume that the list of variables can be only a,b,c,d,...,z = 26 lowercase letters). It must not transform the structure of the equation, for instance:                a (I b + e)      Here, _a_ cannot become _b_ or _e_ , _b_ cannot become _a_ or _e_ , _e_ cannot become _a_ or _b_ , i.e. all of them must be different. All terms a, b, c, d are simple variables, and cannot become Sin[a], Tan[b], 1/c, ... Examples:   * `a (I b + e)`, `b (I a + d)`, `b (I a + f)`, `a (I b + f)` are all similar   * `a^2 + b` and `a + b^2` are similar   * `a (c + d) + b (c + e)` and `a (c + d) + b (e + f)` are not similar because `c` is repeated in the first one but not the second one


DateListPlot with two time list adding 2 labels, and setting the color of the label and lines in plot

This command will produce a chart with two lines on it.               DateListPlot[{CapReg, Equity},  Joined -> True ]      What I would like to do is add a label above the chart "CapReg" in red, and a label below the chart "Equity" in blue. Then I would like to have the color of the `CapReg` line be red, and the line for `Equity` be blue. Any ideas? Many thanks in advance.


In lambda calculus, can the parameter of abstraction be a non-variable lambda expression?

In short, my main confusion is between the two concept `variable` and `lambda expression`: I am reading this reference here: > The syntax of (pure) lambda expressions is defined as follows: > >   1. A variable is a lambda expression (we will use single, lower-case > letters for variables). >   2. If M and N are lambda expressions, then so are each of the following: > > a) (M)   >  b) λid.M   >  c) MN > > > > We can express the rules given above that define the language of lambda > expressions using a context-free grammar: exp → ID | ( exp ) | λ ID . exp // > abstraction | exp exp // application From rule #1 and the context-free grammar, I think the author means that `ID` refers to `variable`, and `variable ∈ lambda expression`. But I am not sure whether `lambda expression ∈ variable`. Question:   May I know whether I can use a "complex" expressions (e.g. a non-variable lambda expression) as `id` in `λid.M`? Intuitively, I interpret `variable` represented by an ID with a single letter, but I could not find reference to support my conjecture. (or in other words, how is `variable` defined in lambda calculus, if this is not too broad a question?)


How to do symbolic definite integral without copy and paste the intermediate results?

I am do a symbolic definite integral, I am doing it like this:               Integrate[1/Sqrt[(ϵ + u)^2 + Δ^2], ϵ] // FullSimplify      It gives an output:               Log[u + ϵ + Sqrt[Δ^2 + (u + ϵ)^2]]      then I **copy** this output and define a function respect to the integrate variable:               F2[ϵ_] := Log[u + ϵ + Sqrt[Δ^2 + (u + ϵ)^2]]      Finally I can substitute the upper and lower limit to `F2` and obtain my results:               F2[ξ - u] - F2[m]      I don't like the **manually** copy step. So how do you do this **automatically**?


Mathematica does not export Turkish characters in a Graphics expression

When I export the following `Graphics` expression as a _PDF_ (or _EPS_ ) file, the _Turkish_ characters _ü_ and _ç_ do not appear.               Graphics[Text[Style["Türkçe", 72, Background -> White], {0, 0}]]       Is it possible to fix this? Here is how it looks in _PDF_ file.   ![1](http://s2.postimage.org/qyd9be995/turkce.jpg)


Unexpected behavior of PasteButton

Assume the following very complex palette:               CreatePalette[       PasteButton[FontColor -> RGBColor[1, 0, 0]]     ];      Its purpose is to insert a `FontColor` rule. It works like expected in a notebook but I plan to use it inside raw cell expressions. Please try the following two examples. Paste the following code into a notebook               NotebookWrite[      SelectedNotebook[],      Cell[Cell["abc", "Text"]]      ]      You get a text cell saying "abc". Now go with the cursor anywhere between the "abc" and press `Ctrl+Shift+E` (this is _Cell->Show Expression_ ) to see the underlying cell data. Go directly in front of the last closing bracket, make a comma and press the palette-button. You should get               Cell[BoxData[      FormBox["abc", Text]],FontColor->RGBColor[1,0,0]]      Pressing `Ctrl+Shift+E` again and the text is red. Works like a charm. Now try the following cell with the same approach:               NotebookWrite[      SelectedNotebook[],      Cell[StyleData["StandardForm"]]      ]      Here I get (Linux 64, Mma 8.0.4)               Cell[StyleData["StandardForm"],       RowBox[{"FontColor", "->", RowBox[{"RGBColor", "[",        RowBox[{"1", ",", "0", ",", "0"}], "]"}]}]     ]      which is not what I expected and which does not work. **Question:** Can anyone explain me what's going on here? Is the `PasteButton` aware of the context? **Background:** The background is, that I have created a palette which I want to use to adjust style-sheet definitions. That was, when I stumbled over this behaviour. **Fix:** One possible way to fix this is to use `NotebookWrite` directly instead of the `PasteButton`. Disadvantage of this approach is, that the expression can no longer be inserted into a normal notebook, because there you have to insert cell-expression.


Making a Mathematica package manager?

I'd like to get a serious discussion started about a package manager. This has come up elsewhere, and many people have implemented their own solutions. It would be nice to have a standardized way to deploy and distribute Mathematica code to anyone. I also imagine we could distribute other content this way. For example, one thing I think would be nice, if there were interest, would be to collate information from this site and serve it as a package that includes tools and supplemental documentation. Please share your ideas on how we can achieve this.


How to extrude a 3D image from a binary 2D image

I'm trying to extrude a nice 3D form from the 2D binary image below using the code posted, but I haven't had any luck in figuring out the error that's keeping `GraphicsComplex` from running. The end result should be the 3D points and a plot. Any help would certainly be appreciated! ![my 2D binary Image](http://i.stack.imgur.com/UWO6k.png)                 pts= ImageData[testimage];       twoD = Rescale[Table[Thread[{pts[[i]], pts[[i]]}], {i, 1, Length[pts]}]];           extrude[pts_, h_] := Module[{vb, vt, len = Length[pts], nh, shape},      If[! NumericQ[h], nh = 0., nh = N@h];      vb = Table[{pts[[i, 1]], pts[[i, 2]], 0}, {i, len}];      vt = Table[{pts[[i, 1]], pts[[i, 2]], nh}, {i, len}];      shape =        GraphicsComplex[        Join[vb, vt], {Polygon[Range[len]],          Polygon[Append[           Table[{i, i + 1, len + i + 1, len + i}, {i, len - 1}], {len, 1,          len + 1, 2 len}]], Polygon[Range[len + 1, 2 len]]}]      ]


How do I find all the possible events that work with EventHandler?

The `EventHandler` documentation, More Information section, lists 5 mouse events:               "MouseClicked" "MouseDown" "MouseDragged" "MouseMoved" "MouseUp"      There is at least one other mouse event that can be used that is not listed in this documentation: `"MouseEntered"` How can I find out all the possible arguments that can be used as events for `EventHandler`? **Edit** Also in this answer we learn of an undocumented option `HandleShiftReturn` which works as a "name" with `MenuCommand`. From the documentation: {"MenuCommand","name"} menu command with specified name chosen How do we find out all the possible "names"? **Edit #2 19th June** I got a reply from tech support. They state that "MouseEntered" and "MouseExited" in the GUI Kit are different from the ones in `EventHandler` and the ones in `EventHandler` are not yet ready for public use hence not documented. I didn't get an answer to my request for a full list of events for `EventHandler` (that are public). **Edit #3 30th June** Contacted tech support again after this question. Tech support advise that there is no (documented) way to use the shift, option, control, and function keys with `EventHandler`. Further they said there is no way to use key combinations with `EventHandler`. Still no closer to getting a complete list of events.


How to efficiently import videos

I need to do frame-by-frame analysis of videos. I can import the video files I need, but each file is too large to import at once. I can use the `Import[fn, "Frames",{n}]` command to import images one-by-one, but this takes a long time once `n` gets large. For example, the first frame it takes 0.14 sec, but the 200th frame takes 2.2 sec. Mathematica seems to be reading from the start of the file each time I do this. Obviously, this will not work. Is there some way to speed this up. E.g. using streams? Or tricking Mathematica to use `ImageCapture` to get images from a video file instead of a webcam? Thanks


setting real parameters in Hamiltonian matrix

The following Matrix represents my Hamiltonian.               m = {{ B/2 - d - j/2 + a, (Sqrt[2]*j)/2, M}, {(Sqrt[2]*j)/2, B/2 + a, 0}, {M, 0, (-3*B)/2 - d + j/2 + a}      How can I define the variables used in matrix such that the Mathematica assumes as they are real. because with this matrix, mathematica gives complex eigenvalues but my eigenvalues are supposed to be real.


Is there a way to find out who is importing a package?

After calling some functions, if I look into `$ContextPath`, I can see that `JLink`` is in there. Is there a way to find out what sequence of functions calls (like a stack-trace) imported a particular package? Something like `FuncA` called `FuncB` which called `FuncD` which executed `Needs["JLink`"]`


How to optimally solve and generalize this Conway's Game of Life puzzle

I tried solving this using mma. I am aware of this command - **Cellular automata**. But i don't want to use that coz then there is no challenge. So below is how i did it and my question is can this be done with fewer lines of code (without resorting to _CellularAutomaton_ ). Also i wanted to generalize it to any initial condition. > I am representing the grid shown in the puzzle as a (n $\times$ m) matrix > such that all the live cells are represented by _1_ and the dead ones by > _0_. Also in this particular case we have $n = 26$ and $m = 27$. Then i > manually made a list of the initial condition given in the question. Here > each pair represents the $(ij)^{th}$ element having live cells.   > > >   * _[as a side note - can this process be automated - i mean finding this > list from that image given for the intial grid by some image processing]_ >               list = {{2, 6}, {2, 13}, {3, 23}, {3, 25}, {4, 3}, {4, 10},            {4, 9}, {4, 18}, {5, 18}, {5, 2}, {8, 11}, {8, 12},             {10, 10}, {10, 12}, {11, 11}, {12, 18}, {13, 2}, {14, 2}, {13,               23}, {14, 8}, {14, 23}, {16, 24}, {17, 25}, {18, 24},               {18, 18}, {18, 17}, {19, 12}, {20, 12}, {20, 3}, {20, 4}, {22,              24}, {23, 23}, {22, 17}, {23, 18}};      > The matrix $A_{n \times m}$ now contains the elements _1_ and _0_ > corresponding to the live and dead cells receptively.   >  $f^{ij}_{0}$ contains the $(ij)^{th}$ element of $A_{n \times m}$                 A[n_, m_] := SparseArray[# -> 1 & /@ list, {n, m}, 0]           Table[f[0][i, j] = A[26, 27][[i, j]], {i, 1, 26}, {j, 1, 27}];      > The recursive function which gives the next generation is:-               f[k_][i_, j_] := f[k][i, j] = Module[{n = 26, m = 27, neg},            findNeighbours[i, j] := Module[{},          f[k - 1][#[[1]], #[[2]]] & /@ {{i - 1, j - 1}, {i - 1,             j}, {i - 1, j + 1}, {i, j - 1}, {i, j + 1}, {i + 1,               j - 1}, {i + 1, j}, {i + 1, j + 1}}];             neg = Cases[findNeighbours[i, j], _Integer];              (* Apply the rules to the ij th element*)         Which[f[k - 1][i, j] == 1,               Which[Count[neg, 1] < 2,                val = 0, (Count[neg, 1] === 2 || Count[neg, 1] === 3), val = 1,                 Count[neg, 1] > 3, val = 0],                 f[k - 1][i, j] == 0,                 Which[Count[neg, 1] === 3, val = 1, True, val = 0]]                 ]      > Finally we can plot the results to see the answer which is 3 if the starting > generation is called $1^{st}$ generation.                  genaration[0] =           ArrayPlot[         Table[f[0][i, j] = A[26, 27][[i, j]], {i, 1, 26}, {j, 1, 27}], Mesh -> True];                  genaration[n_] :=           ArrayPlot[Table[f[n][i, j], {i, 1, 26}, {j, 1, 27}], Mesh -> True]            res = ListAnimate[genaration[#] & /@ Range[0, 3],               AnimationRate -> 0.5]      ![](http://i.stack.imgur.com/mgrZo.gif)


How to substitute the following conditions into an expression?

I have an expression: $p=a\;b\; x + b^2\; y + a\;c\; z$. I want to substitute $a\;b=1$, $b^2 = 2$ and $a\;c = 4$ to obtain $p = x + 2y + 4z$.   How can I tell _Mathematica_ to do that? I dont know how to start.


Choosing the units for plotting

I´m new to using units in Mathematica. I have read other similar posts about this issue but I haven´t found an answer so far. My problem is simple: I want to plot a certain function with a certain unit. In my case, I want a graphic in Angle - mm. I have this function depending on a.               f[a_]:=(1 - Cos[0.017 a])*(Quantity[45.2,"Millimeters"]) +      (Quantity[145.`, "Millimeters"])*(1-Sqrt[1 - 0.097 Sin[0.017 a]^2])      When I plot it using               Plot[Evaluate[f[a]], {a, 0, 720}]      I get a results which is 1/1000 times the correct one (which should be in mm), so I assume that it is being shown in m. But in general, there is no way to know in which unit the graphic is being shown. Or is there a way to do this? Thank you for the help.


Why does initialization slow down manipulate in this case?

I'm trying to manipulate a plot of function with some parameters. The function is a long expression, so I tried to put it inside the Initialization options of `Manipulate`. However, once I did that, the performance is really bad, compared to one that have the function explicitly written out. Here is a simplified version: Here is the original one:               Manipulate[      DensityPlot[       Re[( C10 Exp[I 2 τ] )/(0.1 - I (ω - C10/10)) + (          C10 Exp[I 4 τ] )/(0.1 - I (ω - C10/10)) + (          C10 Exp[I 8 τ] )/(0.1 - I (ω - C10/10))], {τ,         0, π}, {ω, -0.5, 0.5}, PlotRange -> All,        PlotPoints -> 60],      {{C10, 0.5}, 0.1, 1.}]      and here is the one with definition inside `Initialization` option:               Manipulate[      DensityPlot[       f[ω, τ, C10], {τ, 0, π}, {ω, -0.5, 0.5},        PlotRange -> All, PlotPoints -> 60],      {{C10, 0.5}, 0.1, 1.},       Initialization :> {f[ω_, τ_, C10_] :=          Re[( C10 Exp[I 2 τ] )/(0.1 - I (ω - C10/10)) + (            C10 Exp[I 4 τ] )/(0.1 - I (ω - C10/10)) + (            C10 Exp[I 8 τ] )/(0.1 - I (ω - C10/10))]}]      Here is the screenshot for comparison: ![enter image description here](http://i.stack.imgur.com/ApDeZ.gif) ![enter image description here](http://i.stack.imgur.com/0Rjk1.gif) They original one seems much faster than the later one. Why does this happen and how to solve it?


Where is the unit after a calculation?

I was playing with some of the new features, and when I type e.g.               Quantity[10, "ml"] + Quantity[250 - 100, "ml"]      I get               160 mL      as expected. But when I want to solve the following equation               Solve[Quantity[x, "ml"] Quantity[5, "mol"] + Quantity[250 - x, "ml"] Quantity[7, "mol"] ==     Quantity[250, "ml"] Quantity[6, "mol"], x]      I get               {{x -> 125}}      without any unit. But x actually is in mL. So I'm wondering what I am getting wrong, i.e. why don't I get mL here? thanks!


Close programmatically all cell groups in Mathematica?

Is it possible to collapse all cell groups in the current notebook? I tried               nb = SelectedNotebook[];     SelectionMove[nb, Before, CellGroup]     FrontEndTokenExecute["OpenCloseGroup"]      but nothing changes.


Is DateString supposed to be truncating seconds?

If I configure `DateString` to format dates as ISO dates with               $DateStringFormat := {"Year", "-", "Month", "-", "Day", "T", ":",            "Hour", ":", "Minute", ":", "SecondExact",            If[$TimeZone == 0, "Z", "UTC" <> ToString[$TimeZone]]}      I get truncated seconds, rather than rounded seconds               {2012, 10, 12, 21, 32, 22.5359} // DateString     2012-10-12T:21:32:22.535UTC-5.      This seems wrong. The result should either be               2012-10-12T:21:32:22.5359UTC-5.      or               2012-10-12T:21:32:22.536UTC-5.      Is it a bug, or am I misunderstanding `"SecondExact"` or `DateString`?


Can I plot a Parametric and Cartesian functions on same grid?

I am trying to make a simulation of an airfoil in Mathematica. The final coordinates of the airfoil are parametric, but some of the other things like chord line are f(x) functions. Is there any way that I can plot a normal function and a parametric function on the same graph? Thank you.


Double integral over a parallelogram

Problem: Evaluate the following double integral $$\int \\!\\!\\! \int_D (14 x^2+61 xy+42 y^2)^{3} \, dxdy$$ where $D$ is a parallelogram between these four lines: $2x+7y=6$, $2x+7 y=-6$, $7x+6 y=6$ and $7x+6y=-6$. I have defined the lines as graphs of functions $a, b, c, d$ and plotted them in _Mathematica_. Lines $a$ and $c$ intersect at $x=-\frac{78}{37}$ while $b$ and $d$ intersect at $x=\frac{12}{5}$ according to my calculations. Then I try to integrate the function as follows, getting the answer $-4400.1$, but it is not correct.               NIntegrate[       Boole[-(78/37) <= x <= 12/5 && Max[a[x], b[x]] <= y <= Min[c[x], d[x]]]       ((14 x^2 + 61 x*y + 42 y^2)^3),       {x, -4, 4}, {y, -2, 2}]      What am I doing wrong?


how to make graphic timelines in mathematica

Hi does anyone know how to make timelines with mathematica? http://images.nationmaster.com/images/motw/atlas_middle_east/turkey_timeline.jpg something like that would be great! thanks


Exporting multiple arrays in a single HDF5 file in Mathematica 7

I am using _Mathematica_ 7 and I need to export a table of data and the corresponding `x` and `y` arrays. I would like to format them as a single file, say `grid.h5`, and need the arrays named for import in a different program. Unfortunately, applying the command:               Export["MGfunc.h5", {data, x1, y1}, {"Datasets", {"MGfunc", "x", "y"}}]      only seems to save the last array in the file `MGfunc.h5`. Does anyone know how to get this working using the HDF5 format? Here is an example:               In[13]:=  ki = N[Table[i, {i, 0, 3}]]      kj = N[Table[j, {j, 0, 3}]]      testgrid = Table[ki*kj, {ki, 0, 3}, {kj, 0, 3}]           Out[13]= {0., 1., 2., 3.}      Out[14]= {0., 1., 2., 3.}      Out[15]= {{0, 0, 0, 0}, {0, 1, 2, 3}, {0, 2, 4, 6}, {0, 3, 6, 9}}           In[16]:= Export["testgrid.h5", {testgrid, ki, kj}, {"Datasets", {"gridtest", "x", "y"}}]      Out[16]= "testgrid.h5"           In[19]:= Import["testgrid.h5"]      Out[19]= {"/y"}           In[20]:= Import["testgrid.h5", "Data"]      Out[20]= {{0., 1., 2., 3.}}


How do I add options to a built in function, which only apply to a certain class of argument?

I'd like to add an option to a built-in function that only applies when it is given an argument of a certain form. For example, something like this approach to extending `DateString` to support an extra option when it is given a date argument that matches the form `zoned[...]` (forget that `zoned` does nothing here):               DateString[zoned[x_], spec_, opts : OptionsPattern[{TimeZone -> 0,ShowZone->True}]] ^:=      DateString[x, If[OptionValue[ShowZone],        Append[spec, If[OptionValue[TimeZone] != 0, "UTC" <> ToString[OptionValue[TimeZone]], "Z"]], spec]]      Since `ShowZone` is not an option for `DateString`, I get an error. > "DateString::optx: Unknown option ShowZone in DateString..." But I can't just associate `TimeZone` as an up value for `zoned` with               zoned/:Options[DateString]={ShowZone->True}      because that also results in an error: > Options::tag: Rule for Options of Options[DateString] can only be attached > to DateString. It seems I have to (unprotect `DateString` and) then add a new option globally, which is generally just ignored:               Unprotect[DateString];      Options[DateString] = Union[Options[DateString], {ShowZone -> False}];      Protect[DateString];      Is this the only approach? Even this approach leaves `ShowZone` blue in the function definition and red in function invocations.


What Method options does FindInstance accept?

While answering Trouble getting FindInstance to return multiple results for certain constraints it became clear that for this problem `FindInstance` would be better starting with small numbers, but it does not. The function has the `Method` option:               Options[FindInstance, Method]   (*  Out: {Method -> Automatic}  *)      Yet, I cannot find documentation for the methods (and methods sub-options) that it accepts.   * What `Method` values does `FindInstance` accept?   * Will any of them scan an `Integer` search space small-values first?


Linear programming with many variables and parameters

I am trying to reconstruct the answer that is given in this report. (page 153 in Appendix B; Section B.2.1). They are given variables, parameters, constraints, and the objective function to minimize. Summary of the problem:               Minimize: q01 + q11 + q21 + q31 - q02 - q12 - q22 - q32     Variables: {q00 , q01 , q02 , q03 , q10 , q11 , q12 , q13 ,                  q20 , q21 , q22 , q23 , q30, q31 , q32 , q33}     Parameters: {p000 , p010 , p100 , p110 , p001 , p011 , p101 , p111}     Constraints:        1) all q's nonnegative       2) [sum all q's] == 1       3) p000 == q00 + q01 + q10 + q11       4) p010 == q20 + q22 + q30 + q32       5) p100 == q02 + q03 + q12 + q13       6) p110 == q21 + q23 + q31 + q33       7) p001 == q00 + q01 + q20 + q21       8) p011 == q10 + q12 + q30 + q32       9) p101 == q02 + q03 + q22 + q23       10) p111 == q11 + q13 + q31 + q33      Their output is given on page 155 as the maximum of a set of eight linear functions of the parameters:                Minimum of Objective Function is the Maximum of:      p111 + p000 - 1      p110 + p001 - 1      -p011 - p101      -p010 - p100      p110 - p111 - p101 - p010 - p100      p111 - p110 - p100 - p011 - p101      p001 - p011 - p101 - p010 - p000      p000 - p010 - p100 - p011 - p001      When trying to reproduce it in _Mathematica_ 8.0, first tried simple test case of using parameters               LinearProgramming[{1, 1}, {{1, 2}}, {a}]      which gave an error, but using Minimize does give a full answer               Minimize[x + y, x + 2*y >= a && x >= 0 && y >= 0, {x, y}]      I then rephrased the original problem in terms of Minimize function and even after running overnight it was still thinking:               Minimize[q01 + q11 + q21 + q31 - q02 - q12 - q22 - q32,        q00 + q01 + q02 + q03 + q10 + q11 + q12 + q13 + q20 + q21 + q22 +          q23 + q30 + q31 + q32 + q33 == 1 &&        q00 >= 0 && q01 >= 0 &&        q02 >= 0 && q03 >= 0 && q10 >= 0 && q11 >= 0 && q12 >= 0 &&        q13 >= 0 && q20 >= 0 && q21 >= 0 && q22 >= 0 && q23 >= 0 &&        q30 >= 0 && q31 >= 0 && q32 >= 0 && q33 >= 0 &&        p000 == q00 + q01 + q10 + q11 && p010 == q20 + q22 + q30 + q32 &&        p100 == q02 + q03 + q12 + q13 && p110 == q21 + q23 + q31 + q33 &&        p001 == q00 + q01 + q20 + q21 && p011 == q10 + q12 + q30 + q32 &&        p101 == q02 + q03 + q22 + q23 &&        p111 == q11 + q13 + q31 + q33, {q00, q01, q02, q03, q10, q11, q12,        q13, q20, q21, q22, q23, q30, q31, q32, q33}]      Is there a way for _Mathematica_ (8.0) to reproduce their results? Have a feeling I'm either missing a function that would answer it, or not inputting some restriction or assumption which Mathematica needs. Thank you! ### EDIT I tried the suggestion of @Anon:               Minimize[{f, constraints}, {q00, q02, ...}]       instead of               Minimize[f, constraints, {q00, q01, ...}]      hoping that was the answer. It still was thinking overnight, with no answer produced. Is Minimize the correct function to use for this problem? _(Originally posted inStackOverflow, first response recommended posting the question here)_


Odd behavior of GridGraph and DirectedEdges

For some reason the option `DirectedEdges->True`, albeit working internally with grid graph, does not appear in the visualisation for 1D and 2D graphs. It also changes the drawing scheme for 3D grids. **1D Grid-Graphs** Using               g1 = GridGraph[{2}, VertexLabels -> "Name", ImagePadding -> 20, DirectedEdges -> True]      prints: ![enter image description here](http://i.stack.imgur.com/fIVfq.jpg) which shows no directed edges, even though the incidence matrix is modified correctly: \begin{equation} \text{IncidenceMatrix[g1]} = \left( \begin{array}{c} -1 \\\ 1 \end{array} \right) \end{equation} Conversely, issuing the command               GridGraph[{1,2}, VertexLabels -> "Name", ImagePadding -> 20, DirectedEdges -> True]      prints ![enter image description here](http://i.stack.imgur.com/LN8hI.jpg) ie, with the directed edges correctly drawn. **2D Grid-Graphs** For 2D graphs, small dimensions print as a directed edge whereas higher dimensions do not. For instance               g = GridGraph[{2, 2}, VertexLabels -> "Name", ImagePadding -> 20, DirectedEdges -> True]      produces: ![enter image description here](http://i.stack.imgur.com/7Xy9i.jpg) For dimensions {4,2} the graph is: ![enter image description here](http://i.stack.imgur.com/z2DHz.jpg) where some very tiny arrows can in fact be observed. Conversely, for dimensions {2,4} it produces ![enter image description here](http://i.stack.imgur.com/KNsC5.jpg) It thence seems like a problem in adjusting the size of the arrows. But this seems unrelated to the 1D graph since there, no arrow can be seen in any dimension (unless drawn horizontally, in which case a 2D Grid-Graph is actually being called). **3D Grid-Graphs** Apparently, the arrows are drawn correctly for dimensions 3 and larger. However, the drawing scheme is affected, which is not the case in 2D graphs. For instance                GridGraph[{4, 2, 2}, VertexLabels -> "Name", ImagePadding -> 20]      produces ![enter image description here](http://i.stack.imgur.com/RBvkP.jpg) whereas adding `DirectedEdges->True` yields ![enter image description here](http://i.stack.imgur.com/cLOkx.jpg) In summary: odd stuff. Any thoughts? Thank you in advance for the attention.


Keywords to find documentation for this syntax

_Mathematica_ allows this syntax, but I cannot find any documentation (or books) that discuss the various uses/advantages of it               g[1] := Plus;     g[2] := Times;     g[1][3, 5]     (* 8 *)          g[2][3, 5]     (* 15 *)      What keywords can I use to find this in the documentation?


Doing vector manipulations on Mathematica

This is hopefully a simpler version of this previous unanswered question of mine. Let me just focus on the two expressions $F_2^{(s)}$ and $F_3^{(s)}$ given in A.3 and A.4 of page 19 of this paper.   * How do I get Mathematica to just even manipulate such vector expressions? Like if I want to calculate $(F_2^{(s)})^2$ or $F_2^{(s)} F_3^{(s)}$ etc?  * * * To make the question clear let me add in some more details about what I exactly want, I define the function F2s as,               F2s[q_, k1_] := (5/     14) + (3 (Norm[k1])^2)/(28 (Norm[q])^2) + (3 Norm[        k1]^2)/(28 (Norm[q - k1])^2) - (5)/(28 (Norm[q])^2 (Norm[         q - k1])^(-2)) - (5)/(28 (Norm[q])^(-2) (Norm[         q - k1])^(2)) + ( (Norm[        k1])^4)/(14 (Norm[q])^2 (Norm[q - k1])^2 )      But when I ask it to be squared all I get is this! (basically nothing has been done and the situation doesn't change with taking a FullSimplify either)               (2 Norm[k1]^4 - 5 (Norm[q]^2 - Norm[-k1 + q]^2)^2 + 3 Norm[k1]^2 (Norm[q]^2 + Norm[-k1 + q]^2))^2/(784 Norm[q]^4 Norm[-k1 + q]^4)      I would have wanted the answer to be given in the way I gave the functions $F2s$ - as a sum of fractions each of which is a product of powers of $q$, $k1$ and $\vert \vec{q} - \vec{k1}\vert$. How do I get that?


Can Map operations be compiled or otherwise sped up for large lists?

I'm performing a series of `Map` operations in the following script:               inputList = Table[RandomReal[100, {60, 2}], {i, 1, 10^3}];     scalingFactor = 10;     i = 1;     listX = Round[scalingFactor*Table[{inputList[[i, k]], # - inputList[[i, k]] & /@ inputList[[i]]}, {k, 1, Length[inputList[[i]]]}]];     i = 2;     listY = Round[scalingFactor*Table[{inputList[[i, k]], # - inputList[[i, k]] & /@ inputList[[i]]}, {k, 1, Length[inputList[[i]]]}]];          selectedIndices = RandomInteger[{1, 30}, {10^3, 2}];     pairList = {listX[[#[[1]], 1]], listY[[#[[2]], 1]]} & /@ selectedIndices;      The above code is mostly meant to illustrate the kind of `Map` operations I'm doing, however, a description of what's going on would be as follows: (1) We first generate `inputList`, which, at the outermost level, contains $10^3$ lists, each with $60$ pairs of real numbers (the pairs are of the form: `{RandomReal[{0,100}],RandomReal[{0,100}]}`). (2) `listX` and `listY`, computed in precisely the same way but for different lists in `inputList` (with indices $i = 1$ and $2$, respectively), generate $60$ two-element lists (one for each point in `inputList[[i]]`) that look like this:               listXexample = {{{440, 663}, {{0, 0}, {467, 333}, {376, -548}, {-178, -128}, {-254, -560}, {262, -533}, {-203, 202}, {63, -68}, {160, -604}, {382, -187}, {471, -162}, {-292, 336}, {-317, -196}, {-75, 253}, {-199, -125}, {-214, -543}, {246, -456}, {363, -455}, {-366, 235}, {-178, 309}, {211, 255}, {27, -360}, {495, -458}, {-34, -452}, <<12>>, {-259, -133}, {-232, 103}, {-375, -387}, {-98, -455}, {253, -548}, {233, -418}, {207, 245}, {367, -100}, {107, 19}, {419, -85}, {324, -526}, {465, -434}, {-342, -506}, {216, 35}, {452, 254}, {-252, 215}, {307, -110}, {-344, 277}, {387, -449}, {-62, -542}, {140, -78}, {-249, -49}, {-66, -425}, {-251, 175}}}, <<58>>, {<<1>>, {<<1>>}}};         The first element in each list, e.g. `{440, 663}` as above, represents a chosen element, and the second element represents a list of the differences between this chosen element and all other elements in inputList[[i]], e.g. `# - {440, 663}` in the above example. All values in these lists are then rounded, as shown. (3) `pairList` is computed by taking a (here random) set of integer indices of the form `{{20,40},{40,15},...}`, and then performing the mapping operation:               pairList = {listX[[#[[1]], 1]], listY[[#[[2]], 1]]} & /@ selectedIndices;      Where we `#[[1]]` and `#[[2]]` represents the first and second element, respectively, in a particular integer pair in `selectedIndices`. To simulate the script inputs, we're using the following randomly generated test values:               scalingFactor = 10;     inputList = Table[RandomReal[100, {60, 2}], {i, 1, 10^3}];     selectedIndices = RandomInteger[{1, 30}, {10^3, 2}];      As well as the $i = (1,2)$ values. * * * * * * * * * Is there a way to compile and speed up the sort of `Map` operations above? * * * Also, can anyone replicate my finding that changing:               inputList = Table[RandomReal[100, {50, 2}], {i, 1, 10^3}];      To:               inputList = Table[RandomReal[100, {100, 2}], {i, 1, 10^3}];      Counterintuitively halves the effective time to compute:               pairList = {listX[[#[[1]], 1]], listY[[#[[2]], 1]]} & /@ selectedIndices      Why would this happen? * * * * * * * * * Update: Running Mr. Wizard's reformulated code:               inputList = RandomReal[100, {1000, 60, 2}];     selectedIndices = RandomInteger[{1, 30}, {10^3, 2}];     scalingFactor = 10;          t1 = AbsoluteTime[];          i = 1;     listX = Round[scalingFactor*Table[{inputList[[i, k]], # - inputList[[i, k]] & /@ inputList[[i]]}, {k, 1, Length[inputList[[i]]]}]];     i = 2;     listY = Round[scalingFactor*Table[{inputList[[i, k]], # - inputList[[i, k]] & /@ inputList[[i]]}, {k, 1, Length[inputList[[i]]]}]];          myPairList = {listX[[#[[1]], 1]], listY[[#[[2]], 1]]} & /@ selectedIndices;                    t2 = AbsoluteTime[];          f1[m_] := With[{t = m\[Transpose]}, {m, Subtract[t, #]\[Transpose] & /@ m}\[Transpose]]          {listX, listY} = Round[scalingFactor * f1 /@ inputList[[{1, 2}]]];          pairList = {listX[[#, 1]], listY[[#2, 1]]}\[Transpose] & @@ (selectedIndices\[Transpose])               t3 = AbsoluteTime[];               myPairList == pairList      Outputs `True`. We can also note that the timing for my code vs. Mr. Wizard's               myTiming = t2 - t1     mrWizardTiming = t3 - t2      Is about $\approx 65$ milliseconds (me) and $\approx 3$ milliseconds (Mr. Wizard), respectively. Nicely done Mr. Wizard!


How to disable the small pop-up windows when mouse is over a Mathematica command in V10?

In version 10, when the mouse is over a Mathematica command, a small pop-up window comes up that one can click on for help on the command. Is there an option to disable this feature? Screen shot: ![Mathematica graphics](http://i.stack.imgur.com/CYLLQ.png) I tried number of options here, but no effect. It must be in the advanced perferences? But not sure what to look for. **Update:** Thanks to Martin answer below. These options can be changed permanently in advanced options ![Mathematica graphics](http://i.stack.imgur.com/nVmbF.png) I also turned off the "ShowCodeAssist" just in case ![Mathematica graphics](http://i.stack.imgur.com/crjVw.png)


How to get rid of Mathematica 10's help tooltips?

Since _Mathematica 10_ every time your mouse cursor appears above some function or even variable, an annoying tooltip appears offering help: ![enter image description here](http://i.stack.imgur.com/Agjlt.png) I've become quite used to _Mathematica_ now and I don't need these tooltips everywhere every second, and I can just as easily click the function and press `F1` to get help. I've tried almost every promising-looking option in `Edit->Preferences->Interface` page, but I couldn't remove these tooltips. So, how do I finally get rid of them?


FindRoot: getting number of iteration

I'm using FindRoot to solve a nonlinear system. I'd like to see what FindRoot is doing while computation, something like the _display_ option for Matlab _fsolve_. At the end of the day, I want the number of iterations and the residual at each step. Is there an option like that? I found this link, but if I use FindRootPlot the execution is 3 times slower, and since I'm using a vector input, it does not display any plot. My code:               SYS1[X_, U_?VectorQ, RHS_, fun_] := Module[...]          t1 = Timing[            U1 = UU /. Flatten[FindRoot[SYS1[XX, UU, F1, fun1] == 0, {UU, U0}]]        ];      or               << Optimization`UnconstrainedProblems`          t1 = Timing[            U1 = UU /. Flatten[FindRootPlot[SYS1[XX, UU, F1, fun1] == 0, {UU, U0}]]        ];      Thanks in advance for any suggestions. Petrus


Summation limits

The `Sum` is a built-in function in _Mathematica_ , so the summation limits must be assigned. What I need to know is how to use a value computed in a separate `Module` as a Sum upper limit.


Generating replacement rules programatically

I would like to generate sets of replacement rules programatically for predefining some permutations. So a function               MakeRule[cycles_List (* permute cycles *), n_Integer (* rule length *)]`      called as               MakeRule[{{2,3}}, 4]      will generate               {e1_, e2_, e3_, e4_} -> {e1, e3, e2, e4}      For the permutations, I have               Permute[l, Cycles[cycles]]      but I cannot find a way of generating the list of patterns. Something subscripted or indexed would be nice as per the example. I have tried:               1) Pattern[Subscript[e, 1], Blank[]]     2) Pattern[Symbol["e1"], Blank[]]     3) Pattern[e[[1]], Blank[]]      I have a feeling I am missing something obvious. Edit: Apologies for an oversight on my part. The second pattern example works correctly while the first and third do not. Thanks to all who responded.


Basins of Attraction

How does one shade the basin(s) of attraction of a phase plot in _Mathematica_? I have been trying to do this using the system $$\begin{align*} \dot x &= y\\\ \dot y &= -9\sin(x) - 0.20y \end{align*}$$ but I have gotten nowhere.


Manipulate not accepting default values

I have pasted my _Mathematica_ code below. For some reason, the default value for h, or Δx, while set to 4.5 in the code, keeps displaying at -4 instead. I have been over and over this example, and I don't understand why this is happening. If someone would be willing to help me to understand what is going on here and how to fix it, I would really appreciate it.               Manipulate[       f[x_] = 2.195^x - 1;       Grid[{         {Row[{Style[            Text["  approximation of the derivative f'(x) :  " <>               ToString[(f[a + h] - f[a])/h]], Green, 15]}]},         {Row[{Style[            Text["  derivative: f'(x) \[TildeTilde] " <>               ToString[D[f[x], x] /. x -> a]], Red, 15]}]},         {Plot[{f[x],              f[a] + (D[f[t], t] /. t -> a)*(x - a),              f[a] + ((f[a + h] - f[a])/h)*(x - a)},           {x, -0.5, 6.5},           PlotStyle -> {Blue, Red, Green},          PlotRange -> {{-0.5, 6.25}, {-50, 130}}, Axes -> True,           AxesOrigin -> {0, -50},           AxesLabel -> {"time (sec)", "distance (ft)"},          ImageSize -> 450,          Prolog -> {            {Line[{{a + h, f[a + h]}, {a, f[a + h]}}]},            {Line[{{a, f[a + h]}, {a, f[a]}}]},             {PointSize[.02], Blue, Point[{a, f[a]}]},            {Blue, Text["(x,f(x))", {a + .3, f[a] - 5}]},             {Text["Δx", {a + h/2, f[a + h] - 5}]},             {Text["f(x+Δx) - f(x)", {a + .6, f[a] - (f[a] - f[a + h])/2}]},             {PointSize[.02], Green, Point[{a + h, f[a + h]}]},             {Green, Text["(x+Δx,f(x+Δx))", {a + h - .4, f[a + h] + 7}]}}]}}],        {{a, 1, "x"}, 0, 6},       {{h, 4.5, "Δx"}, -a, 6 - a},       TrackedSymbols -> {a, a + h},       SaveDefinitions -> True]


How do I evaluate the terms in an expression, but not the expression itself?

I am trying to write a set of homework questions. I would like the output to evaluate the constants but not the sum, so that I may present the homework question as something like this: $$\sum_{n=1}^{340}(-4n^2-n+3)$$ Here's what I have:               c1 = RandomInteger[{-5, 5}];     c2 = RandomInteger[{-5, 5}];     c3 = RandomInteger[{-5, 5}];     c4 = RandomInteger[{1, 50}]*20     f[x_] := c1*x^2 + c2*x + c3      f[n]      (* 340        3 - n - 4 n^2 *)          Defer[Sum[f[n], {n, 1, c4}]]      $\sum _{n=1}^{\text{c4}} f(n)$ It seems like I am not using `Defer` correctly. How can I fix this?


Custom ticks failing with Frame

I know I can manipulate ticks:                Plot[PDF[NormalDistribution[0, 1.5], x], {x, -7, 7},         Ticks -> {{          {-6, "-6σ"}, {-5, "-5σ"}, {-4, "-4σ"}, {-3, "-3σ"}, {-2, "-2σ"}, {-1, "-σ"},           {1, "σ"}, {2, "2σ"}, {3, "3σ"}, {4, "4σ"}, {5, "5σ"}, {6, "6σ"}      }}]      But the ticks disappear when I add `Frame -> True`. What am I doing wrong?


How to set axes scale for Plot?

Well, maybe its a dumb question, but I can't find how to set axes scale factor for my `Plot`. For example, if I have x and y axes, I want to have 1 unit on the x axis same size as on the y axis.


What properties make this equation difficult to symbolically solve?

I tried to solve the following equation with Mathematica's solve:               Solve[K*(2*Tan[L/2*Sqrt[P/(EI)]]-L*Sqrt[P/(EI)])+4*P*Sqrt[P/(EI)] == 0, P]      It gave the following error:               Solve::nsmet: This system cannot be solved with the methods available to     Solve.      I do not see any strange functions being called here, and I am curious about what properties make this expression difficult for Mathematica.


Taking real and imaginary parts of indexed functions and speeding up ComplexExpand

I am setting up a large system of ODEs and in order to use the IDA method (which is sig. faster for my system and thus attractive), I must split my equations into real and imaginary parts. I am experiencing a severe bottleneck in taking real and imaginary parts of my functions, using `ComplexExpand`, and I suspect that this slowdown has to do with my inability to specify that the range of certain functions are real. A simple example is given below: Consider two tables, whose elements I would like to decompose into real and imaginary parts:               A1 = Table[ar[n]+I*ai[n], {n, 1, 500}];     A2 = Table[(n+I*n),{n,1,500}];      Now, to find the real part of, e.g., `A1.A1`, I would take               Re[ComplexExpand[A1.A1]];      The timing for these computations, however, is radically different. That is               Timing[Re[ComplexExpand[A1.A1]];]       > >     {0.203348, Null} >                 Timing[Re[ComplexExpand[A2.A2]];]       > >     {0.000585, Null} >   So we see there is a difference of around `400`! Intuitively, it would seem that if I can tell _Mathematica_ to treat `{ar[n],ai[n]}` as being functions with ranges over the reals, I can significantly improve the timing. Right now the `{ar[n],ai[n]}` are effectively constants, but in the future they might be functions. For the purpose of `ComplexExpand`, is it possible to have _Mathematica_ treat these objects simply as real constants? **Note:** For completeness, I add that the system of equations I am going to be decomposing, in terms of real and imaginary parts, will be a sum of maximum degree 4 polynomials in the variables `A[n][t]=Ar[n][t]+I*Ai[n][t]` where `n` is some index number on the dependent variables, which will take values between `1` and `N`(right now I have `N` at 40, but in the future it'll be something around `100` or `200`). For each equation, there are around `N+N^2` terms. For my governing equations, with `N=40`, this real/imaginary decomposition is taking around `3500` CPU seconds.


How to represent a continuous monotonic phase of Airy functions?

_Note: In this question I am concerned only with real-valued variables and functions._ * * * DLMF, §9.8 _Airy Functions, Modulus and Phase_, formula $9.8.4$ defines the phase of Airy functions: $$\theta(x)=\arctan\frac{\operatorname{Ai}x}{\operatorname{Bi}x}.$$ The corresponding _Mathematica_ definition is               θ[x_] := ArcTan[AiryAi[x]/AiryBi[x]]       Apparently, in this form the phase has a countable infinite number of jump discontinuities for negative values of $x$. I need to construct a _Mathematica_ expression that represents a continuous monotonic version of the phase $\theta(x)$ (let's name it $\vartheta$), where all pieces between discontinuities are properly shifted and stitched, as shown on the following graph: ![Phases](http://i.stack.imgur.com/7M8Uo.png) One approach would be to get the derivative of $\theta(x)$: $$\theta'(x)=-\frac1\pi\frac1{\operatorname{Ai}^2 x+\operatorname{Bi}^2 x},$$ so that all information about jumps is lost, and then consider the definite integral: $$\vartheta(x)=\frac1\pi\int_x^\infty\frac{dz}{\operatorname{Ai}^2 z+\operatorname{Bi}^2 z}.$$ Or, in _Mathematica_ notation:               1/π Integrate[1/(AiryAi[z]^2 + AiryBi[z]^2), {z, x, ∞}]      Unfortunately, _Mathematica_ leaves this integral unevaluated, even if an explicit value for the boundary $x$ is provided. > Is it possible to write a closed-form _Mathematica_ expression, possibly > containing special functions, that represents the continuous monotonic phase > $\vartheta(x)$?


How do I find the Euclidean distance between one point and all the points in a list?

I want to find the Euclidean distance between one point (x1) and a list of points (y1), which contains a lot of coordinates               x1 = killer[[2]]      > {6.05102, 5.87667}               y1 = victim[[2 ;;]]      > {{1.40687, 4.92494}, {0.419206, 1.70406}, {6.29657,0.577941}, {4.12022, > 4.94952},   >  {2.04784, 5.94545}, {1.29192,1.43152}, {3.26737, 1.90134}, {4.27274, > 0.528028},   >  {2.79659,1.37788}, {5.43955, 1.81355}} Is it possible for me to find the `EuclideanDistance` between x1 and y1, where it will show all results between x1 and each elements in y1.


Speed up Mathematica code involving Convolve

I'm trying to plot the averaged autocorrelation function of a random wire profile $\xi(x)$ which is build from unitsteps which are each L units long. To calculate the average I'm generating nMax realizations of the profile, then I proceed to calculate the autocorrelator $\langle \int_{-\infty}^{\infty} \xi(x)\xi(x-y)~dx \rangle$. Brackets indicate averaging over the `nMax` copies of the profile. My final goal is to plot this expression as a function of `y`. I started out by using both the built-in `Mean` and `Convolve` functions, however it is ridiculously slow on my machine (late 2007 MacBook). To give you an idea, it takes 150 seconds to calculate `corr[0]` alone (even with `nMax=1`). Is there anything I'm completely missing here? Or can someone of you even hint at a faster and more elegant approach to this?               L = 1.; (* step length *)     nMax = 1; (* number of realizations for averaging *)     nSteps = 1; (* number of modules in wire *)          (* define module *)     mod[x_] := UnitStep[x - L + 1.5]*UnitStep[L - x - 0.5]     (* define random profile *)       xi[x_] :=        Sum[RandomReal[{-0.5, 0.5}]*mod[x - n L], {n, -nSteps, nSteps}];     (* get nMax realizations of random profile *)     xiTmp[x_] = Table[xi[x], {n, 1, nMax}]     (* define correlator; normalized to corr[0]=1 *)     corr[y_]:=Table[Convolve[xiTmp[x][[n]], xiTmp[x][[n]], x, y]/      Convolve[xiTmp[x][[n]], xiTmp[x][[n]], x, 0], {n, 1, nMax}]     (* plot mean autocorrelator *)     Plot[Mean[corr[y]],{y,-5,5},PlotRange->All,Filling->Axis]


Elegant way to handle columns operations

Inspired by this question from @sjdh and by my recurrent use of columns operations in database sets, I was looking for one way to make columns operations more symetric, so I can handle with matrix and lists in a more clean way when working with this kind of data. For instance, I think it's not very practical to append a list data to a matrix using `Join[matA, {colA} // Transpose, 2]` or prepend using `Prepend[Transpose@matA, colA] // Transpose`. It's very clumsy, but we get used to it (I realized that teaching to a friend). I created this function called `colAppend`, that I would like to share here, and ask for performance tuning, tips on code organization and maybe another combinations of row operations that I have missed. Here are our test matrix and lists:               matA={{mA1,mA2},{mA3,mA4},{mA5,mA6}};     matB={{mB1,mB2},{mB3,mB4},{mB5,mB6}};     colA={cA1,cA2,cA3};     colB={cB1,cB2,cB3};      Now there are the function `colAppend` definitions. I separated it in 3 blocks: **1- Basic Join Operations**               colAppend[mat1_,mat2_]/;(Length@Dimensions@mat1>1&&Length@Dimensions@mat2>1):=         Join[mat1,mat2,2]          colAppend[mat1_,col1_,pos_:-1]/;(Length@Dimensions@mat1>1&&Length@Dimensions@col1==1):=         Insert[mat1//Transpose, col1, pos]//Transpose          colAppend[col1_,col2_]/;(Length@Dimensions@col1==1&&Length@Dimensions@col2==1):=         Transpose[{col1,col2}]          colAppend[col1_,mat1_,pos_:1]/;(Length@Dimensions@col1==1&&Length@Dimensions@mat1>1):=         Insert[mat1//Transpose, col1, pos]//Transpose          colAppend[colA,matA]//MatrixForm     colAppend[colA,colB]//MatrixForm     colAppend[matA,matB]//MatrixForm     colAppend[matA,colA]//MatrixForm      ![enter image description here](http://i.stack.imgur.com/ly1Vb.png) **2- Deleting Columns** Maybe it could be another function `colDelete`, so we could remove the `Null` parameter.               colAppend[mat1_,Null,pos_:-1]/;(Length@Dimensions@mat1>1):=     Module[{temp=mat1},         temp[[All,pos]]=Sequence[];         temp     ]          colAppend[Null,mat1_,pos_:1]/;(Length@Dimensions@mat1>1):=     Module[{temp=mat1},         temp[[All,pos]]=Sequence[];         temp     ]          colAppend[matA,Null]//MatrixForm     colAppend[Null,matA]//MatrixForm      ![enter image description here](http://i.stack.imgur.com/1ugcZ.png) **3- Join Multiple Elements** Combine all the above function (with except Null one)               colAppend::badargs = "Incompatible Dimensions";     colAppend[args__]:=Module[{list=List[args]},         If[\[Not]Equal@@(First@Dimensions@#&/@list),Return[Message[colAppend::badargs]]];         Fold[colAppend,First@list,Rest@list]     ]          MatrixForm@colAppend[matA,colA,matB,colB]      ![enter image description here](http://i.stack.imgur.com/UDeMc.png) What another functionality I'm missing? **What is the best way to create such function?** **Update 1** As VLC has posted in the comments. For part 3, this answer from @Mr.Wizard is the best option, not just in simplicity, but in performance too!               columnAttach2[ak__List]:=Replace[Unevaluated@Join[ak,2],v_?VectorQ:>{v}\[Transpose],1]


Integrating over Bessel Function erroreous? (Hankel Transform)

The Hankel Transform is given by               Integrate[f[x] x BesselJ[0,x t],{x,0,Infinity}]      It is self-inverse, so               Integrate[F[t] t BesselJ[0,x t],{t,0,Infinity}]      gives the back-transformation. I tried out a simple case:               Integrate[UnitBox[x/2] x BesselJ[0,x t],{x,0,Infinity}]      which promptly results in               BesselJ[1,t]/t      This is correct. However, if I do the back-transformation:               Integrate[BesselJ[1,t]/t t BesselJ[0,x t],{t,0,Infinity}]      the integration takes noticably longer (which is expected since the function oscillates) and the result is               ConditionalExpression[0,x>1]      While that single condition would be correct - UnitBox[x/2] == 0 for x>1 - the rest of the function won't show up. Is there any way to make the obviously missing parts show up? (I am not sure what tags to use. Please retag as appropriate) Related but not quite what I'm asking:   Hankel Transform integrals won't work in Mathematica   Strange result when integrating BesselJ functions


Incompleteness of FindInstance

I've been playing around with `Resolve` and `FindInstance`. I know that `Resolve` should always be decidable when the domain is `Reals` by Tarski's theorem, but I don't know about `FindInstance`. I tried using `FindInstance` to find a lower bound on the absolute value of a real number, but it didn't succeed.               (* First-order logic characterization of absolute value. a = |x|. *)     MyAbs[x_, a_] := (x > 0 \[Implies] a == x) ∧ (x <= 0 \[Implies] a == -x)          (* Returns True, so yes there is a lower bound. *)     Resolve[Exists[l, ForAll[{x, a}, (MyAbs[x, a]) \[Implies] a >= l]], Reals]          (* Returns True, so yes 0 is a lower bound. *)     Resolve[ForAll[{x, a}, (MyAbs[x, a]) \[Implies] a >= 0], Reals]          (* Returns {}, so Mathematica can't find a specific lower bound. *)     FindInstance[ForAll[{x, a}, (MyAbs[x, a]) \[Implies] a >= l], {l}, Reals]          (* Using the standard Abs also returns {} *)     FindInstance[ForAll[x, Abs[x] >= l], {l}, Reals]      Why is `FindInstance` not returning `{{l -> 0}}`?


Does anyone have experience with performing symbolic regression using Mathematica?

I understand that there is at least one Mathematica package, DataModeler commercially available for symbolic regression. I'm seeking any observations with this or any other similar tool. I'm interested in solving single input/single output as well as multi input/single output problems.


Generate a list of all user defined functions including their argument patterns

I have defined a bunch of functions over several different files, and I would like a list of prototypes of all the functions I have defined in my current session (I want the mathematica equivalent of the .h file for my .c file). For example, if I defined two functions,               f[arg1_, arg2_]:= Module[...];     g[t_]:= Module[...];      Then I would want the following list (alphabetized, of course):               f[arg1_, arg2_]     g[t_]      It would be nice if the list could be exported to a notebook or pdf for quick viewing. How can I accomplish this task?