Plotting 2D color function on the plane

Suppose `p` is a some point in the plane. The function `f[q]` defined as               f[q_]:= Block[{d = Norm[p-q]}, RGBColor[1 - d/(1 + d), 0, d/(1 + d)]]      Continuously colors points in the plane by thier distance from `p`. What is the easiest way to plot this in 2D? I tried DensityPlot but that's not exactly what I'm looking for. Basically I want to specify some color function for points in the plane and plot it. Contours would be a bonus. Apologies if this exact question has been asked before.


how to plot and animate an hyperbole?

I am an new user of _Mathematica_ and learning basics so please guide me I tried to use this code               Animate[Plot[x^2/a^2 - y^2/b^2 == 1, {x, 0, 2}, {y, 0, 2}],        {a, 1, 3},        {b, 1, 3}]      but I got this error message: > Plot::nonopt: Options expected (instead of {y,0,2}) beyond position 3 in > Plot[x^2/FE`a$$116^2-y^2/FE`b$$116^2==1,{x,0,2},{y,0,2}]. An option must be > a rule or a list of rules. >> All I want to do is to animate a hyperbole with its asymptotes.


?AspectRatio? setting to obtain equal length pr pixel on all axes

Like these does:               Show[Graphics[Rectangle[{2, 1}, {15, 2}]]]     ParametricPlot[{t,t t},{t,0,2}]      how do I create a `Plot[]` with axes having equal variable length pr. pixel? My first idea was               Show[ParametricPlot[{}, {t, 0, 1}], Plot[t, {t, 0, 1}]]      But that messes with the `PlotRange` and possibly more...


Plotting rainbow circle

I am trying to plot a parametric circle in rainbow colors. It should go round once, but I'd like to be able to make it go round the rainbow an arbitrary amount of times. I currently have:               ParametricPlot3D[{Sin[u] Sin[Theta], Cos[u] Sin[Theta],        Cos[Theta]} /. Theta -> Pi/6, {u, -Pi, Pi},        PlotStyle -> Directive[Thickness[.01]],        ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][(Arg[x + I y] + Pi)/(2 Pi)]]]      Which I think should choose a color from the `ColorData` named `Rainbow` (which changes only between 0 and 1 (the result of `Arg` lies between `-Pi` and `Pi`, so adding `Pi` and dividing the resulting interval by `2 Pi` will give me a number between 0 and 1) depending on the angle of the circle. I get an almost decent result if I divide by `Pi/2` instead of `2 Pi`: ![Nearly rainbow circle](http://i.stack.imgur.com/88y7i.png) But I have no idea why there is yellow and green twice. I'm certainly missing something, does anyone know what?


Plot a perfect looking circle using two functions, always look like an ellipse

I want to use the the following two functions to plot a perfect looking circle, but the graph always ends up looking a bit squashed. I've been playing with some of the parameters of the function but can't seem to get it to look right still. Here is the function:               Plot[{Sqrt[1 - x^2], -Sqrt[1 - x^2]}, {x, -2, 2}, PlotRange -> {-2, 2}]      Thanks for the help!


Indicating the axes

I want to scale the $x$ axis of the plot by $x^0$ and the $y$ axis by $\tan x$. Is this possible ?                Plot[Tan[x], {x, 0, 10}, PlotRange -> Automatic]      EDIT: Actually wanted to know that how to include the axes name like in the below picture mentioned by (x and y) and the curve whiched is defiend in the picture by $f(x)=x^2$? ![enter image description here](http://i.stack.imgur.com/qYMvu.gif)


Are plotting markers with inscribed letters possible?

I have large data consisting of values obtained by sweeping across three parameters (e, w, and f). I want to plot all this data on one graph using different shapes for e (e.g., circle, triangle, square, and diamond), different colors for w, and a letter inside the shape for f. So far I have               Jw1e1 = {{16, 832}, {32, 3150}, {64, 12237}, {128, 48212}};     J1 = ListLogPlot[Jw1e1, PlotMarkers -> (Style[Framed[H], Red]),        Frame -> True]     Jw1e3 = {{16, 826}, {32, 3127}, {64, 12145}, {128, 47851}};     J3 = ListLogPlot[Jw1e1, PlotMarkers -> (Style[Framed[H], Blue]),        Frame -> True]     Show[J1, J3]      I cannot figure out how have a square, circle, etc. appear as the specified shape by changing `Framed[H]`. If I replace `Framed[H]` by `Circle[]`, Circle[{0, 0}] appears on my plots and replacing by `Circle[H]`, `Circle[H]` appears.


Running a script Mathematica 9

I am working in a Linux machine.The name of my mathematica file is deres.nb Code:               a={};     AppendTo[a,1];     a>>"file"      Now, if I run this code, by simply evaluating the cell, there is no problem, I get the file saved in the directory I am working. But I want to run a script. Then I prepare my file by: 1.Cell -> Cell Properties-> Initialization Cell 2.I save the file with a .m extension(deres.m) 3.Format -> Style -> Code Now I run the script by writing in the terminal:   1. screen   2. math -script deres.m & Then I exit by writing "exit". The problem is that I do not get my file saved. This works perfectly for me in Mathematica 8. Any solution please? Thanks a bunch.


Partial differential equation with initial conditions

And so I want to solve the following equation, subject to these initial conditions: $\ u_{tt} - u_{xx} = 6u^5+(8+4a)u^3-(2+4a)u$ $\ u(0,x)=\tanh(x), u_t(0,x)=0$ When I use NDSolve to solve within the intervals $\ [0,10] \times [-5,5]$, I tried this as a code:               NDSolve[{D[u[t, x], t, t] - D[u[t, x], x, x] == 6 u[t, x]^5 + (8+4a) u[t, x]^3 - (2+4a) u[t, x], u[0, x] == Tanh[x], D[u[0, x], t] == 0}, u[t, x], {t, 0, 10}, {x, -5, 5}]      But Mathematica then returns the following line:               NDSolve::deqn: Equation or list of equations expected instead of True in the first argument      where the `True` affirmation seemingly refers to the second initial condition. What is it that I did wrong? Is there anything wrong with the code? Is there anything wrong with the problem?


How to read non-standard-format data into Mathematica from a file

I would like to read non-standard-format data into Mathematica from a file. How can this be achieved? For example, how can I read the following text file of data into Mathematica:               (8.675e-11+3.881e-11j) (7.775e-11+3.815e-11j) (0.675e-11+3.385e-11j)     (2.675e-11+3.889e-11j) (7.075e-11+3.835e-11j) (3.675e-11+3.815e-11j)     (0.675e-11+3.886e-11j) (7.975e-11+3.875e-11j) (7.675e-11+3.885e-11j)     (1.675e-11+3.828e-11j) (7.275e-11+3.185e-11j) (1.675e-11+3.805e-11j)      To explain, the first entry should be entered as the complex number $8.675 \times 10^{-11} + i (3.881 \times 10^{-11})$.


Nested NDSolves with functions

I am trying to solve a system of nested differential equations, and have attached my code below. The first section is some variable declarations, then I solve my first diffeq and store the solution to s. Then I make another function evaluated with that solution, and try to use it in another diffeq, but I get the error > "Computed derivatives do not have dimensionally consistent with the initial > conditions".               ClearAll["Global`*"];     falltime = 5*^-12;     Rd[t_] := 200000000000*E^(-t/falltime) + 1300;          Vc = 5; Va = -200; Rl = 220; Rs = 1000000; Ccs = 2*^-12; Cas = 2*^-12; Cac = 2*^-12;          eq1 = (Vc-V1[t])/Rl == (V1[t]-V2[t])/Rd[t] + Ccs*(V1'[t] - V2'[t]);     eq2 = Cac*(V1'[t]-V2'[t]) + (V1[t]-V2[t])/Rd[t] == (V2[t]-Va)/Rs + V2'[t];     eq3 = V2[0] == (Va*(Rd[0] + Rl) + Rs*Vc)/(Rd[0] + Rl + Rs);     eq4 = V1[0] == (Va*Rl + Vc (Rd[0] + Rs))/(Rd[0] + Rl + Rs);          s = NDSolve[{eq1, eq2, eq3, eq4}, {V1[t], V2[t]}, {t, 0, 100*^-9}];               IdRd[t_] := Evaluate[{(V1[t] - V2[t])/Rd[t]} /. s];  (* Current through Rd *)          qt = 10*^-9; \[Tau]q = .2*^-9; Lifetime1 = 50;          IdQuenched[t_] := IdRd[t]*(UnitStep[t] - (UnitStep[t - qt]*(1 - E^-((t - qt)/\[Tau]q))));          s1 = NDSolve[{n'[t] == (IdQuenched[t]/(1.602*^-19)) - (n[t]/(Lifetime1*1*^-9)),                    n[0] == 0.0000000000001},n[t], {t, 0, 1*^-6}]      I'm really not sure where to go from here and would appreciate any help.


C compilation not working with Visual Studio 2013

I'm running Mathematica 9 on a 64 bit Windows 8.1 laptop. I'm having no luck getting C compilation to work.               Needs["CCompilerDriver`"]          CCompilers[Full]     CCompilers[]       returns > >     {}   >     {} >   The package did load successfully, as `$Packages` shows `CCompilerDriver` entries and               $ContextPath//First      returns > >     "CCompilerDriver`" >   I have the following compilers installed:   * Microsoft Visual Studio Professional 2013   * Intel C++ Composer XE


Copy/paste of Interpretation to Latex fails, but works for InputText

