Subject: Proving inequalities with Mathematica I was wondering whether Mathematica is useful for proving a problem of inequality. My problem is as follows: Let An and Bn (n=1,2,3...) be real sequences. Some characteristics of these sequences are known. i) Abs[An+1/An] < 1 ii) Abs[Bn+1/Bn] < 1 iii) Sum[An, {1,Infinity}] = 0 iv) Sum[An*Bn, {1, Infinity}] = alpha (note: a real number) Then I want to prove with Mathematica that 0 < Abs[alpha] < Abs[A1*B1] Does anyone have an idea? -Toshi === Subject: Re: Proving inequalities with Mathematica I wish I'd thought of that. Brilliant, Andrzej. FWIW, here's a process for making other examples (now that you've pointed the way): Clear[a,b] a[n_]=(100/99)^-n; Simplify[Abs[a[n+1]/a[n]]<1,n>1] True (If that fails, choose another series.) Now choose a[1] and a[2]: s = Simplify[Sum[a[n], {n, 3, Infinity}]]; {a[1], a[2]} = {x, y} /. First@FindInstance[{x + y == -s, Abs@x > Abs@y > Abs@a@3}, {x, y}, Reals] {-(490001/5000), 9703/10000} All premises are guaranteed at this point (setting b == a), but the conclusion can NEVER be true, since Sum[a[i]^2, {i, 1, Infinity}] < a[1]^2 is equivalent to: Sum[a[i]^2, {i, 2, Infinity}] < 0 But wait -- could FindInstance fail? Consider this, just for s >= 0: s =. ; Reduce[{s >= 0, x + y == -s, Abs[x] > Abs[y] > Abs[a3], a3 [Element] Reals}, {x, y}, Reals] s > 0 && ((a3 <= -(s/2) && x < a3 - s) || (Inequality[-(s/2), Less, a3, LessEqual, 0] && (x < a3 - s || -a3 - s < x < -(s/2))) || (0 < a3 < s/2 && (x < -a3 - s || a3 - s < x < -(s/2))) || (a3 >= s/2 && x < -a3 - s)) && y == -s - x The Or in the middle is a run-down of all the ways a3 can stand in relation to +-s/2 and 0; for every case we have a non-empty range in which to choose x and a formula for y. The situation is similar for s<0. Bobby >> I was wondering whether Mathematica is useful for proving a problem of >> inequality. >> My problem is as follows: >> Let An and Bn (n=1,2,3...) be real sequences. >> Some characteristics of these sequences are known. >> i) Abs[An+1/An] < 1 >> ii) Abs[Bn+1/Bn] < 1 >> iii) Sum[An, {1,Infinity}] = 0 >> iv) Sum[An*Bn, {1, Infinity}] = alpha (note: a real number) >> Then I want to prove with Mathematica that >> 0 < Abs[alpha] < Abs[A1*B1] >> Does anyone have an idea? >> -Toshi > First of all, you have written your condition as >> Abs[An+1/An] < 1 > Presumably you meant n+1 to be a subscript (if not the condition is > always false). > Assuming that, Mathematica can certainly be helpful in proving your > claim to be false. Here is an example. > We define the sequence A[n] as follows: > A[1] = -1; A[2] = Log[2]; > A[n_] = (-1)^(n - 1)/(n - 1); > You can check that the condition Abs[A[n+1]/A[n]]<1 is always > satisfied. We also define the sequence B[n] by > B[i_] := A[i] > so that the condition > Abs[B[n+1]/B[n]]<1 > is satisifed. > We check that (iii) is satisfied: > A[1]+A[2]+Sum[A[n],{n,3,Infinity}]//Simplify > Let's now compute alpha: > alpha=A[1]*B[1]+A[2]*B[2]+Sum[A[i]*B[i],{i,3,Infinity}]//N > 2.12539 > Let's see if your inequality holds: > Abs[alpha] False > Oops ... > Andrzej Kozlowski > Chiba, Japan > http://www.akikoz.net/~andrzej/ > http://www.mimuw.edu.pl/~akoz/ -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Proving inequalities with Mathematica > I was wondering whether Mathematica is useful for proving a problem of > inequality. > My problem is as follows: > Let An and Bn (n=1,2,3...) be real sequences. > Some characteristics of these sequences are known. > i) Abs[An+1/An] < 1 > ii) Abs[Bn+1/Bn] < 1 > iii) Sum[An, {1,Infinity}] = 0 > iv) Sum[An*Bn, {1, Infinity}] = alpha (note: a real number) > Then I want to prove with Mathematica that > 0 < Abs[alpha] < Abs[A1*B1] > Does anyone have an idea? > -Toshi First of all, you have written your condition as > Abs[An+1/An] < 1 Presumably you meant n+1 to be a subscript (if not the condition is always false). Assuming that, Mathematica can certainly be helpful in proving your claim to be false. Here is an example. We define the sequence A[n] as follows: A[1] = -1; A[2] = Log[2]; A[n_] = (-1)^(n - 1)/(n - 1); You can check that the condition Abs[A[n+1]/A[n]]<1 is always satisfied. We also define the sequence B[n] by B[i_] := A[i] so that the condition Abs[B[n+1]/B[n]]<1 is satisifed. We check that (iii) is satisfied: A[1]+A[2]+Sum[A[n],{n,3,Infinity}]//Simplify 0 Let's now compute alpha: alpha=A[1]*B[1]+A[2]*B[2]+Sum[A[i]*B[i],{i,3,Infinity}]//N 2.12539 Let's see if your inequality holds: Abs[alpha] I was wondering whether Mathematica is useful for proving a problem of > inequality. > My problem is as follows: > Let An and Bn (n=1,2,3...) be real sequences. > Some characteristics of these sequences are known. > i) Abs[An+1/An] < 1 > ii) Abs[Bn+1/Bn] < 1 > iii) Sum[An, {1,Infinity}] = 0 > iv) Sum[An*Bn, {1, Infinity}] = alpha (note: a real number) > Then I want to prove with Mathematica that > 0 < Abs[alpha] < Abs[A1*B1] > Does anyone have an idea? > -Toshi Sorry Toshi, I can't imagine any sequence of real A_n with |A_n + 1/A_n|<1 -- Peter Pein 10245 Berlin === Subject: Finding the Fourier transform of discrete functions I found out it's possible to determine the Fourier transform of a function. I tried to look for the discrete fourier transform in the guide, but I can find the item in the list without any explaination of the function. Is it possible to find the Fourier transform of a discrete function? Luca === Subject: Re: Re: Finding the Fourier transform of discrete functions >> what is a discrete function. >> if it is a function, the parameter is continuous and FourierTransform[] >> compute the transformation. A discrete function is a function with a discrete domain. For instance, this is a discrete function on the obvious domain: f[x_Integer]/;1<=x<=12 = Sin@x It is NOT the Sin function, for the simple reason that the domain of a function (in math or mathematica) is part of its definition. Bobby > what is a discrete function. If it is discrete you have a array of > discrete data and Fourier[] compute the DFT of the array, if it is > a function, the parameter is continuous and FourierTransform[] > compute the transformation. > Jens > Luca schrieb im Newsbeitrag >> I found out it's possible to determine the Fourier transform of a >> function. I tried to look for the discrete fourier transform in the >> guide, but I can find the item in the list without any explaination of >> the function. Is it possible to find the Fourier transform of a >> discrete function? >> Luca -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Re: Re: Finding the Fourier transform of discrete functions No, I think x_Integer is discrete. Obviously. Bobby > and you think that 1<=x<12 is discret, and not a infinite number > of continuous values ?? Strange ! > Jens > DrBob schrieb im Newsbeitrag >>what is a discrete function. >>if it is a function, the parameter is continuous and FourierTransform[] >>compute the transformation. >> A discrete function is a function with a discrete domain. >> For instance, this is a discrete function on the obvious domain: >> f[x_Integer]/;1<=x<=12 = Sin@x >> It is NOT the Sin function, for the simple reason that the domain of a >> function (in math or mathematica) is part of its definition. >> Bobby >what is a discrete function. If it is discrete you have a array of >discrete data and Fourier[] compute the DFT of the array, if it is >a function, the parameter is continuous and FourierTransform[] >compute the transformation. > Jens >Luca schrieb im Newsbeitrag >>I found out it's possible to determine the Fourier transform of a >>function. I tried to look for the discrete fourier transform in the >>guide, but I can find the item in the list without any explaination of >>the function. Is it possible to find the Fourier transform of a >>discrete function? >> >>Luca >> >> -- >> DrBob@bigfoot.com >> www.eclecticdreams.net -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Re: Re: Re: Finding the Fourier transform of discrete functions >> description discrete apply not to a symbolic expressions. Maybe not, but it does apply to mathematical functions and their domains. See for instance: http://www.2dcurves.com/discrete/discrete.html http://caltechcdstr.library.caltech.edu/5/ http://www.sparknotes.com/math/algebra2/discretefunctions/terms/term_B.2.htm l http://portal.acm.org/citation.cfm?id=225072 http://mathforum.org/epigone/sci.math.research/grorrinroi http://www.informs.org/Conf/NewOrleans95/TALKS/MC26.1.html http://www.ds.unifi.it/VL/VL_EN/dist/dist1.html (I could go on all day.) Bobby > I think x_Integer is a pattern, that stand for any integer number, > it is a symbolic expression and the description discrete apply > not to a symbolic expressions. > Jens > DrBob schrieb im Newsbeitrag >> No, I think x_Integer is discrete. >> Obviously. >> Bobby >and you think that 1<=x<12 is discret, and not a infinite number >of continuous values ?? Strange ! > Jens >DrBob schrieb im Newsbeitrag >>what is a discrete function. >>if it is a function, the parameter is continuous and >>FourierTransform[] >>compute the transformation. >> >>A discrete function is a function with a discrete domain. >> >>For instance, this is a discrete function on the obvious domain: >> >>f[x_Integer]/;1<=x<=12 = Sin@x >> >>It is NOT the Sin function, for the simple reason that the domain of a >>function (in math or mathematica) is part of its definition. >> >>Bobby >> >> > >what is a discrete function. If it is discrete you have a array of >discrete data and Fourier[] compute the DFT of the array, if it is >a function, the parameter is continuous and FourierTransform[] >compute the transformation. Jens > > >Luca schrieb im Newsbeitrag >>I found out it's possible to determine the Fourier transform of a >>function. I tried to look for the discrete fourier transform in the >>guide, but I can find the item in the list without any explaination of >>the function. Is it possible to find the Fourier transform of a >>discrete function? >-- >DrBob@bigfoot.com >www.eclecticdreams.net > -- > DrBob@bigfoot.com > www.eclecticdreams.net === Subject: Re: Re: Finding the Fourier transform of discrete functions and you think that 1<=x<12 is discret, and not a infinite number of continuous values ?? Strange ! Jens DrBob schrieb im Newsbeitrag >what is a discrete function. >if it is a function, the parameter is continuous and FourierTransform[] >compute the transformation. > A discrete function is a function with a discrete domain. > For instance, this is a discrete function on the obvious domain: > f[x_Integer]/;1<=x<=12 = Sin@x > It is NOT the Sin function, for the simple reason that the domain of a > function (in math or mathematica) is part of its definition. > Bobby >> what is a discrete function. If it is discrete you have a array of >> discrete data and Fourier[] compute the DFT of the array, if it is >> a function, the parameter is continuous and FourierTransform[] >> compute the transformation. >> Jens >> Luca schrieb im Newsbeitrag >I found out it's possible to determine the Fourier transform of a >function. I tried to look for the discrete fourier transform in the >guide, but I can find the item in the list without any explaination of >the function. Is it possible to find the Fourier transform of a >discrete function? >Luca > -- > DrBob@bigfoot.com > www.eclecticdreams.net === Subject: Re: Finding the Fourier transform of discrete functions > and you think that 1<=x<12 is discret, and not a infinite number > of continuous values ?? Strange ! > Jens > DrBob schrieb im Newsbeitrag >>what is a discrete function. >>if it is a function, the parameter is continuous and FourierTransform[] >>compute the transformation. >>A discrete function is a function with a discrete domain. >>For instance, this is a discrete function on the obvious domain: >>f[x_Integer]/;1<=x<=12 = Sin@x *^^^^^^^^* >>It is NOT the Sin function, for the simple reason that the domain of a >>function (in math or mathematica) is part of its definition. >>Bobby >>.... I think, it's his firm conviction that there are only 12 Integers x in the interval 1<=x<=12. ;-) -- Peter Pein 10245 Berlin === Subject: Re: Finding the Fourier transform of discrete functions f[x_Integer]]/;1<=x<=12 = Sin@x say that for a integer x in [1,12] the function can be simplifyed to Sin[x], it say *not* that for other arguments the function is indeterminate. The additional definition f[_]:=Indeterminate would do that. Jens Peter Pein schrieb im Newsbeitrag >> and you think that 1<=x<12 is discret, and not a infinite number >> of continuous values ?? Strange ! >> Jens >> DrBob schrieb im Newsbeitrag >what is a discrete function. >if it is a function, the parameter is continuous and FourierTransform[] >compute the transformation. >A discrete function is a function with a discrete domain. >For instance, this is a discrete function on the obvious domain: >f[x_Integer]/;1<=x<=12 = Sin@x > *^^^^^^^^* >It is NOT the Sin function, for the simple reason that the domain of a >function (in math or mathematica) is part of its definition. >Bobby >.... > I think, it's his firm conviction that there are only 12 Integers x in > the interval 1<=x<=12. ;-) > -- > Peter Pein > 10245 Berlin === Subject: Re: Finding the Fourier transform of discrete functions Look up Fourier (not FourierTransform) in the Help Browser. Steve Luttrell >I found out it's possible to determine the Fourier transform of a > function. I tried to look for the discrete fourier transform in the > guide, but I can find the item in the list without any explaination of > the function. Is it possible to find the Fourier transform of a > discrete function? > Luca === Subject: Re: Finding the Fourier transform of discrete functions what is a discrete function. If it is discrete you have a array of discrete data and Fourier[] compute the DFT of the array, if it is a function, the parameter is continuous and FourierTransform[] compute the transformation. Jens Luca schrieb im Newsbeitrag >I found out it's possible to determine the Fourier transform of a > function. I tried to look for the discrete fourier transform in the > guide, but I can find the item in the list without any explaination of > the function. Is it possible to find the Fourier transform of a > discrete function? > Luca === Subject: Re: sort procedure Test data sorted by first values: data=Sort[Table[ {Random[Integer,{0,100}], Random[Integer,{0,100}]},{5}]] {{18, 1}, {25, 29}, {51, 99}, {67, 90}, {81, 45}} Sorted by second value: Sort[data, #1[[2]]<#2[[2]]&] {{18, 1}, {25, 29}, {81, 45}, {67, 90}, {51, 99}} Bob Hanlon === > Subject: sort procedure > If I have a data serie of n paired observations (x_t,x_t-1) ordered according to time, how can i re-order this serie according to the size of x_t-1 > The procedure Sort it seems it does not work well. > anyone has suggestions? > P. > ____________________________________________________________ > Libero ADSL: navighi gratis a 1.2 Mega, senza canone e costi di attivazione. > Abbonati subito su http://www.libero.it === Subject: again Compile In a Compiled Function I have the construct p = Position[Thread[(#1 < #2 < #3) &[lb, x, ub]], False]; gives me the error message Symbol not supported for type True|False What's the problem here. Can't I use another function definition in a Compiled Function? Best, joerg === Subject: Re: again Compile > In a Compiled Function I have the construct > p = Position[Thread[(#1 < #2 < #3) &[lb, x, ub]], False]; > gives me the error message > Symbol not supported for type True|False > What's the problem here. Can't I use another function definition in a > Compiled Function? > Best, > joerg Hi J.9arg, In the moment I see nothing better than substituting the boolean constants by integers: test = Compile[{{l, _Integer}, {x, _Integer, 1}, {u, _Integer}}, p = Position[Thread[l < x < u] /. {True -> 1, False -> 0}, 0], {{p, _Integer, 2}}] test[3, Range[10], 8] {{1}, {2}, {3}, {8}, {9}, {10}} -- Peter Pein 10245 Berlin === Subject: help on sublists xor hi. i'm trying to implement a way to mark all binary lists in which three non overlapping sublists of the same length(of length >= 3) a, b, and c , where c is the result of xor of a and b, in all way they can present (orderless). But it don't work , specially orderless. somebody can help me? any help will be apreciate. giorgio ZeroPad[x__] :=(*Takes Transpose after zero - padding*)Module[{l, y = Map[(# /. d_Integer :> IntegerDigits[d, 2]) &, {x}]}, l = Map[Length, y]; Transpose[MapThread[Join[Table[0, {Max[l] - #1}], #2] &, {l, y}]]] BitwiseXor[x__] := Flatten[Apply[Mod[Plus[##], 2] &, ZeroPad[x], {1}]] << DiscreteMath`Combinatorica` SetAttributes[mm, Orderless] mmQ[t1, t2, t3] := True /; (BitwiseXor[t1, t2] == t3) && (Length[t1] = 3) && ( Length[t2] = 3) && (Length[t3] = 3) m[{x1___, a1__, x2___, a2__, x3___, a3__, x4___}] := {} /; mmQ[{a1}, { a2}, {a3}] m[l_] := l t1 = Strings[{0, 1}, 10]; Rest[Union[Map[m, t1]]] === Subject: Re: canonical mathematical expression represenation? Yes it is annoying the way Mathematica tends to get the minus signs where we would prefer not to have them. One way to fix this, in simple expressions at least, is to Map Minus to the two factors you would wish to change. Sum[a^k, {k, 0, M}] MapAt[Minus, %, {{1, 1}, {2}}] (-1 + a^(1 + M))/(-1 + a) (1 - a^(1 + M))/(1 - a) I find that it is almost always possible to manipulate expressions to the form you want, textbook form say, but it is a bit of an art and sometimes even I have to come to MathGroup to learn the trick. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I noticed that Mathematica represents expressions with some specific 'way' or order. For example, Sum[a^k, {k, 0, M}] gives -1 + a^(1+M) ------------- -1 + a How can I make it display the expression, in what I would consider a more 'natural' way, as follows 1 - a^(1+M) ------------- 1 - a I am sure there is a way to do, and why do you think Mathematica does it the way it does? what is the logic of how it represents things? is there a command to convert the first output to the second? I tried few commands, but can not figure it out. thank you, --nospam === Subject: pair functions applied to Zeta function in two ways When I thought of this , I felt that it might work for the zeta zeros, but experience with it in Mathematica shows these sums functions are too far from analytical in s=1/2 strip. (* pair functions applied to Zeta function in two ways*) (*the first with {1/(n+1),n/(1+n)} as the pair gives nearly a straight line as parametricPlot*) (* second with {1/(x+1),x/(1+x)} as the pair gives seems like conic curve:parabolic or hyperbolic*) (* The second has a definite minimum due to the gzetax near 3.5*) (* it is doubtful these sums will be any good in the zeta zero region of 1/2+I*b[n]*) (* where fzeta[1/2+I*b[n]]=-gzeta[1/2+I*b[n]]: fzetax[1/2+I*b[n]]=-gzetax[1/2+I*b[n]] *) fzeta[x_]=Sum[If[Mod[n,2]==1,(1/(n+1)),(n/(n+1))]/n^x,{n,1,Infinity}] gzeta[x_]=Sum[If[Mod[n,2]==1,(n/(n+1)),(1/(n+1))]/n^x,{n,1,Infinity}] ParametricPlot[{N[fzeta[x]],N[gzeta[x]]},{x,2,5}] Plot[N[fzeta[x]],{x,2,5},PlotRange->All] Plot[N[gzeta[x]],{x,2,5},PlotRange->All] fzetax[x_]=Sum[If[Mod[n,2]==1,(1/(x+1)),(x/(x+1))]/n^x,{n,1,Infinity}] gzetax[x_]=Sum[If[Mod[n,2]==1,(x/(x+1)),(1/(x+1))]/n^x,{n,1,Infinity}] ParametricPlot[{N[fzetax[x]],N[gzetax[x]]},{x,2,5},PlotRange->All] Plot[N[fzetax[x]],{x,2,5},PlotRange->All] Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: Speeding Up Indexing andJoining I think you can get a very substantial reduction in your run-time, down from many, many hours to less than a minute, perhaps. I borrowed the main idea from an example in the Help browser under Split (see the function defined therein, called Classify). This function, which I use in a very restricted sense, takes two lists and constructs disjoint sets of members of both lists which share some condition. In your case, it takes the joint list Join[a, b] and selects those members which have the same value in the first element. It goes on building these sets. In some cases, there will only be one element (where there is no element in b with the same first element as in a); in other cases, there will be two (when it finds an element in b which has the same value in the first position as an element in a). All you have to do then is to Select those cases with two elements, and you obtain your desired objective. The function Classify is defined as In[1]:= Classify[s_,f_:Identity]:= Map[Last,Split[Sort[{f[#],#}&/@s],SameQ[First[#1],First[#2]]&],{2}] Try to understand what's going on - it is really worth your while. Then, applying it to your example, In[2]:= a = {{123, bob, 46, fo}, {133, harry, 45, fo}, {165, pete, 44, fo}, {2569, moe, 56, fo}, {6589, ben, 69, fo}}; b = {{133, 1, 46, go, 6}, {165, 88, 45, mo, 7}, {166, 53, 44, do, 9}, {25, 82, 56, ho, 9}, {6589, 77, 69, xo, 11}, {6570, 77, 69, xo, 11}, {6571, 77, 69, xo, 11}, {6572, 77, 69, x0, 11}}; In[4]:= pp = Join[b, a]; In[5]:= gg[s_] := s[[{1}]] t = Classify[pp, gg] Out[6]= {{{25, 82, 56, ho, 9}}, {{123, bob, 46, fo}}, {{133, harry, 45, fo}, {133, 1, 46, go, 6}}, {{165, pete, 44, fo}, {165, 88, 45, mo, 7}}, {{166, 53, 44, do, 9}}, {{2569, moe, 56, fo}}, {{6570, 77, 69, xo, 11}}, {{6571, 77, 69, xo, 11}}, {{6572, 77, 69, x0, 11}}, {{6589, ben, 69, fo}, {6589, 77, 69, xo, 11}}} Then Select those lists which have two elements, and join the two elements: In[7]:= Join[#[[2]],#[[1]]]&/@(Select[t,Length[#]>1&]) Out[7]= {{133,1,46,go,6,133,harry,45,fo},{165,88,45,mo,7,165,pete,44,fo},{6589,77,69 , xo,11,6589,ben,69,fo}} which is the result you were after. I have applied this to a problem where a has over 280,000 records, each with some 40 elements, and b has around 40,000 records, each with 5 or 6 elements. I obtained the result in about 20 seconds. Notice that I avoid the use of the term matrices; it is quite unnecesary, since your lists inside a and b can have differents lengths, and their elements may not be numbers. There is nothing in the problem that has anything to do with concepts in matrix theory. We use mere lists... This is a beautiful example of the use of functional programming. It also illustrates the benefits of using the Help browser and studying the examples therein. Tomas Garza Mexico City ----- Original Message ----- === Subject: Speeding Up Indexing and Joining > Fellow MathGroup, > Here is a simple example. > Again on large mattices, it takes many many hours > In[31]:= > a={{123,bob,46,fo},{133,harry,45,fo},{ > 165,pete,44,fo},{2569,moe,56,fo},{6589,ben,69,fo}}; > In[32]:= > b={{133,1,46,go,6},{165,88,45,mo,7},{ > 166,53,44,do,9},{25,82,56,ho,9},{6589,77,69,xo,11},{6570,77,69, > xo,11},{6571,77,69,xo,11},{6572,77,69,xo,11}}; > ROUTINE > Create Index from Intersection of the first columns of matrix a and = > matrix b > firstCol=1; > lastCol =1; > aa = Transpose[Take[Transpose[a],{firstCol, lastCol}]]; > bb = Transpose[Take[Transpose[b],{firstCol, lastCol}]]; > idx=Intersection[aa,bb]; > In[40]:= > idx=Intersection[aa,bb] > Out[40]= > {{133},{165},{6589}} > Select Records (Rows) from both matrix a and matrix b that equal the = > idx. > The idx consists of numerics > Locate Position Of Each Record In each matrix using idx > n=Length[idx]+1; > ans01={}; > For[i=1,i step1 = Position[aa,idx[[i]]]; > AppendTo[ans01,step1]] > n=Length[idx]+1; > ans02={}; > For[i=1,i step1 = Position[bb,idx[[i]]]; > AppendTo[ans02,step1]] > Extract a Records > ans01 =Extract[a,ans01]; > ans02 =Extract[b,ans02]; > Sort each matrix by Column 1 using a defined function > ans01=matsort[ans01,1]; ans02=matsort[ans02,1]; > In[69]:= > final=RowJoin[ans02,ans01] > Out[69]= = > {{133,1,46,go,6,133,harry,45,fo},{165,88,45,mo,7,165,pete,44,fo},{ > 6589,77,69,xo,11,6589,ben,69,fo}} > -----Original Message----- > mailto:tgarza01@prodigy.net.mx] === > Subject: Speeding UP Indexing and > Joining > ofDifferentSizeRectangular Matrixes > Perhaps something could be done. Please explain your problem in more > detail. > Never mind your program (what is loc01?). What do you mean by joining > rows? > Give a small example with small matrices (say 5 x 2 or something like > that). > What are your present run times? > Tomas Garza > Mexico City > ----- Original Message ----- === > Subject: Speeding UP Indexing and Joining of > DifferentSizeRectangular Matrixes >> Fellow MathGroup, >> I have been using Mathematica for financial analysis purposes and have >> been developing note book programs for about 5 years. >> My skills at this are self taught with help from Wolfram training and >> support. >> The largest challenge has been the speed in the analysis of large data >> sets. >> The following is an example of a routine that takes many hours. >> PLEASE HELP AND SHOW HOW I CAN IMPROVE THE ROUTINE TO MAKE THE RUN > TIME >> SHORTER. >> Equipment HP XP 3.24 processor 2 Gigs >> Mathematica 5.01 >> Data set a= 257470 by 40, Mixed numeric and string fields, but each >> field >> (column) is either or numeric or string >> Data set b= 258705 by 5, All fields are numeric >> Objective: RowJoin the rows from each data set that have the same ID >> field in their corresponding column one. >> ROUTINE >> Create Index By Invoice ID >> firstCol=loc01[[1]]; >> lastCol =loc01[[1]]; >> aa = Transpose[Take[Transpose[a],{firstCol, lastCol}]]; >> Length[aa] >> 257470 >> firstCol=loc04[[1]]; >> lastCol =loc04[[1]]; >> bb = Transpose[Take[Transpose[b],{firstCol, lastCol}]]; >> Length[bb] >> 258705 >> idx=Intersection[aa,bb]; >> Length[idx] >> 257249 >> n=Length[idx]+1 >> 257250 >> Locate Position Of Each Record In aTable >> ans01={}; >> For[i=1,i> step1 = Position[aa,idx[[i]]]; >> AppendTo[ans01,step1]] >> ans01=Flatten[ans01,1]; >> Locate Position Of Each Record In bTable >> ans02={}; >> For[i=1,i> step1 = Position[bb,idx[[i]]]; >> AppendTo[ans02,step1]] >> ans02=Flatten[ans02,1]; >> Extract a Records by Index >> ans01 =Extract[currentBalance,ans01]; >> Dimensions[ans01] >> Flatten If Not A Matrix >> If[MatrixQ[ans01],ans01=ans01,ans01=Flatten[ans01,1]]; >> Dimensions[ans01] >> Extract b Records by Index >> ans02 =Extract[interestBalance,ans02]; >> Dimensions[ans02] >> Flatten If Not A Matrix >> If[MatrixQ[ans02],ans02=ans02,ans02=Flatten[ans02,1]]; >> Dimensions[ans02] >> ans01=matsort[ans01,loc01[[1]]]; >> ans02=matsort[ans02,loc04[[1]]]; >> noteTerms=RowJoin[ans02,ans01]; >> Dimensions[noteTerms] === Subject: Re: sort procedure >If I have a data serie of n paired observations (x_t,x_t-1) ordered >according to time, how can i re-order this serie according to the >size of x_t-1 >The procedure Sort it seems it does not work well. anyone has >suggestions? And how did you use Sort? If you correctly specify the ordering function then Sort should work fine. For example: In[1]:= data = Table[{Random[], 1/Random[]}, {5}]; Sort[data, OrderedQ[{Last[#1], Last[#2]}] & ] {{0.0853819963788964, 1.1126376511652434}, {0.12440319976153577, 1.4220646967618538}, {0.8122355791743191, 4.349104929218276}, {0.6792157180842403, 6.721164898417004}, {0.7037212527850069, 11.641624761351718}} -- To reply via email subtract one hundred and four === Subject: use of orderless i'm trying to implement a mark all binary lists in which three non overlapping sublists of the same length(of length >= 3) a, b, and c , where c is the result of xor of a and b, in all way they can present (orderless). But it don't work . somebody can help me? ZeroPad[x__] :=(*Takes Transpose after zero - padding*)Module[{l, y = Map[(# /. d_Integer :> IntegerDigits[d, 2]) &, {x}]}, l = Map[Length, y]; Transpose[MapThread[Join[Table[0, {Max[l] - #1}], #2] &, {l, y}]]] BitwiseXor[x__] := Flatten[Apply[Mod[Plus[##], 2] &, ZeroPad[x], {1}]] << DiscreteMath`Combinatorica` SetAttributes[mm, Orderless] mmQ[t1, t2, t3] := True /; (BitwiseXor[t1, t2] == t3) && (Length[t1] = 3) && (Length[t2] = 3) && (Length[t3] = 3) m[{x1___, a1__, x2___, a2__, x3___, a3__, x4___}] := {} /; mmQ[{a1}, { a2}, {a3}] m[l_] := l t1 = Strings[{0, 1}, 10]; Rest[Union[Map[m, t1]]] Length[%] 1023 === Subject: Re: use of orderless > i'm trying to implement a mark all binary lists in which three non > overlapping sublists of the same length(of length >= 3) a, b, and c , > where > c is the result of xor of a and b, in all way they can present > (orderless). > But it don't work . somebody can help me? > ZeroPad[x__] :=(*Takes Transpose after zero - padding*)Module[{l, y = > Map[(# > /. d_Integer :> IntegerDigits[d, 2]) &, {x}]}, l = Map[Length, y]; > Transpose[MapThread[Join[Table[0, {Max[l] - #1}], #2] &, {l, y}]]] > BitwiseXor[x__] := Flatten[Apply[Mod[Plus[##], 2] &, ZeroPad[x], {1}]] > << DiscreteMath`Combinatorica` > SetAttributes[mm, Orderless] > mmQ[t1, t2, t3] := True /; (BitwiseXor[t1, t2] == t3) && (Length[t1] > = 3) && (Length[t2] = 3) && (Length[t3] = 3) > m[{x1___, a1__, x2___, a2__, x3___, a3__, x4___}] := {} /; mmQ[{a1}, { > a2}, {a3}] > m[l_] := l > t1 = Strings[{0, 1}, 10]; > Rest[Union[Map[m, t1]]] > Length[%] > 1023 I'm sorry but from <<..Combinatrica on I don't understand your code. (What is mm?) How should Mathematica determine, which arguments of m[] should be assigned to which argument? I would prefer Lists as arguments. The functions ZeroPad and BitwiseXor can be written easier: In[1]:= ZeroPad[x__] := Module[{l, y = IntegerDigits[#, 2] & /@ {x}}, l = Max[Length /@ y]; Transpose[PadLeft[#, l] & /@ y] ] In[2]:= ZeroPad[1, 2, 3, 4, 5] Out[2]= {{0, 0, 0, 1, 1}, {0, 1, 1, 0, 0}, {1, 0, 1, 0, 1}} In[3]:= BitwiseXor[x__] := PadLeft[IntegerDigits[BitXor[x], 2], If[# == 0, 1, 1 + Floor[Log[2, #]]] &[Max[x]]] In[4]:= BitwiseXor[1, 2, 3, 4, 5] Out[4]= {0, 0, 1} -- Peter Pein 10245 Berlin === Subject: Re: use of orderless i'm sorry the right is SetAttributes[mmQ, Orderless] mmQ is a function feeded by a,b,c where a(xor)b=c , and length >=3, where a,b,c can be interchanged thanx === Subject: Re: use of orderless sorry the right is SetAttributes[mmQ, Orderless] mmQ is a function feeded by a, b c. They have to be sublist of length >=3 and a (xor) b ==c. the problem that i need that a,b,c must be interchangable. thanx === Subject: Re: use of orderless > sorry > the right is SetAttributes[mmQ, Orderless] > mmQ is a function feeded by a, b c. They have to be sublist of length >>=3 and a (xor) b ==c. > the problem that i need that a,b,c must be interchangable. > thanx mmQ[a_,b_,c_]:=If[Length/@{a,b,c}=={3,3,3},Thread[BitXor[a,b,c]]=={0,0,0},Fa lse] should do this job. -- Peter Pein 10245 Berlin === Subject: FourierTransform In Version 4 Mathematica was smart enough to know that FourierTransform[f'[x], x, k] should give -[ImaginaryI] k FourierTransform[f[x], x, k]. Version 5 seems no longer to do this -- a nice classroom demonstration and a valuable method of solving differential equations down in flames. Why is this? Tony Harker (Dr A.H. Harker) Deputy Head of Department Deputy Head, Condensed Matter and Materials Physics Group Department of Physics and Astronomy University College London Gower Street LONDON WC1E 6BT (44)(0)207 679 3404 a.harker@ucl.ac.uk === Subject: Re: FourierTransform Version 5.1 does it correctly. Steve Luttrell > In Version 4 Mathematica was smart enough to know that > FourierTransform[f'[x], x, k] > should give > -[ImaginaryI] k FourierTransform[f[x], x, k]. > Version 5 seems no longer to do this -- a nice classroom demonstration and > a valuable method of solving differential equations down in flames. > Why is this? > Tony Harker (Dr A.H. Harker) > Deputy Head of Department > Deputy Head, Condensed Matter and Materials Physics Group > Department of Physics and Astronomy > University College London > Gower Street > LONDON > WC1E 6BT > (44)(0)207 679 3404 > a.harker@ucl.ac.uk === Subject: Re: FourierTransform why do you think that FourierTransform[f'[x], x, k] for a general function is convergent ? It is simple to add the rule explicit by expr = FourierTransform[f'[x], x, k]; iKnowItIsConvergent = FourierTransform[a_.*Derivative[n_][f_][x_], x_, k_] :> a*(-I k)^n FourierTransform[f[x], x, k]; expr /. iKnowItIsConvergent Jens Dr A.H. Harker schrieb im Newsbeitrag > In Version 4 Mathematica was smart enough to know that > FourierTransform[f'[x], x, k] > should give > -[ImaginaryI] k FourierTransform[f[x], x, k]. > Version 5 seems no longer to do this -- a nice classroom demonstration and > a valuable method of solving differential equations down in flames. > Why is this? > Tony Harker (Dr A.H. Harker) > Deputy Head of Department > Deputy Head, Condensed Matter and Materials Physics Group > Department of Physics and Astronomy > University College London > Gower Street > LONDON > WC1E 6BT > (44)(0)207 679 3404 > a.harker@ucl.ac.uk === Subject: How to solve nonlinear equations? How to solve the following equations, where X1, X2, X3, X4 and X5 are variables? eqns = {20.428836553499018-ln(X1) == 468/67*X1+5790/1273*X2-66257/1273*X3-24660/1273*X4-79150/1273*X5, 17.011108423692498-ln(X2) == 5790/1273*X1+6294/1273*X2-66257/1273*X3-24660/1273*X4-403.8069285*X5, -29.72639373695347-ln(X3) == -66257/1273*X1-66257/1273*X2-2*X3, -26.273726271581616-ln(X4) == -24660/1273*X1-24660/1273*X2+10.15330715*X4, -38.76695085346396-ln(X5) == -79150/1273*X1-403.8069285*X2-10.67374705*X5}; === Subject: Re: Re: How to solve nonlinear equations? The only trouble with THAT is that it doesn't work. eqns = {20.428836553499018 - Log[X1] == 468/67*X1 + 5790/1273*X2 - 66257/1273* X3 - 24660/1273*X4 - 79150/1273*X5, 17.011108423692498 - Log[X2] == 5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/ 1273*X4 - 403.8069285* X5, -29.72639373695347 - Log[X3] == -66257/1273* X1 - 66257/1273*X2 - 2* X3, -26.273726271581616 - Log[X4] == -24660/1273*X1 - 24660/ 1273*X2 + 10.15330715*X4, -38.76695085346396 - Log[X5] == -79150/ 1273*X1 - 403.8069285*X2 - 10.67374705*X5}; FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] eqns /. Equal -> Subtract /. % (FindRoot::lstol error) {X1 -> 0.5287215008048355 + 0.0078093799604902845*I, X2 -> 0.002514442570050682 - 0.007506800892680369*I, X3 -> 0.2750175495952261 + 0.0051666476248725625*I, X4 -> -1.6157105189511614 -4.778719413301337*^-15*I, X5 -> -0.006058532522555838 - 0.003759309847863656*I} {-0.0000172993518866571 - 5.25106242902848*^-7*I, 0.0014397436481736747 + 0.000060457451791506855*I, -0.23588972784670026 + 0.007297504899863284*I, -0.057825246363192695 + 3.1474540831359445*I, 0.0009303265262765592 + 0.00036856201666024546*I} Bobby > a) learn the correct syntax of Mathematica > b) read the Mathematica book carefully > c) type: > eqns = {20.428836553499018 - Log[X1] == > 468/67*X1 + 5790/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - > 79150/1273*X5, > 17.011108423692498 - Log[X2] == > 5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - > 403.8069285*X5, -29.72639373695347 - Log[X3] == -66257/1273*X1 - > 66257/1273*X2 - 2*X3, -26.273726271581616 - > Log[X4] == -24660/1273*X1 - 24660/1273*X2 + > 10.15330715*X4, -38.76695085346396 - Log[X5] == -79150/1273*X1 - > 403.8069285*X2 - 10.67374705*X5} > FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] > Jens > Wei Wang schrieb im Newsbeitrag >> How to solve the following equations, where X1, X2, X3, X4 and X5 are >> variables? >> eqns = {20.428836553499018-ln(X1) == >> 468/67*X1+5790/1273*X2-66257/1273*X3-24660/1273*X4-79150/1273*X5, >> 17.011108423692498-ln(X2) == >> 5790/1273*X1+6294/1273*X2-66257/1273*X3-24660/1273*X4-403.8069285*X5, -29.72639373695347-ln(X3) >> == -66257/1273*X1-66257/1273*X2-2*X3, -26.273726271581616-ln(X4) >> == -24660/1273*X1-24660/1273*X2+10.15330715*X4, -38.76695085346396-ln(X5) >> == -79150/1273*X1-403.8069285*X2-10.67374705*X5}; -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Re: Re: How to solve nonlinear equations? > Neither of us has answered the original question, which was How to solve.... > Let's say we need 200 digits. How do you solve it? > Bobby > [...] >>DrBob schrieb im Newsbeitrag >The only trouble with THAT is that it doesn't work. >eqns = {20.428836553499018 - Log[X1] == 468/67*X1 + 5790/1273*X2 - >66257/1273* > X3 - 24660/1273*X4 - 79150/1273*X5, 17.011108423692498 - > Log[X2] == 5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/ > 1273*X4 - 403.8069285* > X5, -29.72639373695347 - Log[X3] == -66257/1273* > X1 - 66257/1273*X2 - 2* > X3, -26.273726271581616 - Log[X4] == -24660/1273*X1 - 24660/ > 1273*X2 + 10.15330715*X4, -38.76695085346396 - Log[X5] >== -79150/ > 1273*X1 - 403.8069285*X2 - 10.67374705*X5}; >FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] >eqns /. Equal -> Subtract /. % >(FindRoot::lstol error) >{X1 -> 0.5287215008048355 + 0.0078093799604902845*I, > X2 -> 0.002514442570050682 - 0.007506800892680369*I, > X3 -> 0.2750175495952261 + 0.0051666476248725625*I, > X4 -> -1.6157105189511614 -4.778719413301337*^-15*I, > X5 -> -0.006058532522555838 - 0.003759309847863656*I} >{-0.0000172993518866571 - 5.25106242902848*^-7*I, > 0.0014397436481736747 + 0.000060457451791506855*I, > -0.23588972784670026 + 0.007297504899863284*I, > -0.057825246363192695 + 3.1474540831359445*I, > 0.0009303265262765592 + 0.00036856201666024546*I} >Bobby >[...] >> >>Wei Wang schrieb im Newsbeitrag >> >How to solve the following equations, where X1, X2, X3, X4 and X5 are >variables? > >eqns = {20.428836553499018-ln(X1) == >468/67*X1+5790/1273*X2-66257/1273*X3-24660/1273*X4-79150/1273*X5, >17.011108423692498-ln(X2) == >5790/1273*X1+6294/1273*X2-66257/1273*X3-24660/1273*X4-403.8069285*X5, -29.72639373695347-ln(X3) >== -66257/1273*X1-66257/1273*X2-2*X3, -26.273726271581616-ln(X4) >== -24660/1273*X1-24660/1273*X2+10.15330715*X4, -38.76695085346396-ln(X5) >== -79150/1273*X1-403.8069285*X2-10.67374705*X5}; > >-- >DrBob@bigfoot.com >www.eclecticdreams.net I'm not sure about the case of complex roots, but there is no real solution to this system. Showing that took me several steps though there may be a more enlightened method than what I reproduce below. Start with eqns = {20.428836553499018 - Log[X[1]] - (468/67*X[1] + 5790/1273*X[2] - 66257/1273*X[3] - 24660/1273*X[4] - 79150/1273*X[5]), 17.011108423692498 - Log[X[2]] - (5790/1273*X[1] + 6294/1273*X[2] - 66257/1273*X[3] - 24660/1273*X[4] - 403.8069285X[5]), -29.72639373695347 - Log[X[3]] - (-66257/1273*X[1] - 66257/1273*X[2] - 2*X[3]), -26.273726271581616 - Log[X[4]] - (-24660/1273*X[1] - 24660/1273*X[2] + 10.15330715*X[4]), -38.76695085346396 - Log[X[5]] - (-79150/1273*X[1] - 403.8069285*X[2] - 10.67374705*X[5])}; exprs = eqns /. Equal->Subtract; First notice that we can replace each X[j] by its exponential. Moreover as all right hand sides are free of the logs, we know the X[j]'s must be positive. Hence we can use PowerExpand to in effect make those logs our new variables. I will also Rationalize though that's not strictly necessary. newexprs = Rationalize[PowerExpand[exprs /. X[j_]:>Exp[lX[j]]], 0] I now use some elimination ideals to obtain various expressions that expr34 = GroebnerBasis[newexprs, Exp[Array[lX,5]], Complement[Array[lX,5],{lX[3],lX[4]}]]; We first investigate what happens if lX[4] is nonnegative. In[280]:= InputForm[e3 = First[expr34] /. lX[4]->Interval[{0,Infinity}]] Out[280]//InputForm= 647238762444175200000000*E^lX[3] + Interval[{22053533331180859235803693, Infinity}] - 323619381222087600000000*lX[3] The next steps perhaps obvious to many people. We first see that this is strictly positive if lX[3] is negative. In[289]:= e3 /. lX[3]->Interval[{-Infinity,0}] Out[289]= Interval[{22053533331180859235803693, Infinity}] We now check that the derivative with respect to lX[3] is strictly positive at for positive lX[3]. This guarantees that e3 cannot get smaller, hence is positive for all real lX[3]. In[290]:= D[e3,lX[3]] /. lX[3]->Interval[{0,Infinity}] Out[290]= Interval[{323619381222087600000000, Infinity}] We conclude at this point that we must require lX[4] to be negative. Taking this into account we will show that lX[1]<1 by showing that if we assume otherwise then a certain expression in our list will be strictly positive. In[291]:= N[newexprs[[-2]] /. {lX[1]->Interval[{1,Infinity}], lX[4]->Interval[{-Infinity,0}], lX[2]->Interval[{-Infinity,Infinity}]}] Out[291]= Interval[{16.2303, Infinity}] Similarly we see we must have lX[2]<1. In[293]:= N[newexprs[[-2]] /. {lX[2]->Interval[{1,Infinity}], lX[4]->Interval[{-Infinity,0}], lX[1]->Interval[{-Infinity,Infinity}]}] Out[293]= Interval[{16.2303, Infinity}] We now show these each must in fact be negative. expr5 = First[GroebnerBasis[newexprs, Exp[Array[lX,5]], Complement[Array[lX,5],{lX[5]}]]]; e15 = expr5 /. {lX[1]->Interval[{0,1}], lX[2]->Interval[{-Infinity,1}]}; First show this is strictly positive for all negative lX[5]. In[297]:= e15 /. lX[5]->Interval[{-Infinity,0}] Out[297]= Interval[{1022379647864000000, Infinity}] Next show the derivative with respect to lX[5] is strictly positive for lX[5]>0. In[299]:= D[e15,lX[5]] /. lX[5]->Interval[{0,Infinity}] Out[299]= Interval[{422497213422049953, Infinity}] This shows e15 cannot vanish for any real lX[5]. We can similarly show that e25 = {lX[2]->Interval[{0,1}], lX[1]->Interval[{-Infinity,1}]}; cannot vanish for any lX[5]. We now know that {lX[1],lX[2],lX[4]} are all negative. We move to another elimination ideal. expr3 = First[GroebnerBasis[newexprs, Exp[Array[lX,5]], Complement[Array[lX,5],{lX[3]}]]] We see that this is strictly positive if lX[3] is 3. In[311]:= (expr3 /. {lX[3]->3, lX[1]->Interval[{-Infinity,0}], lX[2]->Interval[{-Infinity,0}]}) > 0 Out[311]= True The derivative with respect to lX[3] is always positive for lX[3]>3. In[313]:= (D[expr3,lX[3]] /. lX[3]->Interval[{3,Infinity}]) > 0 Out[313]= True Thus expr3 cannot vanish for lX[3]>=3, so lX[3]<3. We next look at one of our original expressions when lX[3]<-30. We will see it must in this case be strictly positive. In[316]:= (newexprs[[3]] /. {lX[3]->Interval[{-Infinity,-30}], lX[2]->Interval[{-Infinity,0}], lX[1]->Interval[{-Infinity,0}]}) > 0 Out[316]= True We now know -30Interval[{-30,3}], lX[2]->Interval[{-Infinity,0}], lX[4]->Interval[{-Infinity,0}], lX[5]->Interval[{-Infinity,Infinity}], lX[1]->Interval[{-Infinity,0}]}) > 0 Out[318]= True As it is strictly positive there are no real values that make newexprs simultaneously vanish. Daniel Lichtblau Wolfram Research === Subject: Re: Re: Re: How to solve nonlinear equations? Neither of us has answered the original question, which was How to solve.... Let's say we need 200 digits. How do you solve it? Bobby > the problem will never solved by Mathematica > when the input uses a invalid syntax and the original posting > say nothing about the desired precision. But from the > equations it is easy to see that one nneds several hundred > digits. > Jens > DrBob schrieb im Newsbeitrag >> The only trouble with THAT is that it doesn't work. >> eqns = {20.428836553499018 - Log[X1] == 468/67*X1 + 5790/1273*X2 - >> 66257/1273* >> X3 - 24660/1273*X4 - 79150/1273*X5, 17.011108423692498 - >> Log[X2] == 5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/ >> 1273*X4 - 403.8069285* >> X5, -29.72639373695347 - Log[X3] == -66257/1273* >> X1 - 66257/1273*X2 - 2* >> X3, -26.273726271581616 - Log[X4] == -24660/1273*X1 - 24660/ >> 1273*X2 + 10.15330715*X4, -38.76695085346396 - Log[X5] >> == -79150/ >> 1273*X1 - 403.8069285*X2 - 10.67374705*X5}; >> FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] >> eqns /. Equal -> Subtract /. % >> (FindRoot::lstol error) >> {X1 -> 0.5287215008048355 + 0.0078093799604902845*I, >> X2 -> 0.002514442570050682 - 0.007506800892680369*I, >> X3 -> 0.2750175495952261 + 0.0051666476248725625*I, >> X4 -> -1.6157105189511614 -4.778719413301337*^-15*I, >> X5 -> -0.006058532522555838 - 0.003759309847863656*I} >> {-0.0000172993518866571 - 5.25106242902848*^-7*I, >> 0.0014397436481736747 + 0.000060457451791506855*I, >> -0.23588972784670026 + 0.007297504899863284*I, >> -0.057825246363192695 + 3.1474540831359445*I, >> 0.0009303265262765592 + 0.00036856201666024546*I} >> Bobby >a) learn the correct syntax of Mathematica >b) read the Mathematica book carefully >c) type: >eqns = {20.428836553499018 - Log[X1] == >468/67*X1 + 5790/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - >79150/1273*X5, >17.011108423692498 - Log[X2] == >5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - >403.8069285*X5, -29.72639373695347 - Log[X3] == -66257/1273*X1 - >66257/1273*X2 - 2*X3, -26.273726271581616 - >Log[X4] == -24660/1273*X1 - 24660/1273*X2 + >10.15330715*X4, -38.76695085346396 - Log[X5] == -79150/1273*X1 - >403.8069285*X2 - 10.67374705*X5} >FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] > Jens >Wei Wang schrieb im Newsbeitrag >>How to solve the following equations, where X1, X2, X3, X4 and X5 are >>variables? >> >>eqns = {20.428836553499018-ln(X1) == >>468/67*X1+5790/1273*X2-66257/1273*X3-24660/1273*X4-79150/1273*X5, >>17.011108423692498-ln(X2) == >>5790/1273*X1+6294/1273*X2-66257/1273*X3-24660/1273*X4-403.8069285*X5, -29.72639373695347-ln(X3) >>== -66257/1273*X1-66257/1273*X2-2*X3, -26.273726271581616-ln(X4) >>== -24660/1273*X1-24660/1273*X2+10.15330715*X4, -38.76695085346396-ln(X5) >>== -79150/1273*X1-403.8069285*X2-10.67374705*X5}; >> >> -- >> DrBob@bigfoot.com >> www.eclecticdreams.net -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Re: How to solve nonlinear equations? the problem will never solved by Mathematica when the input uses a invalid syntax and the original posting say nothing about the desired precision. But from the equations it is easy to see that one nneds several hundred digits. Jens DrBob schrieb im Newsbeitrag > The only trouble with THAT is that it doesn't work. > eqns = {20.428836553499018 - Log[X1] == 468/67*X1 + 5790/1273*X2 - > 66257/1273* > X3 - 24660/1273*X4 - 79150/1273*X5, 17.011108423692498 - > Log[X2] == 5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/ > 1273*X4 - 403.8069285* > X5, -29.72639373695347 - Log[X3] == -66257/1273* > X1 - 66257/1273*X2 - 2* > X3, -26.273726271581616 - Log[X4] == -24660/1273*X1 - 24660/ > 1273*X2 + 10.15330715*X4, -38.76695085346396 - Log[X5] > == -79150/ > 1273*X1 - 403.8069285*X2 - 10.67374705*X5}; > FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] > eqns /. Equal -> Subtract /. % > (FindRoot::lstol error) > {X1 -> 0.5287215008048355 + 0.0078093799604902845*I, > X2 -> 0.002514442570050682 - 0.007506800892680369*I, > X3 -> 0.2750175495952261 + 0.0051666476248725625*I, > X4 -> -1.6157105189511614 -4.778719413301337*^-15*I, > X5 -> -0.006058532522555838 - 0.003759309847863656*I} > {-0.0000172993518866571 - 5.25106242902848*^-7*I, > 0.0014397436481736747 + 0.000060457451791506855*I, > -0.23588972784670026 + 0.007297504899863284*I, > -0.057825246363192695 + 3.1474540831359445*I, > 0.0009303265262765592 + 0.00036856201666024546*I} > Bobby >> a) learn the correct syntax of Mathematica >> b) read the Mathematica book carefully >> c) type: >> eqns = {20.428836553499018 - Log[X1] == >> 468/67*X1 + 5790/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - >> 79150/1273*X5, >> 17.011108423692498 - Log[X2] == >> 5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - >> 403.8069285*X5, -29.72639373695347 - Log[X3] == -66257/1273*X1 - >> 66257/1273*X2 - 2*X3, -26.273726271581616 - >> Log[X4] == -24660/1273*X1 - 24660/1273*X2 + >> 10.15330715*X4, -38.76695085346396 - Log[X5] == -79150/1273*X1 - >> 403.8069285*X2 - 10.67374705*X5} >> FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] >> Jens >> Wei Wang schrieb im Newsbeitrag >How to solve the following equations, where X1, X2, X3, X4 and X5 are >variables? >eqns = {20.428836553499018-ln(X1) == >468/67*X1+5790/1273*X2-66257/1273*X3-24660/1273*X4-79150/1273*X5, >17.011108423692498-ln(X2) == >5790/1273*X1+6294/1273*X2-66257/1273*X3-24660/1273*X4-403.8069285*X5, -29.72639373695347-ln(X3) >== -66257/1273*X1-66257/1273*X2-2*X3, -26.273726271581616-ln(X4) >== -24660/1273*X1-24660/1273*X2+10.15330715*X4, -38.76695085346396-ln(X5) >== -79150/1273*X1-403.8069285*X2-10.67374705*X5}; > -- > DrBob@bigfoot.com > www.eclecticdreams.net === Subject: Re: How to solve nonlinear equations? a) learn the correct syntax of Mathematica b) read the Mathematica book carefully c) type: eqns = {20.428836553499018 - Log[X1] == 468/67*X1 + 5790/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - 79150/1273*X5, 17.011108423692498 - Log[X2] == 5790/1273*X1 + 6294/1273*X2 - 66257/1273*X3 - 24660/1273*X4 - 403.8069285*X5, -29.72639373695347 - Log[X3] == -66257/1273*X1 - 66257/1273*X2 - 2*X3, -26.273726271581616 - Log[X4] == -24660/1273*X1 - 24660/1273*X2 + 10.15330715*X4, -38.76695085346396 - Log[X5] == -79150/1273*X1 - 403.8069285*X2 - 10.67374705*X5} FindRoot[eqns, {{X1, 1}, {X2, 1}, {X3, 1}, {X4, 1}, {X5, 1}}] Jens Wei Wang schrieb im Newsbeitrag > How to solve the following equations, where X1, X2, X3, X4 and X5 are > variables? > eqns = {20.428836553499018-ln(X1) == > 468/67*X1+5790/1273*X2-66257/1273*X3-24660/1273*X4-79150/1273*X5, > 17.011108423692498-ln(X2) == > 5790/1273*X1+6294/1273*X2-66257/1273*X3-24660/1273*X4-403.8069285*X5, -29.72639373695347-ln(X3) > == -66257/1273*X1-66257/1273*X2-2*X3, -26.273726271581616-ln(X4) > == -24660/1273*X1-24660/1273*X2+10.15330715*X4, -38.76695085346396-ln(X5) > == -79150/1273*X1-403.8069285*X2-10.67374705*X5}; === Subject: Animating Solutions of NDSolve with respect to Initial Conditions To see all circularly bent shapes of a strip fixed at one end it is animated as follows: << Graphics`Animation` MovieParametricPlot[{Sin[t*s]/t , (1 - Cos[t*s])/t}, {s, 0, 2 Pi}, {t, -1,1}, Frames -> 20, Axes -> False, AspectRatio -> Automatic, PlotRange -> {{-3, 7}, {-3, 7}}]; Like the above and unlike the example below where solutions are superimposed in Show mode in a single frame, I like to animate an NDSolve output to varoious Boundary Conditions to see their effect dynamically in separate frames. How can this be done? yvar = y /. First /@ (NDSolve[{y'''[t] + y[t] == 0, y[0] == #1, y'[0] == #2, y''[0] == #3}, y, {t, 0, 2 Pi}] & @@@ {{5, 1, -2}, {5, 1, -1}, {5, 1, 0}, {5, 1, 1}, {5, 1, 2}}); Plot[Evaluate[#[t] & /@ yvar], {t, 0, 5}]; === Subject: Re: Animating Solutions of NDSolve with respect to Initial Conditions If you use Map[Plot[#,options]&, list-of-plots] this forces each plot to be created separately, so you need to replace your Plot expression with the following: Map[Plot[#,{t,0,5},PlotRange->{{0,5},{-40,10}}]&,Evaluate[#[t] & /@ yvar]]; The options must include a fixed PlotRange in order to ensure that the axes are the same in each plot. Steve Luttrell > To see all circularly bent shapes of a strip fixed at one end it is > animated as follows: > << Graphics`Animation` > MovieParametricPlot[{Sin[t*s]/t , (1 - Cos[t*s])/t}, {s, 0, 2 Pi}, > {t, -1,1}, Frames -> 20, Axes -> False, AspectRatio -> Automatic, > PlotRange -> {{-3, 7}, {-3, 7}}]; > Like the above and unlike the example below where solutions are > superimposed in Show mode in a single frame, I like to animate an > NDSolve output to varoious Boundary Conditions to see their effect > dynamically in separate frames. How can this be done? > yvar = y /. > First /@ (NDSolve[{y'''[t] + y[t] == 0, y[0] == #1, y'[0] == #2, > y''[0] == #3}, y, {t, 0, 2 Pi}] & @@@ {{5, 1, -2}, {5, > 1, -1}, {5, 1, 0}, {5, 1, 1}, {5, 1, 2}}); > Plot[Evaluate[#[t] & /@ yvar], {t, 0, 5}]; === Subject: Re: Animating Solutions of NDSolve with respect to Initial Conditions > To see all circularly bent shapes of a strip fixed at one end it is > animated as follows: > << Graphics`Animation` > MovieParametricPlot[{Sin[t*s]/t , (1 - Cos[t*s])/t}, {s, 0, 2 Pi}, > {t, -1,1}, Frames -> 20, Axes -> False, AspectRatio -> Automatic, > PlotRange -> {{-3, 7}, {-3, 7}}]; > Like the above and unlike the example below where solutions are > superimposed in Show mode in a single frame, I like to animate an > NDSolve output to varoious Boundary Conditions to see their effect > dynamically in separate frames. How can this be done? > yvar = y /. > First /@ (NDSolve[{y'''[t] + y[t] == 0, y[0] == #1, y'[0] == #2, > y''[0] == #3}, y, {t, 0, 2 Pi}] & @@@ {{5, 1, -2}, {5, > 1, -1}, {5, 1, 0}, {5, 1, 1}, {5, 1, 2}}); > Plot[Evaluate[#[t] & /@ yvar], {t, 0, 5}]; You nearly got it: yvar = y /. First /@ (NDSolve[{y'''[t] + y[t] == 0, y[0] == #1, y'[0] == #2, y''[0] == #3}, y, {t, 0, 2 Pi}] & @@@ Table[{5, 1, p}, {p, -2, 2, .1}]); Plot[#, {t, 0, 5}, PlotRange -> {-40, 10}] & /@ Evaluate[#[t] & /@ yvar]; -- Peter Pein 10245 Berlin === Subject: Asymptotic SE One of the output parameters from the regression packages is the asymptotic SE. Up to now I have not found any definition of this parameter. Is the asymptotic standard error the standard deviation on the estimated parameter ? And if this is not so, what is it and how do I get the standard deviation on the estimated parameter. Also, the way the CI (Confidence interval) is defined is not explained. I read somewhere it is a 95% level CI. Is this true and how can I change the confidence level ? Peter === Subject: Re: FourierTransform You do not have to give up your classroom demos. Adding some properties to a built-in function is easy. Try Unprotect[FourierTransform]; FourierTransform[f_'[x_], x_, k_] := -[ImaginaryI] k FourierTransform[f[x], x, k]; Protect[FourierTransform] yehuda >In Version 4 Mathematica was smart enough to know that >FourierTransform[f'[x], x, k] >should give >-[ImaginaryI] k FourierTransform[f[x], x, k]. > Version 5 seems no longer to do this -- a nice classroom demonstration and >a valuable method of solving differential equations down in flames. > Why is this? > Tony Harker (Dr A.H. Harker) > Deputy Head of Department > Deputy Head, Condensed Matter and Materials Physics Group > Department of Physics and Astronomy > University College London > Gower Street > LONDON > WC1E 6BT > (44)(0)207 679 3404 > a.harker@ucl.ac.uk === Subject: Re: FourierTransform $Version FourierTransform[f'[x],x,k] (-I)*k*FourierTransform[f[x], x, k] Bob Hanlon === > Subject: FourierTransform > In Version 4 Mathematica was smart enough to know that > FourierTransform[f'[x], x, k] > should give > -[ImaginaryI] k FourierTransform[f[x], x, k]. > Version 5 seems no longer to do this -- a nice classroom demonstration and > a valuable method of solving differential equations down in flames. > Why is this? > Tony Harker (Dr A.H. Harker) > Deputy Head of Department > Deputy Head, Condensed Matter and Materials Physics Group > Department of Physics and Astronomy > University College London > Gower Street > LONDON > WC1E 6BT > (44)(0)207 679 3404 > a.harker@ucl.ac.uk === Subject: Inserting user material in the HelpBrowser my post about time complexity in some Mathematica functions. Now, I have spent some time trying to understand how help browser notebooks (and related style sheets) work, and to the present, I do not have problems to insert the help material in the browser (following the guidance by Bob Treat, that is very easy). However, I am having problems in developing the help material. Assuming that I am using the default help browser style sheet (HelpBrowser) to construct my help notebooks, these are being the two main sources for my difficulties: 1) If I make a mistake in laying out some type of cells (like emphasis boxes, object definitions, chapter and section, among many others) the notebook becomes useless because there is not a visible way to delete the mistaken cells. And I have to restart time and again. At least, I cannot see it. 2) There are cell styles in the actual default help browser style sheet (HelpBrowser) that do not appear in the help browser style sheet listing in, as it appears in the Format/Style menu. For example: ObjectName and Command, among many others. However these are repeatedly used in the help browser material by Wolfram and others. Some of my questions are: - Are regular notebooks and help browser notebooks different sorts of notebook? - How can one be able to affordably lay out a browser notebook without the possibility of deleting mistaken cells through the menu interface? - How can one affordably insert the needed instances of cell types without the possibility applying the intended cell style format through the menu interface? - MathCaption, for example, is one of the styles available in the Format/Style menu. Why Command, ObjectName and Usage are not? - ObjectName, for example, does not appear in the in the Format/Style menu for the HelpBrowser style sheet. How can one apply this style cell to a help browser notebook through the menu interface? I have been diving into the help browser Front End/Style Sheets/ (and the options inspector) trying to figure out how to solve the inconvenience, and I did not find any direct or menu driven procedure to deal with the issues, I even tried altering the default style sheet: even worse. Modifying the default help browser style sheet seems to be not that straightforward or neutral. No doubt that the guidance is, somehow (but, how?), and somewhere (but, where?) in the help browser mesh (since other users did produce their own help material, it should be there). Finally, the thing I have not tried yet is editing the cells definition after having showing the cell expression by Format/(Shift+Ctrl+E). Should I? I will really appreciate any help. E. Martin-Serrano === Subject: Re: Re: Inserting user material in the HelpBrowser I don't think you've explained how the new menu item would be used; I'm guessing you'd put the cursor in the invisible cell, then use the menu item? Anyway, THIS SHOULD BE WRI-SUPPLIED. Be that as it may, here's what I do in the OP's situation: 1) I click between cells above (below) the one I want to select. 2) I hold down the shift key and arrow down (up). 3) There may be no visual clue that the cell is selected; but it is. If I want to delete the cell, I push delete. Bobby >> my post about time complexity in some Mathematica functions. >> Now, I have spent some time trying to understand how help browser >> notebooks (and related style sheets) work, and to the present, I do not >> have problems to insert the help material in the browser (following the >> guidance by Bob Treat, that is very easy). However, I am having problems >> in developing the help material. >> Assuming that I am using the default help browser style sheet >> (HelpBrowser) to construct my help notebooks, these are being the two >> main sources for my difficulties: >> 1) If I make a mistake in laying out some type of cells (like >> emphasis boxes, object definitions, chapter and section, among many >> others) the notebook becomes useless because there is not a visible way >> to delete the mistaken cells. And I have to restart time and again. At >> least, I cannot see it. >> 2) There are cell styles in the actual default help browser style >> sheet (HelpBrowser) that do not appear in the help browser style sheet >> listing in, as it appears in the Format/Style menu. For example: >> ObjectName and Command, among many others. However these are >> repeatedly used in the help browser material by Wolfram and others. >> Some of my questions are: >> - Are regular notebooks and help browser notebooks different sorts of notebook? >> - How can one be able to affordably lay out a browser notebook without >> the possibility of deleting mistaken cells through the menu interface? >> - How can one affordably insert the needed instances of cell types >> without the possibility applying the intended cell style format through >> the menu interface? >> - MathCaption, for example, is one of the styles available in the >> Format/Style menu. Why Command, ObjectName and Usage are not? >> - ObjectName, for example, does not appear in the in the Format/Style >> menu for the HelpBrowser style sheet. How can one apply this style cell >> to a help browser notebook through the menu interface? >> I have been diving into the help browser Front End/Style Sheets/ (and >> the options inspector) trying to figure out how to solve the >> inconvenience, and I did not find any direct or menu driven procedure to >> deal with the issues, I even tried altering the default style sheet: >> even worse. Modifying the default help browser style sheet seems to be >> not that straightforward or neutral. No doubt that the guidance is, >> somehow (but, how?), and somewhere (but, where?) in the help browser >> mesh (since other users did produce their own help material, it should >> be there). >> Finally, the thing I have not tried yet is editing the cells definition >> after having showing the cell expression by Format/(Shift+Ctrl+E). >> Should I? >> I will really appreciate any help. >> E. Martin-Serrano > It is possible to select a cell even though the cell bracket is not > visible. I modify my MENUSETUP.TR file with a text editor (but take a > backup first!) to contain an extra menu item thus: > Item[Select Cell,FrontEndExecute[ > Module[{Set[nb,InputNotebook[]]}, > SelectionMove[nb,All,Cell]; > ] > Obviously, you have to chose which main menu to attach it to. > Be very careful - if you get the file wrong Mathematica will not start. > You can use & characters in the menu item name to create an alt-shortcut > under Windows. > After you have selected a cell - even though it is not visible - you can > cut/copy/delete it. > David Bailey -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Inserting user material in the HelpBrowser > my post about time complexity in some Mathematica functions. > Now, I have spent some time trying to understand how help browser > notebooks (and related style sheets) work, and to the present, I do not > have problems to insert the help material in the browser (following the > guidance by Bob Treat, that is very easy). However, I am having problems > in developing the help material. > Assuming that I am using the default help browser style sheet > (HelpBrowser) to construct my help notebooks, these are being the two > main sources for my difficulties: > 1) If I make a mistake in laying out some type of cells (like > emphasis boxes, object definitions, chapter and section, among many > others) the notebook becomes useless because there is not a visible way > to delete the mistaken cells. And I have to restart time and again. At > least, I cannot see it. > 2) There are cell styles in the actual default help browser style > sheet (HelpBrowser) that do not appear in the help browser style sheet > listing in, as it appears in the Format/Style menu. For example: > ObjectName and Command, among many others. However these are > repeatedly used in the help browser material by Wolfram and others. > Some of my questions are: > - Are regular notebooks and help browser notebooks different sorts of notebook? > - How can one be able to affordably lay out a browser notebook without > the possibility of deleting mistaken cells through the menu interface? > - How can one affordably insert the needed instances of cell types > without the possibility applying the intended cell style format through > the menu interface? > - MathCaption, for example, is one of the styles available in the > Format/Style menu. Why Command, ObjectName and Usage are not? > - ObjectName, for example, does not appear in the in the Format/Style > menu for the HelpBrowser style sheet. How can one apply this style cell > to a help browser notebook through the menu interface? > I have been diving into the help browser Front End/Style Sheets/ (and > the options inspector) trying to figure out how to solve the > inconvenience, and I did not find any direct or menu driven procedure to > deal with the issues, I even tried altering the default style sheet: > even worse. Modifying the default help browser style sheet seems to be > not that straightforward or neutral. No doubt that the guidance is, > somehow (but, how?), and somewhere (but, where?) in the help browser > mesh (since other users did produce their own help material, it should > be there). > Finally, the thing I have not tried yet is editing the cells definition > after having showing the cell expression by Format/(Shift+Ctrl+E). > Should I? > I will really appreciate any help. > E. Martin-Serrano It is possible to select a cell even though the cell bracket is not visible. I modify my MENUSETUP.TR file with a text editor (but take a backup first!) to contain an extra menu item thus: Item[Select Cell,FrontEndExecute[ Module[{Set[nb,InputNotebook[]]}, SelectionMove[nb,All,Cell]; ] Obviously, you have to chose which main menu to attach it to. Be very careful - if you get the file wrong Mathematica will not start. You can use & characters in the menu item name to create an alt-shortcut under Windows. After you have selected a cell - even though it is not visible - you can cut/copy/delete it. David Bailey === Subject: Re: New User - Programming Dean, This looks like a great application for functional programming in Mathematica. a = {5, 6, 3, 2, 8, 2}; b = {5, 4, 1, 3, 9, 4}; If you want to combine two equal length lists to make a new list, a good command to use is Inner. signal = Inner[Sign[#1 - #2] &, a, b, List] {0, 1, 1, -1, -1, -1} The Sign function is used on the difference of the elements in the a and b lists. We want the whole operation to return a new List so that is the last argument. If you wanted to go with your first specification and sum all the signal elements you could use... Inner[Sign[#1 - #2] &, a, b, Plus] -1 If you want to sum the signal elements but clamp the cumulative sum between -1 and +1 then you can use another functional command, FoldList on the signal elements, FoldList[Max[-1, Min[1, #1 + #2]] &, 0, signal] {0, 0, 1, 1, 0, -1, -1} That has the starting value, 0, at the beginning of the list, which you could get rid of by using the Drop command. If you want to sum this new series you can Apply Plus to the intermediate result. Plus @@ FoldList[Max[-1, Min[1, #1 + #2]] &, 0, signal] 0 David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I am a new user who is well and truly stuck. Any help would be greatly appreciated. I have two lists, a and b, that when compared, will produce a third list of signals. This third list is then summed to get a cumulative total of the signals. The rules are fairly simple. If a = b, the signal is 0, if a > b, the signal is 1 and finally, if a < b, then the signal is ö1. a={5,6,3,2,8,2}; b={5,4,1,3,9,4}; c={a,b}; p=0; Fun[t_,u_]/;t==u :=0; Fun[t_,u_]/;t>u:=1; Fun[t_,u_]/;tRow, TableHeadings->{{a,b,Signal,Cumm.Total},None}, TableSpacing->{4,4,4,4,4}] a b Signal Cum.Total 5 5 0 0 6 4 1 1 3 1 1 2 2 3 -1 1 8 9 -1 0 2 4 -1 -1 I want to modify slightly how the signal is generated. The rules are the same except that if the cumulative total is already 1 or -1, then no new signal is generated unless the new signal would make the cumulative total move back towards zero. Ideally, I am looking to modify my code, so it produces, signal = {0,1,0,-1,-1,0} and cumTotal = {0,1,1,0,-1,-1}.The maximum size of the cumulative total need not be 1, but rather any value that is chosen as a limit. This has been causing me a great deal of grief and I would greatly welcome any help and suggestions. Given my lack of experience, I am sure that there is a more efficient way to tackle this type of problem, especially as I am dealing with many large lists. Dean Williams === Subject: 4th subharmoic functions These actually give a spiral and not a circle when added together. They are my best bet so far at the next level of complexity in a subharmonic reduction of a circle. Groups of this type are different than traditional rotation and point groups and determinant groups as they are based on substitution groups that have associated fractal effects. I found this IFS space fill this year in my trifraction expertiments. If you take away the (x/2+1/2,y/2+1/2) it becomes a nonlinear equivalent to a Sierpinski gasket which I called a trifraction about 1999. I've included a short IFS demonstration program at the end. (*using a set of functions that give a space filling curve in True Basic as as an IFS to get a set of 4th level subharmonic functions*) (* based on for parts of the functional inversion group of the anharmonic group with x->x/2 and x+1->x/2+1/2*) digits=100 f1[n_]:=n/2/;Mod[n,4]==1 f1[n_]:=n/2+1/2/;Mod[n,4]==2 f1[n_]:=n/(1+n)/;Mod[n,4]==3 f1[n_]:=1/(1+n)/;Mod[n,4]==0 f2[n_]:=n/2/;Mod[n,4]==2 f2[n_]:=n/2+1/2/;Mod[n,4]==3 f2[n_]:=n/(1+n)/;Mod[n,4]==0 f2[n_]:=1/(1+n)/;Mod[n,4]==1 f3[n_]:=n/2/;Mod[n,4]==3 f3[n_]:=n/2+1/2/;Mod[n,4]==0 f3[n_]:=n/(1+n)/;Mod[n,4]==1 f3[n_]:=1/(1+n)/;Mod[n,4]==2 f4[n_]:=n/2/;Mod[n,4]==0 f4[n_]:=n/2+1/2/;Mod[n,4]==1 f4[n_]:=n/(1+n)/;Mod[n,4]==2 f4[n_]:=1/(1+n)/;Mod[n,4]==3 f1sin[x_]:=Sum[(-1)^(n)*f1[n]*x^(2*n+1)/((2*n+1)!),{n,0,digits}] f2sin[x_]:=Sum[(-1)^(n)*f2[n]*x^(2*n+1)/((2*n+1)!),{n,0,digits}] f3sin[x_]:=Sum[(-1)^(n)*f3[n]*x^(2*n+1)/((2*n+1)!),{n,0,digits}] f4sin[x_]:=Sum[(-1)^(n)*f4[n]*x^(2*n+1)/((2*n+1)!),{n,0,digits}] f1cos[x_]:=Sum[(-1)^(n)*f1[n]*x^(2*n)/((2*n)!),{n,0,digits}] f2cos[x_]:=Sum[(-1)^(n)*f2[n]*x^(2*n)/((2*n)!),{n,0,digits}] f3cos[x_]:=Sum[(-1)^(n)*f3[n]*x^(2*n)/((2*n)!),{n,0,digits}] f4cos[x_]:=Sum[(-1)^(n)*f4[n]*x^(2*n)/((2*n)!),{n,0,digits}] Plot[f1sin[x],{x,-Pi,Pi}] Plot[f1cos[x],{x,-Pi,Pi}] Plot[f2sin[x],{x,-Pi,Pi}] Plot[f2cos[x],{x,-Pi,Pi}] Plot[f3sin[x],{x,-Pi,Pi}] Plot[f3cos[x],{x,-Pi,Pi}] Plot[f4sin[x],{x,-Pi,Pi}] Plot[f4cos[x],{x,-Pi,Pi}] Plot[f1sin[x]+f2sin[x]+f3sin[x]+f4sin[x],{x,-Pi,Pi}] Plot[f1cos[x]+f2cos[x]+f3cos[x]+f4cos[x],{x,-Pi,Pi}] ParametricPlot[{f1sin[x]+f2sin[x]+f3sin[x]+f4sin[x],f1cos[x]+f2cos[x]+f3cos[ x]+f4cos[x]},{x,-Pi,Pi}] (* ifs of the four parts function as two 1d ifs*) (* quadfraction as nonlinear spacefill*) f1[{x_,y_}] = {x/2, y/2}; f2[{x_,y_}] = {1/(x+1), y/(y+1)}; f3[{x_,y_}] = {x/(x+1), 1/(y+1)}; f4[{x_,y_}] = {x/2+1/2, y/2+1/2}; f[x_] := Which[(r=Random[]) <= 1/4, f1[x],r <=2/4, f2[x],r <= 3/4, f3[x],r <= 1.00, f4[x]] ifs[n_] := Show[Graphics[{PointSize[.001], Map[Point, NestList[f, {0,0}, n]]}], PlotRange->All,AspectRatio->Automatic] ifs[10000] Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: canonical mathematical expression represenation? To use that kind of solution, you'd probably have to look at FullForm to decide what indices to use in MapAt. In this case, for instance: Sum[a^k,{k,0,M}]//FullForm Times[Power[Plus[-1,a],-1],Plus[-1,Power[a,Plus[1,M]]]] The denominator is Plus[-1,a] at position {1,1} in the expression, and the numerator is Plus[-1, Power[a, Plus[1, M]]] at position {2}. A more automatic but somewhat bulky option is: expr /. {Denominator[expr] -> -Denominator[expr], Numerator[expr] -> -Numerator[expr]} (1 - a^(1 + M))/(1 - a) Here's a simpler solution, though not as general: expr /. {-1 + x_ :> 1 - x} (1 - a^(1 + M))/(1 - a) And finally, try this one: expr /. {x_ + y_ /; x < 0 -> (-x) + (-y)} (1 - a^(1 + M))/(1 - a) That's less general than the Numerator/Denominator solution, but more general than the others. Bobby > Yes it is annoying the way Mathematica tends to get the minus signs where we > would prefer not to have them. One way to fix this, in simple expressions at > least, is to Map Minus to the two factors you would wish to change. > Sum[a^k, {k, 0, M}] > MapAt[Minus, %, {{1, 1}, {2}}] > (-1 + a^(1 + M))/(-1 + a) > (1 - a^(1 + M))/(1 - a) > I find that it is almost always possible to manipulate expressions to the > form you want, textbook form say, but it is a bit of an art and sometimes > even I have to come to MathGroup to learn the trick. > David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ > I noticed that Mathematica represents expressions with > some specific 'way' or order. > For example, > Sum[a^k, {k, 0, M}] > gives > -1 + a^(1+M) > ------------- > -1 + a > How can I make it display the expression, in what I would consider > a more 'natural' way, as follows > 1 - a^(1+M) > ------------- > 1 - a > I am sure there is a way to do, and why do you think > Mathematica does it the way it does? what is the logic > of how it represents things? is there a command to convert > the first output to the second? I tried few commands, but > can not figure it out. > thank you, > --nospam -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: canonical mathematical expression represenation? David.... Mathgroup to me is like Golf....both have really humbled me.... Jerry blimbaum -----Original Message----- === Subject: canonical mathematical expression represenation? Yes it is annoying the way Mathematica tends to get the minus signs where we would prefer not to have them. One way to fix this, in simple expressions at least, is to Map Minus to the two factors you would wish to change. Sum[a^k, {k, 0, M}] MapAt[Minus, %, {{1, 1}, {2}}] (-1 + a^(1 + M))/(-1 + a) (1 - a^(1 + M))/(1 - a) I find that it is almost always possible to manipulate expressions to the form you want, textbook form say, but it is a bit of an art and sometimes even I have to come to MathGroup to learn the trick. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I noticed that Mathematica represents expressions with some specific 'way' or order. For example, Sum[a^k, {k, 0, M}] gives -1 + a^(1+M) ------------- -1 + a How can I make it display the expression, in what I would consider a more 'natural' way, as follows 1 - a^(1+M) ------------- 1 - a I am sure there is a way to do, and why do you think Mathematica does it the way it does? what is the logic of how it represents things? is there a command to convert the first output to the second? I tried few commands, but can not figure it out. thank you, --nospam === Subject: Re: pair sums applied to trignometry sums Just for grins.... :) Here's a plot of the error from Pi to 36 Pi. relative returns $MachinePrecision whenever fsin == fsin2 to machine precision or when the computed precision would be Indeterminate. fsin2[x_] = Together[- Sum[((1 + 2*k)*x^(3 + 4*k))/(( 2 + 2*k)*(3 + 4*k)!), {k, 0, Infinity}] + Sum[x^(1 + 4*k)/((1 + 2*k)*( 1 + 4*k)!), {k, 0, Infinity}]]; fs[x_, n_] = If[Mod[n, 2] == 1, (-1)^(n)*n*x^(2* n + 1)/((n + 1)*(2*n + 1)!), (-1)^(n)*x^(2*n + 1)/((n + 1)*( 2*n + 1)!)]; fsin[x_] := N[Sum[fs[x, n], {n, 0, 100}]]; relative[x_] := Module[{f2 = fsin2[x], f = fsin[x]}, If[ f2 == 0 || f2 == f, $MachinePrecision, -Re[Log[10, Abs[(f2 - f)/f2]]]]] Plot[relative@x, {x, Pi, 36Pi}, PlotRange -> All] data = Flatten[Cases[%, Line[a_] -> a, Infinity], 1] {{3.1415972350790797, 15.954589770191003}, {7.602166348219689, 15.954589770191003}, {12.466807244518934, 15.954589770191003}, {17.03553064863929, 15.954589770191003}, {21.429256733925268, 15.954589770191003}, {26.106134429025374, 15.954589770191003}, {30.608014805291102, 15.954589770191003}, {35.39304679137096, 15.954589770191003}, {40.00308145861644, 15.954589770191003}, {44.438118807027536, 15.954589770191003}, {49.15630776525276, 15.954589770191003}, {53.69949940464361, 15.954589770191003}, {58.06769372520007, 15.954589770191003}, {62.71903965557067, 15.954589770191003}, {67.19538826710688, 15.954589770191003}, {71.95488848845723, 15.954589770191003}, {76.5393913909732, 15.954589770191003}, {80.94889697465477, 15.954589770191003}, {85.64155416815049, 15.954589770191003}, {90.15921404281183, 15.954589770191003}, {94.96002552728729, 15.954589770191003}, {99.58583969292837, 15.954589770191003}, {104.03665653973508, 15.954589770191003}, {106.29344388909165, 15.954589770191003}, {108.7706249963559, 15.954589770191003}, {109.85057065751995, 15.954589770191003}, {110.44508404208645, 15.954589770191003}, {111.00828024416123, 15.954589770191003}, {111.53167179744722, 15.954589770191003}, {111.67506457856302, 15.954589770191003}, {111.82740138112412, 15.954589770191003}, {111.95745531629451, 13.830647317435913}, {112.10100969273067, 13.774015253747038}, {113.09733094774326, 13.422761176770164}} fsin == fsin2 to $MachinePrecision (or relative precision would be Indeterminate) for x < 35.6 Pi, approximately. Here's a detail from 35.6 Pi to 59 Pi, where precision drops to less than one digit: Plot[relative@x, {x, 35.6Pi, 59Pi}, PlotRange -> All] data = Flatten[Cases[%, Line[a_] -> a, Infinity], 1] {{111.84070153084949, 15.954589770191003}, {111.93144524257782, 15.954589770191003}, {112.01400659892401, 13.814681804761431}, {112.10930712101167, 13.784858379354139}, {112.19939538276357, 13.738175075338768}, {112.28270974211034, 13.697691853954574}, {112.35962783140114, 13.681352311306712}, {112.44405392616041, 13.651723425970497}, {112.53355515172996, 13.623110566921143}, {113.29245103946467, 13.35737265411109}, {114.82291059506349, 12.838656285970202}, {118.07527050858927, 11.783127184339914}, {120.9957204257613, 10.892462794496971}, {124.10547741920908, 9.999964393416649}, {127.09823620520758, 9.192817934425467}, {130.2803020674818, 8.387554124021328}, {133.34536972230677, 7.6609988186866}, {136.29343916968244, 7.005489683461993}, {139.43081569333387, 6.352381579407274}, {142.451194009536, 5.765009989587841}, {145.6608794020139, 5.183271195912701}, {148.7535665870425, 4.662242307292363}, {151.72925556462184, 4.195890995272771}, {154.89425161847691, 3.735847149213959}, {157.9422494648827, 3.3263312946868275}, {160.87324910383924, 2.9622066095079154}, {163.9935558190715, 2.605145907944078}, {166.99686432685448, 2.2899632140849886}, {170.1894799109132, 1.9841665287753802}, {173.26509728752265, 1.7167736020631528}, {176.22371645668284, 1.483554180588469}, {179.37164270211875, 1.2600052198559342}, {182.40257074010538, 1.0675211814520018}, {185.31650057064275, 0.9024102087396019}, {185.35396349874495, 0.9004100875184318}} Bobby >> I had used the mechanism with Bailey type of sequences >> and their sums in the work on b normalness in iteratives functions. >> It occurred to me that by adding the variable x , I could get >> functiond that used the nonlinear Cantor pair {1/(n+1),n/(n+1)} >> to split the sine and the cosine down the middle. >> The result is entirely new trignometric sum functions that converge very >> well. >> (* pair sums applied to trignometry sums: {1/(n+1),n/(n+1)} modulo 2 >> switched sums*) >> (* these sums break the trignometry of a circle into four functions >> instead of two*) >> (* these are subharmonic functions of a nonlinear Rational Cantor type*) >> fs[x_,n_]:= >> If[Mod[n,2]==1,(-1)^(n)*n*x^(2*n+1)/((n+1)*(2*n+1)!),(-1)^(n)* >> x^(2*n+1)/((n+1)*(2*n+1)!)] >> gs[x_,n_]:= >> If[Mod[n,2]==1,(-1)^n*x^(2*n+1)/((n+1)*(2*n+1)!),(-1)^n*n* >> x^(2*n+1)/((n+1)*(2*n+1)!)] >> fc[x_,n_]:= >> If[Mod[n,2]==1,(-1)^(n)*n*x^(2*n)/((n+1)*(2*n)!),(-1)^(n)* >> x^(2*n)/((n+1)*(2*n)!)] >> gc[x_,n_]:= >> If[Mod[n,2]==1,(-1)^(n)*x^(2*n)/((n+1)*(2*n)!),(-1)^(n)*n* >> x^(2*n)/((n+1)*(2*n)!)] >> digits=100; >> fsin[x_]:=N[Sum[fs[x,n],{n,0,digits}]]; >> gsin[x_]:=N[Sum[gs[x,n],{n,0,digits}]] >> fcos[x_]:=N[Sum[fc[x,n],{n,0,digits}]] >> gcos[x_]:=N[Sum[gc[x,n],{n,0,digits}]] >> Plot[fsin[x],{x,-Pi,Pi}] >> Plot[fsin[x],{x,-Pi,Pi}] >> Plot[gsin[x],{x,-Pi,Pi}] >> Plot[fcos[x],{x,-Pi,Pi}] >> Plot[gcos[x],{x,-Pi,Pi}] >> Plot[(fsin[x]+gsin[x]),{x,-Pi,Pi},PlotRange->All] >> Plot[(fcos[x]+gcos[x]),{x,-Pi,Pi}] >> ParametricPlot[{fsin[x],gsin[x]},{x,-Pi,Pi}] >> ParametricPlot[{fcos[x],gcos[x]},{x,-Pi,Pi}] >> ParametricPlot[{fsin[x],fcos[x]},{x,-Pi,Pi}] >> ParametricPlot[{gsin[x],gcos[x]},{x,-Pi,Pi}] >> ParametricPlot[{fsin[x]+gsin[x],fcos[x]+gcos[x]},{x,-Pi,Pi},PlotRange->All] >> Respectfully, Roger L. Bagula >> tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : >> alternative email: rlbtftn@netscape.net >> URL : http://home.earthlink.net/~tftn > It occurs to me that these functions might be simplified, as they are > each themselves sums of pairs of functions with terms satisfying simple > recurrences. For example, fs can be written as the sum of n-even + n-odd > terms, and these are just the sums of terms 1/(2*k+1)*x^(4*k+1)/(4*k+1)! > and (-1)*(2*k+1)/(2*k+2)*x^(4*k+3)/(4*k+3)! respectively. > In more detail we get the function below. > InputForm[fsin2[x_] = Together[-Sum[(2*k+1)/(2*k+2)*x^(4*k+3)/(4*k+3)!, > {k,0,Infinity}] + > Sum[1/(2*k+1)*x^(4*k+1)/(4*k+1)!, {k,0,Infinity}]]] > Out[10]//InputForm= (-4 + 4*Cosh[x] + x*Sin[x] - x*Sinh[x])/(2*x) > (Isn't it great to have a symbolic math engine at ones fingertips?) > As a quick check: > In[11]:= InputForm[Max[Abs[Table[fsin2[x]-fsin[x], {x,-Pi,Pi,.1}]]]] > Out[11]//InputForm= 3.372302437298913*^-15 > (Isn't it great to have a numeric math engine at ones fingertips?) > The advantage to using the closed form is twofold. One is that numeric > computations are better, and the other is that they are significantly > faster. To see the latter: > In[5]:= Timing[Plot[fsin[x],{x,-Pi,Pi}]] > Out[5]= {0.3 Second, -Graphics-} > In[6]:= Timing[Plot[fsin2[x],{x,-Pi,Pi}]] > Out[6]= {0.01 Second, -Graphics-} > For the former, just notice what happens when we get outside the range > -Pi Daniel Lichtblau > Wolfram Research -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: pair sums applied to trignometry sums > I had used the mechanism with Bailey type of sequences > and their sums in the work on b normalness in iteratives functions. > It occurred to me that by adding the variable x , I could get > functiond that used the nonlinear Cantor pair {1/(n+1),n/(n+1)} > to split the sine and the cosine down the middle. > The result is entirely new trignometric sum functions that converge very > well. > (* pair sums applied to trignometry sums: {1/(n+1),n/(n+1)} modulo 2 > switched sums*) > (* these sums break the trignometry of a circle into four functions > instead of two*) > (* these are subharmonic functions of a nonlinear Rational Cantor type*) > fs[x_,n_]:= > If[Mod[n,2]==1,(-1)^(n)*n*x^(2*n+1)/((n+1)*(2*n+1)!),(-1)^(n)* > x^(2*n+1)/((n+1)*(2*n+1)!)] > gs[x_,n_]:= > If[Mod[n,2]==1,(-1)^n*x^(2*n+1)/((n+1)*(2*n+1)!),(-1)^n*n* > x^(2*n+1)/((n+1)*(2*n+1)!)] > fc[x_,n_]:= > If[Mod[n,2]==1,(-1)^(n)*n*x^(2*n)/((n+1)*(2*n)!),(-1)^(n)* > x^(2*n)/((n+1)*(2*n)!)] > gc[x_,n_]:= > If[Mod[n,2]==1,(-1)^(n)*x^(2*n)/((n+1)*(2*n)!),(-1)^(n)*n* > x^(2*n)/((n+1)*(2*n)!)] > digits=100; > fsin[x_]:=N[Sum[fs[x,n],{n,0,digits}]]; > gsin[x_]:=N[Sum[gs[x,n],{n,0,digits}]] > fcos[x_]:=N[Sum[fc[x,n],{n,0,digits}]] > gcos[x_]:=N[Sum[gc[x,n],{n,0,digits}]] > Plot[fsin[x],{x,-Pi,Pi}] > Plot[fsin[x],{x,-Pi,Pi}] > Plot[gsin[x],{x,-Pi,Pi}] > Plot[fcos[x],{x,-Pi,Pi}] > Plot[gcos[x],{x,-Pi,Pi}] > Plot[(fsin[x]+gsin[x]),{x,-Pi,Pi},PlotRange->All] > Plot[(fcos[x]+gcos[x]),{x,-Pi,Pi}] > ParametricPlot[{fsin[x],gsin[x]},{x,-Pi,Pi}] > ParametricPlot[{fcos[x],gcos[x]},{x,-Pi,Pi}] > ParametricPlot[{fsin[x],fcos[x]},{x,-Pi,Pi}] > ParametricPlot[{gsin[x],gcos[x]},{x,-Pi,Pi}] > ParametricPlot[{fsin[x]+gsin[x],fcos[x]+gcos[x]},{x,-Pi,Pi},PlotRange->All] > Respectfully, Roger L. Bagula > tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : > alternative email: rlbtftn@netscape.net > URL : http://home.earthlink.net/~tftn It occurs to me that these functions might be simplified, as they are each themselves sums of pairs of functions with terms satisfying simple recurrences. For example, fs can be written as the sum of n-even + n-odd terms, and these are just the sums of terms 1/(2*k+1)*x^(4*k+1)/(4*k+1)! and (-1)*(2*k+1)/(2*k+2)*x^(4*k+3)/(4*k+3)! respectively. In more detail we get the function below. InputForm[fsin2[x_] = Together[-Sum[(2*k+1)/(2*k+2)*x^(4*k+3)/(4*k+3)!, {k,0,Infinity}] + Sum[1/(2*k+1)*x^(4*k+1)/(4*k+1)!, {k,0,Infinity}]]] Out[10]//InputForm= (-4 + 4*Cosh[x] + x*Sin[x] - x*Sinh[x])/(2*x) (Isn't it great to have a symbolic math engine at ones fingertips?) As a quick check: In[11]:= InputForm[Max[Abs[Table[fsin2[x]-fsin[x], {x,-Pi,Pi,.1}]]]] Out[11]//InputForm= 3.372302437298913*^-15 (Isn't it great to have a numeric math engine at ones fingertips?) The advantage to using the closed form is twofold. One is that numeric computations are better, and the other is that they are significantly faster. To see the latter: In[5]:= Timing[Plot[fsin[x],{x,-Pi,Pi}]] Out[5]= {0.3 Second, -Graphics-} In[6]:= Timing[Plot[fsin2[x],{x,-Pi,Pi}]] Out[6]= {0.01 Second, -Graphics-} For the former, just notice what happens when we get outside the range -PiIt occurs to me that these functions might be simplified, as they are >each themselves sums of pairs of functions with terms satisfying simple >recurrences. For example, fs can be written as the sum of n-even + n-odd >terms, and these are just the sums of terms 1/(2*k+1)*x^(4*k+1)/(4*k+1)! >and (-1)*(2*k+1)/(2*k+2)*x^(4*k+3)/(4*k+3)! respectively. >In more detail we get the function below. >InputForm[fsin2[x_] = Together[-Sum[(2*k+1)/(2*k+2)*x^(4*k+3)/(4*k+3)!, >{k,0,Infinity}] + > Sum[1/(2*k+1)*x^(4*k+1)/(4*k+1)!, {k,0,Infinity}]]] >Out[10]//InputForm= (-4 + 4*Cosh[x] + x*Sin[x] - x*Sinh[x])/(2*x) >(Isn't it great to have a symbolic math engine at ones fingertips?) >As a quick check: >In[11]:= InputForm[Max[Abs[Table[fsin2[x]-fsin[x], {x,-Pi,Pi,.1}]]]] >Out[11]//InputForm= 3.372302437298913*^-15 >(Isn't it great to have a numeric math engine at ones fingertips?) >The advantage to using the closed form is twofold. One is that numeric >computations are better, and the other is that they are significantly >faster. To see the latter: >In[5]:= Timing[Plot[fsin[x],{x,-Pi,Pi}]] >Out[5]= {0.3 Second, -Graphics-} >In[6]:= Timing[Plot[fsin2[x],{x,-Pi,Pi}]] >Out[6]= {0.01 Second, -Graphics-} >For the former, just notice what happens when we get outside the range >-PiDaniel Lichtblau >Wolfram Research There is a reason for using the specific pair {1/(n+1),n/(1+n)}. It stems from group theory and functional inversion. The pair function {1/(1+x),x/(1+x)} is connected to the Farey tree functions by functional inversion: x/(1-x) if the functional inverse to x/(1+x) Solve[z-x/(1-x)==0,x] (1-x)/x if the functional inverse to 1/(1+x) Solve[z-(1-x)/x==0,x] There is a larger group that contains these Farey tree transforms too called the anharmonic group: {x, 1/x, 1/(x-1),x-1,x/(1-x),(1-x)/x} and it implies an functional inversion group of: {x,1/x,(1+x)/x,x+1,x/(1+x),1/(1+x)} I have done a lot of work in this area in the last few years. I'm glad someone realized that these functions are important besides me. There should be a number of ways to do them as is usual when dealing with fundamentals in Mathematics. I chose the ones I did because they are a torus under the inverse substitution: {1/(1+x),x/(1+x)}/. x->1/x I thank you for your work and I'll see if they work on my version of Mathematica. The anharmonic group connection makes me believe that there are further subharmonic functions yet to be discovered. Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: pair sums applied to trignometry sums I had used the mechanism with Bailey type of sequences and their sums in the work on b normalness in iteratives functions. It occurred to me that by adding the variable x , I could get functiond that used the nonlinear Cantor pair {1/(n+1),n/(n+1)} to split the sine and the cosine down the middle. The result is entirely new trignometric sum functions that converge very well. (* pair sums applied to trignometry sums: {1/(n+1),n/(n+1)} modulo 2 switched sums*) (* these sums break the trignometry of a circle into four functions instead of two*) (* these are subharmonic functions of a nonlinear Rational Cantor type*) fs[x_,n_]:= If[Mod[n,2]==1,(-1)^(n)*n*x^(2*n+1)/((n+1)*(2*n+1)!),(-1)^(n)* x^(2*n+1)/((n+1)*(2*n+1)!)] gs[x_,n_]:= If[Mod[n,2]==1,(-1)^n*x^(2*n+1)/((n+1)*(2*n+1)!),(-1)^n*n* x^(2*n+1)/((n+1)*(2*n+1)!)] fc[x_,n_]:= If[Mod[n,2]==1,(-1)^(n)*n*x^(2*n)/((n+1)*(2*n)!),(-1)^(n)* x^(2*n)/((n+1)*(2*n)!)] gc[x_,n_]:= If[Mod[n,2]==1,(-1)^(n)*x^(2*n)/((n+1)*(2*n)!),(-1)^(n)*n* x^(2*n)/((n+1)*(2*n)!)] digits=100; fsin[x_]:=N[Sum[fs[x,n],{n,0,digits}]]; gsin[x_]:=N[Sum[gs[x,n],{n,0,digits}]] fcos[x_]:=N[Sum[fc[x,n],{n,0,digits}]] gcos[x_]:=N[Sum[gc[x,n],{n,0,digits}]] Plot[fsin[x],{x,-Pi,Pi}] Plot[fsin[x],{x,-Pi,Pi}] Plot[gsin[x],{x,-Pi,Pi}] Plot[fcos[x],{x,-Pi,Pi}] Plot[gcos[x],{x,-Pi,Pi}] Plot[(fsin[x]+gsin[x]),{x,-Pi,Pi},PlotRange->All] Plot[(fcos[x]+gcos[x]),{x,-Pi,Pi}] ParametricPlot[{fsin[x],gsin[x]},{x,-Pi,Pi}] ParametricPlot[{fcos[x],gcos[x]},{x,-Pi,Pi}] ParametricPlot[{fsin[x],fcos[x]},{x,-Pi,Pi}] ParametricPlot[{gsin[x],gcos[x]},{x,-Pi,Pi}] ParametricPlot[{fsin[x]+gsin[x],fcos[x]+gcos[x]},{x,-Pi,Pi},PlotRange->All] Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: pair sums applied to trignometry sums This male/ female Fibonacci is another application of the pair type functions. In Mathematica: f[n_]:=(1/(n+1))^Mod[n,2]*(n/(n+1))^(1-Mod[n,2]) but g[n_]:=(n/(n+1))^Mod[n,2]*(1/(n+1))^(1-Mod[n,2]) doesn't seem to work. I had to change it to: g[n_]:=If[Mod[n,2]==1,(n/(n+1)),(1/(n+1))] The modulo power version seems functionallt equivalent, but fails completely in the zeta function versions of these. (* (1/(n+1),n/(1+n)) pair function used to get a dual population Fibonacci *) (* if the Fibonacci is a rabbit population , thn it has male and femal components*) (* in this case the gfib ( female) population is always larger or the same*) (* natural birth rate has the female popoulation slightly larger than the male in many mammals*)*) digits=50 f[n_]:=(1/(n+1))^Mod[n,2]*(n/(n+1))^(1-Mod[n,2]) g[n_]:=If[Mod[n,2]==1,(n/(n+1)),(1/(n+1))] fib[n_Integer?Positive] :=fib[n] =fib[n-1]+fib[n-2] fib[0]=0;fib[1] = 1; ffib[n_Integer?Positive] :=ffib[n] =ffib[n-1]*f[n-1]+ffib[n-2]*f[n-2] ffib[0]=0;ffib[1] = 1; gfib[n_Integer?Positive] :=gfib[n] =gfib[n-1]*g[n-1]+gfib[n-2]*g[n-2] gfib[0]=0;gfib[1] = 1; a=Table[Floor[ffib[n]*fib[n]],{n,0,digits}] b=Table[Floor[gfib[n]*fib[n]],{n,0,digits}] {0,1,0,1,1,3,4,7,11,18,29,47,75,123,197,321,514,836,1343,2181,3508,5692,9167 , 14865,23959,38838,62635,101503,163773,265344,428291,693791,1120191,1814345, 2930173,4745365,7665395,12412755,20054413,32471888,52470417,84953526, 137291667,222271983,359249034,581585233,940082660,1521822386,2460102246, 3982297570,6438059697} {0,1,0,1,2,3,5,8,13,20,34,54,88,141,230,368,599,962,1562,2512,4077,6562,1064 4, 17149,27804,44827,72655,117201,189907,306473,496500,801528,1298303,2096510, 3395454,5484273,8881231,14347563,23232342,37537787,60778546,98216903, 159015502,256996472,416059948,672493991,1088669150,1759816751,2848763556, 4605344794,7454779663} === Subject: Getting at an AutoGenerated Package OK, I created a notebook myModules containing a bunch of modules that I want to use in my main notebook; set all the cells in this notebook to Initialization cells; set the AutoGeneratedPackage option for this notebook to Automatic; and indeed, each time I Save this notebook, it creates a file myModule.m in the same folder as the myModules notebook it's derived from, and the main notebook in which I want to use these modules. So, now how do I make this package available to my main notebook? If I put an Input line Needs[myModules`] in my main notebook as advised by Maeder's book, I get an error message Needs::cxt: Context (string ending in `) expected at position 1 in Needs[myModules`]. === Subject: Re: New User - Programming First, here's a cleaner solution for the original cumulative sum: a = {5, 6, 3, 2, 8, 2}; b = {5, 4, 1, 3, 9, 4}; signal = Sign[a - b]; cumulative = Rest@FoldList[Plus, 0, signal]; table := TableForm[{a, b, signal, cumulative}, TableDirections -> Row, TableHeadings -> {{a, b, Signal, Cumulative}, None}, TableSpacing -> {4, 4, 4, 4, 4}] table Next, here's a solution for the revised cumulative sum, leaving the signal column as is: limit = 1; delimit = Max[-limit, Min[limit, #]] &; cumulative = Rest@FoldList[delimit[#1 + #2] &, 0, signal]; table You seemed to say you want to modify the SIGNAL, however, not just the cumulative sums. In that case you can calculate signal the original way, calculate cumulative, then recalculate signal: signal = Sign[a - b]; cumulative = Rest@FoldList[delimit[#1 + #2] &, 0, signal]; signal = FoldList[#2 - #1 &, First@cumulative, Rest@cumulative]; table Or you can compute the modified signal and cumulative simultanously, something like this: helper[{oldS_, oldC_}, newS_] := {newS, delimit[oldC + newS]} {signal, cumulative} = Transpose@Rest@FoldList[helper, {0, 0}, Sign[a - b]]; table or helper[{oldS_, oldC_}, newS_] := {Sign@newS, delimit[oldC + Sign@newS]} {signal, cumulative} = Transpose@Rest@FoldList[helper, {0, 0}, a - b]; table You could find a way to do this without computing a-b first, but it probably wouldn't be an improvement. In all cases, delimit could be replaced with Sign if limit==1, but the more general version is needed otherwise. For instance, the last solution becomes: helper[{oldS_, oldC_}, newS_] := {Sign@newS, Sign[oldC + Sign@newS]} {signal, cumulative} = Transpose@Rest@FoldList[helper, {0, 0}, a - b]; table Bobby > I am a new user who is well and truly stuck. Any help would be greatly > appreciated. > I have two lists, a and b, that when compared, will produce a third > list of signals. This third list is then summed to get a cumulative > total of the signals. > The rules are fairly simple. If a = b, the signal is 0, if a > b, the > signal is 1 and finally, if a < b, then the signal is .89¥ã1. > a={5,6,3,2,8,2}; > b={5,4,1,3,9,4}; > c={a,b}; > p=0; > Fun[t_,u_]/;t==u :=0; > Fun[t_,u_]/;t>u:=1; > Fun[t_,u_]/;t signal=Map[ (Fun[#[[1]],#[[2]]])&,Transpose[c]]; > c4={signal}; > cumTotal=Flatten[Map[p+={Last[#]} &,Transpose[c4]]]; > TableForm[{a,b,signal,total},TableDirections->Row, > TableHeadings->{{a,b,Signal,Cumm.Total},None}, > TableSpacing->{4,4,4,4,4}] > a b Signal Cum.Total > 5 5 0 0 > 6 4 1 1 > 3 1 1 2 > 2 3 -1 1 > 8 9 -1 0 > 2 4 -1 -1 > I want to modify slightly how the signal is generated. The rules are > the same except that if the cumulative total is already 1 or -1, then > no new signal is generated unless the new signal would make the > cumulative total move back towards zero. > Ideally, I am looking to modify my code, so it produces, signal = > {0,1,0,-1,-1,0} and cumTotal = {0,1,1,0,-1,-1}.The maximum size of the > cumulative total need not be 1, but rather any value that is chosen as > a limit. > This has been causing me a great deal of grief and I would greatly > welcome any help and suggestions. Given my lack of experience, I am > sure that there is a more efficient way to tackle this type of > problem, especially as I am dealing with many large lists. > Dean Williams -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: New User - Programming > I am a new user who is well and truly stuck. Any help would be greatly > appreciated. > I have two lists, a and b, that when compared, will produce a third > list of signals. This third list is then summed to get a cumulative > total of the signals. > The rules are fairly simple. If a = b, the signal is 0, if a > b, the > signal is 1 and finally, if a < b, then the signal is ö1. > a={5,6,3,2,8,2}; > b={5,4,1,3,9,4}; > c={a,b}; > p=0; > Fun[t_,u_]/;t==u :=0; > Fun[t_,u_]/;t>u:=1; > Fun[t_,u_]/;t signal=Map[ (Fun[#[[1]],#[[2]]])&,Transpose[c]]; > c4={signal}; > cumTotal=Flatten[Map[p+={Last[#]} &,Transpose[c4]]]; > TableForm[{a,b,signal,total},TableDirections->Row, > TableHeadings->{{a,b,Signal,Cumm.Total},None}, > TableSpacing->{4,4,4,4,4}] > a b Signal Cum.Total > 5 5 0 0 > 6 4 1 1 > 3 1 1 2 > 2 3 -1 1 > 8 9 -1 0 > 2 4 -1 -1 > > I want to modify slightly how the signal is generated. The rules are > the same except that if the cumulative total is already 1 or -1, then > no new signal is generated unless the new signal would make the > cumulative total move back towards zero. > Ideally, I am looking to modify my code, so it produces, signal = > {0,1,0,-1,-1,0} and cumTotal = {0,1,1,0,-1,-1}.The maximum size of the > cumulative total need not be 1, but rather any value that is chosen as > a limit. > This has been causing me a great deal of grief and I would greatly > welcome any help and suggestions. Given my lack of experience, I am > sure that there is a more efficient way to tackle this type of > problem, especially as I am dealing with many large lists. > Dean Williams First, to compute the signal and the accumulated totals you can use much simpler code. a = {5,6,3,2,8,2}; b = {5,4,1,3,9,4}; signal = Sign[a-b] Out[54]= {0, 1, 1, -1, -1, -1} runningTotal[sig_] := FoldList[Plus, First[sig], Rest[sig]] cumTotal = runningTotal[signal] Out[56]= {0, 1, 2, 1, 0, -1} If I understand correctly what it is you require for modifying the signal, then you can do it using the code below, beginning with the original signal and its accumulated totals. It has a simple loop that runs over the accumulated totals, keeping a new cumulative offset. It modifies both that offset and the resulting signal (initialized to the original one) appropriately whenever a bound is overstepped. signalTruncation[sig_, cumsig_, lim_] := Module[ {len=Length[sig], cum=0, newsig=sig}, Do [ Which [ cumsig[[j]]+cum>lim, newsig[[j]] = 0; cum--, cumsig[[j]]+cum<-lim, newsig[[j]] = 0; cum++ ]; , {j,len}]; newsig ] signalTruncation[signal, cumTotal, 1] Out[57]= {0, 1, 0, -1, -1, 0} There are no doubt slicker ways to do this. Also faster. For example, if you use large lists that are (or can be coerced to) machine integers or machine real numbers, then use of Compile will help considerably should speed become an issue for signalTruncation. Daniel Lichtblau Wolfram Research === Subject: Re: New User - Programming Excellent example for MapThread or Thread :) Your data is a = {5, 6, 3, 2, 8, 2}; b = {5, 4, 1, 3, 9, 4}; your function should be f[x_, y_] := Which[x > y, 1, x < y, -1, True, 0] and use MapThread in the following way MapThread[f, {a, b}] to get the result {0, 1, 1, -1, -1, -1} If you prefer the pure functions notation you may do it as MapThread[Which[#1 > #2, 1, #1 < #2, -1, True, 0] &, {a, b}] and get the same output. With Thread you may do it as the following Release[Thread[Hold[f][a, b]]] to get the same result. In general, for long vectors the Transpose is less recommended. yehuda >I am a new user who is well and truly stuck. Any help would be greatly >appreciated. >I have two lists, a and b, that when compared, will produce a third >list of signals. This third list is then summed to get a cumulative >total of the signals. >The rules are fairly simple. If a = b, the signal is 0, if a > b, the >signal is 1 and finally, if a < b, then the signal is -1. >a={5,6,3,2,8,2}; >b={5,4,1,3,9,4}; >c={a,b}; >p=0; >Fun[t_,u_]/;t==u :=0; >Fun[t_,u_]/;t>u:=1; >Fun[t_,u_]/;tsignal=Map[ (Fun[#[[1]],#[[2]]])&,Transpose[c]]; >c4={signal}; >cumTotal=Flatten[Map[p+={Last[#]} &,Transpose[c4]]]; >TableForm[{a,b,signal,total},TableDirections->Row, > TableHeadings->{{a,b,Signal,Cumm.Total},None}, > TableSpacing->{4,4,4,4,4}] >a b Signal Cum.Total >5 5 0 0 >6 4 1 1 >3 1 1 2 >2 3 -1 1 >8 9 -1 0 >2 4 -1 -1 >I want to modify slightly how the signal is generated. The rules are >the same except that if the cumulative total is already 1 or -1, then >no new signal is generated unless the new signal would make the >cumulative total move back towards zero. >Ideally, I am looking to modify my code, so it produces, signal = >{0,1,0,-1,-1,0} and cumTotal = {0,1,1,0,-1,-1}.The maximum size of the >cumulative total need not be 1, but rather any value that is chosen as >a limit. >This has been causing me a great deal of grief and I would greatly >welcome any help and suggestions. Given my lack of experience, I am >sure that there is a more efficient way to tackle this type of >problem, especially as I am dealing with many large lists. >Dean Williams === Subject: Re: New User - Programming > I am a new user who is well and truly stuck. Any help would be greatly > appreciated. > I have two lists, a and b, that when compared, will produce a third > list of signals. This third list is then summed to get a cumulative > total of the signals. > The rules are fairly simple. If a = b, the signal is 0, if a > b, the > signal is 1 and finally, if a < b, then the signal is ö1. An easier way to generate your signal is signal=Sign[a-b] > cumTotal=Flatten[Map[p+={Last[#]} &,Transpose[c4]]]; Similarly FoldList[Plus,First[signal],Rest[signal]] will generate your cumulative sum. > I want to modify slightly how the signal is generated. The rules are > the same except that if the cumulative total is already 1 or -1, then > no new signal is generated unless the new signal would make the > cumulative total move back towards zero. In this case it's probably easier to work in the other direction; compute the cumulative totals first then calculate the signal. Using FoldList the cumulative signal can be computed with: FoldList[Block[{s = Sign[#2[[ 1]] - #2[[2]]]}, If[Abs[#1 + s] > 1, #1, #1 + s]] &, Sign[First[a] - First[b]], Transpose[{Rest[a], Rest[b]}]] The signal can of course be recovered from the pairwise differences Drop[RotateLeft[cum] - cum, -1] where cum are the cumulative totals. > I am sure that there is a more efficient way to tackle this type of > problem, especially as I am dealing with many large lists. The drawback to my suggestion is the formation of the temporary list Transpose[{Rest[a],Rest[b]}], if your lists are not too large that shouldn't be too significant a problem. Otherwise you should use a Do or For loop. Ssezi === Subject: New User - Programming I am a new user who is well and truly stuck. Any help would be greatly appreciated. I have two lists, a and b, that when compared, will produce a third list of signals. This third list is then summed to get a cumulative total of the signals. The rules are fairly simple. If a = b, the signal is 0, if a > b, the signal is 1 and finally, if a < b, then the signal is ö1. a={5,6,3,2,8,2}; b={5,4,1,3,9,4}; c={a,b}; p=0; Fun[t_,u_]/;t==u :=0; Fun[t_,u_]/;t>u:=1; Fun[t_,u_]/;tRow, TableHeadings->{{a,b,Signal,Cumm.Total},None}, TableSpacing->{4,4,4,4,4}] a b Signal Cum.Total 5 5 0 0 6 4 1 1 3 1 1 2 2 3 -1 1 8 9 -1 0 2 4 -1 -1 I want to modify slightly how the signal is generated. The rules are the same except that if the cumulative total is already 1 or -1, then no new signal is generated unless the new signal would make the cumulative total move back towards zero. Ideally, I am looking to modify my code, so it produces, signal = {0,1,0,-1,-1,0} and cumTotal = {0,1,1,0,-1,-1}.The maximum size of the cumulative total need not be 1, but rather any value that is chosen as a limit. This has been causing me a great deal of grief and I would greatly welcome any help and suggestions. Given my lack of experience, I am sure that there is a more efficient way to tackle this type of problem, especially as I am dealing with many large lists. Dean Williams === Subject: Re: New User - Programming > I am a new user who is well and truly stuck. Any help would be greatly > appreciated. > I have two lists, a and b, that when compared, will produce a third > list of signals. This third list is then summed to get a cumulative > total of the signals. > The rules are fairly simple. If a = b, the signal is 0, if a > b, the > signal is 1 and finally, if a < b, then the signal is ö1. > a={5,6,3,2,8,2}; > b={5,4,1,3,9,4}; > c={a,b}; > p=0; > Fun[t_,u_]/;t==u :=0; > Fun[t_,u_]/;t>u:=1; > Fun[t_,u_]/;t signal=Map[ (Fun[#[[1]],#[[2]]])&,Transpose[c]]; > c4={signal}; > cumTotal=Flatten[Map[p+={Last[#]} &,Transpose[c4]]]; > TableForm[{a,b,signal,total},TableDirections->Row, > TableHeadings->{{a,b,Signal,Cumm.Total},None}, > TableSpacing->{4,4,4,4,4}] > a b Signal Cum.Total > 5 5 0 0 > 6 4 1 1 > 3 1 1 2 > 2 3 -1 1 > 8 9 -1 0 > 2 4 -1 -1 > > I want to modify slightly how the signal is generated. The rules are > the same except that if the cumulative total is already 1 or -1, then > no new signal is generated unless the new signal would make the > cumulative total move back towards zero. > Ideally, I am looking to modify my code, so it produces, signal = > {0,1,0,-1,-1,0} and cumTotal = {0,1,1,0,-1,-1}.The maximum size of the > cumulative total need not be 1, but rather any value that is chosen as > a limit. > This has been causing me a great deal of grief and I would greatly > welcome any help and suggestions. Given my lack of experience, I am > sure that there is a more efficient way to tackle this type of > problem, especially as I am dealing with many large lists. > Dean Williams Hi Dean, if I understood you well, you're looking for sth. like: In[1]:= a = {5, 6, 3, 2, 8, 2}; b = {5, 4, 1, 3, 9, 4}; c = {a, b}; (* this is your old version: *) Sign[Subtract @@ #] & /@ Transpose[c] Out[4]= {0, 1, 1, -1, -1, -1} Rest@FoldList[Plus, 0, %] Out[5]= {0, 1, 2, 1, 0, -1} In[6]:= newsignal[l1_, l2_] := Module[{tr = Transpose[{l1, l2}], cum = 0, ct = {}, s, ns}, {( s = Sign[Subtract @@ #]; ns = If[cum == 0 || cum + s == 0, s, 0]; ct = {ct, cum += ns}; ns ) & /@ tr, Flatten[ct]}] In[7]:= {signal, total} = newsignal[a, b]; In[8]:= TableForm[{a, b, signal, total}, TableDirections -> Row, TableHeadings -> {{a, b, Signal, Cumm.Total}, None}, TableSpacing -> {4, 4, 4, 4}, TableAlignments -> Right] a b Signal Cumm.Total 5 5 0 0 6 4 1 1 3 1 0 1 2 3 -1 0 8 9 -1 -1 2 4 0 -1 -- Peter Pein 10245 Berlin === Subject: Re: Re: Changing CellMargins? I followed your steps in editing the Default.nb style file and see no problem. You can replace any Inherited value by a value of your formatting needs. You do not have to inherit any value. You can change the CellMargin values of the working environment or at lower levels if you need. I would like to recommend to you to import a local copy of the style file, and practice on it before changing (permanently, if you are not careful enough). Good luck, yehuda -----Original Message----- === Subject: Re: Changing CellMargins? > I want to change the default margins above and below all the >> Input cells in all my notebook, on screen and in printouts. > The values for the CellMargins settings in my Default.nb seem to be > Inherited, even at the Global level. Where are these values inherited > from, and how can I change them? > The values are inherited from the style file. You can always modify a local > copy of the style file to your preferences. If you need to change some values > to specific cells use the cell options such as CellMargins-> {} or similar. > Pay attention that if you make changes in the style file, the changes take > place only for the environment (screen, printout, working, etc.) while if you > change the cell options it will effect all the environments, since the value > is not inherited anymore. Starting from one of my notebooks I've * Used the Format>>Edit Style Sheet menu command; * Chosen the Edit Shared Style Sheet option, since I do want to make this particular change globally in all my notebooks; * Doing this opens Default.nb and I use the Option Inspector menu command on the Styles for Input/Output section of Default.nb; * In fact, I've used Option Inspector, in both Selection and Global display modes, on every level of Default.nb; and so far as I can see, CellMargins are labelled as Inherited at **every** level of the Default.nb notebook. If there's a progenitor somewhere, I've not found it . . . --AES (Just for the record, Mac OS 9.2, Mathematica 4.2) === Subject: Invoking a function using full package name fail, but works without full package name Hello; In my code, I usually like to add the package name to the function name to know where each function is comming from. (A sort of self documenting the code) Now I found this to cause a problem with this Mathematica package. This is an example << ImageProcessing` img = ImageProcessing`ImageRead[test.gif]; Show[Graphics[img]]; The above gives an error Graphics::gprim: ImageProcessing`ImageRead[test.gif] was encountered where a Graphics primitive or directive was expected BUT when I do this: img = ImageRead[test.gif]; Show[Graphics[img]]; Then it works. This completely destroyes my naming convention of using full package names in my code. any idea why this is so? It seems to work ok with another user package I tried, but not this one?? --nospam === Subject: Re: Invoking a function using full package name fail, but works without full package name > Hello; > In my code, I usually like to add the package name to the > function name to know where each function is comming from. > (A sort of self documenting the code) > Now I found this to cause a problem with this Mathematica > package. > This is an example > << ImageProcessing` > img = ImageProcessing`ImageRead[test.gif]; > Show[Graphics[img]]; > The above gives an error > Graphics::gprim: ImageProcessing`ImageRead[test.gif] was encountered > where a Graphics primitive or directive was expected > BUT when I do this: > img = ImageRead[test.gif]; > Show[Graphics[img]]; > Then it works. > This completely destroyes my naming convention of using full > package names in my code. > any idea why this is so? It seems to work ok with another user > package I tried, but not this one?? > --nospam I guess it's the same phenomenon as in In[2]:= NumericalMath`NLimit[Sin[x]/x, x -> 0] Out[2]= !(NumericalMath`NLimit[Sin[x]/x, x -> 0]) In[3]:= NumericalMath`NLimit`NLimit[Sin[ x]/x, x -> 0] Out[3]= 1. In[4]:= Contexts[Numer*Limit*] Out[4]= {NumericalMath`NLimit`, NumericalMath`NLimit`Private`} Do you have a context named ImageProcessing`ImageRead` ? -- Peter Pein 10245 Berlin === Subject: Re: Invoking a function using full package name fail, but works without full package name it is so, because the ImageProcessing calls an other package for the data import and ImageRead[] is implemented in the ImageProcessing`ImageData` package and it stand in this context. So if you to know where each function is comming from you have to *know* where thie function come from. Jens nospam nospam schrieb im Newsbeitrag > Hello; > In my code, I usually like to add the package name to the > function name to know where each function is comming from. > (A sort of self documenting the code) > Now I found this to cause a problem with this Mathematica > package. > This is an example > << ImageProcessing` > img = ImageProcessing`ImageRead[test.gif]; > Show[Graphics[img]]; > The above gives an error > Graphics::gprim: ImageProcessing`ImageRead[test.gif] was encountered > where a Graphics primitive or directive was expected > BUT when I do this: > img = ImageRead[test.gif]; > Show[Graphics[img]]; > Then it works. > This completely destroyes my naming convention of using full > package names in my code. > any idea why this is so? It seems to work ok with another user > package I tried, but not this one?? > --nospam === Subject: Re: Compile ReplacePart Well, I am afraid that the specific code line will not really help you, but here it is: Compile[ ..... p = CheckXBounds[x, lb, ub]; x = ReplacePart[x, new, p, p]; .... ]; where p is of the same form as is returned by the function Position. The code works perfectly well, when is is not part of a Compiled Function. Best joerg >It is difficult to comment to your posting without an exact reference to the >line (or block of code) that caused the problem. Can you send it so we will >be able to figure out what is wrong? >yehuda >-----Original Message----- === >Subject: Compile ReplacePart >using ReplacePart with 4 arguments in a Compiled Function gives me the >error 'ReplacePart::argrx: ReplacePart called with 4 arguments; 3 >arguments are expected', even though ReplacePart is defined also for 4 >arguments in regular Mathematica code. >What's the problem here? >best, >joerg -- ---------------------------------------------- J.9arg Schaber Max Planck Institute for Molecular Genetics Ihnestrasse 63-73, 14196 Berlin, Germany Phone: +49 30 804093 19, Fax: +49 30 804093 22 ---------------------------------------------- === Subject: Compile ReplacePart using ReplacePart with 4 arguments in a Compiled Function gives me the error 'ReplacePart::argrx: ReplacePart called with 4 arguments; 3 arguments are expected', even though ReplacePart is defined also for 4 arguments in regular Mathematica code. What's the problem here? best, joerg === Subject: Boltzmann Exponent according to the documentation the BoltzmannExponent in the Simulated Annealing algorithm of NMinimize is automatically set to 'Function[{i, df,f0},-df*Log[i+1]/10]'. How do I change the BoltzmannExponent to 'Function[{i, df,f0},-df*i^6]'? Setting it in NMinimize (BoltzmannExponent->Function[{i,df,f0},-df*i^6]) results in an error. joerg === Subject: Re: Getting at an AutoGenerated Package Why don't you create a real package? I have copied the code for a ToyPackage at the end of this posting. In this case the package was meant to be placed in a folder Algebra within the ExtraPackages folder. Or, alternatively, it could be put in a folder Algebra within an Applications folder. (The location of the Applications folder can be found by evaluating $BaseDirectory or $UserBaseDirectory in Mathematica.) Your problem is caused by the fact that the Needs statement needs a file path to get to the package. It knows how to find ExtraPackages or Applications but it doesn't know where to go from there. So notice that in ToyPackage the BeginPackage is BeginPackage[Algebra`ToyPackage`] Algebra` tells the folder that ToyPackage will be in. You would then load the package with Needs[Algebra`ToyPackage`] Also note that the package itself is still stored under the name ToyPackage.nb and ToyPackage.m. When Mathematica evaluates a Needs statement it automatically starts looking in StandardPackages, ExtraPackages and the various Applications folders. But you have to give it the path from there. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ OK, I created a notebook myModules containing a bunch of modules that I want to use in my main notebook; set all the cells in this notebook to Initialization cells; set the AutoGeneratedPackage option for this notebook to Automatic; and indeed, each time I Save this notebook, it creates a file myModule.m in the same folder as the myModules notebook it's derived from, and the main notebook in which I want to use these modules. So, now how do I make this package available to my main notebook? If I put an Input line Needs[myModules`] in my main notebook as advised by Maeder's book, I get an error message Needs::cxt: Context (string ending in `) expected at position 1 in Needs[myModules`]. ___________________________________________________________________________ Notebook[{ Cell[CellGroupData[{ Cell[A Toy Package, Title], Cell[BoxData[ (BeginPackage[])], Input, InitializationCell->True], Cell[BoxData[ ((Algebra`ToyPackage::usage = ;))], Input, InitializationCell->True], Cell[BoxData[ ((SquareTheQuantity::usage = ;))], Input, InitializationCell->True], Cell[BoxData[ (Begin[<`Private`>])], Input, InitializationCell->True], Cell[BoxData[ (SquareTheQuantity[x_] := x^2)], Input, InitializationCell->True], Cell[BoxData[ (End[])], Input, InitializationCell->True], Cell[BoxData[ ((Protect[Evaluate[$Context <> <*>]];))], Input, InitializationCell->True], Cell[BoxData[ (EndPackage[])], Input, InitializationCell->True] }, Open ]] }, FrontEndVersion->5.0 for Microsoft Windows, ScreenRectangle->{{0, 1280}, {0, 941}}, AutoGeneratedPackage->Automatic, WindowSize->{494, 740}, WindowMargins->{{81, Automatic}, {Automatic, 61}} ] === Subject: Re: ReplacePart position You do not have any syntax error. I checked your code and it is functional. newes1 = Table[0, {11}, {4}, {1}, {2}, {3}]; (* generate an artificial list to reference to *) newes1[[11, 4, 1, 2, 3]] = 18; (* assign a value to the required place *); Part[newes1, 11, 4, 1, 2, 3] 18 (* this notation is working *) Position[newes1, 18] {{11, 4, 1, 2, 3}} (* working *) ReplacePart[newes1, 19, {11, 4, 1, 2, 3}] (* 19 appears as the last element *) {{{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 19}}}}} Also working the same ReplacePart[newes1, 19, {{11, 4, 1, 2, 3}}] Better check the dimensions of your list by Dimensions[news1] to see if there is another problem yehuda. >Hello-- >Half way through my simulations I run into the following problem. The model >generates a list and when I try to replace parts of that list it does fine >in most cases. However, there is a position in the list that does not exist >according to ReplacePart. For example: >newes1[[11, 4, 1, 2, 3]] >Part[newes1, 11, 4, 1, 2, 3] >Position[newes1, 18] >{{11, 4, 1, 2, 3}} >ReplacePart[newes1, 19, {11, 4, 1, 2, 3}] >ReplacePart :: partw : Part {11, 4, 1, 2, 3} of ..... does not exist. >newes1 is the list of lists (5 levels) mentioned above. I can understand it >would be helpful to actually have that list here, but it is too long to >include. Furthermore it wouldn't help, because when I close the Kernel and >define the list exactly as newes1 is at this moment, and replace the part as >above it works fine. I can even copy the part of the output after the error >message and execute it and no problem, the part is there. FullForm doesn't >give me any new insights, the list is there and nothing seems to be wrong. >Same for Trace, the whole list is there, but ReplacePart cannot replace the >element at above mentioned position. >Strangely enough the following does work: >Part[newes1, 11, 4, 1, 2, 3] = 19 >Part[newes1, 11, 4, 1, 2, 3] >Bas Straatman === Subject: Re: ReplacePart position I solved the problem by using MapAt in stead of ReplacePart. All I wanted to do is increase the current value of a number of locations by 1. So instead of ReplacePart[newes1, newes1[[Sequence@@loc]]+1, loc] I used MapAt[(#+1)&, newes1, loc] and this works fine. I still don't understand why Replacepart doesn't recognize the location though, every other function I have tried recognizes the location without any trouble. > You do not have any syntax error. I checked your code and it is > functional. > newes1 = Table[0, {11}, {4}, {1}, {2}, {3}]; (* generate an artificial > list to reference to *) > newes1[[11, 4, 1, 2, 3]] = 18; (* assign a value to the required place *); > Part[newes1, 11, 4, 1, 2, 3] > 18 (* this notation is working *) > Position[newes1, 18] > {{11, 4, 1, 2, 3}} (* working *) > ReplacePart[newes1, 19, {11, 4, 1, 2, 3}] (* 19 appears as the last > element *) > {{{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, > 0}}}, {{{0, 0, 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, > {{{0, 0, > 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, > 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, { > 0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, > 0}, {0, 0, 0}}}}, {{{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, > 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 0}}}, {{{0, 0, 0}, {0, 0, 19}}}}} > Also working the same > ReplacePart[newes1, 19, {{11, 4, 1, 2, 3}}] > Better check the dimensions of your list by Dimensions[news1] to see if > there is another problem > yehuda. >Hello-- >Half way through my simulations I run into the following problem. The model >generates a list and when I try to replace parts of that list it does fine >in most cases. However, there is a position in the list that does not exist >according to ReplacePart. For example: >newes1[[11, 4, 1, 2, 3]] >18 >Part[newes1, 11, 4, 1, 2, 3] >18 >Position[newes1, 18] >{{11, 4, 1, 2, 3}} >ReplacePart[newes1, 19, {11, 4, 1, 2, 3}] >ReplacePart :: partw : Part {11, 4, 1, 2, 3} of ..... does not exist. >newes1 is the list of lists (5 levels) mentioned above. I can understand it >would be helpful to actually have that list here, but it is too long to >include. Furthermore it wouldn't help, because when I close the Kernel and >define the list exactly as newes1 is at this moment, and replace the part as >above it works fine. I can even copy the part of the output after the error >message and execute it and no problem, the part is there. FullForm doesn't >give me any new insights, the list is there and nothing seems to be wrong. >Same for Trace, the whole list is there, but ReplacePart cannot replace the >element at above mentioned position. >Strangely enough the following does work: >Part[newes1, 11, 4, 1, 2, 3] = 19 >19 >Part[newes1, 11, 4, 1, 2, 3] >19 >Bas Straatman === Subject: ReplacePart position Hello-- Half way through my simulations I run into the following problem. The model generates a list and when I try to replace parts of that list it does fine in most cases. However, there is a position in the list that does not exist according to ReplacePart. For example: newes1[[11, 4, 1, 2, 3]] 18 Part[newes1, 11, 4, 1, 2, 3] 18 Position[newes1, 18] {{11, 4, 1, 2, 3}} ReplacePart[newes1, 19, {11, 4, 1, 2, 3}] ReplacePart :: partw : Part {11, 4, 1, 2, 3} of ..... does not exist. newes1 is the list of lists (5 levels) mentioned above. I can understand it would be helpful to actually have that list here, but it is too long to include. Furthermore it wouldn't help, because when I close the Kernel and define the list exactly as newes1 is at this moment, and replace the part as above it works fine. I can even copy the part of the output after the error message and execute it and no problem, the part is there. FullForm doesn't give me any new insights, the list is there and nothing seems to be wrong. Same for Trace, the whole list is there, but ReplacePart cannot replace the element at above mentioned position. Strangely enough the following does work: Part[newes1, 11, 4, 1, 2, 3] = 19 19 Part[newes1, 11, 4, 1, 2, 3] 19 Bas Straatman === Subject: Re: GUIKit and VisibleRect > The following draws a little plot and shows the associated visible > rectangle: > ref = GUIRun[ > Widget[Frame, > {Widget[ImageLabel, > {data -> Script[ExportString[ > Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, > DisplayFunction -> Identity], > GIF, > ImageSize -> 300, > ConversionOptions -> {Transparency -GrayLevel[1]}]] > }, Name -> myImageLabel]}, Name -> myFrame]]; > (ref@PropertyValue[{myImageLabel, VisibleRect}])@toString[] > (ref@PropertyValue[{myImageLabel, Bounds}])@toString[] > The following resizes the frame and puts a bigger image into it. The > visible rectangle is not updated. It is also not writable. > ref @ Script[ > newData = ExportString[ > Plot3D[Sin[2x y], {x, 0, Pi}, {y, 0, Pi}, > DisplayFunction -> Identity], > GIF, > ImageSize -> 500, > ConversionOptions -> {Transparency -> GrayLevel[1]}]; > SetPropertyValue[{myImageLabel, data}, newData]; > SetPropertyValue[{myFrame, Size}, Widget[Dimension, > {width -> 600, height -> 500}]]; > ] > (ref@PropertyValue[{myImageLabel, VisibleRect}])@toString[] > (ref@PropertyValue[{myImageLabel, Bounds}])@toString[] > A mouse resize will fix this. How do I do that with a program? > Peter Dickof Hello Peter, After calling: SetPropertyValue[{myFrame, Size}, Widget[Dimension, {width -> 600, height -> 500}]]; try adding InvokeMethod[{myFrame, Validate}]; which will programmatically recompute the new sizes of the frame and all its children, including the image label's new display and size based on its new image data. Jeff Adams Wolfram Research === Subject: GUIKit and VisibleRect The following draws a little plot and shows the associated visible rectangle: ref = GUIRun[ Widget[Frame, {Widget[ImageLabel, {data -> Script[ExportString[ Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, DisplayFunction -> Identity], GIF, ImageSize -> 300, ConversionOptions -> {Transparency -> GrayLevel[1]}]] }, Name -> myImageLabel]}, Name -> myFrame]]; (ref@PropertyValue[{myImageLabel, VisibleRect}])@toString[] (ref@PropertyValue[{myImageLabel, Bounds}])@toString[] The following resizes the frame and puts a bigger image into it. The visible rectangle is not updated. It is also not writable. ref @ Script[ newData = ExportString[ Plot3D[Sin[2x y], {x, 0, Pi}, {y, 0, Pi}, DisplayFunction -> Identity], GIF, ImageSize -> 500, ConversionOptions -> {Transparency -> GrayLevel[1]}]; SetPropertyValue[{myImageLabel, data}, newData]; SetPropertyValue[{myFrame, Size}, Widget[Dimension, {width -> 600, height -> 500}]]; ] (ref@PropertyValue[{myImageLabel, VisibleRect}])@toString[] (ref@PropertyValue[{myImageLabel, Bounds}])@toString[] A mouse resize will fix this. How do I do that with a program? Peter Dickof === Subject: New user - Integration domain question I'm trying to integrate a gaussian over a circle (radius r) domain (in the x-y plane) by the way of a double integral : 'Integrate[f[x, y], {x, 0, r}, {y, -Sqrt[r - x^2], Sqrt[r - x^2]}]' and 'Integrate[f[x, y], {x, -r, 0}, {y, -Sqrt[r - x^2], Sqrt[r - x^2]}]' Unfortunately, Mathematica v.5 does not seem to respond correctly and returns 'SeriesData::csa' errors. Is there a simple way to solve this problem ? I expect to get the volume of the gaussian located over the circle. I'll then add offsets to the center of the circle (x0,y0). B. Oliver === Subject: .WAV file headers Is there a way to extract the information from wave file headers in Mathematica? The header is the first 11 words of the wave file and consists of 4 byte ASCII words and 4 byte integers encoded as ASCII strings. I need the integers from header words 7 (samples/second), 9 (two 2 byte words, bytes/sample and bits/sample) , and 11 (number of bytes in the file). John Reed === Subject: Re: .WAV file headers Without going into any detail, in Versions 5.0.1 and less you can use Experimental`BinaryImport. So load the Experimental package: < Is there a way to extract the information from wave file headers in > Mathematica? The header is the first 11 words of the wave file and > consists > of 4 byte ASCII words and 4 byte integers encoded as ASCII strings. I > need > the integers from header words 7 (samples/second), 9 (two 2 byte words, > bytes/sample and bits/sample) , and 11 (number of bytes in the file). > John Reed === Subject: Re: .WAV file headers if I can get BinaryRead to decode headers. John Reed > Without going into any detail, in Versions 5.0.1 and less you can use > Experimental`BinaryImport. > So load the Experimental package: > < and then use BinaryImport. You obviously know the header structure and > so you can select how bytes are read in at a time and where from. > In V5.1 this has changed and you can use BinaryRead to read in specific > chunks. > Yas >> Is there a way to extract the information from wave file headers in >> Mathematica? The header is the first 11 words of the wave file and >> consists >> of 4 byte ASCII words and 4 byte integers encoded as ASCII strings. I >> need >> the integers from header words 7 (samples/second), 9 (two 2 byte words, >> bytes/sample and bits/sample) , and 11 (number of bytes in the file). >> John Reed === Subject: Re: .WAV file headers You can extract that information from the Sound object that is created when you import a WAV file. Here is an example of how you can do this (assuming you are using Windows): 1. Import the chimes sound from the Windows media folder: chimes=Import[C:WINDOWSmediachimes.wav,WAV]; Show[chimes]; 2. This gets the size of the (stereo) data: Dimensions[chimes[[1,1]]] {2,13921} 3. This gets the samples per second and the bits per sample chimes[[1,2]] {22050,16} Steve Luttrell > Is there a way to extract the information from wave file headers in > Mathematica? The header is the first 11 words of the wave file and > consists > of 4 byte ASCII words and 4 byte integers encoded as ASCII strings. I > need > the integers from header words 7 (samples/second), 9 (two 2 byte words, > bytes/sample and bits/sample) , and 11 (number of bytes in the file). > John Reed === Subject: Re: .WAV file headers > Is there a way to extract the information from wave file headers in > Mathematica? The header is the first 11 words of the wave file and consists > of 4 byte ASCII words and 4 byte integers encoded as ASCII strings. I need > the integers from header words 7 (samples/second), 9 (two 2 byte words, > bytes/sample and bits/sample) , and 11 (number of bytes in the file). > John Reed I think you can only get the Mathematica formated informatin itself of the header (i.e. not the header data as it is in the file) To see the header information, set the option PrintHeader to be True, like this: sound = ReadSoundFile[file.wav, PrintHeader -> True]; There might be a way to capture this output to a string, and then parse it to extract the info in a more usable way. === Subject: Re: .WAV file headers > Is there a way to extract the information from wave file headers in > Mathematica? The header is the first 11 words of the wave file and consists > of 4 byte ASCII words and 4 byte integers encoded as ASCII strings. I need > the integers from header words 7 (samples/second), 9 (two 2 byte words, > bytes/sample and bits/sample) , and 11 (number of bytes in the file). > John Reed At 5.1 you have fast binary I/O - so since you know exactly what information you want, it should be very easy using the new BinaryRead function. David Bailey === Subject: JLink to remote kernel not possible? I have a little java app that does some operations connecting to the kernel via JLink. I use the following lines to get a link to the kernel (locally, on my PowerBook): -------- String argsOSX = -linkmode launch -linkname '/Applications/Mathematica 5.0.app/Contents/MacOS/MathKernel -mathlink'; KernelLink ml = MathLinkFactory.createKernelLink(argsOSX); -------- Now, here is what I would like to do (probably a newbie question): I have access (via ssh) to a remote kernel ('math' command) on my Unix machine (let's call it host1.mydomain.edu) which is running Mathematica 5.0 for Sun Solaris. I would like my java app to use the remote kernel (on the unix host) instead of the one installed on my PowerBook (so that I can use the java app from other computers where there's not Mathematica installed). Is there a way to do that? I was dreaming it was something trivial like make the remote kernel listen to a specific port (let's say 60000) and then, on the java client, use something like createKernelLink(...name:pass@host1.mydomain.edu:60000)...but of course createKernelLink doesn't seem to accept a remote host as parameter. Please, can anybody help?