m-11 ==== The new servers and new ISP are now installed and tested. Posts to the Mathematica newsgroup ==== it appears that yahoo does something with the lines, and the I copied and pasted for the NDsolve errors isn't properly formatted. I haven't been able to locate the problem. but I think its the problem. so here's goes nothing. let me know if you would like to see my notebook. i could send it as an attachment( which i think works better...) !(* RowBox[{ RowBox[{ RowBox[{odes, , =, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ SuperscriptBox[b, [Prime], MultilineFunction->None], [, t, ]}], ==, (v1 - d1 b[t] - bi k1 b[t] + k2 c[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[c, [Prime], MultilineFunction->None], [, t, ]}], ==, (bi k1 b[t] - k2 c[t] - k3 c[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[d, [Prime], MultilineFunction->None], [, t, ]}], ==, (k3 c[t] - k4 d[t] e[t] + k5 f[t] + k6 f[t] - k7 d[t] i[t] + k8 j[t] - k12 d[t] k[t] + k13 l[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[f, [Prime], MultilineFunction->None], [, t, ]}], ==, (k4 d[t] e[t] - k5 f[t] - k6 f[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[j, [Prime], MultilineFunction->None], [, t, ]}], ==, (k7 d[t] i[t] - k8 j[t] - k9 j[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[p, [Prime], MultilineFunction->None], [, t, ]}], ==, (v2 - d2 p[t] - k19 o[t] p[t] + k20 q[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[n, [Prime], MultilineFunction->None], [, t, ]}], ==, (v7 - d7 n[t] - k17 m[t] n[t] + k18 o[t] - k23 n[t] s[t] + k24 t[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[t, [Prime], MultilineFunction->None], [, t, ]}], ==, (k23 n[t] s[t] - k24 t[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[h, [Prime], MultilineFunction->None], [, t, ]}], ==, (v6 - d6 h[t] - k10 h[t] i[t] + k11 k[t] + k22 q[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[k, [Prime], MultilineFunction->None], [, t, ]}], ==, (k10 h[t] i[t] - k11 k[t] - k12 d[t] k[t] + k13 l[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[l, [Prime], MultilineFunction->None], [, t, ]}], ==, (k12 d[t] k[t] - k13 l[t] - k14 l[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[u, [Prime], MultilineFunction->None], [, t, ]}], ==, (v3 - d3 u[t] - k25 m[t] u[t] + k26 v[t] + k27 v[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[e, [Prime], MultilineFunction->None], [, t, ]}], ==, (v4 - d4 e[t] - k15 e[t] - k4 d[t] e[t] + k5 f[t] - k28 e[t] i[t] + k16 w[t] + k29 x[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[w, [Prime], MultilineFunction->None], [, t, ]}], ==, (k15 e[t] + k27 v[t] - k16 w[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[g, [Prime], MultilineFunction->None], [, t, ]}], ==, (k6 f[t] - k15 g[t] + k16 m[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[m, [Prime], MultilineFunction->None], [, t, ]}], ==, (k15 g[t] - k16 m[t] - k17 m[t] n[t] + k18 o[t] - k25 m[t] u[t] + k26 v[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[o, [Prime], MultilineFunction->None], [, t, ]}], ==, (k17 m[t] n[t] - k18 o[t] - k19 o[t] p[t] + k20 q[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[q, [Prime], MultilineFunction->None], [, t, ]}], ==, (k19 o[t] p[t] - k20 q[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[v, [Prime], MultilineFunction->None], [, t, ]}], ==, (k25 m[t] u[t] - k26 v[t] - k27 v[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[x, [Prime], MultilineFunction->None], [, t, ]}], ==, (k28 e[t] i[t] - k29 x[t] - k30 x[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[s, [Prime], MultilineFunction->None], [, t, ]}], ==, (v8 - d8 s[t] - k23 n[t] s[t] + k24 t[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[i, [Prime], MultilineFunction->None], [, t, ]}], ==, (v5 - d5 i[t] - k7 d[t] i[t] - k28 e[t] i[t] - k10 h[t] i[t] + k8 j[t] + k9 j[t] + k11 k[t] + k14 l[t] + k29 x[t] + k30 x[t])}], ,, RowBox[{ RowBox[{ SuperscriptBox[r, [Prime], MultilineFunction->None], [, t, ]}], ==, (k21 q[t])}]}], }}]}], ;}], [IndentingNewLine], [IndentingNewLine], (ics = {b[0] == v1/d1, p[0] == v2/d2, u[0] == v3/d3, w[0] == ((d5 k15 ((k29 + k30)) v4))/((k16 ((d4 d5 k29 + d4 d5 k30 + k28 k30 v5)))), t[0] == (k23 v7 v8)/(d7 d8 k24), k[0] == (k10 v5 v6)/(d5 d6 k11), x[0] == (k28 v4 v5)/(d4 d5 k29 + d4 d5 k30 + k28 k30 v5 ), n[0] == v7/d7, h[0] == v6/d6, s[0] == v8/d8, e[0] == (d5 ((k29 + k30)) v4)/(d4 d5 k29 + d4 d5 k30 + k28 k30 v5), i[0] == v5/d5, c[0] == 0, d[0] == 0, f[0] == 0, j[0] == 0, q[0] == 0, g[0] == 0, m[0] == 0, l[0] == 0, o[0] == 0, v[0] == 0, r[0] == 0};), [IndentingNewLine], [IndentingNewLine], (vars = {b[t], c[t], d[t], f[t], j[t], p[t], n[t], t[t], h[t], k[t], l[t], u[t], e[t], w[t], g[t], m[t], o[t], q[t], v[t], x[t], s[t], i[t], r[t]};), [IndentingNewLine], [IndentingNewLine], (For[ ii = 1, ii < 5, [IndentingNewLine]np = {k1 -> ((Random[ Real, {1, 10}]))* 10^ ((Random[Integer, {4, 8}])), k2 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-7), (-4)}])), [IndentingNewLine]k3 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {1, 3}])), k4 -> ((Random[Real, {1, 10}])) * 10^ ((Random[ Integer, {5, 8}])), [IndentingNewLine]k5 -> ((Random[ Real, {1, 10}]))*10^ ((Random[ Integer, {(-4), (-1)}])), k6 -> ((Random[Real, {1, 10}])) * 10^ ((Random[ Integer, {1, 2}])) , [IndentingNewLine]k7 -> ((Random[ Real, {1, 10}])) * 10^ ((Random[Integer, {1, 3}])) , k8 -> ((Random[Real, {1, 10}])) * 10^((Random[ Integer, {(-7), (-4)}])), [IndentingNewLine]k9 -> ((Random[Real, {19, 10}]))* 10^((Random[Integer, {(-6), (-3)}])), k10 -> ((Random[Real, {1, 10}])) * 10^ ((Random[ Integer, {1, 3}])), [IndentingNewLine]k11 -> ((Random[ Real, {1, 10}])) * 10^((Random[Integer, {(-7), (-4)}])), k12 -> ((Random[Real, {1, 10}])) * 10^ ((Random[ Integer, {1, 3}])), [IndentingNewLine]k13 -> ((Random[ Real, {1, 10}])) * 10^((Random[Integer, {(-7), (-4)}])), k14 -> ((Random[Real, {1, 10}]))* 10^((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]k15 -> ((Random[Real, {1, 10}]))* 10^ ((Random[Integer, {(-4), (-1)}])), k16 -> ((Random[Real, {1, 10}]))* 10^ ((Random[Integer, {(-4), (-1)}])), k17 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {2, 5}])) , k18 -> ((Random[Real, {1, 10}])) * 10^ ((Random[ Integer, {(-7), (-4)}])) , [IndentingNewLine]k19 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {3, 6}])) , k20 -> ((Random[Real, {1, 10}])) * 10^((Random[ Integer, {(-8), (-5)}])) , [IndentingNewLine]k21 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {1, 3}])), k22 -> ((Random[Real, {1, 10}])) * 10^((Random[ Integer, {1, 3}])), [IndentingNewLine]k23 -> ((Random[ Real, {1, 10}])) * 10^ ((Random[Integer, {3, 6}])) , k24 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {(-7), (-4)}])) , k25 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {3, 6}])), k26 -> ((Random[Real, {1, 10}])) * 10^ ((Random[ Integer, {(-7), (-5)}])) , [IndentingNewLine]k27 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {1, 4}])) , k28 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {1, 3}])), k29 -> ((Random[Real, {1, 10}])) * 10^ ((Random[Integer, {(-7), (-4)}])), k30 -> ((Random[Real, {1, 10}]))* 10^ ((Random[Integer, {(-6), (-3)}])), v1 -> ((Random[Real, {1, 10}]))* 10^ ((Random[Integer, {(-12), (-9)}])), d1 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]v2 -> ((Random[Real, {1, 10}]))* 10^ ((Random[Integer, {(-10), (-8)}])), d2 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]v3 -> ((Random[Real, {1, 10}]))* 10^((Random[Integer, {(-11), (-8)}])), d3 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]v4 -> ((Random[Real, {1, 10}]))* 10^ ((Random[Integer, {(-10), (-8)}])), d4 -> ((Random[Real, {1, 10}]))* 10^ ((Random[Integer, {(-6), (-3)}])), v5 -> ((Random[Real, {1, 10}]))* 10^((Random[Integer, {(-10), (-8)}])), d5 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]v6 -> ((Random[Real, {1, 10}]))* 10^((Random[Integer, {(-10), (-8)}])), d6 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]v7 -> ((Random[Real, {1, 10}]))* 10^((Random[Integer, {(-10), (-8)}])), d7 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]v8 -> ((Random[Real, {1, 10}]))* 10^((Random[Integer, {(-10), (-8)}])), d8 -> ((Random[Real, {1, 10}]))* 10^ ((Random[ Integer, {(-6), (-3)}])), [IndentingNewLine]bi -> ((Random[Real, {1, 10}])) * 10^ ((Random[ Integer, {(-10), (-5)}]))}; [IndentingNewLine] [IndentingNewLine]nics = ics /. np; [IndentingNewLine]nodes = odes /. np; [IndentingNewLine]Join[nodes, nics]; [IndentingNewLine]Print[< iteration = >, ii , np, nics ]; [IndentingNewLine][IndentingNewLine]soln = NDSolve[ Join[nodes, nics], vars, {t, 0, 100000}, MaxSteps -> 1000000]; [IndentingNewLine][IndentingNewLine]pb = Plot[Evaluate[b[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> b, DisplayFunction -> Identity]; [IndentingNewLine]pc = Plot[ Evaluate[c[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> c, DisplayFunction -> Identity]; [IndentingNewLine]pd = Plot[Evaluate[c[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> d, DisplayFunction -> Identity]; [IndentingNewLine]pf = Plot[Evaluate[f[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> f, DisplayFunction -> Identity]; [IndentingNewLine]pj = Plot[Evaluate[j[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> j, DisplayFunction -> Identity]; [IndentingNewLine]pp = Plot[Evaluate[p[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> p, DisplayFunction -> Identity]; [IndentingNewLine]pn = Plot[Evaluate[n[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> n, DisplayFunction -> Identity]; [IndentingNewLine]pt = Plot[Evaluate[t[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> t, DisplayFunction -> Identity]; [IndentingNewLine]ph = Plot[Evaluate[h[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> h, DisplayFunction -> Identity]; [IndentingNewLine]pk = Plot[Evaluate[k[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> k, DisplayFunction -> Identity]; [IndentingNewLine]pl = Plot[Evaluate[l[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> l, DisplayFunction -> Identity]; [IndentingNewLine]pu = Plot[Evaluate[u[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> u, DisplayFunction -> Identity]; [IndentingNewLine]pe = Plot[Evaluate[e[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> e, DisplayFunction -> Identity]; [IndentingNewLine]pw = Plot[Evaluate[w[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> w, DisplayFunction -> Identity]; [IndentingNewLine]pg = Plot[Evaluate[g[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> g, DisplayFunction -> Identity]; [IndentingNewLine]pm = Plot[Evaluate[m[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> m, DisplayFunction -> Identity]; [IndentingNewLine]po = Plot[Evaluate[o[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> o, DisplayFunction -> Identity]; [IndentingNewLine]pq = Plot[Evaluate[q[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> q, DisplayFunction -> Identity]; [IndentingNewLine]pv = Plot[Evaluate[v[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> v, DisplayFunction -> Identity]; [IndentingNewLine]px = Plot[Evaluate[x[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> x, DisplayFunction -> Identity]; [IndentingNewLine]ps = Plot[Evaluate[s[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> s, DisplayFunction -> Identity]; [IndentingNewLine]pi = Plot[Evaluate[i[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> i, DisplayFunction -> Identity]; [IndentingNewLine]pr = Plot[Evaluate[r[t] /. soln], {t, 0, 100000}, PlotRange -> Automatic, PlotLabel -> r, DisplayFunction -> Identity]; [IndentingNewLine][IndentingNewLine]Show[ GraphicsArray[{{pb, pc, pd, pf}, { pj, pp, pn, pt}, {ph, pk, pl, pu}, {pe , pw , pg, pm}, {po , pq , pv , px} , {ps, pi, pr }}, ImageSize -> 750]]; [IndentingNewLine][IndentingNewLine]Share[]; [IndentingNewLine](ii++)])}]) ===== when riding a dead horse, some dismount. while others... write memoirs on the subject of riding a dead horse. __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com ==== if Solve[(x*c + 3*x)*(Sqrt[x + 1]*-4) == 0, c] is the correct interpretation of your equation then {{c -> -3}} is its solution. Matthias Bode. -----Ursprungliche Nachricht----- An: mathgroup@smc.vnet.net Betreff: Need help with a equation please. I just line the eqution up here and wonder if i can get a full solution on it, and what this types of equitions is called, thank you. !i=square root. (x(c)?+3x)(!i(x+1)-4)=0 There it is, hope you can solve it, would be great help thanks! Greetings John Andre _________________________________________________________________ http://join.msn.com/?page=features/virus ==== >-----Original Message----- > >Consider the following: In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; >Can somebody suggest a general way to seperate the terms above >into like >groups. By like I mean having the same second argument for >(f). So for >this example I want to get {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} The pattern matcher should be able to do this because Plus has >attributes >Flat and Orderless. However I can't find a way to make it happen. ------------------- > > Using some sort of Delete (with complementary criterion) appears to work, e.g. In[17]:= seca = Union[Cases[expr, f[_, a_] :> a]] Out[17]= {2, 3} In[18]:= patts = Prepend[e_ /; ! MatchQ[e, f[_, #]] & /@ seca, f[_, _]] Out[18]= {f[_, _], e_ /; ! MatchQ[e, f[_, 2]], e_ /; ! MatchQ[e, f[_, 3]]} In[19]:= DeleteCases[expr, #] & /@ patts Out[19]= {a + b + c + x + y, f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2], f[w, 3] + f[x, 3]} ... based on observations In[3]:= Cases[expr, f[_, 2]] Out[3]= {f[w, 2], f[x, 2], f[y, 2], f[z, 2]} In[5]:= DeleteCases[expr, f[_, _]] Out[5]= a + b + c + x + y so this could work, but ugly: In[6]:= Head[expr] @@ Cases[expr, f[_, 2]] Out[6]= f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2] perhaps more convenient, but ugly again at use of pattern matching: In[7]:= Select[expr, MatchQ[#, f[_, 2]] &] Out[7]= f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2] negating DeleteCases, ugly same way: In[8]:= DeleteCases[expr, e_ /; ! MatchQ[e, f[_, 2]]] Out[8]= f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2] Extracting gives same as Cases: In[9]:= Extract[expr, Position[expr, f[f_, 2]]] Out[9]= {f[w, 2], f[x, 2], f[y, 2], f[z, 2]} As does Take: In[10]:= Take[expr, #] & /@ Position[expr, f[f_, 2]] Out[10]= {f[w, 2], f[x, 2], f[y, 2], f[z, 2]} Delete is fine (as DeleteCases) In[12]:= Delete[expr, Complement[List /@ Range[Length[expr]], Position[expr, f[f_, 2]]]] Out[12]= f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2] -- ==== i have matlab v6.x and mathematica 4.x and 5.0. i would like to invoke mathematica code and return various matrices for use within a matlab session. is there a more uptodate version of the code found at http://library.wolfram.com/infocenter/MathSource/624/ ? applying mex to math41.c from that download produces the output below. but, substituting the newer mxIsChar for the obsolete mxIsString produces numerous compilation errors thanks for any insights you can offer. gary ++++++++++++++++some mex output peakmx1(137)% mex CC=gcc CFLAGS=-dalign -O -I/opt/mathematica/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/ -L/opt/mathematica/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/ -lML math41.c -o math.mex math41.c:146: arguments given to macro `mxIsString' math41.c:157: arguments given to macro `mxIsString' math41.c:157: arguments given to macro `mxIsString' math41.c:160: arguments given to macro `mxIsString' math41.c:213: arguments given to macro `mxIsString' math41.c:213: arguments given to macro `mxIsString' math41.c:214: arguments given to macro `mxIsString' math41.c:214: arguments given to macro `mxIsString' mex: compile of 'math41.c' failed. peakmx1(138)% ==== Please check to ensure that you have not previously assigned values to your variables, if you are using them. That could cause unintended consequences if you have. Steven Shippee shippee@jcs.mil > I'm getting an odd problem under both Mathematica 4.1 and 5.0 -- sometimes, > and it seems pretty random, when I go to evaluate a notebook cell, > Mathematica will just refuse to evaluate it. There will be no output, no > error message, nothing -- shift-enter and zero response. Not even the first > line of that particular section gets evaluated (even if its something as > simple as Print[Please work]; As I said, this behavior is pretty random, and reboots, restarts of > Mathematica, etc do not seem to take care of it. Any suggestions? --j > ==== Jonathan Greenberg schrieb: > I'm getting an odd problem under both Mathematica 4.1 and 5.0 -- sometimes, > and it seems pretty random, when I go to evaluate a notebook cell, > Mathematica will just refuse to evaluate it. There will be no output, no > error message, nothing -- shift-enter and zero response. Not even the first > line of that particular section gets evaluated (even if its something as > simple as Print[Please work]; > > As I said, this behavior is pretty random, and reboots, restarts of > Mathematica, etc do not seem to take care of it. Any suggestions? > > --j > I don«t know if this is relevant to this problem, but if you kill the kernel from outside (not via the frontend) then the frontend does not seem to notice the kernel has been killed. The first evaluation (Shift-Enter) does not take place in this case. At the second attempt the kernel is reloaded all right though. This is on W2K, Mathematica 4.2.1, anyway... ==== You can extract the points by digging into the graphics. Here is an example. f[x_, y_] := x^2 + y^2 plot1 = ContourPlot[f[x, y], {x, -1.5, 1.5}, {y, -1.5, 1.5}, Contours -> {0.5, 1.0}, ContourShading -> False] Now if we convert plot1 from ContourGraphics to Graphics we will obtain clines = Cases[First[Graphics[plot1]], Line[_], Infinity] You will notice that this contains a number of spurious lines that contain only one point or the same point repeated. We can massage clines to get rid of these cases. clines2 = clines /. Line[{begin___List, a_List, b_List, end___List}] /; Sqrt[(a - b).(a - b)] < 10.*^-10 -> Line[{begin, end}] /. Line[{}] -> Sequence[] /. Line[{a_}] -> Sequence[] Then you can extract the points themselves with points = Cases[clines2, Line[pts_] -> pts, Infinity] David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.net ==== I am using NDSolve and sometimes the integrator hits a snag as it's calculating. I'll get an error message like: NDSolve::ndsz : At t == 4.198615826788436`, step size is effectively zero; singularity or stiff system suspected. Now as it turns out that's just fine; by the time the integrator fails I have all the results I need. But I would really like to be able to extract the value of the variable t at which the integrator stopped so that I can use it when I plot the results. I'd rather not kluge something in to parse it out of the error message. Is there an elegant way to do this? Eric ==== How possible is it to compute a fourier transform of a data set {t,x} in order to have the fourier coefficient and the corresponding frequency? Tahnks ==== hi, if you have equaly spaced samples x={x1,x2,x3......xn} you simply apply Fourier[x] the result you get is {f1,f2,f3,....fn} where f1 gives the constant term f2,fn give the basic frequency, f3,fn-1 give the harmonic with twice the basic frequency and so on, ... if you have unevenly spaced samples s={{t1,x1},{t2,x2},.....{tn,xn}} then you will have to do some nonlinaer fitting, perhaps using NonliearFit[] > How possible is it to compute a fourier transform of a data set {t,x} in > order to have the fourier coefficient and the corresponding frequency? > Tahnks > ==== >can you tell us you operating system ? Windows2000. BTW, I have no problems with Webdings either. But this is exceptional; most of the fonts that I've tried (from the list in Format->Font) fail to show (the display reads fine, but the font used is not the one requested). But if I *type* the same text in a cell, select it, and choose the font in question from Format->Font, then I get the desired font. This suggests that at least some parts of Mathematica can find the problematic fonts, but the Graphics-display routines can't. bill ==== If Wave is a 2-dimensional matrix, Wave[[j,0]] is the wrong notation -- the 0-th element of the j-th row will be the head List, and I don't think you mean to integrate List over x! Anyway, it's j that Mathematica is complaining about, before getting to that issue. Simplifying things a little, this works: wave = Range[10]; Sum[ConstantCalc[someVars, j, someMoreVars]*wave[[j]], {j, 1, 10}] But this doesn't: wave = Range[10]; Sum[ConstantCalc[someVars, j, someMoreVars]*wave[[j]], {j, 1, n}] That makes a certain amount of sense, since the second form is undefined if n > 10, for instance. But then the Sum should return unevaluated. The error messages make no sense at all. Bobby > I am basically trying to sum something while calling a function of it. > Mathematica is giving me the error that IntegerPart[j] is not an > integer. This is the general idea of my command. (ConstantCalc is a > function) Sum[ConstantCalc[someVars,j,someMoreVars]*Integral[Wave[[j,0]],{x,- > Infinity,Infinity}],{j,1,n}] -- majort@cox-internet.com Bobby R. Treat ==== That could easily be a dissertation project. Maybe you should get past step one on your own. Bobby > I have to do a project on face recognition. I have read the bitmap pixal > of the whole image but I want to extract only the face from the picture. > So can you help me in this regard. Any idea of face recognition > technique. > ___________________________________________________ > Meet your old school or college friends from > 1 Million + database... > Click here to reunite www.batchmates.com/rediff.asp > -- majort@cox-internet.com Bobby R. Treat ==== is it a gray or a RGB image ? For RGB images a segmentation with the skin color work reasonable good Have you only one face in the image or more of them ? Can the head be rotated ? Jens > > I have to do a project on face recognition. I have read the > bitmap pixal of the whole image but I want to extract only the > face from the picture. So can you help me in this regard. Any idea > of face recognition technique. > ___________________________________________________ > Meet your old school or college friends from > 1 Million + database... > Click here to reunite www.batchmates.com/rediff.asp ==== The first of these --- the (not) rotated text bug --- has not been fixed either. Another bizarre bug has popped up in 5.0: In text cells, lines are sometimes broken after apostrophes. So a word like can[CloseCurlyQuote]t will break between [CloseCurlyQuote] and t. Astonishing. I wonder if that happens in Windows too. ----- http://www.math.armstrong.edu/faculty/hollis > Does anyone know if either of the following bugs been corrected in >> version 5 >> for Mac OS X? >> http://groups.google.com/ >> groups?q=At+long+last,+Sir,+have+you+no+shame%3F+gr >> oup:comp.soft-sys.math.mathematica+group:comp.soft- >> sys.math.mathematica+grou >> p:comp.soft-sys.math.mathematica&start=10&hl=en&lr=&ie=UTF- >> 8&group=comp.soft >> - >> sys.math.mathematica&scoring=d&selm=7ku02a%24996%40smc.vnet.net&rnum=1 >> 8&fil >> ter=0 >> http://groups.google.com/groups?q=quicktime+group:comp.soft- >> sys.math.mathema >> tica+group:comp.soft-sys.math.mathematica&hl=en&lr=&ie=UTF- >> 8&group=comp.soft >> - >> sys.math.mathematica&scoring=d&selm=bbf32m%24q2c%241%40smc.vnet.net&rn >> um=4 I can tell you for sure that the second one has not been fixed. The > only > solution is to set the notebook magnification at 100%. It is incredibly > annoying. -- > Gary L. Gray Engineering Science & Mechanics > Associate Professor Penn State University > http://www.esm.psu.edu/faculty/gray/ (814) 863-1778 ==== Well I was actually able to answer my own question by using an NDSolve StateData object and the CurrentTime method. But I am still wondering if there is a way to have a *notebook* do something with error messages automatically, something like throwing and catching exception. Any ideas? Eric > I am using NDSolve and sometimes the integrator hits a snag as it's > calculating. I'll get an error message like: > > NDSolve::ndsz : > At t == 4.198615826788436`, step size is effectively zero; singularity or > stiff system suspected. > > Now as it turns out that's just fine; by the time the integrator fails I have > all the results I need. But I would really like to be able to extract the > value of the variable t at which the integrator stopped so that I can use it > when I plot the results. > > I'd rather not kluge something in to parse it out of the error message. Is > there an elegant way to do this? > > Eric ==== >-----Original Message----- >> >>Dear MathGroup, >>The two argument function, ArcTan[x,y], is a very nice function and >>Mathematica knows how to do a lot with it. But sometimes it is >>difficult to >>bring it into play without just typing it in. >>Consider the case of inverting polar coordinates. >>eqns = {x == r Cos[t], y == r Sin[t]}; >>Solve[eqns, {r, t}, {x, y} [Element] Reals] // Simplify >>If we discard the two negative r solutions, we obtain two solutions >>involving ArcCos. But couldn't we have a single solution using >>ArcTan[x,y]? >>I'm curious to know if there is a method to get Mathematica to >>produce that >>solution? >>David Park >>djmp@earthlink.net >>http://home.earthlink.net/~djmp/ > >Dear David, if you have cartesian coordinates defined (symbolically) as In[1]:= {x, y} = r{ Cos[t], Sin[t]} ; then you may revert (symbolically) to polar with >In[11]:= >FullSimplify[{Sqrt[{x, y}.{x, y}], ArcTan[x, y]}, > {Positive[r], t [Element] Reals}, > TransformationFunctions -> {Automatic, TrigToExp, PowerExpand}] Out[11]= {r, t} (It also works with assuption r [Element] Reals (but I hate that). Of course numerical work is easier. -- >Hartmut > ----------------------------------------------------------------------- --------------------------------- I think that it is easier to get results with Arg[] rather than ArcTan[] for an inverse function, so starting from something like Hartmut's case applied to simplification of the Solve[]: In[5]:=Clear[x,y,r,t]; In[6]:=FullSimplify[ Solve[eqns, {r, t}, {x, y} [Element] Reals], {x, y} [Element] Reals, TransformationFunctions -> {Automatic, ComplexExpand, PowerExpand}] the neatest however should be when using Exp[] rather than Cos[] and Sin[], but I am annoyed that you have to supply redundant information (Solve[] does not recognise that a complex equation has 2 Real unknowns..) and with the remaining oddities in the result: In[7]:=eqns2={x^2+y^2==r^2,x+I*y == r *Exp[I*t]}; In[8]:=FullSimplify[Solve[eqns2,{r,t},{x,y}[Element]Reals], {x,y}[Element]Reals, TransformationFunctions->{Automatic,ComplexExpand,PowerExpand}] The inverse functions (Sqrt[] and Arg[]) are so simple that these subtleties only matter for much more complex expressions: this can be a real voyage of discovery! The deepest darkest notes of Help for FullSimplify, ComplexExpand etc. give fascinating options even before resorting to specific pattern matching rules [oh I do love COMPLEXEXPAND from Andrzej Kozlowski, 30/3/2000. Using Andrej's function myComplexExpand[] as a transformation, the result of the evaluation looks just what you want: In[9]:=myComplexExpand[z_] := ComplexExpand[Abs[z], TargetFunctions -> {Re, Im}]* Exp[I*ComplexExpand[Arg[z], TargetFunctions -> {Re, Im}]] In[10]:=myComplexExpand[x + I*y] Out[10]:=Exp[I*ArcTan[x, y]]*Sqrt[x^2 + y^2] To get inverse results from Solve with ArcTan[] directly in this case, unfortunately using myComplexExpand directly as a TransformationFunction did not work <>, but using the hints from Andrej and Hartmut my first imperfect result is: In[11]:=FullSimplify[Solve[eqns,{r,t},{x,y}[Element]Reals], {x,y}[Element]Reals, TransformationFunctions->{Automatic, ComplexExpand[#,TargetFunctions->{Re,Im}]&, PowerExpand}] Hopefully somebody can neaten up these examples a bit more, I thought this would be an easy one to link in to Solve[] but I was wrong.. fascinating. Now to delve into the online help to see what more version 5.0 has to offer.. -- from - John Tanner home - john@janacek.demon.co.uk mantra - curse Microsoft, curse... work - john.tanner@baesystems.com I hate this 'orrible computer, I really ought to sell it: It never does what I want, but only what I tell it. ==== this is not actually the answer to Ted's question, but instead the way to extract like groups of elements from the list. pickPattern[list_,pat_] picks elements from the list that matches pattern pat, and splits them into like groups where like means that the elements have matched the same *named* subpatterns. The third argument, if supplied, explicitly lists pattern names that should match the same entity. Clear[pickPattern]; pickPattern[expr_, pat_, isti_:{}] := Module[{i, j, k, p, q, localpat, isti1}, localpat = pat; isti1 = isti; q = If[isti == {}, Cases[localpat, x_Pattern :> First[x], {0, [Infinity]}, Heads -> True], isti1]; k[localpat] := Evaluate[Sequence @@ q]; i[f : localpat] := (p = k[f]; j[p] = {j[p], f}); j[n__] := Sequence[]; i /@ expr; Flatten /@ Union[j[k[#]] & /@ expr] ]; Tests: expr = {a, b, c, x, y, f[1, 1], f[w, 2], f[w, 3], f[x, 2], f[x, 3], f[y, 2], f[z, 2], g[w, 2], g[w, 3], h[1, 1], j[1, 1]}; In[]:= pickPattern[expr, _[_, a_]] Out[]= {{f[1, 1], h[1, 1], j[1, 1]}, {f[w, 3], f[x, 3], g[w, 3]}, {f[w, 2], f[x, 2], f[y, 2], f[z, 2], g[w, 2]}} In[]:= pickPattern[expr, a_[_, b_]] Out[]= {{f[1, 1]}, {g[w, 2]}, {g[w, 3]}, {h[1, 1]}, {j[1, 1]}, {f[w, 3], f[x, 3]}, {f[w, 2], f[x, 2], f[y, 2], f[z, 2]}} In[]:= pickPattern[expr, b_[_, a_], {b}] Out[]= {{h[1, 1]}, {j[1, 1]}, {g[w, 2], g[w, 3]}, {f[1, 1], f[w, 2], f[w, 3], f[x, 2], f[x, 3], f[y, 2], f[z, 2]}} In[]:= pickPattern[expr, _[a_, b_]] Out[]= {{f[x, 2]}, {f[x, 3]}, {f[y, 2]}, {f[z, 2]}, {f[w, 2], g[w, 2]}, {f[w, 3], g[w, 3]}, {f[1, 1], h[1, 1], j[1, 1]}} In[]:= pickPattern[expr, _[a_, b_] /; a =!= b] Out[]= {{f[x, 2]}, {f[x, 3]}, {f[y, 2]}, {f[z, 2]}, {f[w, 2], g[w, 2]}, {f[w, 3], g[w, 3]}} In[]:= pickPattern[2expr, _.*t_[a_, b_] /; (a =!= b && t =!= Times), {a}] Out[]= {{2 f[y, 2]}, {2 f[z, 2]}, {2 f[x, 2], 2 f[x, 3]}, {2 f[w, 2], 2 f[w, 3], 2 g[w, 2], 2 g[w, 3]}} In[]:= pickPattern[2expr, _.*(f | g | h)[a_, b_] /; a =!= b] Out[]= {{2 f[x, 2]}, {2 f[x, 3]}, {2 f[y, 2]}, {2 f[z, 2]}, {2 f[w, 2], 2 g[w, 2]}, {2 f[w, 3], 2 g[w, 3]}} In[]:= pickPattern[2expr, _.*(f | g | h)[a_, b_], {a}] Out[]= {{2 f[y, 2]}, {2 f[z, 2]}, {2 f[1, 1], 2 h[1, 1]}, {2 f[x, 2], 2 f[x, 3]}, {2 f[w, 2], 2 f[w, 3], 2 g[w, 2], 2 g[w, 3]}} Mihajlo Vanevic mvane@EUnet.yu ************************************************************** ************************************************************** >Consider the following: In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; >Can somebody suggest a general way to seperate the terms above into like >groups. By like I mean having the same second argument for (f). So for >this example I want to get {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} The pattern matcher should be able to do this because Plus has attributes >Flat and Orderless. However I can't find a way to make it happen. ------------------- > ************************************************************** ==== Dear MathGroup, If I use the Default notebook style and type: a -> b then the two character arrow is immediately changed to the single character arrow. And there are other automatic replacements. I believe these replacements are specified by the ImportAutoReplacements option in the Option Inspector. But when I make my own style sheet this feature is lost and no replacement takes place. I would like to restore the feature but don't know how to do it. When I look up ImportAutoReplacements in Help it says that it is a notebook option. But when I look at the Option Inspector, it is blanked out at the notebook level, both in a notebook in Default style and in a notebook in one of my own styles. And the regular replacements are there at the global level. So why doesn't it work in a private notebook style? The private style sheet has a Notebook Options Section. I opened the prototype for Notebook and added InputAutoReplacements->{ ->->[Rule], :>->[RuleDelayed], <=->[LessEqual], >=->[GreaterEqual], !=->[NotEqual], ==->[Equal]} but that didn't correct the problem. When I checked the options for the notebook with Option Inspector the replacement rules were there and active. But they still didn't work in the notebook. Is there a way to fix this? David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ ==== it's been sugested that the problem i was having with my earlier post was due more or less to starting step size, number of maximum steps. is it possible that the the weird oscillations seen and the failures are due to the accumulative numerical errors? i have tried changing maxstep size and starting stepsize but it seems do very little. is there a limit as to how high ( maxsteps) and how low( starting step size) i can designate? if so what are they? and what else can i do here to ensure more accurate results from the NDSolve? I have tried precision goals and accuracy goals along with machine precision but it seems to take too long with the step size i have specified. ( at the time i was using like 100000000 steps. since then i have tried it with smaller number of steps but the speed seems to be an issue) thanks in advance for all helpful comments as always. sean __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com ==== , 43294,43380,43381] concerning my notebook c37.I have to apologize for the missing of a more extensive description concerning the notebook.I have not been aware of the fact, that mathgroup users not yet having read the pages 216 -219 of my book (F. Cap, Mathematical Methods in ISBN01584884029) would have difficulties to understand, that the notebook has the intention to demonstrate that variational methods are able to solve elliptic partial differential equations with inhomogeneous boundary values on two different closed boundary curves. Since you are a specialist in the field (sorry, I did not read your book on the same matters) I am glad to have discussion with you. I agreee that the very low order (3rd) solution by Wallnoefer, Ref [4.17], is very rough. To apologize for the missing explanations in the notebook, I send an improved version.I hope this answers all open questions? (* c37: Two boundaries for the Laplace equation see Fig.4.14 in the book Mathematical Methods in Physics and Engineering with Mathematica, CRC Press, ISBN 1584884029.There are two different closed boundary curves, a square of length a= 4 and a circle of radius 1. On both boundaries the boundary condition u[ boundary]= x^2+y2 is valid. The solution method is the RITZ variational method.It gives the very approximative solution f - only 3rd approximation*) Clear[f,P1,Q,CG,QG,QQG,A,U];(* f is formula (4.7.22)*)f[x_,y_]= x^2+y^2+(x^2+ y^2-1)*(x^2-4)*(y^2-4)*(0.0969+0.0521*(x+y)-0.0673*(x^2+y^2)-0.0474* x*y+0.0131*(x^3+y^3)+0.0186*(x^2*y+x*y^2)) P1=Plot3D[f[x,y],{x,-2.,2.},{y,-2.,2.},Shading[Rule]False, ClipFill[Rule]None, PlotRange[Rule]{0.,8.}, PlotPoints[Rule]100](*this gives Fig 4.14*) In[7]:= f[2.,2] In[10]:= Sqrt[0.5] In[11]:= f[0.707107,0.707107] In[4]:= g[x_,y_]=Simplify[D[f[x,y],{x,2}]+D[f[x,y],{y,2}]] In[6]:= Plot3D[Evaluate[g[x,y],{x,-2.,2.},{y,-2.,2.}, Shading[Rule]False, (*ClipFill[Rule]None,*) PlotRange[Rule]{0.,8.}, PlotPoints[Rule]100]] CG=Graphics[Circle[{0.,0.},1.],AspectRatio[Rule]Automatic] Show[CG] Q=Line[{{-2.,-2.},{2.,-2.},{2.,2.},{-2.,2.},{-2.,-2.}}]; QG=Graphics[Q,AspectRatio->Automatic] Show[QG] QQG=Show[QG,CG] (* The RITZ trial function G[x, y], (4.7.22) and (4.7.23) does not satisfy the Laplace equation*) G[x_,y_]=x^2+ y^2+(x^2+y^2-1)*(x^2-4)*(y^2-4)*(co+c1*(x+y)+c2*(x^2+y^2)+c3*x*y+ c4*(x^3+y^3)+c5*(x^2*y+x*y^2)) FullSimplify[D[G[x,y],{x,2}]+D[G[x,y],{y,2}]] ==== > I am interested in using GridBoxes to create a table that has row > headings and column headings . The headings should not have the same > style or background as the table. Here is a simple example of what I > am trying to do. First , I create my table > > box1 = StyleBox[ GridBox[{{a, b, d, e}, {f, g, h, i}, {j, k, l , m}}, > Background -> RGBColor[1, 1, 0]]; > > Here are the column headings: > > RGBColor[1, 1, 1]]; > > Now if I combine these two sets of Gridboxes I get the desired result > > DisplayForm[GridBox[{{columnbox}, {box1}}]] > > The difficulty I have is adding the row headings > > RGBColor[1, 1, 1]]; > > DisplayForm[GridBox[{{rowbox},{GridBox[{{columnbox}, {box1}}]}}]] > > which does not give the desired result. Here is one way to do what you have requested: rowbox = GridBox[Transpose[{{ , 1, 2, 3}}]]; columnbox = GridBox[{{1, 2, 3, 4}}]; box1 = StyleBox[GridBox[{{a, b, d, e},{f, g, h, i},{j, k, l, m}}, Background -> RGBColor[1, 1, 0]]]; DisplayForm[GridBox[{{, columnbox}, {rowbox, box1}}]] The problem with this approach, I think, is that there is no simple way to force the row and column headings to be aligned with the rows and columns of box1. This is especially important if the elements in the matrix are of different widths. Another approach (for which the headings must have the same style or background as the table) is mat = {{a, b, d, e}, {f, g, h, i}, {j, k, l, m}}; top = {{1, 2, 3, 4}}; side = Transpose[{{1, 2, 3}}]; corner = {{}}; << LinearAlgebra` DisplayForm[GridBox[BlockMatrix[{{corner, top}, {side, mat}}], Personally, I think this approach is preferable because alignment is automatic, and I think that it looks quite neat. Paul -- The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul ==== first I should explain what I want to do: I implemented an algorithm to calculate the jacobian symbol for polynomials. Till now I define two polynomials and after that I start the algorithm. This gives the desired result, but I`d like to have a function, say jacPol, which gets the 2 polynomials and returns the result. I tried to define a function with jacPol[a_,b_]:= where a and b are polynomials, but this does not give the desired result. I get an error message or jacPol is not evaluated at all. So perhaps a experienced mathematica user could have a look at the notebook, which can be found here: http://www.rz.unibw-muenchen.de/~j0ws0775/ Stefan Wagenbrenner ------------ And now a word from our sponsor ------------------ Want to have instant messaging, and chat rooms, and discussion groups for your local users or business, you need dbabble! -- See http://netwinsite.com/sponsor/sponsor_dbabble.htm ---- ==== > I plot a couple of 2D contours by using ContourPlot. Now, I want to > pick up the coordinate of each point along each contour for next step > calculation purposes. I appreciate with your any suggestion of how to > get the coordinates of each point along a specific contour (suppose > two contours have been created). Jun > Jun, Here are some ideas cp = ContourPlot[x*y, {x, -1, 1}, {y, -1, 1}] -ContourGraphics- -ContourGraphics- is a name for the actual output, cp, which we do not normally want to see (the picture is a side effect). We can, however, look at it: InputForm[cp] We see that it is simply an array of values of the x*y at sample points together with instructions to create a picture when operated on with Show - no lines - these are constructed each time the picture is created. To get explicit lines we convert cp into a Graphics object: gr = Graphics[cp] -Graphics- Again, we can look at the actual output: InputForm[gr] We see lines (the contour lines) and polygons (for constructing the shading). Now extract the lines lns = Cases[gr, _Line, Infinity] We may need to label the lines with their heights, especially if there are several contour segments at the same height. lns /. ln:Line[{___, {x_, y_}}] :> {x*y, ln}. Note: we can avoid the polygons in gr by begining with ContourPlot[x*y, {x, -1, 1}, {y, -1, 1}, ContourShading->False] -- Allan --------------- Allan Hayes hay@haystack.demon.co.uk Voice: +44 (0)116 241 8747 ==== suppose you need the lines from fun[] fun[x_, y_] := Cos[Sqrt[x^2 + y^2]] gr = Graphics[ ContourPlot[fun[x, y], {x, -2Pi, 2Pi}, {y, -2Pi, 2Pi}, Contours -> {-1/2, 1/2}, PlotPoints -> 30, DisplayFunction -> Identity]] one generates the contour graphics and convert it to an ordinary Graphics[] with lines now you wish to select all lines, that include points {x,y} with Abs[f[x,y]-level]< eps level = 1/2; dta = Select[Cases[gr, _Line, Infinity], And @@ ( # < 0.05 & /@ (Abs[fun @@ # - level] & /@ First[#] )) &]; Show[Graphics[dta, AspectRatio -> 1]]; eps (here 0.05) should be not too small because ContourPlot[] is not very accurate .. Jens > > I plot a couple of 2D contours by using ContourPlot. Now, I want to > pick up the coordinate of each point along each contour for next step > calculation purposes. I appreciate with your any suggestion of how to > get the coordinates of each point along a specific contour (suppose > two contours have been created). > > Jun ==== (RedHat 8.0): 1) Plot[x,{x,0,1}] 2) Plot[0.00000001*x,{x,0,1}] While the first one comes out fine, the second one just freezes when the plot is being rendering (the title bar shows: Rendering...Running...Untitled.nb*), and the whole Mathematica stops to respond so that I have to kill the frontend process in order to exit. I suspect the problem have something to do with converting the tick points from their original form to the scientific notation. I also found that 1) Running in the kernel environment does not have this problem. 2) V5 frontend can still successfully load in plots, ones generated in V4, with tick points in scientific notation. Any idea or possible solution? C.P. ==== (woody). > (RedHat 8.0): > > 1) Plot[x,{x,0,1}] > > 2) Plot[0.00000001*x,{x,0,1}] > > While the first one comes out fine, the second one just freezes when the > plot is being rendering (the title bar shows: > Rendering...Running...Untitled.nb*), and the whole Mathematica stops to > respond so that I have to kill the frontend process in order to exit. > > I suspect the problem have something to do with converting the tick > points from their original form to the scientific notation. > > I also found that > > 1) Running in the kernel environment does not have this problem. > > 2) V5 frontend can still successfully load in plots, ones generated in > V4, with tick points in scientific notation. > > Any idea or possible solution? > > > C.P. ==== -Francesco ==== > Consider the following: In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; > Can somebody suggest a general way to seperate the terms above into > like > groups. By like I mean having the same second argument for (f). So > for > this example I want to get {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} The pattern matcher should be able to do this because Plus has > attributes > Flat and Orderless. However I can't find a way to make it happen. ------------------- > > I do not see any obvious way to do this using just pure pattern matching, but one can always do something like this: expr /. (x__) + (y__f) :> {{x}, Apply[Plus, Split[Sort[{y}, #1[[2]] =!= #2[[2]] & ], #1[[2]] == #2[[2]] & ], {1}]} {{a, b, c, x, y}, {f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2], f[w, 3] + f[x, 3]}} Andrzej Kozlowski Yokohama, Japan http://www.mimuw.edu.pl/~akoz/ http://platon.c.u-tokyo.ac.jp/andrzej/ ==== I tried the following in Mathematica 5.0 trial version for Windows and got the following unexpected result: In[1]:= Thread[FourierTransform[{Tanh[x], ArcTan[x]},x,f]] Out[1]={I*Sqrt[Pi/2]*Csch[(f*Pi)/2], 0} The second item is obviously wrong since the Fourier transform of ArcTan is not zero. I tried other funcitons, it seems that whenever Tanh[x] and ArcTan[x] show up together, the result of ArcTan[x] is always 0! Art ==== followups with the answer. I have a messy nonlinear regression where I want to constrain a subset of the parameter values to be positive. The general problem is that there is some software slowdown problems that I want to take account of. I am adding a Exp[a*(t-1)] term to the model (which is nonlinear anyways). So I want to make sure that a>=0. I understand that nonlinearfit is based on findminimum, which I know has that capability, but it doesn't seem to be an option for nonlinearfit. Ming ==== > Consider the following: In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; > Can somebody suggest a general way to seperate the terms above into like > groups. By like I mean having the same second argument for (f). So for > this example I want to get {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} The pattern matcher should be able to do this because Plus has attributes > Flat and Orderless. However I can't find a way to make it happen. ------------------- > > Ted, Here is one way - but not very elegant! ClearAll[f,a,b,c,w,x,y,z]; expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; Prepend[Plus @@@ Split[#[[Ordering[#[[All, 2]]]]] &[ Cases[expr, _f]], #[[2]] === #2[[2]] &], DeleteCases[expr, _f]] Allan --------------- Allan Hayes hay@haystack.demon.co.uk Voice: +44 (0)116 241 8747 ==== Ted, Here is a kludge approach: Flatten[{DeleteCases[expr, f[_, _], Infinity], Apply[Plus, Split[Sort[Cases[expr, f[_, _], Infinity], #2[[2]] > #1[[2]] & ], #1[[2]] == #2[[2]] & ], 1]}] Brian > Consider the following: > > In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; > > > Can somebody suggest a general way to seperate the terms above into like > groups. By like I mean having the same second argument for (f). So for > this example I want to get > > {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} > > The pattern matcher should be able to do this because Plus has attributes > Flat and Orderless. However I can't find a way to make it happen. > > ------------------- > ==== > Consider the following: > > In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; > > > Can somebody suggest a general way to seperate the terms above into like > groups. By like I mean having the same second argument for (f). So for > this example I want to get > > {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} Not a full answer to your question, but one can get the partitioning you are after using Collect[expr /. c:f[_, n_] :> g[n] c, g[_]] Paul -- The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul ==== >Consider the following: In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; >Can somebody suggest a general way to seperate the terms above into like >groups. By like I mean having the same second argument for (f). So for >this example I want to get {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} The pattern matcher should be able to do this because Plus has attributes >Flat and Orderless. However I can't find a way to make it happen. ------------------- > > ----------------------------------------------------------------------- --------------------------------- If you are sure you have a simple sum, then use Cases or equivalent on expr itself: In[3]:=Plus @@ Cases[expr, _Symbol] Out[3]:=a+b+c+x+y In[4]:= Plus @@ Cases[expr, _[_, 2]] Out[4]:=f[w,2]+f[x,2]+f[y,2]+f[z,2] This procedure is slightly unsafe, so it is probably better to do a bit of expanding first (hopefully this catches most problems, but such problem cases will need extra Cases[]). Fortunately the List generation works even for negative valued terms, but to be general beware of sums in the denominator(s) of any term(s)!: In[5]:= exprlist=ExpandAll[expr] /. Plus -> List Out[5]:={a,b,c,x,y,f[w,2],f[w,3],f[x,2],f[x,3],f[y,2],f[z,2]} In[6]:= Cases[exprlist, _[_, 2]] Out[6]:={f[w, 2], f[x, 2], f[y, 2], f[z, 2]} so finally (if a little inelegant and not really general: feel free to improve!): In[7]:=Prepend[ (Plus @@ Cases[exprlist,_[_,#]])& /@ {2,3}, Plus @@ Cases[exprlist,_Symbol]] Out[7]:={a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} There are various other ways of improving the use of the list: possibly Union[Part[#,-1]& /@ Cases[exprlist,_[_,_]]] to generate the list of the values of the second argument, or Split[ Sort[Cases[exprlist,_[_,_]],OrderedQ[{Part[#1,-1],Part[#2,-1]}]&], Part[#1,-1]==Part[#2,-1]&] which goes some way towards being more general. [use these at your own risk..] There is also a really risky but very direct alternative, good luck if you want to try to make it general: In[8]:=DeleteCases[expr,#]& /@ {_[_,_],_Symbol | _[_,3],_Symbol | _[_,2]} Out[8]:={a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} -- from - John Tanner home - john@janacek.demon.co.uk mantra - curse Microsoft, curse... work - john.tanner@baesystems.com I hate this 'orrible computer, I really ought to sell it: It never does what I want, but only what I tell it. ==== I would take a different approach: ClearAll[f,a,b,c,w,x,y,z,sep]; sep[expr_] := Module[ {tm = List@@expr, at}, at = Select[tm,AtomQ]; Tr/@Prepend[ Split[ Sort[Complement[tm,at], #1[[2]]<#2[[2]]&], #1[[2]]==#2[[2]]&], at]]; expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; sep[expr] {a + b + c + x + y, f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2], f[w, 3] + f[x, 3]} Bob Hanlon << Consider the following: In[1]:= ClearAll[f,a,b,c,w,x,y,z]; expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; Can somebody suggest a general way to seperate the terms above into like groups. By like I mean having the same second argument for (f). So for this example I want to get {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} The pattern matcher should be able to do this because Plus has attributes Flat and Orderless. However I can't find a way to make it happen. ==== you mean Plus @@@ Split[List @@ expr, Head[#1] === Head[#2] &] or {Select[#, Symbol === Head[#] &], Select[#, f === Head[#] &]} & [expr] or Plus @@@ {Cases[#, _Symbol], Cases[#, _f]} & [expr] or (lst = Cases[#, _.*_f]; {# - Plus @@ lst, Plus @@ lst}) & [expr] or {DeleteCases[#, _.*_f], Cases[#, _.*_f]} &[expr] ? Jens > > Consider the following: > > In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; > > > Can somebody suggest a general way to seperate the terms above into like > groups. By like I mean having the same second argument for (f). So for > this example I want to get > > {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} > > The pattern matcher should be able to do this because Plus has attributes > Flat and Orderless. However I can't find a way to make it happen. > > ------------------- > ==== > > this post is kinda long. and the cell that is causing me whole lotta > problems is copied and pasted below. Thi scell has everythign that is > needed to do the analysis that i'm talking about in this post. also I > let me know if this post doesn't make much sense. > > I have an ode system with 47 parameters and 23 differential equation. > To study its behaviours, I'm randomy choosing parameters that are > within the reasonable ranges(4 orders of magnitude for most) > > the initial conditions are derived from algebraic system that arise > from the ode systems with assupmtions that some variables must be 0 in > the initial system. Combined with the assumption that, at equilibrium, > fact that you have the time derviatives == 0 allows for the reduction > of the system and thus allows solving for the initial values of the > remaining variables.( granted that the system is balanced, which is the > problem I had with the last solve errors I posted about not so long > ago. That problem is troubleshot by adding terms into the systems that > allows for creation and destruction of the terms. I can describe in > more detail if anyone wants to see it.) This initial condition must > allow the system to reach the equilibrium. > > But obviously in my hands, this appears not to be the case. ( well not > the equilibrium that i was expecting I was expecting smooth rises and > falls) > > It seems to me the system has two odd behaviours after having picked > thousands of random parameters sets and analyzed the system. First is > that it gives lotta errors and doesn't give any plots. Second is that > it seems to show plots of b[t] and few other variables oscillating > wildly all the while the y axis doesn't change in the values. ( they > could in theory and in real life oscillate but the oscillations that > the system was giving was something that was unreasonable) > > and above two behavior is quite consistent which makes me think > something isn't right. > > I have copied and pasted the problematic cell at the end of this > message. Iteration is for 5 loops in this particular cell but i have > done a lot more and the consistency of the errors and the weird > oscillation is one thing that remains constant. One of the problems you have is that it is not a good idea to use a dependent variable with the same name as the independent variable. i.e. t[t] Mathematica 5 disallows this explicitly, in Mathematica 4.x it could possibly lead to unpredictable behavior depending on exactly how substitution is handled. > > The following message from Mathematica 4.0 is an example of the first kind of > behvaiour. Although I have seen other errors as well regarding > suspected singularity. > > These are the errors I would like to learn to get rid of and the > question of this post... I'm sure there are ways to turn the error > messages off, but the mathemtica will still go through the bad > parametersets? how do change this so that the mathematica doesn't do > the bad parameter sets? what am I missing here? You can use the command Check which would check for messages issued and have your program do something accordingly. > > I could implement a simulated annealing or gradient descent for this > system, but i would like to make sure the system is behaving in > reasonably relevant manner. and with all these errors and oscillations, > it's kinda hard to believe the system is doing something correct... One way to check to see if NDSolve is doing something reasonable is to use different (ODE integration) methods and error tolerances and see if you get qualitativly similar results. With Mathematica 4.0, the number of methods is quite limited, but with Mathematica 5, there are numerous methods to choose from. When I ran you example with the t[t] variable corrected, and some different methods in Mathematica 5, I still got messages about evaluation at points where the function did not have a numerical value (usually a singularity) and the integration stopped early, so my best guess would be that the behavior is a property of the system for that choice of parameters. Rob Knapp Wolfram Research ==== > How possible is it to compute a fourier transform of a data set {t,x} > in > order to have the fourier coefficient and the corresponding frequency? > Tahnks The Fourier Transform is computed as normal Fourier[x] Traditionally the 0 frequency is placed in the center of the spectrum, after an FFT though it is at the left so we rotate the data: RotateRight[Fourier[x],Quotient[Length[x],2] The frequencies are determined from the time with the following function freq[t_]:=With[{tau=t[[2]]-t[[1]],n=Length[t]},Table[-tau/2+i/(n tau),{i,0,n-1}] You can the use ListPlot to get the spectrum, assuming the data is in the list x and the times in the list t ListPlot[Transpose[{freq[t],RotateRight[Fourier[x],Quotient[Length[x],2] ]}],PlotJoined->True] Ssezi ==== There is no problem with Plot[0.00000001*x,{x,0,1}] David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ points from their original form to the scientific notation. I also found that 1) Running in the kernel environment does not have this problem. 2) V5 frontend can still successfully load in plots, ones generated in V4, with tick points in scientific notation. Any idea or possible solution? C.P. ==== Selwyn, The CloseCurlyQuote bug does sometimes happen in Windows98. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ > Does anyone know if either of the following bugs been corrected in >> version 5 >> for Mac OS X? >> http://groups.google.com/ >> groups?q=At+long+last,+Sir,+have+you+no+shame%3F+gr >> oup:comp.soft-sys.math.mathematica+group:comp.soft- >> sys.math.mathematica+grou >> p:comp.soft-sys.math.mathematica&start=10&hl=en&lr=&ie=UTF- >> 8&group=comp.soft >> - >> sys.math.mathematica&scoring=d&selm=7ku02a%24996%40smc.vnet.net&rnum=1 >> 8&fil >> ter=0 >> http://groups.google.com/groups?q=quicktime+group:comp.soft- >> sys.math.mathema >> tica+group:comp.soft-sys.math.mathematica&hl=en&lr=&ie=UTF- >> 8&group=comp.soft >> - >> sys.math.mathematica&scoring=d&selm=bbf32m%24q2c%241%40smc.vnet.net&rn >> um=4 I can tell you for sure that the second one has not been fixed. The > only > solution is to set the notebook magnification at 100%. It is incredibly > annoying. -- > Gary L. Gray Engineering Science & Mechanics > Associate Professor Penn State University > http://www.esm.psu.edu/faculty/gray/ (814) 863-1778 ==== linear integral along a given or fixed curve. Does anyone have Jun Lin ==== Dear Ted, One method is the 1:1 Translation trick, from words directly into the Mathematica syntax In words, Take at first the terms without f, Cases[expr,a_/;FreeQ[a,_f] ] then those f 2 terms, Cases[expr,f[_,2]] then those f 3 terms, Cases[expr,f[_,3]] Put it all together: In[4]:= Clear[a,b,c,x,f,g,y,z]; expr =a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; Plus@@@{ Cases[expr, a_/;FreeQ[a,_f]], Cases[expr,f[_,2]], Cases[expr,f[_,3]] } Out[6]= {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3] } or the (slightly improved) marker method from Paul Abbot: In[7]:= CoefficientList[Collect[expr /. c:f[_, n_] :> c g^n , g], g] /.( 0->Sequence[] ) Out[7]= {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3] } Actually you are collecting the coefficients of the powers of g: In[9]:= Collect[expr /. c:f[_, n_] :> g^n c, g ]//InputForm Out[9]//InputForm= a + b + c + x + y + g^3*( f[w, 3] + f[x, 3] ) + g^2*( f[w, 2] + f[x, 2] + f[y, 2] + f[z, 2] ) > Consider the following: > > In[1]:= > ClearAll[f,a,b,c,w,x,y,z]; > expr=a+b+c+f[w,2]+f[w,3]+x+f[x,2]+f[x,3]+y+f[y,2]+f[z,2]; > > Can somebody suggest a general way to seperate the terms above into like > groups. By like I mean having the same second argument for (f). So for > this example I want to get > > {a+b+c+x+y, f[w,2]+f[x,2]+f[y,2]+f[z,2], f[w,3]+f[x,3]} ******************************************** Dr. Reinhard Simonovits Handelsakademie | Karl Franzens University Math Department | Inst. of Th. Physics Grazbachgasse 71 | Universitaetsplatz 5 A-8010 Graz, Austria ********************************************* ==== I have tried to use the FileBrowse command in Mathematica 5 on Mac OS 10.2. I am presented with a browser dialog with a blank file name entry box. If I enter a name in the dialog, the evaluation returns a full path name for this new file name. What I really wanted, and what I expected from the documentation, was to be able to select a file in the browser,and have it return the full path name of the selected file. Unfortunately, all file name are grayed out, and not available for selection. Any ideas or experience with this? Harvey Moseley ==== I just upgraded my mathematica 4.2 to version 5. I created a code which was running fine on the old version. When I run the code with the new version it gives me the following message CholeskyDecomposition::obslt: CholeskyDecomposition is now a System` function. The package LinearAlgebra`Cholesky` is obsolete. Needs::nocont: Context LinearAlgebra`Cholesky` was not created when Needs was evaluated. I do not understand. Can anyone help? -- ch akpovo Laboratory for Modern Fluid Physics Florida A & M University ==== Is anyone using the Mathemtica 5 on an AMD Opteron? Doug Pickering Professor Dept of Mathematics and Computer Science Brandon University (204) 727-9674 Pickering@Brandonu.ca ==== Is there a way to accomplish something like the following and get the desired answer from MemberQ? (Or an alternative approach OpenWrite[testFile] OutputStream[testFile, 21] openStreams = Streams[] {OutputStream[stdout, 1], OutputStream[stderr, 2], OutputStream[testFile, 21]} openStreams[[3]] OutputStream[testFile, 21] openStreams[[3, 1]] testFile MemberQ[openStreams, testFile] False MemberQ[openStreams, testFile] False ==== I guess this is the function that you need. Try it out discreteconvolution[t_] := With[{tt = Partition[t, 2, 1]}, Table[Plus @@ (f[Plus @@ #]*g[t[[i + 1]] - T, Sequence @@ #] & /@ Take[tt, i]), {i, 1, Length[t] - 1}]] In[1]:= discreteconvolution[{t0, t1, t2, t3}] Out[1]= {f[t0 + t1] g[-T + t1, t0, t1], f[t0 + t1] g[-T + t2, t0, t1] + f[t1 + t2] g[-T + t2, t1, t2], f[t0 + t1] g[-T + t3, t0, t1] + f[t1 + t2] g[-T + t3, t1, t2] + f[t2 + t3] g[-T + t3, t2, t3]} Hope this help Julius ==== Dear group, I have this problem Given two functions f[t] and g[t] I wish to obtain their discrete convolution in points t: {t0, t1, t2, t3, ..} given with this pattern {f[t0+t1] g[t1-T,t0,t1], f[t0+t1] g[t2-T,t0,t1]+f[t1+t2] g[t2-T,t1,t2], f[t0+t1] g[t3-T,t0,t1]+f[t1+t2] g[t3-T,t1,t2]+ f[t2+t3] g[t3-T,t2,t3]} Some thing like this: discreteConvolution[list, f[t], g[t], t] = (Function to be defined) them Inp[]:=discreteConvolution[{t0, t1, t2, t3},f[t], g[t], t] Out[]:= {f[t0+t1] g[t1-T,t0,t1], f[t0+t1] g[t2-T,t0,t1]+f[t1+t2] g[t2-T,t1,t2], f[t0+t1] g[t3-T,t0,t1]+f[t1+t2] g[t3-T,t1,t2]+ f[t2+t3] g[t3-T,t2,t3]} Guillermo ==== discreteConvolution[tm_?VectorQ, f_, g_, T_] := Tr /@ Table[f[tm[[j]]+tm[[j+1]]]* g[tm[[i+1]]-T,tm[[j]],tm[[j+1]]], {i,1,Length[tm]-1},{j,i}]; discreteConvolution[{t0,t1,t2,t3}, f, g, T] {f[t0 + t1]*g[t1 - T, t0, t1], f[t0 + t1]*g[t2 - T, t0, t1] + f[t1 + t2]*g[t2 - T, t1, t2], f[t0 + t1]*g[t3 - T, t0, t1] + f[t1 + t2]*g[t3 - T, t1, t2] + f[t2 + t3]*g[t3 - T, t2, t3]} << Given two functions f[t] and g[t] I wish to obtain their discrete convolution in points t: {t0, t1, t2, t3, ..} given with this pattern {f[t0+t1] g[t1-T,t0,t1], f[t0+t1] g[t2-T,t0,t1]+f[t1+t2] g[t2-T,t1,t2], f[t0+t1] g[t3-T,t0,t1]+f[t1+t2] g[t3-T,t1,t2]+ f[t2+t3] g[t3-T,t2,t3]} Some thing like this: discreteConvolution[list, f[t], g[t], t] = (Function to be defined) them Inp[]:=discreteConvolution[{t0, t1, t2, t3},f[t], g[t], t] Out[]:= {f[t0+t1] g[t1-T,t0,t1], f[t0+t1] g[t2-T,t0,t1]+f[t1+t2] g[t2-T,t1,t2], f[t0+t1] g[t3-T,t0,t1]+f[t1+t2] g[t3-T,t1,t2]+ f[t2+t3] g[t3-T,t2,t3]} >>

==== what may ListConvolve[] do ? ListConvolve[ker, list] forms the convolution of the kernel ker with list. ListConvolve[ker, list, k] forms the cyclic convolution in which the kth element of ker is aligned with each element in list. ListConvolve[ker, list, {kL, kR}] forms the cyclic convolution whose first element contains list[[1]] ker[[kL]] and whose last element contains list[[-1]] ker[[kR]]. ListConvolve[ker, list, klist, p] forms the convolution in which list is padded at each end with repetitions of the element p. ListConvolve[ker, list, klist, {p1, p2, ... }] forms the convolution in which list is padded at each end with cyclic repetitions of the pi. ListConvolve[ker, list, klist, padding, g, h] forms a generalized convolution in which g is used in place of Times and h in place of Plus. ListConvolve[ker, list, klist, padding, g, h, lev] forms a convolution using elements at level lev in ker and list Jens > > Dear group, I have this problem > > Given two functions f[t] and g[t] I wish to obtain their discrete > convolution in points t: {t0, t1, t2, t3, ..} given with this pattern > {f[t0+t1] g[t1-T,t0,t1], > f[t0+t1] g[t2-T,t0,t1]+f[t1+t2] g[t2-T,t1,t2], > f[t0+t1] g[t3-T,t0,t1]+f[t1+t2] g[t3-T,t1,t2]+ f[t2+t3] g[t3-T,t2,t3]} > > Some thing like this: > discreteConvolution[list, f[t], g[t], t] = (Function to be > defined) > > them > > Inp[]:=discreteConvolution[{t0, t1, t2, t3},f[t], g[t], t] > > Out[]:= > {f[t0+t1] g[t1-T,t0,t1], > f[t0+t1] g[t2-T,t0,t1]+f[t1+t2] g[t2-T,t1,t2], > f[t0+t1] g[t3-T,t0,t1]+f[t1+t2] g[t3-T,t1,t2]+ > f[t2+t3] g[t3-T,t2,t3]} > > > Guillermo ==== I am trying to show that the inverse of the Zeta(s) function is the infinite summation as n goes from 1 to infinity of MobiusMu(n)/(n^s). The Zeta(s) function is defined as the infinite summation as n goes from 1 to infinity of 1/(n^s). To do this, I am first calculating the product of two generic summations: {the infinite summation as n goes from 1 to infinity of a_n/(n^s)} times {the infinite summation as n goes from 1 to infinity of b_n/(n^s)}. What I believe is the answer is: {the infinite summation as n goes from 1 to infinity of the summation of divisors d of n of [a_d * (b_(n/d))]/(n^s)}. Using this formula, I am trying to show that: {the infinite summation as n goes from 1 to infinity of 1/(n^s) of the summation of divisors d of n of MobiusMu(n/d)/(n^s)} is one. I am trying to test my formulas on Mathematica, and understand how to program regular summations. But, I am unsure how to code the summation of divisors d of n with Mathematica. I hope that my text is understandable, without math fonts. Can someone help with the proof/Mathematica code? Diana M. -- ===================================================== ==== I came across your reply to one of the queries in the relevant context and I have been trying to implement NonlinearFit using Mathematica 4, but apparantly Mathematica is not executing it. I've tried both Need[Statistics`NonlinearFit`] as well as << Statistics`NonlinearFit` to load the package, but none of them works. The problem is that of a three parameter non-linear fitting and there must be some standard procedure of doing that in the Mathematica 4 version. Could you kindly advice. Biplab Dept. of Physics. IIT Kanpur ==== I have a problem with rounding: I create a list with rounded numbers and when I look at it in Mathematica it«s ok. But then I export the table and read it in in Exel. There 0.573 becomes 0.573000001 suddenly. Is there an Option for Export or what could I do? Uli ==== If I plot a function in 3D I get a realistic projection of the x,y and z axes. The following command will give me a box where the z-axes is almost vertical up, the y axes comes a bit out of the paper and the x-axes comes a lot out of the paper. SphericalPlot3D[SphericalHarmonicY[1, -1, th, ph] Conjugate[SphericalHarmonicY[1, -1, th,ph]],{th,0,[Pi]},{ph,0, 2[Pi]},PlotPoints->30, PlotRange->{{-0.35,0.35},{-0.35,0.35},{-0.35,0.35}},Boxed->True, Axes->True,AxesLabel->{x,y,z}, ViewPoint->{2.4,1.3,2}]; I am searching for an option where I can put the y and z axes in the paper plane and make the x-axes come on an angle out of the paper. This will not give me a realistic perspective, but it will leave the y-z plane undistorted. Hope I am clear. If anybody knows how to do so I would like to know. Maurits Haverkort ==== I'm using Time Series Package and I noticed that there is a difference between the power spectrum computed from the command Spectrum[] and that using Abs[Fourier[]. I would like to know why that difference and which method is the best as far as deriving the energy (parseval's theorem) carried in the data is concerned. Can anyone help? -- ch akpovo Laboratory for Modern Fluid Physics Florida A & M University ==== I would like to ask some questions on loading and running specific third party programs (involving symmetry analysis of differential equations). Also, I would like some pointers on programming with Mathematica. I do not intend to take a course in Mathematica, and asking for support I am happy to pay a consultant to ask questions of as I need to know them. I live in Baltimore, MD and if anyone has a suggestion for a knowledgeable consultant in the area, I would be grateful. Please reply directly to me. Raghu Raghavan. ==== Dear Mathematica friends Solve[{{a,b},{c,d}}==0] gives the correct solution in Mathematica 5.0 while NSolve[{{a,b},{c,d}}==0] fails. Is it a bug or an intention? It would be nice to have Solve and NSolve giving as close results as possible. -- Pavel Pokorny Math Dept, Prague Institute of Chemical Technology http://www.vscht.cz/mat/Pavel.Pokorny ==== I need function which finds nonzero minimum in the list. My definitions are now slower in comparison with kernel function Min[ ]. findmin1[data_] := Min[data] findmin1[dat] // Timing (* 0.01 Second*) (* Very good time consumption but wrong result for me. *) It's possible shorter time consumption for this problem? My definition are now: (* Testing data are Integer or Real numbers (possible mixed). *) SeedRandom[1]; dat = Abs[Join[Array[Random[ Integer, {-10, 10}]&, {10^4}], Array[Random[Real, {-10, 10}]&, {10^4}]]]; (*** 2. - Select ***) findmin2[data_] := Min[Select[data, Not[ZeroQ[#]]&]]; findmin3[dat] // Timing (* 0.12 Second *) (*** 3. - Sort ***) dropfirstzeros[dat_List] := Block[{i}, i = 1; While[ZeroQ[dat[[i]]], i = i + 1;]; Drop[dat, i - 1]]; findmin2[data_] := dropfirstzeros[Sort[data]][[1]]; findmin2[dat] // Timing (* 0.14 Second *) (*** 4. - Map ***) getnznum[list_] := Block[{i = 1}, While[ZeroQ[list[[i]]], i++]; list[[i]] ]; findmin4[data_] := Block[{minim = getnznum[data]}, If[(# > 0) && (minim > #), minim = #] & /@ data; minim ]; findmin4[dat] // Timing (* 0.26 Second *) (*** 5. - Do ***) getnznum[list_] := Block[{i = 1}, While[ZeroQ[list[[i]]], i++]; list[[i]] ]; findmin5[data_] := Block[{minim, p}, minim = getnznum[data]; Do[ p = data[[i]]; If[((p > 0) && (minim > p)), minim = p], {i, 1, Length[data]} ]; minim ] findmin5[dat] // Timing (* 0.32 Second *) (*************************************************************) ==== In an (unsuccessful) attempt to depict each frame as part of an animation of cone/plane intersections (circle, ellipse, parabola, hyperbola), instead of Showing [( gr1,gr2)n] ( n frames) , the following program Shows [gr1,(gr2)n] (single frame) : Needs[Graphics`ParametricPlot3D`]; gr1=CylindricalPlot3D[r, {r, -1, 1},{theta, 0,2 Pi}] ; gr2=Table[ ParametricPlot3D[{-x,y, Tan[al] (x-1)+.5 }, {x, -1, 1},{y,-1,1}],{al,-1.5,1.5,.5}]; Show[gr1,gr2]; This has the undesirable effect of the required cone section being obscured by the next succeeding intersection plane. How is it done in separate frames in a DO loop or Table? TIA G.L.Narasimham ==== [This NG seems to have gone on an extended summer vacation, on my server anyway, just as I started a big project that's been stimulating lots of queries. Hope it's having a good time, and will be back soon.] I can successfully Map OpenWrite onto a list of file names, and also Map Close onto a list of streams; in particular Map[Close, Rest[ Rest[ Streams[] ] ] ] seems to be a good way to close all open streams except the two standard ones (though maybe it's risky to assume there are always just two such standard streams?). Is there a way to use Map to Write a list of variable values to a matching list of files, e.g., something like Map[ Write, {x,y,z}, {xFile,yFile,zFile} ] ==== > dear group, > > i have a set of points which describe a varaible and his frequency, e.g. > counting the age of N people in age-bins 0-10 a,10-20 a,20-30 a,... . > Given this discrete frequency distribution i want to produce random > numbers. > How could i do this? > > > Jan Schmedes I only found this thread because I was searching the group for the answer to the same question, so sorry that this is a bit late. Here is my solution: discreteRandom[c_List] := With[{r = Random[]}, Position[c, x : _ /; x > r, 1, 1] ]; discreteRandomN[c_List, n_Integer /; n > 0] := Module[{counts}, counts = Table[0, {Length[c]}]; Map[counts[[#]]++ &, Flatten[Table[discreteRandom[c],{n}]]]; Return[counts]; ]; and called as like so, where the vector is the cumulative distribution function: In[314]:=discreteRandomN[{0.1, 0.3, 0.6, 1.0}, 10000] Out[314]:={1033, 2010, 2996, 3961} As written, discreteRandom annoyingly returns something like {{2}} instead of 2. This doesn't bother me, as I only intend to access it through discreteRandomN, not directly, but if you prefer to remove this wart: discreteRandom[c_List] := With[{r = Random[]}, Position[c, x : _ /; x > r, 1, 1][[1]][[1]] ]; discreteRandomN[c_List, n_Integer /; n > 0] := Module[{counts}, counts = Table[0, {Length[c]}]; Map[counts[[#]]++ &, Table[discreteRandom[c],{n}]]; Return[counts]; ]; If you have a the non-cumulative frequencies (i.e. {0.1,0.2,0.3,0.4} in the above example) you can convert with: cumulative = Table[Sum[nonCumulative[[j]], {j, 1, i}], {i, 1, Length[nonCumulative]}]; Comments on efficiency and style are welcome - I haven't been at this for long. (Yes, I know I could say counts instead of Return[counts]; but I prefer an explicit return from any multi-statement function.) username M.D.Woodhams. -- Quattour res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas. ==== Using the DiscreteMath`Combinatorica` package I can create a 2D visualisation of a Hypercube of n dimmensions using the command ShowGraph[Hypercube[n]]. Is it possible to create a 3D visualisation of the image? There is a nice example of what i mean on the following page: http://mathworld.wolfram.com/Tesseract.html. I can find no reference to it in the documentation. Joanthan. ==== I am trying to annotate some 2D plots made in Mathematica 5.0 (Mac OS X). I exported the plot as EPS. However, when I import it into Canvas 9, a few of the fonts are messed up. For example, what is supposed to be a bold parenthesis ( appears as a radical sign. I can't decide if this is a Mathematica problem or a Canvas problem. A few observations: * Canvas does have access to the Mathematica-specific fonts, such as Mathematica2. However, when I type ( using the Mathematica2 font within a Canvas text field, I get the same radical sign which appears when importing the 2D plot. * I tried exporting the EPS file with and without the embedded Mathematica fonts. Still had the same result. * I can convert the EPS file to PDF using ghostscript and it looks great using Adobe Acrobat 6 and Preview.app - all fonts are scalable, not bitmapped. * If I use the tool eps2eps on the EPS file, some of the fonts, e.g. the (, are rasterized while others are preserved as outline fonts. I'd rather not use bitmap versions of the fonts as I intend to scale up the plot considerably. (eps2eps is part of the ghostscript collection of tools and will essentially clean up an EPS file) * The same problem occurs when importing the ghostscript-converted PDF file into Canvas. * You can look at the problematic EPS and PDF files here: http://kc144.dyndns.org/~kevin/temp.eps http://kc144.dyndns.org/~kevin/temp.pdf Kevin -- ==== I cannot get Mathematica 5.0 (Windows NT, 512MB RAM) to efficiently manipulate a 14MB data set, which is a 2D image in a single file. The file contains a sequence of unsigned 16-bit integers stored in row-major order. I started with Utilities`BinaryFiles` - impossibly slow. Similar things happen when I ReadList bytes. Data is read much faster than even FastBinaryFiles (~ 4 sec, great!), but memory usage is just as excessive. I can't even translate bytes to unsigned ints - virtual memory thrashes (again) on the conversion function. Packed arrays don't seem to help. As a long shot, I though perhaps the 'arbitrary precision' data structures was hogging memory, so I set $MinPrecision=$MaxPrecision=16. No improvement. So, my Mathematica chops are not up to a seemingly common task. But perhaps I am misapplying Mathematica. I have seen a reference in somewhere in Mathematica documentation which refers to 400kb files as 'large'. If that is Wolfram Inc's frame of reference, then I have to change horses, to another system or Python/Mayavi/Vtk, since 14MB is only a small test case. I had hoped to process much larger chunks of much larger images (512MB). Vince Virgilio ==== I am trying to transform an expression that involves Sin[x] and Cos[x] into an expression that only contains Cos[x] terms. However, I do not succeed. The very problem seems to be that the built in rules that Mathematica knows, will always rewrite e.g. terms like -Cos[x + Pi/2] to Sin[x]. E.g. assume: f = Sin[x] + Cos[x] Now, for the sake of the example, I want mathematica to start represening f as Cos[x] - Cos[x + Pi/2]. So I try: In : f /. Sin[x] -> -Cos[x + Pi/2] Out: Sin[x] + Cos[x] It seems that mathematica does nothing, but it does: It does the replacement, then uses its internal definitions to simplify back -Cos[x + Pi/2] to Sin[x]. You can convince yourself about this by doing: In : f /. Sin[x] -> Cos[x + Pi/2] Out: Sin[x] - Cos[x] Mathematica changed the sign since you gave the wring rule. QUESTION: How can I achieve what I want, namely the form: Cos[x] - Cos[x + Pi/2]. ??? The expression I wan to simplify is of course more complex, but the same principle applies. In advance, thanks for any help. Geir Ove Norway ==== Does anybody know what the best way of multiplying ill-conditioned matrices in Mathematica is? I also need to solve a linear system with an ill-conditioned representing matrix. What is the most efficient and Arash __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ==== Try this : SetDirectory[ DirectoryName[ ToFileName[FileName/.NotebookInformation[SelectedNotebook[]]]]] > I want to put a SetDirectory (?) command at the beginning of a notebook > that will reset the working directory to the folder containing the > notebook itself. > > Objective is to have the results of any Exports, OpenWrites, etc, > executed within that notebook automatically be directed to that same > folder -- even if I close the notebook, rename it in the Finder (in Mac > jargon), and re-open it. > > Or, if I Copy or Move the notebook to a different folder and later open > it there, Exports or OpenWrites should go to that new, different folder. ==== Stuff follows below > I want to put a SetDirectory (?) command at the beginning of a notebook > that will reset the working directory to the folder containing the > notebook itself. Objective is to have the results of any Exports, OpenWrites, etc, > executed within that notebook automatically be directed to that same > folder -- even if I close the notebook, rename it in the Finder (in Mac > jargon), and re-open it. Or, if I Copy or Move the notebook to a different folder and later open > it there, Exports or OpenWrites should go to that new, different folder. > Here something that you may want to put at the beginning of your notebook and make it an initialisation celly. Alternatively you can make a package that you can load and then call the function. Hopefully this is platform independent. (* you need to load this package *) <]; (* finally set the current working directory *) SetDirectory[pathToFileDirectory] ] setDirectoryToCurrentFileDirectory[] You can write all of the above into an initialisation cell so that it evaluates everytime you open that notebook. There are probably many other ways to handle this sort of stuff but this seems the most direct. There is no error handling or final checking to see if you are in the correct directory. I tested this on a PC with Windows XP with two different files and it returned the correct directory. Yas ==== I want to put a SetDirectory (?) command at the beginning of a notebook that will reset the working directory to the folder containing the notebook itself. Objective is to have the results of any Exports, OpenWrites, etc, executed within that notebook automatically be directed to that same folder -- even if I close the notebook, rename it in the Finder (in Mac jargon), and re-open it. Or, if I Copy or Move the notebook to a different folder and later open it there, Exports or OpenWrites should go to that new, different folder. ==== Maybe you can try to remove the cache using testnbcache and rmnbcache from http://www.analog-insydes.de/utilities.html > ----- Original Message ----- > > In fact you don't need to go outside Mathematica to reduce notebook > size > > by > > removing the image cache data. See > > http://support.wolfram.com/mathematica/interface/notebooks/removeimagecac >he.html > > > We've tried this solution several years ago but found it unreliable, so > you *do* have to go outside Mathematica. > > > > > -- > Dr.-Ing. Hennig > www.kaninkolo.de/ai > aidev at kaninkolo dot de ==== ----- Original Message ----- -- Dr.-Ing. Hennig www.kaninkolo.de/ai aidev at kaninkolo dot de ==== I took a notebook that worked fine in v4.2, and it won't work in v5.0. Main culprits are: 1.) results that in v4.2 came out as numbers now appear in 5.0 as Overflow[]. Just before the Overflow error, the numbers that are given for other parameters are extremely small, but v5.0 seems to refuse to just call it zero. I've played with Precision, but to no avail. 2.) NDSolve won't recognize the given equations as equations anymore - something to do with substituting numerical values in for the symbols. I've tried using the fix (Developer`SetSystemOptions[EvaluateNumericalFunctionArgument -> False]) given under the FAQ's for numerical operations in v5.0, but it doesn't change anything. Even if it worked, basically all this command does is tell 5.0 to work like 4.2 did. So far this update doesn't work for me. ==== Does anyone now how can one switch off the spelling error check in Mathematica? Sometimes the use of similar names for variables is more convenient, and in this case the spelling error check just slows the work. ==== Try this: f[x_, y_] := x^4 + 3 x^2 + 5 y^2 + x + y; m = FindMinimum[f[x, y], {x, -3, 4}, {y, -3, 4.3}] {xmin, ymin} = {m[[2, 1, 2]], m[[2, 2, 2]]}; fplot = fplot = Plot3D[f[x, y], {x, -3, 4}, {y, -3, 4.3}, DisplayFunction -> Identity]; Show[fplot, Graphics3D[{PointSize[0.02], Hue[0], Point[{xmin, ymin, 1 + f[xmin, ymin]}]}], DisplayFunction -> $DisplayFunction]; ContourPlot[f[x, y], {x, -3, 4}, {y, -3, 4.3}, ContourShading -> False, Contours -> 20, Epilog -> {{PointSize[.02], Hue[0], Point[{xmin, ymin}]}}]; I hope this is what you want. ==== I'm running Mathematica 5 on a Solaris 8 box. When using for example the save dialog, rather than getting buttons that read 'OK', 'Cancel', and so on, I get '_okButton' and '_cancelButton'. Can anybody offer (a) and explanation for this and (b) a solution? I know there are two files named 'XMathematica' and 'XMathematica.cde' which appear to contain some sort of mapping (?) between the buttons and the button text; are they somehow unavailable, maybe due to erroneous path settings? TIA, Martin PS. I'm not a BOFH; they have tried to fix the problem, but with no luck so far. ==== I am trying to plot a contour that is a function of 3 variables, x, y, and z. I am plotting the function over a biologically interesting range of values using ContourPlot3d. The problem is that the function does not give real values over some parts of the space near an edge. When I try to plot, mathematica shows these lines in blue CompiledFunction::cfn: Numerical error encountered at instruction !(52); proceeding with uncompiled evaluation. General::stop: Further output of !(CompiledFunction :: cfn) will be suppressed during this calculation. and ContourPlot3D::gval: Function value !(((-0.6727485829490804`)) - ((0.22711205859697875` [ImaginaryI]))) at grid point x = !(0.19`), y = !(0.29`), z = !(0.28`) is not a real number. The plot that mathematica produces looks good except for one edge which is jagged! As I tell mathematica to plot more points, the size of the jags diminishes. However I am reaching the practical limit of plot points (25) in terms of time and screen resolution and that edge is still not smooth like I expect that it really is (after plotting points from a numerical simulation). I would like to get a smooth plot somehow for this function. Is there anything else I can try? I am new to mathematica. Is there anyway to say, in the function for example, that only real numbers are valid? Or will any of the ContourPlot3D options like min/max recursion or singularity help? Michael ==== with MathReader you can READ Mathematica Notebooks. You can get MR free from WRI, but every Mathematica has a MR mode, if you have no password. Regrads Peter -----Urspr.9fngliche Nachricht----- An: mathgroup@smc.vnet.net Betreff: Re: How does MathReader work? ----- Original Message ----- -- Dr.-Ing. Hennig www.kaninkolo.de/ai aidev at kaninkolo dot de ==== Using: NMaximize[{x^2 + y^2, x^2/9 + y^2/4 <= 1}, {x, y}] Mathematica 5 gives as solution: {9., {x -> -3., y -> 3.242576952529308*^-19}}. Becouse it is a simetric problem (x^2 and y^2 >= 0) the true solution should be: x -> -3 and x -> +3. What is wrong? Guillermo Sanchez ==== I am new here, and have a question about how to make my plots look the way I want. If any body knows the answer I would be glad. If I plot a function in 3D I get a realistic projection of the x,y and z axes. The following command will give me a box where the z-axe is almost vertical up, the y axe comes a bit out of the paper and the x-axe comes a lot out of the paper. SphericalPlot3D[SphericalHarmonicY[1, -1, th, ph] Conjugate[SphericalHarmonicY[1, -1, th,ph]],{th,0,[Pi]},{ph,0, 2[Pi]},PlotPoints->30, PlotRange->{{-0.35,0.35},{-0.35,0.35},{-0.35,0.35}},Boxed->True, Axes->True,AxesLabel->{x,y,z}, ViewPoint->{2.4,1.3,2}]; I am searching for an option where I can put the y and z axes in the paper plane and make the x-axe come on an angle out of the paper. This will not give me a realistic perspective, but it will leave the y-z plane undistorted. Like the plots in mathemetic text books. Hope I am clear. If anybody knows how to do so I would like to know. Maurits Haverkort ==== I was hoping someone could help me out getting this done in Mathematica: I have two continuous variables, X and Y that I regress with no intercept, so the equation ends up being: Y = MX My question is, does M significantly differ from some arbitrary value Z (Z <> 0 in this case)? How do I do this in Mathematica? Is there someplace I can just type in my expected Z and have Mathematica spit out a p-value? --j -- Jonathan Greenberg Graduate Group in Ecology, U.C. Davis http://www.cstars.ucdavis.edu/~jongreen http://www.cstars.ucdavis.edu AIM: jgrn307 or jgrn3007 MSN: jgrn307@msn.com or jgrn3007@msn.com ==== I'm looking for a fast algorithm of inverse Terras/Collatz function (i.e. f(m)={(2m-1)/3 (if integer), 2m}). This program should return the list: {1},{2},{4},{8},{5,16},{3,10,32},{6,20,21,24},{12,13,40,42,128}... etc. That correspond to the tree 1 | 2 | 4 | 8 / / / 5 16 / 3 10 32 / 6 20 21 64 ... ................. . ==== I've come to a standstill with v 5 on OS X (10.2.6). After months of back-and-forth with Wolfram support, they have declared it a personal problem. (Can't duplicate but won't tell me what machines they tested it on.) Apparently the problem is machine dependent-- it happens with 100% reliability on our fast dual processor machines, but not on our laptops. To see the problem (or not), put a series of expressions of the form (multiple expressions accelerates the crash) into a cell and evaluate: ExportString[a,GIF]; ExportString[a,GIF]; . . . . Also crashes Mathematica with other image formats. I would appreciate hearing how others fare with this (esp. w.r.t. machine). Wolfram support accuses me (literally!!) of having an impure system. Impure thoughts maybe, but I replicated this on a machine right out of its carton, with -only- Mathematica installed. (Hmm, maybe they meant Mathematica....) I'm sorry for sending what amounts to a bug report to the list, but I went through channels with no joy. Unfortunately, this feature is important to a series of my applications, hence my frustration. A few other notes: - Even if this fails to crash Mathematica (on a PB for example), it's an order of magnitude (!!) slower than 4.2 - Under Panther, any export call of this type is DOA (dead stall), whatever the machine. - Nothing like this happens under v 4.2 (even under Panther), but it is apparent from my observations that Mathematica's converter, gif.exe/pnm.exe, has a memory leak. The converters (4.2) are unusably slow under Panther. Michael Williams Mathematics Virginia Tech On 9/16/03, selwynh@earthlink.net () said: >The first of these --- the (not) rotated text bug --- has not been >fixed either. Another bizarre bug has popped up in 5.0: In text cells, lines are >sometimes broken after apostrophes. So a word like >can[CloseCurlyQuote]t will break between [CloseCurlyQuote] and t. >Astonishing. I wonder if that happens in Windows too. ----- http://www.math.armstrong.edu/faculty/hollis ....