As part of another issue, the following has come up. Create an `Interpretaion`:               Interpretation[Subscript[a, b], a[b]]      Select and copy the $a_b$ output from the notebook. If you paste it into a text file, you get: `a[b]`, which is correct as the `Inputform`, and what we want. However, if you select it and choose Copy as Latex, you get: `\text{$\$$CellContext$\grave{ }$a}(\text{$\$$CellContext$\grave{ }$b})` in a text file. I would like to be able to copy this and get the latex as $a_b$, or $a[b]$ as a worst case. Are there any tricks that could help here? (I don't think this has anything to do with subscripts)


Finding a certain invariant polynomial using matrix coordinates

Here's a math problem that I would like to solve. This is also my first time posting on the Mathematica stackexchange website so please excuse me if this looks messy. Let               a = {{a11, a12, a13}, {0, a22, a23}, {0, 0, a33}};     b = {{b11, b12, b13}, {0, b22, b23}, {0, 0, b33}};     c = {{c11, c12, c13}, {0, c22, c23}, {0, 0, c33}};     d = {{d11, d12, d13}, {0, d22, d23}, {0, 0, d33}};     r = {{r11, r12, r13}, {0, r22, r23}, {0, 0, r33}};     s = {{s11, s12, s13}, {0, s22, s23}, {0, 0, s33}};     u = {{1, u12, u13}, {0, 1, u23}, {0, 0, 1}};       Consider               MatrixForm[Expand[u.a.Inverse[u]]]     MatrixForm[Expand[u.b.Inverse[u]]]     MatrixForm[Expand[u.c.Inverse[u]]]     MatrixForm[Expand[u.d.Inverse[u]]]     MatrixForm[Expand[u.r.Inverse[u]]]     MatrixForm[Expand[u.s.Inverse[u]]]      I would like to find an invariant polynomial in the entries of $a,b,c,d,r$, and/or $s$ such that at least one of its monomials is divisible by the $(1,3)$-entry of $a,b,c,d,r$ and/or $s$. For example, consider the polynomial $(a11-a22)c12-(c11-c22)a12$. Then under the u-action, this polynomial becomes $(a11-a22)(c12 + (c22 - c11) u12) - (c11-c22)(a12 + (a22 - a11) u12)$, which simplifies to $(a11-a22)c12-(c11-c22)a12. So (a11-a22)c12-(c11-c22)a12$ is a polynomial in the entries of $a$ and $c$ such that at least one of its monomials is divisible by the $(1,2)$-entry of $a$ or $c$. By the way, I tried:               Simplify[(c11 - c33) (a13) - (a11 - a33) (c13) + c12 a23 - a12 c23 ]       by guessing and checking (which is not an invariant polynomial) but is there a systematic way to use mathematica to help me find such polynomials?


With/Function(/etc) replacement behaviour

Can anyone explain to me this behaviour? I've been having more than a couple of similar doubts these last weeks. For example               f[_?NumericQ] := 8;      Now, if I do               With[{a = f[a]}, HoldForm@Block[{NumericQ = True &}, a]]      I get               Block[{NumericQ = True &}, f[a]]      And if I do               Block[{NumericQ = True &}, f[a]]      I get               8      So far so good... Another so-far-so-goodie is (notice the `:=`)               With[{a := f[a]}, Block[{NumericQ = True &}, a]]          8      Question: Can anyone help me understand why this output?               With[{a = f[a]}, Block[{NumericQ = True &}, a]]          f[a]      Could it be that `With` (`=` version) not only evaluates and replaces, but also guarantees that the replaced expression won't be reevaluated no matter what until the `With` is exited? If that's the case I wasn't expecting that. What's happening here? **EDIT** Question also applies to Function               Block[{NumericQ = True &}, #] &[f[a]]          f[a]      And not just those too. Everything I try behaves the same way... A couple of other examples               Block @@ (Hold[{NumericQ = True &}, exp] /. exp -> f[a])          With[{a := Evaluate@f[a]}, Block[{NumericQ = True &}, a]]      both give `f[a]` **EDIT**               With[{g = h}, h = 8; Print[g] ]      prints 8, not h, so clearly h is reevaluated inside the `With` in this case, so `g` is not so constant. **EDIT** Ok, another couple of examples               In[10]:= ClearAll[h, f];     h := 8 /; NumericQ["a"];     f[_?NumericQ] := 8;      Now, both `h` and `f[a]` remain unevaluated               In[21]:= {h, f[a]}          Out[21]= {h, f[a]}      Now, with the `OwnValues` everything works as expected               In[17]:= With[{g = h},      Block[{NumericQ = True &}, g]]          Out[17]= 8      But with the `DownValues`, it doesn't               In[19]:= With[{g = f[a]},      Block[{NumericQ = True &}, g]]          Out[19]= f[a]      Similarly               f[a_?NumericQ] := 8;     g[e_] := Block[{NumericQ = True &}, e]      `f[a]` evaluates to `f[a]`, but weirdly               In[17]:= g[Unevaluated@f[a]]          Out[17]= 8          In[18]:= g[f[a]]          Out[18]= f[a]


Epilog->Text placement on LogLogPlot

Hopefully this is a simple question. I'm trying to overlay some text on top of a `LogLogPlot` using `Epilog` and `Text`. However, I'm struggling with the coordinates that `Text` seems to be using for placement. For example:               LogLogPlot[x + Sin[2x], {x, 1, 1000},       Epilog -> Style[Text["x+sin(2x)", {5, 5}], 14]]      places the label "x+sin(x)" at roughly {x,y}={150,150} on the plot's coordinate system, and not {5,5} as in the input. However, if I change the LogLogPlot to just Plot, the label will get placed at {5,5} (or wherever I specify). What's going on? How it looks right now: ![graph](http://i.stack.imgur.com/7FP4e.png)


How to use MathPSfrag package in Mathematica 10?

I am interested to use LaTeX like labels in the plots that I prepare in Mathematica, and hence, I downloaded the MathPSfrag package from this website http://wwwth.mpp.mpg.de/members/jgrosse/mathpsfrag/ . Since I cannot attach any file here, I request anyone who is interested to help me, to download the package and run the MathPsfrag-Test.nb notebook. I apologize if the manner in which I am asking the question violates any code of conduct, but since I am new to this group, and because there are multiple files involved with long codes, I am not entirely sure about how else to ask. This package has been tested only up to version 6, and I am using Mathematica 10 on Windows 7 machine. Unfortunately the package does not work, and I tried finding the problem and any solution to it myself, but without much success. Here is a summary of what I have found. After unzipping the contents on the package, I followed the instructions and tried running the MathPSfrag-Test.nb notebook line by line. First and foremost I realized that the Windows 7 has a space in their folder names like Program Files, where all programs are installed, and hence, I gave the absolute path to the GhostScript executable, after which the `MathPSfragConfigurationTest[]` was successful. After that I started executing the notebook step-by-step, and got stuck at the command:               CreatePSfragRules[HandleAutomaticPSfrag[exampleplot]][[1]]      I tried investigating a bit into MathPSfrag.m file, and found the following:   1. The Utilities`FilterOptions` is replaced by `FilterRules` in version 10. Hence, I replaced all the commands with `FilterOptions` functions with the `FilterRules` function, but with the right syntax.    2. Despite the above step, I get an error saying that `FilterRules` function needs two arguments. So I checked the `HandleAutomaticPSfrag` function defined in the package file, which is defined as `HandleAutomaticPSfrag[gr_Graphics,opts___Rule]:= ...` and realized that there is a `opts___` argument that denotes a `BlankNullSequence`. The `FilterRules` as an example is used within this function as as               FilterRules[opts, Options @ HandleAutomaticPSfrag]      By using the `HandleAutomaticPSfrag[exampleplot]` command in the Test notebook, there seem to be no opts provided as a second argument, and this is where I think the `FilterRules` gets stuck. However, if my explanation of the `opts___` above is correct, then I do not understand how the old versions of _Mathematica_ were able to run the package. This makes me feel that I am missing something obvious. Could someone please help me changing the package so that I can also use it with version 10? Thanks!


Non-linear curve fitting with multiple parameters and conditional expression

![Bloch-Gruneissen formula](http://i.stack.imgur.com/0xWbt.gif) The above integral(Bloch Gruneissen formula) is what i like to fit with my experimental data.I am new to Mathematica. To cross-check the fit results obtained in other software, I try to fit with my experimental data(Resistivity Vs Temperature) using this software. I make the integral analytical and then i get a conditional expression at the end..Following the steps as   1. mydata = ReadList["Sheet1.dat", Number, RecordLists -> True];               mydata={{50.3838, 0.241641}, {50.886, 0.242787}, {51.3245,      0.243584}, {51.8868, 0.244274}, {52.2609, 0.244107}, {52.6343,      0.245124}, {53.0692, 0.246065}, {53.5032, 0.246445}, {53.9364,      0.247621}, {54.3688, 0.248046}, {54.8004, 0.248783}, {55.2927,      0.250672}, {55.7226, 0.250763}, {56.2743, 0.252342}, {56.6414,      0.25238}, {57.069, 0.253314}, {57.5569, 0.25537}, {57.9831,      0.255082}, {58.4087, 0.256258}, {58.8943, 0.2577}, {59.3185,      0.25852}, {59.8026, 0.259537}, {60.2859, 0.26019}, {60.6479,      0.26129}, {61.0698, 0.261632}, {61.5512, 0.263006}, {61.972,      0.263711}, {62.5122, 0.264979}, {62.9319, 0.266193}, {63.411,      0.266641}, {63.8895, 0.267749}, {64.3675, 0.269039}, {64.8449,      0.269191}, {65.2623, 0.270026}, {65.7389, 0.271741}, {66.215,      0.272462}, {66.6311, 0.272994}, {67.0469, 0.274345}, {67.5216,      0.275073}, {68.0551, 0.276204}, {68.5287, 0.278656}, {69.0018,      0.278633}, {69.4153, 0.279194}, {69.9463, 0.280652}, {70.3589,      0.282094}, {70.8298, 0.283566}, {74.2852, 0.290996}, {74.8094,      0.292765}, {75.3909, 0.293334}, {75.9134, 0.294814}, {76.3192,      0.295664}, {76.7824, 0.297675}, {77.2449, 0.297858}, {77.7645,      0.2998}, {78.168, 0.30081}, {78.6285, 0.301432}, {79.0308,      0.302366}, {79.49, 0.304195}, {80.063, 0.304802}, {80.4062,      0.305925}, {80.9204, 0.307709}, {81.3196, 0.309075}, {81.8322,      0.310024}, {82.2302, 0.311481}, {82.798, 0.313166}, {83.1948,      0.314054}, {83.7042, 0.314616}, {84.1563, 0.316528}, {84.6077,      0.31709}, {85.0585, 0.318668}, {85.5649, 0.320665}, {86.0143,      0.321727}, {86.4631, 0.32307}, {86.9113, 0.32364}, {87.4148,      0.325545}, {87.9175, 0.327214}, {88.3637, 0.328072}, {88.865,      0.32918}, {89.2543, 0.330895}, {89.8098, 0.331563}, {90.1981,      0.332838}, {90.6413, 0.334113}, {91.084, 0.335449}, {91.6365,      0.336975}, {92.078, 0.338379}, {92.5188, 0.339601}, {92.9592,      0.340094}, {93.454, 0.34272}, {93.9481, 0.343244}, {94.3319,      0.344898}, {94.8796, 0.346136}, {95.4265, 0.347236}, {95.9181,      0.349156}, {96.3545, 0.34968}, {96.7904, 0.351076}, {97.2803,      0.352784}, {97.7695, 0.353778}, {98.1495, 0.355334}, {98.746,      0.356799}, {99.1793, 0.358082}, {99.612, 0.358826}, {100.098,      0.360404}, {100.53, 0.361558}}      2.Then making the integral analytical(B,C and Capital Theta are my desired parameters to be evaluated).... ![enter image description here](http://i.stack.imgur.com/PJ6st.png) 3.I will be happy if you can tell me where I go wrong and give me advice on this fitting![enter image description here](http://i.stack.imgur.com/pHP8G.png)


Making two lists which share part of its name, while its name is also an element of the list

I am stalled with the following problem: I want two lists, for example:               name={1,2,3}      and               namec={{1,2,3},{x,y,z},name}      The list "namec" is a list with extra information for internal use in a (non- comercial) package, while the List "name" is a vector shown to the user. The "name" inside the list has               Head[name]=String      I tried the following piece of code:                g = {1, 2, 3};      c = {x, y, z};      (ToExpression["Set[" <> # <> "c" <> ", {g,c," <> # <> "}]"];       ToExpression["Set[" <> # <> ", g]"]) &["name"];      the problem is that with the second assignment, the full list "name" replace the string "name" in the list "namec" (I know it could be a little confusing, this is counterintuitive to me). With the code above I get:                name={1,2,3}      and                namec={{1,2,3},{x,y,z},{1,2,3}}      Without the second assignment in the piece of code shown above, I get the list "namec" I want, however, the problem appears when I added the second assignment (name=g). Actually "name" is obtained interactively with an Input, but I simplified the code here. How can I solve this problem?, I suspect that I must use the Hold attribute but what I tried didn't work. Can somebody help me ? Just for reference the real piece of code is:               With[{symbol = Input["enter a new name"]},     nom = ToString[symbol];     ToExpression[     "Set[" <> ToString[symbol] <> "c" <> ", {g,c," <>      ToString[symbol] <> "}]"];     ToExpression["Set[" <> ToString[symbol] <> ", g]"];       (* finally I get the solution based on a suggestion of george2079 (I only modified the last line of his solution) :*)               In[68]:= name = InputString["enter symbol name"]     ToExpression[name <> "={1,2,3}"]     ToExpression[name <> "c" <> "={{1,2,3},{x,y,z},name}"]          Out[68]= "ju"          Out[69]= {1, 2, 3}          Out[70]= {{1, 2, 3}, {x, y, z}, "ju"}          In[71]:= ju          Out[71]= {1, 2, 3}          In[72]:= juc          Out[72]= {{1, 2, 3}, {x, y, z}, "ju"}


BarChart include multiple fields on x-axis

I want to chart data using a BarChart, the labels on the x-axis should consist of three values, however I can only use one of the values (the street name), where I would like to include the city and country name. The relevant piece of code:               rEntities = {{1261, "C/O C T Corporation System", "Boston",      "UNITED STATES"}, {1017, "C/O National Registered Agents, Inc.",      "New York", "UNITED STATES"}, {1004, "49, Avenue J.F. Kennedy",      "Luxembourg", "LUXEMBOURG"}, {799,      "C/O National Corporate Research, Ltd.", "Dover",      "UNITED STATES"}, {793, "C/O CT Corporation System", "Boston",      "UNITED STATES"}}          BarChart[#, ChartStyle -> "DarkRainbow",      PlotLabel -> Framed[Text[Grid[{         {Style["Entities with same address", Blue, FontSize -> 18]},         {Style["Address's with 200 to 6999 entities", Red,            FontSize -> 12]}}]]],      ChartLabels -> (Placed[       Rotate[Style[#, Black], Pi/3] & /@ #2, {{.7, 0}, {1, 1}}])] & @@     Transpose[rEntities]      ![only 1 field on x-axis](http://i.stack.imgur.com/omzTP.jpg) What I would like to see would be the city and country as well. For example: "C/O C T Corporation System, Boston, UNITED STATES" under the blue bar. "49, Avenue J.F. Kennedy, Luxembourg, LUXEMBOURG" under the olive bar, etc. Thank you in advance!


Most Efficient Way to Calculate the Product of All Items in a List?

Say that I have a list of returns on a financial asset over time and want to know the total compounded return. To get the answer, I need to add 1 to each return and then calculate the product of all of them. So, I'm looking for a function like `Total`, except that it computes the product. The `Product` function works, but seems clumsy and slower than my alternatives (at first, I was having trouble getting `Product` to work, so I wrote a few of my own functions). Here are the alternatives:               listProduct[x_List] := Exp[Total[Log[x]]];     listProduct2[x_List] := Last[FoldList[Times, 1, x]];     listProduct3[x_List] := Fold[Times, 1, x];     listProduct4[x_List] := Product[x[[i]], {i, 1, Length[x]}];      Those are in the order that I thought of them. A couple of surprising things: The first seems to be the fastest by quite a lot (though none are super slow). The slowest is the last one using `Product`, which I thought would be highly optimized and fast. Here are my tests:               s = RandomVariate[NormalDistribution[0.05, 0.1], 10^6];     listProduct[1 + s] - 1; // AbsoluteTiming     listProduct2[1 + s] - 1; // AbsoluteTiming     listProduct3[1 + s] - 1; // AbsoluteTiming     listProduct4[1 + s] - 1; // AbsoluteTiming      which produces these results:               {0.0312000, Null} {1.4820026, Null} {1.4040025, Null} {1.8252032, Null}      So, the question is: Is there a faster way, and am I missing some built-in function that would do this better? I won't be using lists this long, but I may be doing a lot of lists if I can get the rest of my idea implemented.


Showing the terms in a partial sum?

I am trying to get                  s[n_]:=Sum[1/2^k,{k,1,n}]      to show me the actual terms involved in the $n$th partial sum and not just the sum itself. I've tried `Expand`, `Apart`, etc. to no avail. Ideas? Edit based on early comments: Is it necessary to use `Table` to accomplish this rather than some algebraic command applied to `s[n]` or some option of `Sum`?


Derivative of the composition of two functions

Background, this seems to work (This is manually transcribed from the program, beware of errors):               J1[f_, i_] := DifferenceDelta[f[i], i]^2     D[J1[f + t v, i], t]      > >     2 (-v[i] + v[i+1]) (-(f + t v)[i] + (f + t v)[i+1]) >   What I would like to do is replace the `()^2` with a generic function `JJ`, and later specify               JJ[x_] := ...      Here's what happens with the generic `JJ`:               J2[f_, i_] := JJ[DifferenceDelta[f[i], i]]     D[J2[f + t v, i],t]      > >     0 >   Why can't it return a derivative expression in terms of a generic derivative `JJ'`, and how could I modify my code to make it work?


Make contour lines level with graph interval?

I am graphing the voltage traveling through some water with two electrodes. I have the graph with contour lines and all, but is there any way that I can get the contour lines to be at the tick marks along the Z axis? So, if every tick mark is 1volt, can I have contour lines at every integer voltage?![enter image description here](http://i.stack.imgur.com/EhhJ8.png)


Can I apply a ColorFunction to FaceGrids, or otherwise have FaceGrids with varying color?

I want to make a 3d plot with `FaceGrids` with a certain color scheme. Specifically, I'd like them to be one color below a diagonal line, and a different color above it. (So for example, on the `y=0` surface, I'd like the `FaceGrids` to be pink below `x=z`, and blue above `x=z`.) If I were coloring the plot itself, I'd define a `ColorFunction`, but it seems that `FaceGrids` doesn't take `ColorFunction` as an option. Here's an example of my best attempt:               Graphics3D[Cylinder[],       FaceGrids -> {{{0, -1,           0}, {{{-1/2, ColorFunction -> Function[{x, y, z}, Hue[z]]}, {0,             Green}, {1/2, Blue}}, {-1/3, {1/3,             Directive[Thick, Dashed]}}}}}]      Note that while the other gridlines have the properties assigned, the one with a `ColorFunction` is just gray. Is there any way to have varying colors on `FaceGrids`?


WholeCellGroupOpener and Hyperlinks

My problem is: I would like to activate WholeCellGroupOpener on a cell containing hyperlinks. But when I do that, the hyperlinks are no longer active. Is there a way to change the order of the two, so that 'Hyperlink' is activated before 'WholeCellGroupOpener'. More precisely: I want the cell group to collapse when I click anything but a hyperlink. Does anyone know a way to achieve that?


3D Plot of .txt File of the Surface Plotting Variety

I'm having a bit of trouble. I've seen other questions answered on here about how to 3D plot data from .txt files of the format:               x y z          x y z          x y z      Which works well with the `ListPointPlot` function. However, using that methodology seems to confuse poor _Mathematica_ when trying to do surface plotting of data that is in the format               ` y y y y y y y y y y y y y y          z x x x x x x x x x x x x x x          z x x x x x x x x x x x x x x          z x x x x x x x x x x x x x x       Where the ` is a place holder (just an empty space in my case). I've tried the manipulations that I know of or could find around the web, but those attempts end with errors being kicked back at me. How would I get _Mathematica_ to plot this .txt data?


complicated color function and color bar legend (summary of the results from previous relevant posts)

At first let me apologize. I should have read the policies of this forum before attempting a post. I was more accustomed to a moderated forum like MathGroup than such an active one like the StackExchange. Let me also thank from this position the following people that answering in my previous questions. **Szabolcs kguler eldo Chenminqi** I really hope that I did not forget anyone! So in order to say a thank to these people and summarize for future reference the results I made the current post. The codes are based to replies I recieved. I wish that this will make up for any incovenience I caused:-)! Let me state the problem now. I have the following list of parametric equations (of an ellipsoid)               lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};      I also have the following functions of (u,v)               dam = 3*Sqrt[2]*Sqrt[(Cos[u]^2*(409 - 391*Cos[2*u] + 1800*Cot[v]^2))/(109 -              91*Cos[2*u] + 450*Cot[v]^2)^2];       I want a parametric plot of `lst` according to the values of `dam`. I found the maximum value that `dam` can take.               Cases[Flatten[Table[{u, v, N[dam]}, {u, 0, 2*Pi, Pi/10}, {v, 0, Pi,          Pi/10}], 1], {a_, b_, c_ /; c > 1}]          FindMaximum[dam, {{u, Pi/10}, {v, Pi/2}}, WorkingPrecision -> 30]     maxDam = %[[1]]      Next, I define the color function               colFun = Function[{u, v},         Evaluate@Hue[Rescale[FullSimplify@dam, {0, maxDam}]]];      And now the plots.               g1 = ParametricPlot3D[lst, {u, 0, 2 π}, {v, 0, π}, Mesh -> False,        ColorFunction -> (colFun[#4, #5] &), ColorFunctionScaling -> False,        PlotPoints -> 100, ImageSize -> 800, ViewPoint -> {2, 2, 1}];          g2 = Plot3D[dam, {u, 0, 2 Pi}, {v, 0, Pi}, Mesh -> False,        ColorFunction -> colFun, ColorFunctionScaling -> False,        PlotRange -> All, PlotPoints -> 100, ImageSize -> 400];          Row[{Show[g1, ImageSize -> Large], Show[g2, ImageSize -> Medium]}]      At this point I have one question. See the extremities of the ellipsoid. There, after the purple color, comes the red and again (it seems to me) purple. Can anyone figure out what is going on? Now, regarding the color bar.               {min, max} = {0, maxDam};     ParametricPlot3D[lst, {u, 0, 2 π}, {v, 0, π}, Mesh -> False,       ColorFunction -> (colFun[#4, #5] &), ColorFunctionScaling -> False,       PlotPoints -> 100, ImageSize -> 800,       PlotLegends ->        BarLegend[{Hue, {min, max}}, ColorFunctionScaling -> True]]      I want now to see a different color scheme. I tried               coldata = ColorData["Gradients"];          col = Table[{i, coldata[[i]], ColorData[coldata[[i]]]}, {i, 51}];          Table[{min, max} = {0, maxDam};      lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};      colFun =        Function[{u, v}, Evaluate@col[[i, 3]][Rescale[dam, {0, maxDam}]]];      ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,        ColorFunction -> (colFun[#4, #5] &), ColorFunctionScaling -> False,        ImageSize -> 800,        PlotLegends -> BarLegend[{col[[i, 3]], {min, max}}]], {i, 51}]      Still, not satisfying with the coloring I tried the following function which I found here http://stackoverflow.com/questions/5753508/custom-colorfunction-colordata-in- arrayplot-and-similar-functions               jet[u_?NumericQ] :=       Blend[{{0, RGBColor[0, 0, 9/16]}, {1/9, Blue}, {23/63, Cyan}, {13/21,           Yellow}, {47/63, Orange}, {55/63, Red}, {1,           RGBColor[1/2, 0, 0]}}, u] /; 0 <= u <= maxDam          {min, max} = {0, maxDam};     lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};     colFun = Function[{u, v}, Evaluate@jet[Rescale[dam, {0, maxDam}]]];     h = ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,        ColorFunction -> (colFun[#4, #5] &), PlotPoints -> 100,        ColorFunctionScaling -> False, ImageSize -> 800,        PlotLegends -> BarLegend[{jet[#] &, {min, max}}]]      Now, the coloring scheme is great. But again it appears to exist the above mentioned problem with the extremities color rendering. Last but not least, is it possible to make a function like `jet` above according to combination of colors {green, yellow, orange, blue, red}? Dimitris


direct assignment to the element in a Table

I have already asked a related question here why set values in this way doesn't work? But I think I have to write the question which I encountered explicitly?               tmp = {1, 2, 3, 4, 5}     label[i_, p_] := i + p     test[p_] := Table[tmp[[label[i, p]]], {i, 1, 2}]      Here I defined a function `test` and the thing I want to is that change the values of list `tmp` via setting values to function `test`. While simply write               test[1]={111,222}      and expecting `tmp` will change to {1,111,222,3,4,5} is not possible. So how to achive this? I have tried many `Hold` things, but failed. Inspired by **andre**. I know that `Set` has attribute `HoldFirst`. So I tried `Evaluate`                Evaluate[test[1]]={111,222}      this won't work! I guess the problem is that I must properly Hold `label[i,p]` and `tmp[[]]` in the table. But I can't work it out. Anyone help?


Benefits of using Intellij IDEA as Mathematica IDE?

I use Intellij IDEA for Java programming, but have not really considered it for Mathematica. I saw a video with a Wolfram programmer who was describing it as "essential" for him, but from what I could gather of what he said, most of the benefits for him were either workgroup related (sharing code with other Wolfram programmers) or were doing things involving "internal" Mathematica code, not notebook code/problem solving. So, for a person doing normal Mathematica calculations and models in the science world, what, if any, are the significant benefits to using Intellij IDEA?


How can I get Mathematica to simplify my square root expression?

$$\sqrt{r^2 e^{4 \gamma (r)-4 \psi (r)}}$$ If I set               var = r^2*E^(4 \[Gamma][r] - 4 \[Psi][r])          Simplify[Sqrt[var], var > 0]      I just get $$\left| r\right| \sqrt{e^{4 \gamma (r)-4 \psi (r)}}$$ How to tell Mathematica to perform the full square root calculation? $$r e^{2 \gamma (r)-2 \psi (r)}$$


How to output a bat file and execute it?

I tried to write a bat file which helped me rename files. Command to do this in that file is "ren file1 file2" which is equivalent to RenameFile[file1,file2].               renameFiles[directory_, files_, rename_] :=      Module[{list, i = 1, newfiles},       SetDirectory[directory];       newfiles = ("ren " <> #) & /@ FileNames[files];       list = Table[         " " <> rename <> ToString[i] <> ".png", {i, 1, Length[newfiles]}];       While[i <= Length[newfiles],         newfiles[[i]] = newfiles[[i]] <> list[[i]]; i++];       Return[newfiles]       ]     a = renameFiles["E:\\Download Pictures", ___, "save"]     Export["E:\\Download Pictures\rename.txt", a]      The renameFiles[] has three arguments which take the path, files in that path and name I want to change to respectively, and then convert them into a list "ren file1 file2". Afterwards, I output it as a txt file. I tried to output it as a bat file, however it displays error after I do: `Export["E:\\Download Pictures\rename.bat", a]` Therefore, I attempt to do that in a different way, which renames "rename.txt" afterwards by doing: `RenameFiles["E:\\Download Pictures\rename.txt","E:\\Download Pictures\rename.bat"]` So, now, I have my "rename.bat" file. I try to use `SystemOpen["E:\\Download Pictures\rename.bat"]` to execute it. However, it cannot work well, and I have to do it by clicking the file. My questions are: 1. Sometimes I get the syntax: `OpenWrite::noopen: "Cannot open \!\(\"E:\\\\Download Pictures\\\\nename.txt\"\). "` , how can I fix this? 2\. Is this the only way I can output a bat file. 3\. and, how can I execute via MMA. Thanks a lot!


Using FunctionExpand to evaluate symbolic derivatives

Some symbolic derivatives of certain special function are not expanded automatically, but `FunctionExpand` often helps to get a derivative-free closed form expression.               Derivative[1, 0][BesselJ][0, 1]     (* Derivative[1, 0][BesselJ][0, 1] *)          FunctionExpand[%]     (* 1/2 π BesselY[0, x] *)      But for some functions it takes too much time to evaluate. Possibly, there is even an infinite loop. For example, I left the following expression to evaluate overnight, and it was still running in the morning without any result or messages.               FunctionExpand[Derivative[1, 0][StruveL][0, 1]]      * * *   * Is there a workaround that could get an expanded form the expression `Derivative[1, 0][StruveL][0, 1]` in reasonable time?   * Is there an infinite-loop bug in the implementation of `FunctionExpand` or I just have to wait longer for the results (weeks, months, ...)?   * Are there any public information about what approaches are used by `FunctionExpand` to expand derivatives?


problem solving coupled second order differential equations using Dsolve

I have three coupled second order ODE's given as below      $x''[t] = -c_1*y'[t]-c_2*z[t]-c_3$   $y''[t] = -c_4*x'[t]$   $z''[t] = \frac{c_5}{c_6}*x[t]-c_6$   where $c_i$'s are know constants. The boundary conditions are      $x[-1]=x[1]=y[-1]=y[1]=z'[-1]=z'[1]=0$. I followed the example given here How do I solve coupled ordinary differential equations?               {x, y, z} = {x, y, z} /.              Dsolve[{x''[t] == -c1*y'[t] - c2*z[t] - c3, y''[t] == -c4*x'[t],                z''[t] == -c5 + c5*x[t]/c6, x[-1] == 0, x[1] == 0, y[-1] == 0,                y[1] == 0, z'[-1] == 0, z'[1] == 0}, {x, y, z}, t] //             FullySimplify // First      I get the following output      > >     ReplaceAll::reps: {Dsolve[{x''[t] == -c3 - c2 z[t] - c1 y'[t], <<8>>}, > {x, y, z}, t]} >      is neither a list of replacement rules nor a valid dispatch table, and >      so cannot be used for replacing. >   >     Set::shape: Lists {x, y, z} and {x, y, z} /. Dsolve[{x''[t] == >     -c3 - c2 z[t] - c1 y'[t], <<8>>}, {x, y, z}, t] are not the same shape. >   > > Could someone please tell me what is wrong with my approach and please > suggest me how to solve this system.   >  Thank you for your time


Why do identifiers of the form ${\tt c}k\$nnn$ appear in the rules returned by my function?

I want to define a function, `PolynomialInterpolation` to find the coefficients of a polynomial interpolation function. My trial is as shown below:               PolynomialInterpolation[tb_, tf_, θb_, θf_, θbDot1_, θfDot1_, θbDot2_, θfDot2_] :=        Module[         {InterpolationResult, u, θ, θDot1, θDot2, c0, c1, c2, c3, c4, c5, PolynomialParameter},         θ[t_] := c0 + c1 t + c2 t^2 + c3 t^3 + c4 t^4 + c5 t^5;         θDot1[t_] := D[θ[u], u] /. u -> t;         θDot2[t_] := D[θ[u], {u, 2}] /. u -> t;         PolynomialParameter =            Solve[{             θ[tb] == θb,              θ[tf] == θf,              θDot1[tb] == θbDot1,              θDot1[tf] == θfDot1,             θDot2[tb] == θbDot2,              θDot2[tf] == θfDot2             },             {c0, c1, c2, c3, c4, c5}]       ]      However, when I use my function `PolynomialInterpolatio`, it returns:               PolynomialInterpolation[0, 5, 30, 75, 0, 0, 5, - 5]      > >     {{c0$698 -> 30, c1$698 -> 0, c2$698 -> 5/2, c3$698 -> 8/5, >       c4$698 -> -(29/50), c5$698 -> 29/625}} >   So my question is why does the result contain variables with `$` in their names?


Making Mathematica graphics exported as PDF "usable" performance wise

> **Possible Duplicate:**   >  Exporting graphics to PDF - huge file   >  Saner alternative to ContourPlot fill   >  How can all those tiny polygons generated by RegionPlot be joined into a > single FilledCurve? When exporting a 3D plot to PDF my viewer takes quite long to render the PDF, which especially makes for a very bad scrolling experience. I've also tried exporting as EPS, but that seems to be much worse, especially when trying to load the generated files in Illustrator (a simple graph took a minute to load and Illustrator needed 5Gb of memory for it...). I don't really want to include the graphics as rasterized images in my thesis :(


How to reduce the memory necessary for the image?

> **Possible Duplicate:**   >  Exporting graphics to PDF - huge file I have a figure that is created to use in a paper. Here it is:               h = 5.8;     a = 0.6;          pl3 = Plot3D[       If[x >= 2,           0.5*(-Tanh[2*(Sqrt[x^2 + y^2] - 5*(1 + x/Sqrt[x^2 + y^2 + 0.01]))] + 1),              0.5*(Tanh[If[y >= 0, a*x + h - y, y + a*x + h]] + 1)], {x, -15,              12},      {y, -10, 10}, PlotRange -> All, Ticks -> None,      PlotPoints -> 30,      AxesLabel -> {Style["x-Vt", 18, Italic, "TimesNewRoman"],      Style["y", 18, Italic, "TimesNewRoman"],      Style["\[Eta]", 18, Italic]},      ColorFunction -> Function[{x, y, z}, Hue[.65 (1 - z)]],      BoxRatios -> {1.7, 0.7, 0.4}, ViewPoint -> {1.81`, -3.52`, 1.642`}];     plX = Graphics3D[{Red, Thick,              Line[{Scaled[{0.868, 0.256, 0.5}], Scaled[{0.956, 0, 0.5}]}]}];     plY = Graphics3D[{Red, Thick,              Line[{Scaled[{0.865`, 0.269`, 0.5}],                Scaled[{0.972`, 0.494`, 0.5}]}]}];     txtX = Graphics3D[            Text[Style["x'", 24, Italic, Red, Bold], Scaled[{0.989`, 0, 0.5}]]];     txtY = Graphics3D[            Text[Style["y'", 24, Italic, Red, Bold],              Scaled[{0.979`, 0.633`, 0.5}]]];          fig1A = Show[{pl3, plX, plY, txtX, txtY}, ImageSize -> 350]      However, if I directly save the notebook containing this picture into the pdf format it appears to occupy too much memory. On the other hand, if I export the picture itself into say, jpg ot tiff or gif formats, the file size is OK. However, if I then import the obtained jpg, tiff or gif files into the notebook it appears that the image has dramatically lost its quality becoming unacceptable for the publication. One problem of this image is that it contains both the "useful" surface part that is on the front view and the one behind. The latter is useless, but is contained in the image file. Is there a way to decrease the memory used by such an image?


Place graph vertex labels in circles

Consider the following code:               vsh[{xc_, yc_}, name_, {w_, h_}] := {LightYellow,         Rectangle[{xc - w, yc - h}, {xc + w, yc + h}],         Inset[Style[Text[name], 14, Black, Bold], {xc, yc}]};     options =        Sequence[VertexSize -> 0.1, VertexShapeFunction -> vsh,         GraphLayout -> "CircularEmbedding", ImageSize -> 350,         EdgeStyle -> Blue];          g1 = Graph[{1 -> 2, 1 -> 3, 2 -> 4, 3 -> 4}, options];     g1      The output will be a simple graph with vertex labels depicted in rectangles (as can be inferred from `vsh`): ![Mathematica output](http://i.stack.imgur.com/TqTkf.png) My question is: how can I encapsulate the vertex labels in circles instead? Nothing I've tried seems to be working.


Checking from a preemptive evaluation whether a main evaluation is ongoing

How can I programmatically check from a preemptive evaluation whether a main evaluation is currently ongoing? I need a function `mainEvaluationOngoingQ[]` so that               Button["Evaluating?", Print@mainEvaluationOngoingQ[], Method -> "Preemptive"]      will print `True` only if a main evaluation is ongoing.


What is the purpose of tags like :Name:, :Context:, etc. in packages?

I noticed that all of the packages that come with Mathematica start with a header that is in a standard format. (See e.g. the header of `NIntegrateUtilities`` at the end.) There are several commented sections, each starting with a word surrounded by colons. **Question:** What is the purpose of these colon-surrounded words? Do they have any meaning to Mathematica? They look like they were made for a machine to parse. Does Mathematica have any functions/tools that can read these? > >     (* :Name: NIntegrateUtilities` *) >   >     (* :Title: Utility functions for NIntegrate. *) >   >     (* :Author: Anton Antonov *) >   >     (* :Summary: >      This package provides a number of supporting functions for NIntegrate. >     *) >   >     (* :Context: DifferentialEquations`NIntegrateUtilities` *) >   >     (* :Package Version: 1.0 *) >   >     (* :Copyright: Copyright 2007, Wolfram Research, Inc. *) >   >     (* :History: >      Version 1.0 by Anton Atnonov, March 2007. >     *) >   >     (* :Keywords: >      NIntegrate, integration, evaluations, profiling. >     *) >   >     (* :Source: >     *) >   >     (* :Mathematica Version: 6.0 *) >   >     (* :Limitation: >     *) >   >     (* :Discussion: >     *) >


Unable to evaluate reasonable max expression

Consider the following statement:               Max[0, Sqrt[1 - Cos[4 \[Theta]]]]      You'll find that Mathematica won't evaluate this, because it doesn't know the range of $\theta$. Okay, that makes sense, so change it to:               Simplify[Max[0, Sqrt[1 - Cos[4 \[Theta]]]], {0 <= \[Theta] <= 2 \[Pi]}]      This evaluates happily. As it should. But then consider this not-impactful adjustment:               Simplify[Max[0, Sqrt[1 - Cos[4 \[Theta]]]/       Sqrt[2]], {0 <= \[Theta] <= 2 \[Pi]}]      This doesn't evaluate. I don't know why; because it seems quite obvious that it should be exactly the same as the previous case, right? (The constant factor of `1/Sqrt[2]` can't change the fact that it is still $\geq 0$). Any thoughts on how to fix this? Of course, in my case I want to actually keep the `Max` ..., but I don't know the exact form of the other side, so I can't just arbitrarily remove constants ...


Approximate the largest and the smallest values of the integral

How do I solve this:approximate the largest and the smallest values of the integral ![enter image description here](http://i.stack.imgur.com/AWPK8.png) for ![enter image description here](http://i.stack.imgur.com/r8FuV.png)


How can I threshold for a minimum value with MatrixPlot?

Looking at the `Options` for `MatrixPlot`, there doesn't seem to be a mechanism for lowerbound threshold - i.e. ignoring values that fall below a certain cutoff. If my data set is very large, and I need a fast method of accomplishing this, would anyone have a recommendation?


Generating a table of contents

This is my oldest question on SO. It still hasn't generated a useful answer there, so I thought I'd give it a try here. The question was: I don't seem to be able to find the method to generate the table of contents for a Mathematica notebook. AuthorTools, an old v5.1 utility package is still hidden in Mathematica, but it doesn't work for me. The TOC should contain correct section numbers (if present in the stylesheet) and list page numbers (this requires taking page size settings into account).


> **Possible Duplicate:**   >  Generating a table of contents How to create a dynamically self-updating table of content for a notebook? The TOC should contain the titles for the section, subsection, subsubsection etc. and should self-update as the new sections are added, and existing ones changed. A "dynamic self-updating" part may be loosen from the question if it's too hard, i.e. a function that can be ran to generate a TOC which i can then manually copy.


Cannot solve equation

I just started using mathematica and I'm facing a problem that I just can't solve. I want to solve the following equation: ![enter image description here](http://i.stack.imgur.com/71VXO.jpg) Code:               eqn = {(ao)/((c*Exp[a*(n - o)/n]) (-Log[(c*Exp[a*(n - o)/n])] + Log[c] + a)^2) == m,             ao*1/2 < n};          Solve[eqn, n, Reals]      Program says ' This system cannot be solved with the methods available to Solve.' Can anybody help me with this?


What are the possible ways of visualizing a 4D function in Mathematica?

I have a function $F$ that maps the xyz space to a set of reals, more clearly: $c = F[x,y,z]$ Where $c$,$x$,$y$ and $z$ are reals. What are the possible ways of visualizing this 3d function in Mathematica? (if possible, please post a how-to-do-it)


Monitor doesn't work with ParallelTable

I can't monitor ParallelTable:               Monitor[ParallelTable[Pause[3]; i, {i, 1, 10}], i]      just displays `i` until it is finished. Do you guys know of alternatives?


How can I generate and color annular sectors?

![enter image description here](http://i.stack.imgur.com/9rU6Z.png) How can I generate such an image and fill every annular sector with a random colour?


Option Inspector -- option definitions

Relatively new to Mathematica, using v. 8.0.4.0 on OSX, and wanting to know where I can find something like a list of definitions for each of the many Global, Notebook, Cell, etc. options listed in the OptionsInspector. Some are fairly obvious, and I've come across the definitions of several others in my learning a little about the system. But I'd like to know how I can get the definition of any option in which I'm interested (at least a description of what that option does). If you know of such a source, I would appreciate you pointing it up to me. Thank you.


Exporting graphics to PDF results in destroyed fonts on Windows 8

Executing               plot = Plot[x^2, {x, 0, 100}, PlotLabel -> "Plot"];     SetDirectory[NotebookDirectory[]];     Export["plot.pdf", plot, "PDF"];      results in ![Distorted fonts](http://i.stack.imgur.com/Nvd7P.png) Is this a bug? OS is Windows 8, 64bit.


Some questions about Integral Equation

I am trying to solve the finite Hilbert transformation like the following form $ f(x)= \frac{1}{π} \int_{-1}^{1} \frac{g(y)}{(y-x)}dy $ the given function f(x)=1 and I want to solve the g(x) I know there is no direct way to solve the integral equation in Mathematica. Moreover, I found some boundary problems when solving it. Does anyone provide some useful tips?


Package autoloading not working in CDF and Player Pro

I have made a package                BeginPackage["top`"]      t[x_]:=MessageDialog["This is top"]      t1[x_]:=MessageDialog["This is top1"]      EndPackage[]      and used the code of this link and I am able to auto load packages in `Mathematica` and it is working fine. But when I have used it with `Player Pro`. It is not working. Automatically load packages at startup                initFileName = FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}];          (* Make a back-up *)      CopyFile[initFileName, initFileName <> "_" <>     StringReplace[ToString@Round[DateList[]], " " -> ""] <> ".bak"];     exprs = Import[initFileName, {"Package", "HeldExpressions"}];           Export[initFileName,        Append[exprs, HoldComplete[Needs["VectorAnalysis`"]]],          {"Package", "HeldExpressions"}       ]              Row[{Button["Click for function t", top`t[5]], Button["Click for f1", top`t[7]]}]      I have deployed the notebook in to `CDF Player`. But when I am opening the `CDF` by closing Mathematica and opening it with `CDF Player`, it is not working. I have also added that package in Autoload folder of Mathematica Player. What should I do so that my CDF or Player Pro also works fine as `Mathematica` notebook was working fine by autoloading packages at startup? I was getting this output in mathematica when I clicked at "click for function t".![enter image description here](http://i.stack.imgur.com/oiW7q.png) But I am not getting any output when I click on these two buttons in case of CDF or Player Pro.


How to find pixel position in a graph , given two points?

I have a graph where on my Y axis , I have price and on X axis I have period/time. My range on Y axis is from 10 (lower limit) to 200 (upper limit), so to draw the point on graph I need the Y position of the value for example if my price is 100.50 then how should I calculate Y position of this price . Example: If my upper limit point is (200,HeightOfGraph) that is P1, and the lower limit point is (0,0) is P2, so if height of graph is 100 so if the value is 100 it's y position will be 50 , but how should I calculate it , is there any formula to do this ?


How to create hedcut style images?

Yesterday the hedcut style was brought up in chat. How can we create a hedcut- like style automatically in Mathematica, using a photograph as a starting point? ![](http://i.stack.imgur.com/R3nUd.jpg) I am looking to create a similar artistic feel, not necessarily reproduce the hedcut style precisely. * * * Relevant resources:   * Hedcut-like effect in Photoshop   * A blog showing illustrations of this style   * Halftone, spiral cut/engraving, and 'pointillism' effects from the recent image vectorization question. All of these re-compose the image out of dots of varying size or lines of varying width. Sample portraits to work with: ![](http://i.stack.imgur.com/3LkNC.jpg) ![](http://i.stack.imgur.com/eQtVz.jpg) ![](http://i.stack.imgur.com/qaZpG.jpg) ![](http://i.stack.imgur.com/UZg4t.jpg) ![](http://i.stack.imgur.com/YajUp.jpg) @Silvia's idea from yesterday:               ImageDeconvolve[Import["http://www.alleba.com/blog/wp-content/photos/put001.jpg"],      GaussianMatrix[2.7], Method -> "TSVD"]      ![Mathematica graphics](http://i.stack.imgur.com/jPlBC.png) ![Mathematica graphics](http://i.stack.imgur.com/ITXL1.png) * * * My own failed first attempt (the part that detect line directions may be useful to people who work on answers): ![Mathematica graphics](http://i.stack.imgur.com/irocm.png) ![Mathematica graphics](http://i.stack.imgur.com/Iu8ig.png)               img = Import[       "http://www.stars-portraits.com/img/portraits/stars/j/jimi-hendrix/jimi-hendrix-by-BikerScout.jpg"]          (* "Real" images support negative numbers---for convenience *)          img = Image[ColorConvert[img, "GrayLevel"], "Real"];     img = ImageRotate[img, Right];          (* horizontal and vertical components of the gradient;        the direction can be computed using ArcTan *)     gv = ImageCorrelate[img, ( {          {0, -1, 0},          {0, 0, 0},          {0, 1, 0}         } )];     gh = ImageCorrelate[img, ( {          {0, 0, 0},          {1, 0, -1},          {0, 0, 0}         } )];          g = GradientFilter[img, 1];          (* verify the number of white pixels in Binarize[g] *)     Count[ImageData@Binarize[g], 1, Infinity]          (* create small strokes along the outlines *)     outline =       With[{point = RandomChoice[Position[ImageData@Binarize[g], 1], 1500]},       Graphics@MapThread[         Rotate[Disk[#1, {4, 1}], #2] &,         {point,          ArcTan @@@            Transpose[{Extract[ImageData[gh], point],              Extract[ImageData[gv], point]}]}         ]       ]               (* try to tone down plain grey/dark backgrounds *)     detail = ImageAdjust@       ImageAdd[img,         ImageMultiply[ColorNegate@ImageAdjust@EntropyFilter[img, 15], 2]]          coords = Outer[List, #2, #1] & @@ Range /@ ImageDimensions[img];          fill = With[{point =          RandomChoice[          Join @@ ImageData@ImageClip@ColorNegate[detail] ->            Join @@ coords, 5000]},       Graphics@MapThread[         Rotate[Disk[#1, {3, 0.8}], #2] &,         {point,          ArcTan @@@            Transpose[{Extract[ImageData[gh] + 10 $MachineEpsilon, point],              Extract[ImageData[gv], point]}]}         ]       ]          Show[fill, outline]      Note: I'm not fond of Putin, but his portrait I linked to seems to be easier to handle than some others. * * * **Update:** Second attempt, based on @Silvia's suggestion to try `ContourPlot` and wxffles's image vectorization approach. It's better, but still not achieving that feel. ![Mathematica graphics](http://i.stack.imgur.com/KsTuo.png)               img = Import["http://i.stack.imgur.com/YajUp.jpg"]          baseimg =        ColorConvert[ImageReflect@CurvatureFlowFilter[img], "GrayScale"];          (* Here we could simply use           ct=Table[p,{p,0,1,0.02}];           but the following approach gives a better balanced image *)          if = Interpolation[ImageLevels[baseimg]];          cif = Derivative[-1][if];          cifmax = cif[1];          f[x_] := cif[x]/cifmax          ct = Block[{x},       Table[        x /. First@FindRoot[f[x] == p, {x, 0.5, 0, 1}], {p, 0, 1, 0.02}]      ];          lcp = ListContourPlot[ImageData[baseimg], Frame -> False,        Contours -> ct,        ContourStyle -> (Dashing[{#, 1/50}] &) /@ ((1 - ct)/50),        PlotRange -> {0, 1}, AspectRatio -> Automatic,        ContourShading -> None]


eigenvector bug?

This bug was fixed in version 10.0.0 * * * I have a fairly simple $3\times3$ complex matrix, $$ M=\left( \begin{array}{ccc} \frac{7}{2}-\frac{i}{2} & -1+i & \frac{1}{2}+\frac{5 i}{2} \\\ -1+i & 5+i & -1+i \\\ \frac{1}{2}+\frac{5 i}{2} & -1+i & \frac{7}{2}-\frac{i}{2} \\\ \end{array} \right) $$ Solving for the eigenvalues and eigenvectors:               mat = {{7/2 - I/2, -1 + I, 1/2 + 5 I/2}, {-1 + I,          5 + I, -1 + I}, {1/2 + 5 I/2, -1 + I, 7/2 - I/2}};      {vals, vecs} = Eigensystem[mat]      gives (Mathematica 9.0.1) \begin{array}{ccc} 6 & 3+3 i & 3-3 i \\\ \\{1,-2,1\\} & \left\\{\frac{17}{13}+\frac{6 i}{13},0,1\right\\} & \\{-1,0,1\\} \\\ \end{array} But that 2nd eigenvector is not right; it should be $(1,1,1)$. Is there a bug, or am I being incredibly obtuse?


Timing Differences

In More efficient implementation for comparing coefficient lists in a Do-loop link, george2079 posts in his first answer a piece of code that takes 352 seconds to compute. When I run this same piece of code on my 2.3 GHz Intel Core i7 MacBook Pro laptop, it takes 853 seconds. What are the reasons for this, and how can I get the code running optimally on my machine? (Would it be appreciably faster if I used a desktop?) Perhaps this question is best posed to George2079, but the original thread is unfortunately dead and there doesn't seem to be a way to contact individual users.


A simple error with stochastic variables

f = Piecewise[{         {0.1, x == 1 && y == 1}, {0.1, x == 2 && y == 1}, {0.0,           x == 3 && y == 1}, {0.3, x == 1 && y == 2}, {0.1,           x == 2 && y == 2}, {0.2, x == 3 && y == 2}, {0.0,           x == 1 && y == 3}, {0.2, x == 2 && y == 3}, {0.1,           x == 3 && y == 3}, {0, True}}];     fi = ProbabilityDistribution[f, {x, 1, 3, 1}, {y, 1, 3, 1}];     Probability[      x <= 2 && y <= 2, {x \[Distributed] fi, y \[Distributed] fi}]      I am trying to compute this problem. The result I am looking for is 0.9


Make a huge vector in a wise way

I need to construct a vector similar to:               v[x_]:={0, 0, x, 0, 0, 2*x, 0, 0, 3*x, ....., 0, 0, n*x};      where `n=10^9`. How can I make such a vector wisely?


Plotting $\omega(k_x, k_z)$ in $(\omega, k)$ plane with assumption of $k^2 = k_x^2 + k_z^2$

I'm currently studying atmospheric-gravity waves and their dispersion relations. For analysis I need to plot the dispersion function: \begin{equation} \omega^4 - \omega^2\cdot C_s^2(k_x^2 + k_z^2 + \dfrac{1}{4H^2}) + (\gamma - 1)g^2\cdot k_x^2 = 0 \end{equation} where, $C_s^2$, $H$, $\gamma$ and $g$ are some constant values. I used `Solve` to get $\omega$ as a function of $k_x^2$ and $k_z^2$ - $\omega = \omega(k_x^2, k_z^2)$. Code for solving:                  Solve[\[Omega]^4 - \[Omega]^2*(Subscript[k, x]^2 +              Subscript[k, z]^2 + 1/(4*H^2)) + (\[Gamma] - 1)*g^2*Subscript[k, x]^2 == 0, \[Omega]]      What I want:               Plot[f, {k, 0, 20}]      where `f` is any solution of `Solve`. It plot nothing, because _Mathematica_ didn't know about $k^2 = k_x^2 + k_z^2$ relation.


Implement settable properties

I am looking for advice on implementing the following. (It is possible that the answer is that it is simply not a good idea to do this.) I would like to have an object similar to `FittedModel`. Let's call its head `Obj`. Like `FittedModel`, it will have properties, e.g.               properties = {42}; (* properties stored here for the sake of this toy example *)          Obj[id_]["Property"] := properties[[id]]      Now let's define `obj = Obj[1]` and evaluating `obj["Property"]` will yield `42`. I am looking to make it possible to do `obj["Property"] = 137` to _set_ this property. Here's an attempt that doesn't quite work (let's ignore `SetDelayed` for now and stick to `Set`):               Obj /: (Obj[id_]["Property"] = value_) := setObjProperty[id, value]          setObjProperty[id_, value_] := properties[[id]] = value      Now `Obj[1]["Property"] = 137` will work as I want it to. However, `obj["Property"] = 256` will not. Instead of changing the property, it will associate the following definition with `Obj`: `Obj[1]["Property"] = 256`. ![enter image description here](http://i.stack.imgur.com/HZwzn.png) **Question:** Is there a way to implement this syntax for property setting in a reliable way? I realize that this isn't exactly in the spirit of Mathematica objects being immutable. In my case `Obj` represents a data structure implemented in C++ and `id` is a handle to it. * * * Note the following behaviour of `=` and `:=`: ![enter image description here](http://i.stack.imgur.com/rkAwI.png) The head of the expression to be set is evaluated by `Set` (or `SetDelayed`). * * * `Graph` has settable properties which are handled through `SetProperty`, `PropertyValue`, etc. I find this syntax very tedious, so I was looking for something simpler. For my application having mutable state seems very natural, and I think it's not worth avoiding. I have a simulation that has a complex internal state, _not fully exposed to Mathematica_. The simulation can be stopped and resumed. Parameters can be adjusted when the simulation is stopped. I think (I may be wrong) that in order to work only with immutable objects, in the natural Mathematica way, it would be necessary to expose the full simulation state to Mathematica and to store it as a pure Mathematica expression (instead of data on the C side). I would then store the _full_ state as an `Association`, and have a function that runs the simulation and returns a new `Association` (simulation state), along with data collected during the simulation process. Associations would also give me this easy property-setting syntax for free. However, exposing the full state may not be worth all the extra work.


Plotting Uncertainty for a Sample of Functions

I am trying to produce a plot showing the variation in a sample of functions. It should look like this plot or that plot. I tried to use `SmoothDensityHistogram`. Even for the following simple example this does not look right. Do you have other suggestions? My approach so far was:               dx = 0.01;     functionSample =      Table[noise = Random[NormalDistribution[0, 0.5]];      Table[ {x, x (1 - x) + noise}, {x, 0, 1, dx}], {i, 1, 60}];     var = Flatten[diff, 1];     ListPlot[functionSample[[All, All]], Joined -> True]     SmoothDensityHistogram[var,      ColorFunction -> (Blend[{White, Black}, #] &)]      Producing ![ListPlot](http://i.stack.imgur.com/wgDiy.jpg)![SmoothDensityHistogram](http://i.stack.imgur.com/ishQV.jpg) Maybe things can be improved by choosing a small bandwidth of the kernel in x direction and a larger in y direction of the underlying kernel smoother.


Cheat sheets or reference cards for Mathematica

In order to improve my workflow with _Mathematica_ , I'm looking for _cheat sheets_. The purpose of such reference cards is to be printed and to stay on the desk during the learning of a new programming langage. They are _not_ extensive lists. It should be   * printable,   * readable at a glance. It may be   * general,   * or specific to a given task (algebra, analysis, style, ...) I found a first list of such cheat sheets for _Mathematica_ at devcheatsheet.com, with a special thumb up for this one at the Wolfram Library Archive. They might be unpractical (referring mostly for programming instead of shortcuts) or outdated (as they are mostly for version 5.2). Any suggestion? **Edit:** I am asking for good reference cards or cheat sheets. For a extensive list of all keyboard shortcuts, please refere to Wolfram's documentation. **Edit2:** This good cheatsheet for git is a good example of what I'm looking for. As you may see, the way information is chosen, sorted and put together has much importance in the process. It is very usefull for people that have already understood the syntax but not yet memorized it. It is a speedy and smart summary. It is also a tool for beginners to detect what is important. Please see also the example from Wolfram's archive I gave above. I would be surprised it is the only one out there.


Load Mathematica packages from the network

Is it possible to load packages (.m) directly from the network (http, https) without installing it locally?


How to save (large) data generated from simulations

The following is a simple example of a much larger simulation that I want to run Define some processes               norTheta[mu_, sigma_] := Random[NormalDistribution[mu, sigma]];     norPi[mu_, sigma_] := Random[NormalDistribution[mu, sigma]];          thetaNext[thetaNow_] :=      thetaNow + (-lambdaTheta*(thetaNow - thetaBar)*deltaT +      sigmaTheta*norTheta[0, 1]*Sqrt[deltaT]);     piNext[piNow_, thetaNow_] :=      piNow + (-lambdaPi*(piNow - thetaNow)*deltaT +      sigmaPi*norPi[0, 1]*Sqrt[deltaT]);      Then define some parameters               lambdaTheta = 0.07;     thetaBar = 0.02;          sigmaTheta = 0.012;      lambdaPi = 1.0;             sigmaPi = 0.0125;      Then simulate the system               steps = 252;     T = 50;      deltaT = 1/steps; // N      Maturity = T*steps;          process = Transpose[NestList[{  piNext[#[[1]], #[[2]]],     thetaNext[#[[2]]]} &,{0.02, 0.02}, Maturity]];      I have two questions: (1) what is the best MMA of repeating the above 10,000 at each loop saving the output 'process' for use later; (2) what is the fastest way of doing this? Many thanks, Paul


Plot roots of B(z) according to angle small to large

I have the following function:                  B[z_]=((z*(z - 0.5)*(z + 0.5))/((1 - 0.5*z)*(1+0.5*z)))      I want to plot the roots this polynomial according to angel like below the picture with Mathematica. ![enter image description here](http://i.stack.imgur.com/34lwM.png)


What is wrong with my use of Flatten?

Why does               Flatten[f[g[a, f[b]], f[c, d]]]      result in > >     f[g[a, f[b]], c, d] >   I expected the answer to be > >     f[g[a, b], c, d] >   What is wrong in this code?


SetAccuracy behavior

I'm puzzled by the output I get from `SetAccuracy`. According to the documentation, when `SetAccuracy` is used to increase the accuracy of a number, the number is padded with zeros. But, let's take a look at a couple of examples:               SetAccuracy[1.2, 5]     (* 1.2000 *)     SetAccuracy[1., 5]     (* 1.0000 *)     SetAccuracy[0.2, 5]     (* 0.2000 *)      These examples seem to work properly, so why does it behave differently in this case?               SetAccuracy[0., 5]     (* 0.*10^-5 *)      What should I do to get a zero with four trailing zeros? **Update** I'm asking this question, because I need to export data to a txt file and I would like to avoid having `0.*10^-5` sort of numbers.


Workaround for Import not supporting the \leqslant TeX macro

$\{A\leqslant x\leqslant B\}$      Copy the code into Notebook, and you'll lose the `less sign`, this can be rendered well in Mathematica.StackExchange $\\{A\leqslant x\leqslant B\\}$ * * * And you can also `ImportString["$\{A\\leqslant x\\leqslant B\\}$","TeX"]//CreateDocument`, Here is the problem, the `leqslant` was removed, are there any options of `ImportString` or are there any other methods to Import some latex codes without losing some information?


In LineLegend, how do I force the legend entries to appear in a single column?

I want to create a **_single_** column `LineLegend` with at least 12 different entries. Suppose that I define lists `colors` and `names` as follows:               colors = {Red, Magenta, Pink, Orange, Yellow, Green, Darker[Green],         Cyan, Blue, Purple, Black, Gray};     names = Table["Color " <> ToString[i], {i, 1, Length[colors]}];      If I use `colors[[;; 10]]` to show only the first 10 entries in `LineLegend` with `LegendLayout -> "Column"`, I get a nice single column `LineLegend`:               LineLegend[colors[[;; 10]], names, LegendLayout -> "Column",       LabelStyle -> {20, FontFamily -> "Arial"}]      ![singleColumn](http://i.stack.imgur.com/T8yxR.png) However, if I show 11 or more entries, the legends become double-columned:               LineLegend[colors[[;; 11]], names, LegendLayout -> "Column",       LabelStyle -> {20, FontFamily -> "Arial"}]      ![doubleColumn1](http://i.stack.imgur.com/BMQNK.png)               LineLegend[colors, names, LegendLayout -> "Column",       LabelStyle -> {20, FontFamily -> "Arial"}]      ![doubleColumn2](http://i.stack.imgur.com/lOUPx.png) How can I force `LineLegend` to put the legend entries in a single column?


How can I program my own financial indicator to be plotted in a TradingChart?

FinancialIndicator["ind",par1,par2,...], represents a financial indicator "ind" with parameters par1,par2, etc. All available financial indicators can be displayed with FinancialIndicator[]. Is it possible to program my own financial indicator and to plot it in a TradingChart ? How can I do it?


Simplifying a trigonometric expression

I'm sure this has been addressed before, but I can't find it! I want _Mathematica_ to simplify               Sqrt[1 - Sin[π/6 - θ]^2]      to               Cos[π/6 - θ]      Just as               PowerExpand[FullSimplify[Sqrt[1 - Sin[θ]^2]]]      Does what you would expect. Maybe the polite question would be how to transform               Sqrt[1 - Sin[π/6 - θ]^2]      to               Sqrt[Cos[π/6 - θ]^2]


Poisson solver using Mathematica

I am looking for some help with a Poisson solver I am writing in Mathematica. The code is quite long with Arrays plugged in, so the full details can be found at http://pastebin.com/uSrSDcW6 I am calculating voltages given charge densities using the central difference method derived from Poisson's equation. After calculating the voltage, I test the data set for convergence. I am setting convergence thresholds on the order of 10^-1000+. I have the loop set up to kick out after 10000 iterations in case something goes awry, as a fail safe. I have a loop counter in place for sanity. The program seems to run fine as long as the convergence threshold is set to 10^-10. My question is this: No matter what I update the threshold to, for example, 10^-100 or 10^-150, the computation stops after 633 iterations and kicks out of the loop. I would appreciate any help with this, I am completely stuck. I've added comments to the program that should be explanatory for anyone on this forum. * ** _Update 10/9/12_ **** I've narrowed my problem down to Machine Precision. I need to expand the Machine Precision to my Max Machine Precision of ~10^-309. How do I set this globally within my program when Im using 10x10x34 arrays initialized at ~15 digit precision?


NIntegrate using Boole doesn't work

This doesn't want to work for me - I don't know why not. It usually gives me `0`, but sometimes also a different number. I know it should be a small, non- zero number.               myO[e1_, e2_] := (e1)/((e1) + (e2));     myU[e1_, e2_] := (1 - e2)/((1 - e1) + (1 - e2));     myV[p_, e1_, e2_] := p (e1)/(p (e1) + (1 - p) (1 - e2));     myW[p_, e1_, e2_] := p (1 - e1)/(p (1 - e1) + (1 - p) e2);          NIntegrate[ Boole[0 < e1 < e2 < 1/2 && 0 < e3 < 1/2 && e1 < p < 1 - e1 &&                        e3 < myV[p, e1, e2] < 1 - e3 < myW[p, e1, e2] &&                        myO[e1, e2] < e3 < myU[e1, e2]],                       {p, 0, 1}, {e1, 0, 1/2}, {e2, 0, 1/2}, {e3, 0, 1/2}]


What is the right way to write a function that includes other functions?

I want to include multiple **sub functions** : $b(x) = 10x$ $w(x) = s + b(x)$ $c(x) = x^2$ into two **main functions** : $ua(x) = w(x)-c(x)$ $ub(x) = w(x)-c(x)^2$ As a reaction to this answer, I wrote the following in mathematica:               b[x_] := 10 x     w[b_, x_] := s + b[x]     c[x_] := x^2          ua[w_,b_,c_,x_] := w[b,x] - c[x]     ub[w_,b_,c_,x_] := w[b,x] - (c[x])^2      My intention is to have those main functions that can be called with just x values (e.g. Plot functions with x as the dependent variable) I want subfunctions building my main function **because** :   * Easier control of the sub functions   * Main function looks "cleaner"   * No code duplication **Q:** What is the right way to achieve the desired behavior?


Removing edge weights from a Graph

How can I remove `EdgeWeight`s from a `Graph` without affecting any other properties of the graph? Let's construct a graph with weights:               g = RandomGraph[{10, 20}, EdgeWeight -> ConstantArray[1, 20]]      Based on the documentation I would expect the following to return `Automatic` (the same thing it returns for a graph that has no edge weights):               PropertyValue[RemoveProperty[g, EdgeWeight], EdgeWeight]          (* ==> {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} *)      However, it returns the weights that were originally set. The following seems to work, but it removes other properties as well               PropertyValue[RemoveProperty[g], EdgeWeight]          (* ==> Automatic *)      Extracting the edges and vertices, then re-building the graph will discard other properties as well. `Graph` objects are atomic, and they don't have a Mathematica-expression form, so trying to modify them at the expression level is not a possibility either. **How can one then remove`EdgeWeight`s from a `Graph` without modifying any other properties of the `Graph`?** **Update:** It turns out `WeightedGraphQ@RemoveProperty[g]` still returns `True`. So even though the weight values are removed, the system still considers the graph to be weighted.


What is the most effective way to setup a Notebook with transparent background but solid contents?

I know there is a Notebook option `WindowOpacity` can be used to adjust the opacity of a whole notebook. But what I want is keeping the text and graphics and so on being `Opacity[1]` while the other parts of the window being `Opacity[0.3]`, which may look like (the pic is roughly produced by photoshop): ![enter image description here](http://i.stack.imgur.com/OoFhr.jpg) I guess this effect might be achieved by capture the screen prior and set it as the background of a Cell/Cells. But even if that is applicable, it must be very inefficiency. My questions are: how to achieve this transparent effect in Mathematica (maybe with some help from external applications)? and how to do it effectively?


Solve returns a wrong answer

I'm afraid the following is rather localized questions, but I don't know how to simplify and generalize it. I have the following two points (in the real plane):               p = {Sqrt[b y1^2 + 4 ϵ], y1}     q = {(3 b y1^2 + 12 ϵ + Sqrt[5] y1 Sqrt[b (b y1^2 + 4 ϵ)])/(2 Sqrt[b y1^2 + 4 ϵ]),           (3 b y1 + Sqrt[5] Sqrt[b (b y1^2 + 4 ϵ)])/(2 b)}      In particular, I have also the following assumptions:               $Assumptions = b > 0 && y1 ∈ Reals && ϵ > 0;      Then I try to solve the following:               Solve[p[[2]] == -q[[2]] && p[[1]] == q[[1]], y1]      and obtain the answer               {{y1 -> -(Sqrt[ϵ]/Sqrt[b])}, {y1 -> Sqrt[ϵ]/Sqrt[b]}}      However, one can easily test that the second answer is wrong:               In: {p, q} /. % // Simplify      returns: $\left\\{\left\\{\left\\{\sqrt{5} \sqrt{\epsilon },-\sqrt{\frac{\epsilon }{b}}\right\\},\left\\{\sqrt{5} \sqrt{\epsilon },\sqrt{\frac{\epsilon }{b}}\right\\}\right\\},\left\\{\left\\{\sqrt{5} \sqrt{\epsilon },\sqrt{\frac{\epsilon }{b}}\right\\},\left\\{2 \sqrt{5} \sqrt{\epsilon },\frac{4 \epsilon }{\sqrt{b \epsilon }}\right\\}\right\\}\right\\}$ What am I missing?


Can one use Map during Expand?

Can one `Map` a simplifying function to the summands of an `Expand` before fully expanding the expression in question first? Consider the following example: I want to integrate the following product over `[0,1]` in the variable `t`.               imax = 30;     p1 = Product[a t^i + b t^(imax - i) , {i, imax}];      For that I define a custom integration (much faster than the general Integrate)               CustomIntegration[exp_] := exp /. t^k_. -> 1/(k + 1)      for which I have to use `Expand` first. The problem is that the expansion really eats a ton of memory, even though the final result is actually much smaller.               ByteCount@p1     ByteCount[p2 = Expand@p1]     ByteCount[CustomIntegration /@ p2]      gives               9376     1404216     13696      So, the expansion requires around 100-times as much memory as needed. My actual script currently needs around 70 GB of memory. So, how could I reduce that?


How can I calculate a combination of limit and sum?

![enter image description here](http://i.stack.imgur.com/Ed7G5.jpg) How can I solve the above problem? I enter it as:               Limit[Sum[Sqrt[1 + i^2/n^2]/n, {i, n}], n -> Infinity]      but this is not working: ![enter image description here](http://i.stack.imgur.com/GWVw6.jpg)


Scoping inside of Module and Manipulate

This is driving me nuts: I'm trying to control the parameters for a relatively large system of ODEs using Manipulate.               With[{todo =       Module[        {sol, ode, timedur = 40},        ode = Evaluate[odes /. removeboundaries /. moieties];        sol = NDSolve[Join[ode, init], vars, {t, 0, timedur}];        Plot[Evaluate[c[1][t] /. parms] /. sol, {t, 0, timedur}]        ],      controls =        Sequence @@         Table[{{parms[[i]][[1]], parms[[i]][[2]]},           0, (3*parms[[i]][[2]])}, {i, 1, Length[parms]}]},     Manipulate[todo, controls, ContinuousAction -> False,       ControlPlacement -> Bottom]]      The solve step, in which sol is created, performs successfully. When trying to make a Plot from this however, I get all kinds of errors like               NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`      Although NDSolve runs fine when Plot is commented out! Note that this code relies on global variables defined elsewhere in the script. I should also add that the code inside the Module[] works when copied to a fresh cell. Could someone help me out? Thanks!!


how to simplify symbolic integration

The following is the code:                   In[3]:= Simplify[Integrate[f[x]*c, {x, a, b}]/c, Assumptions -> c > 0]              Integrate[c f[x], {x, a, b}]         ----------------------------                     c      but obviously the right answer should be:                   Integrate[f[x], {x, a, b}]      how to solve it without placing c outside the integrate function?


Strange behavior of MemberQ, Position

After importing an array of latitudes and longitudes and trying to find the position of some latitudes I was encountered with an unexpected problem since certain values could not be found for some reason. Position and MemberQ behave the same. Everything works just fine if converted to strings. I work with _Mathematica_ Version 9. Example:               r = Range[39.7026, 39.703, 0.0001];     r == {39.7026, 39.7027, 39.7028, 39.7029, 39.703}      > >     True >                 MemberQ[r, #] & /@ r      > >     {True, True, True, True, True} >                 MemberQ[r, #] & /@ {39.7026, 39.7027, 39.7028, 39.7029, 39.703}      > >     {True, True, False, True, True} >                 Position[r, #] & /@ r      > >     {{{1}}, {{2}}, {{3}}, {{4}}, {{5}}} >                 Position[r, #] & /@ {39.7026, 39.7027, 39.7028, 39.7029, 39.703}      > >     {{{1}}, {{2}}, {}, {{4}}, {{5}}} >   Out of the 1001 values of the following list rr, this problem is encountered with 17 of them               rr = Range[39.69, 39.79, 0.0001];      Notice the spacings of 30 Positions: > >     {{92}, {122}, {199}, {229}, {259}, {336}, {366}, {443}, {473}, >      {503}, {580}, {610}, {717}, {747}, {824}, {854}, {884}} >   Values: > >     {39.6891, 39.6921, 39.6998, 39.7028, 39.7058, 39.7135, 39.7165, 39.7242, > 39.7272, >      39.7302, 39.7379, 39.7409, 39.7516, 39.7546, 39.7623, 39.7653, 39.7683} >


HoldForm and RandomChoice

I'm trying to get random expressions displaying. For that, I'm starting with addition, multiplication, substraction and division. When trying out this code                HoldForm[c e d] /. c -> RandomInteger[{1, 15}] /.       d -> RandomInteger[{1, 15}] /.       e -> RandomChoice[{"-", "+", "/", "*"}]      , I sometimes get indeed expressions as "11 "+" 6" as expected, but I also get                14 "-"      or                "-" 9.      Why is that? Perhaps anyone has another idea for making randomised arithmetic expressions? Thanks, once again!


Can Mathematica determine part-of-speech for each word in a text?

I've found that `WordData` has a database of English words and their possible parts of speech. But some words are ambiguous, e.g. _result_ can be a verb or a noun:               In[7]:= WordData["result", "PartsOfSpeech"]     Out[7]= {"Noun", "Verb"}      Such cases can, however, be distinguished based on context. So my question is: can one use _Mathematica_ to perform parts-of-speech tagging of a text, either through built-in functions or as an extension? There are many known algorithms and implementations available, yet I have not been able to find a way to leverage them in Mathematica.


Export to Excel gives error for large lists

This is my data mwedata.dat I do this:               mwe = Import["mwedata.dat"];     dataforexcel20 = DeleteCases[mwe, a_ /; a[[3]] > 20];     dataforexcel80 = DeleteCases[mwe, a_ /; a[[3]] > 80];          Dimensions[dataforexcel80]     Dimensions[dataforexcel20]          {48011, 6}     {2384, 6}          Export["mwe20.xlsx", dataforexcel20]     "mwe20.xlsx"          Export["mwe80.xlsx", dataforexcel80]     $Failed      The Export works for the smaller file but not the larger file. The error message says               Export::fmterr: "Invalid \!\(\"XLS\"\) format. "      When I do this               Table[dataforexcel[k] = DeleteCases[mwe, a_ /; a[[3]] != k], {k, 1,100}];     Table[Export["mwetest.xlsx", dataforexcel[k]], {k, 1, 100}]      I get               {"mwetest.xlsx", "mwetest.xlsx", "mwetest.xlsx",   "mwetest.xlsx" ....}      and so on a 100 times. So there is nothing wrong with the data when `a[[3]]>20` In a unrelated question, when doing an `Export` inside the Table.. would it have been possible to index the excel files with `k`?                Table[Export["mwetest[k].xlsx", dataforexcel[k]], {k, 1, 100}]      Ok.. back to my earlier problem, I thought that excel could handle up to 65,000 rows. I'd appreciate some help in figuring out what I am doing wrong here or what can I do to fix my `Export` of a large file.


Data interpolation and ListContourPlot

I am fairly new to _Mathematica_ and I have two quick questions on using it for a Hydrology and Hydrogeology class. One is about data interpolation and interpolating without any data defined in an area. First question: I have a set of data:                   data = {           {875, 3375, 632}, {500, 4000, 634}, {2250, 1250, 654.2}, {3000, 875, 646.4},           {2560, 1187, 641.5}, {1000, 750, 650}, {2060, 1560, 634}, {3000, 1750, 643.3},           {2750, 2560, 639.4}, {1125, 2500, 630.1}, {875, 3125, 638}, {1000, 3375, 632.3},           {1060, 3500, 630.8}, {1250, 3625, 635.8}, {750, 3375, 625.6}, {560, 4125, 632},           {185, 3625, 624.2}                 }      where $x$ and $y$ are coordinates in space and $z$ is the elevation of bedrock underground. What I want to do is to have a "smooth" and not jagged contour plot. I created the following code which is extremely cumbersome and inefficient, but works:               ListContourPlot[data,       Contours -> Function[{min, max}, Range[min, max, 2]],       ColorFunction -> "TemperatureMap",       Epilog -> {PointSize[.015],         Point[{{875, 3375}, {500, 4000}, {2250, 1250}, {3000, 875}, {2560,            1187}, {1000, 750}, {2060, 1560}, {3000, 1750}, {2750,            2560}, {1125, 2500}, {875, 3125}, {1000, 3375}, {1060,            3500}, {1250, 3625}, {750, 3375}, {560, 4125}, {185, 3625}}],         Text[GB2, {875, 3450}], Text[GB4, {500, 4070}],         Text[220, {2250, 1330}], Text[221, {3000, 940}],         Text[222, {2560, 1250}], Text[223, {1050, 820}],         Text[224, {2060, 1630}], Text[225, {3000, 1810}],         Text[226, {2750, 2630}], Text[227, {1125, 2580}],         Text[10, {875, 3190}], Text[15, {1000, 3430}],         Text[16, {1100, 3550}], Text[17, {1250, 3700}],         Text[18, {750, 3455}], Text[20, {630, 4125}],         Text[21, {185, 3690}],         Text[Style[626.2, Bold, Medium], {390, 3590}],         Text[Style[628.2, Bold, Medium], {600, 3590}],         Text[Style[630.2, Bold, Medium], {800, 3590}],         Text[Style[632.2, Bold, Medium], {1000, 3640}],         Text[Style[634.2, Bold, Medium], {1200, 3375}],         Text[Style[636.2, Bold, Medium], {1500, 3390}],         Text[Style[638.2, Bold, Medium], {1301, 1669}],         Text[Style[640.2, Bold, Medium], {1301, 1469}],         Text[Style[642.2, Bold, Medium], {1301, 1269}],         Text[Style[644.2, Bold, Medium], {1301, 1100}],         Text[Style[646.2, Bold, Medium], {1160, 1000}],         Text[Style[648.2, Bold, Medium], {1470, 1000}],         Text[Style[650.2, Bold, Medium], {1500, 850}],         Text[Style[652.2, Bold, Medium], {2000, 1070}]}]      The `ListContourPlot` only uses a linear interpolation for the data. I tried adding in               InterpolationOrder -> 5      Any other order does not really change the contour lines. I had a problem using               ContourLabels -> All      ; otherwise I would not manually place text for labeling each contour and similarly for labeling each data point. My second question: The contour plot does not extend contours out past where points are interpolated (I think). ![contour plot](http://i.stack.imgur.com/ApUZR.png) Is there any way to continue these contour lines and extend them to the graph's boundaries? Normally, one would hand draw these contours and extend them. Thanks so much!


how to solve second order nonlinear coupled differential equations using NDSolve with hyperbolic function

i have to solve some solitons scattering through this coupled equations. i need to get two different graph, but still the graph did not come out. and also the equations quite complicated containing hyperbolic trigo . (maybe just for me). i dont know whether the problems come from the hyperbolic equations that i used, or becoz of initial condition.the coding as below:                   u = 0.05;         g = 0.2;         s = NDSolve[{x''[t] == 4/(\[Pi]^2 x[t]^3) - 10/(\[Pi]^2 x[t]^2) - (80 g)/(3 \[Pi]^2 x[t]^3) - ((6 u)/(\[Pi]^2 x[t]^2))[1/Cosh[y[t]/x[t]]^2 - (2 y[t])/x[t] Sinh[y[t]/x[t]]/Cosh[y[t]/x[t]]^3],        y''[t] == u (y[t]/(x[t]^3))[Sinh[y[t]/x[t]]/Cosh[y[t]/x[t]]^3],       x[1] == -3, x'[1] == 0, y[0] == 1, y'[0] == 3}, {x, y}, {t, 0,100}]     Plot[Evaluate[{x[t], y[t]} /. %], {t, 0, 100}, PlotRange -> All, PlotPoints -> 200]


What am I doing wrong when using DSolve

I'm trying to solve a simple PDE in _Mathematica_. I just can't get _Mathematica_ to give me an explicit analytical solution. This is the code that I made and it basically repeats in the output what I have given in the input. Below are my input and output. What am I doing wrong?               pde = D[u[z, t], {t, 1}] + const* D[u[z, t], {z, 2}] == 0     DSolve[pde, u[z, t], {z, t}]      > >     (u^(0,1))[z,t]+const (u^(2,0))[z,t]==0 >     DSolve[(u^(0,1))[z,t]+const (u^(2,0))[z,t]==0,u[z,t],{z,t}] >


Single image import from stack via FTP connection

**Background** I would like to create a `CDF` document that is embedded on a webpage. The `CDF` will contain some image display elements and upon pressing a button a specific image from an image stack will be displayed. The data will be located on a FTP server where the images are loaded from. Unfortunately, I cannot provide access to the FTP since it is protected with password. **The problem** To speed up the process of importing single images from a stack I came across the option `"ImageList"` for `Import`:               Import["R:\\...Largetest1.1.tif", {"ImageList", 5}]      which does exactly what I want. It directly imports only the fifth image of the image stack. My test stack here is located on a local hard drive and contains 101 images of image dimensions 600x1000 pixels. The file size is about 118 MB. I checked for `AsboluteTiming` when importing the single image from the stack compared to the complete import. Depending on the current CPU load the timings differ a little bit.               First@AbsoluteTiming@Import["R:\\...Largetest1.1.tif", {"ImageList", 5}]      > 0.060000               First@AbsoluteTiming@Import["R:\\...Largetest1.1.tif"][[5]]      > 2.426500 Since the `Import` option works fine for image stacks on the local hard drive I want to use the same option when importing the same image via `FTP`. Unfortunately, this takes like forever which suggests that it doesn't import only a single image but rather the complete stack and then takes out the fifth image:               First@AbsoluteTiming@Import["ftp://...Largetest1.1.tif", {"ImageList", 5}]      > 242.915000 When I import a single image via `FTP` it works quite fast:               First@AbsoluteTiming@Import["ftp://...5Largetest1.1.tif"]      > 0.120000 **Attemps** I then tried to find out what is happening and came across the function `ImageReadTIFF`. It seems to be possible to also specify import of a single image from a stack. However, the function fails when importing via `FTP`:               AbsoluteTiming@Image`ImportExportDump`ImageReadTIFF["R:\\...Largetest1.1.tif", {5}]      > {0.070000, {Image}}               AbsoluteTiming@Image`ImportExportDump`ImageReadTIFF["ftp://...Largetest1.1.tif", {5}]      > {0., {{$Failed, 1}}} **Edit** Unfortunately, this is also an issue when importing a single file from compressed archives such as `ZIP`. I tried to pack the single `TIFF` files from the above mentioned stack into a `ZIP` archive and then checked whether importing a single file works when the `ZIP` file is on my local hard drive and on the `FTP` server. The file size is reduced to about 36 MB upon compression compared to the 118 MB of the original image stack. First@AbsoluteTiming[Import["R:\ ... .zip", "Image5.tif"]] > 0.160000 First@AbsoluteTiming[Import["ftp://... .zip", "Image5.tif"]] > 23.970000 It still semms to download the complete `ZIP` file first and then accesses the image when importing from `FTP`. **Questions**   * Is there a fast way to import a single image form a stack via `FTP`? I mean, importing only one image of about 1 MB instead of importing the whole stack of 118 MB and then having to wait until the whole data is transferred.   * Is there a possible workaround I could use such that I do not have to import complete files or archives?   * Is it even possible to do such an import via `FTP`?  **No solution but** After talking to some guys who know more about `FTP` protocols, I learned that the `FTP` protocol doesn't allow such operations. It is indeed necessary to download the whole `ZIP`/`TIFF` file and then access single files within the file afterwards. Unfortunately, I will have to find another solution for that. Anyhow, thanks for comments and ideas.


Slow plotting of trigonometric functions

I have two sets of solutions for `a` and `b`. I'm plotting solution only if it is positive for both `a` and `b`.                a = 2; b = 3;      solutionsA[x_, a_, b_] = {a Sin[b*x], a Sin[b*x + Pi/2], a Sin[b*x + Pi]};      solutionsB[x_, a_, b_] = {a Tan[b*x], a Tan[b*x + Pi/2], a Tan[b*x + Pi]};      Plot[Select[         Transpose[           {solutionsA[x, a, b], solutionsB[x, a, b]}         ]        , (#[[1]] > 0 && #[[2]] > 0 ) &]      , {x, 0, 10}, Exclusions -> {Cos[b*x] == 0, Sin[b*x] == 0}]      My output is very slow. Why?


Mathematica cannot calculate a limit

When I evaluate               Limit[E^(-n)*Sum[n^k/(k!),{k,0,n}], n -> ∞]      _Mathematica_ gives me the result               Limit[Gamma[1 + n, n]/(n Gamma[n]), n -> ∞]      Actually, the answer is exactly 1/2. Is there any way to coax _Mathematica_ to find the limit?


Display truncation of numerical values when writing to a file

I am trying to copy some numerical values of parameters from a plain text file into Mathematica, then arranging them in a list and exporting them to another text file, with .ini extension. My problem is that I want the exact same precision for the output file, as the one I have in the input, but Mathematica is truncating the output, no matter what I do. I am aware of this question Annoying display truncation of numerical results, but the methods there are not working for me. This is what I am trying:               a = 70.3029753444001     70.303     bparam = 0.225980870923660     0.225981     paramlist = {aparam, bparam}      This is my exporting function:               exportText[parlist_,      name_] := (outtext = {"a = " <> ToString[parlist[[1]]],     "b = " <> ToString[parlist[[2]]]};     Export["./" <> ToString[name] <> ".ini", outtext, "Text"])      And now I export:               exportText[paramlist, "param1"]      The output in my param1.ini file is of course: a = 70.303   b = 0.225981 I cannot use:               SetOptions[InputNotebook[], PrintPrecision-> 10]      Because I want for each number I copy into Mathematica, the same precision in the output, and all parameters have different precisions. Also using NumberForm as was suggested to me in the other post, ruins my output:               exportText[NumberForm[#, {10, 7}] &@paramlist, "param1"]      The file looks like: a = {70.303, 0.225981}   b = {10, 7} And anyway this is not dynamical, for any number I copy into Mathematica. I tried to create a dynamical function:               setPrecisionOfNumber =      SetPrecision[#, Length[RealDigits[#][[1]]] - RealDigits[#][[2]]] &;      But then this adds extra zeros at the end, for example:               setPrecisionOfNumber@bparam     0.2259808709236600          setPrecisionOfNumber@0.2541     0.2541000000000000      So what is the solution you propose? I have of course tried things like `N[aparam,10]` but it doesn't work. And anyway I need it to be dynamical. I would be grateful for ideas on how to solve this. **EDIT** Using @billisphere solution, I changed my exportText function definition to:               exportText[parlist_,      name_] := (outtext = {"a = " <>      ToString[parlist[[1]], InputForm, NumberMarks -> False],     "b = " <> ToString[parlist[[2]], InputForm]};     stringfile = ExportString[outtext, "Text"];     Export["./" <> ToString[name] <> ".ini", outtext, "Text"])      I still want to understand certain things of number representation. As you can see, if I don't use `NumberMakrs->False`, I get for a number like:               bparam = 0.225980870923660011      The following prints in my file:               FilePrint["./param1.ini"]            a = 70.3029753444001     b = 0.225980870923660011`17.35407167806817      Using `NumberMakrs->False` also for the bparam, I get:               FilePrint["./param1.ini"]     a = 70.3029753444001     b = 0.225980870923660011      I still want to understand why there are still truncations, if I have a number like:               bparam = 0.22598087092366001      The printed file is then:               FilePrint["./param1.ini"]            a = 70.3029753444001     b = 0.22598087092366      So, the 001 at the end of bparam was truncated. If I add another 1 at the end of bparam, I don't get any truncation. I know these numbers are quite large with many decimal digits, and in the praxis I don't need this. But I want to be sure that my output is the same as my input in all cases.