I had the same problem and found that Mathematica defines own functions in the eps-file. But the function Mistroke which cuts all the curves doesn«t seem to be necessary: filename = D:figure1.eps; Export[filename, fig1] epsfile = Import[filename, Text]; epsneu = StringReplace[epsfile, Mistroke -> ]; Export[filename, epsneu, Text] Till now I had no problems with this (not very clean) method! Thomas use Adobe Illustrator to edit the EPS files. Here's my problem: I plot y = x^2 and open the EPS file in Illustrator, but when I click on the curve, Illustrator only highlights (selects) a piece of the parabola (and not the entire parabola). Sometimes it even selects a piece of the curve and a piece of an axis, but I cannot select just the curve, or just an axis. I've posted a similar question on the Adobe Forums, but with little success. Any suggestions? I appreciate any help that's out there. R ==== I wish to integrate numerically a function which is integrable but has singularities at the endpoints. Help states that NIntegrate tests for singularities at the end points of the integration range so I am optimistic that Mathematica can deal with my integral. However, the following happens. I start by defining my integrand where I have Rationalized all my numbers so that everything is defined exactly In[1]:= a = {48397463/62999302, 73182719/200515778, 20053837/72775587, 70325974/50617151, 72672481/359982590}; In[2]:= b = {26714619/25510582, 26714619/12755291, 245850922/78256779, 122925461/26085593, 491701844/78256779}; In[3]:= integrand = Product[(1 - z/E^(I*b[[n]]))^(a[[n]] - 1), {n, Length[a]}]; In[4]:= (* I try integrating between the first and second singularity *) NIntegrate[integrand, {z, E^(I*b[[1]]), E^(I*b[[2]])}] Out[4]= -2.28889+1.16263 [ImaginaryI] In[5]:= (* This works so I am pleased. I move on to a second integral *) NIntegrate[integrand, {z, E^(I*b[[1]]), E^(I*b[[3]])}] !(Power::infy ((:)( )) Infinite expression !(1/(((([LeftSkeleton] 28 [RightSkeleton])) + (((([LeftSkeleton] 29 [RightSkeleton])) [ImaginaryI]))))^(52721750/72775587)) encountered.) !(NIntegrate::rnderr ((:)( )) Numerical approximation has caused !({ z}) to take the value !({((-1.`)) + ((7.817936619907544`*^-17 [ImaginaryI]))}) where the integrand is singular.) Out[5]= !(NIntegrate[integrand, {z, [ExponentialE]^([ImaginaryI] b?1?), [ExponentialE]^([ImaginaryI] b?3?)}]) In[6]:= (* This does not work. So I try making the integrand a numerical value *) NIntegrate[N[integrand], {z, E^(I*b[[1]]), E^(I*b[[3]])}] !(Power::infy ((:)( )) Infinite expression !(1/(((([LeftSkeleton] 28 [RightSkeleton])) + (((([LeftSkeleton] 29 [RightSkeleton])) [ImaginaryI]))))^(52721750/72775587)) encountered.) !(NIntegrate::rnderr ((:)( )) Numerical approximation has caused !({ z}) to take the value !({((-1.`)) + ((7.817936619907544`*^-17 [ImaginaryI]))}) where the integrand is singular.) Out[6]= !(NIntegrate[N[integrand], { z, [ExponentialE]^([ImaginaryI] b?1?), [ExponentialE]^([ImaginaryI] b?3?)}]) In[7]:= (* This does not work. So I try making the end points numerical *) NIntegrate[integrand, {z, N[E^(I*b[[1]])], N[E^(I*b[[3]])]}] !(NIntegrate::ncvb ((:)( )) NIntegrate failed to converge to prescribed accuracy after !(7) recursive bisections in !(z) near !(z) = !(((-1.`)) + ((1.2250406712299894`*^-16 [ImaginaryI])) ).) Out[7]= -2.46651-2.71438 [ImaginaryI] In[8]:= (* This begins to show promise so I increase the number of bisections *) NIntegrate[integrand, {z, N[E^(I*b[[1]])], N[E^(I*b[[3]])]},MaxRecursion -> 10 ] Out[8]= -2.46651-2.71438 [ImaginaryI] In[9]:= (* This works, I am pleased, so now I go back to my first example and check out my method *) NIntegrate[integrand, {z, N[E^(I*b[[1]])], N[E^(I*b[[2]])]},MaxRecursion -> 10] !(Power::infy ((:)( )) Infinite expression !(1/((((0.` [InvisibleSpace])) + ((0.` [ImaginaryI]))))^(14601839/62999302)) encountered.) NIntegrate::rnderr: Numerical approximation has caused {z} to take the value {0.5[InvisibleSpace]+0.866025 [ImaginaryI]} where the integrand is singular. Out[9]= !(NIntegrate[integrand, {z, N[[ExponentialE]^([ImaginaryI] b?1?)], N[[ExponentialE]^( [ImaginaryI] b?2?)]}, MaxRecursion [Rule] 10]) In[10]:= (* This fails. It worked without the refinements and now it fails with refinements. I attempt a third integral *) NIntegrate[integrand, {z, N[E^(I*b[[1]])], N[E^(I*b[[ 5]])]},MaxRecursion -> 10] NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration being 0, oscillatory integrand, or insufficient WorkingPrecision. If your integrand is oscillatory try using the option Method->Oscillatory in NIntegrate. Out[10]= 1.08293[InvisibleSpace]-2.77243 [ImaginaryI] (* This may have worked but I have a new problem. I am clearly just tinkering around and need help. *) How do you do a numerical integration with singularities at the end ponts? Hugh Goyder -- This message has been scanned for viruses and dangerous content by the Cranfield MailScanner, and is believed to be clean. ==== i want to build a package about computer aided Geometirc design for me! ____________________________________ ...... Begin[`Private`] Bernstein[i_, n_, v_] := Binomial[n, i]*(1 - v)^(n - i)*v^i BezierCurve[pts : {{_, _} ..} | {{_, _, _} ..}, v_] := Module[{n = Length[pts] - 1}, Simplify[ Table[Bernstein[i, n, v], {i, 0, n}].pts] ]; BernsteinPolynomial[fx_, x_,n_] :=Module[{},Sum[Replace[fx, x ->i/n]*Bernstein[i, n, t], {i, 0, n}]]; End[] EndPackage[] ___________________________________ i want use BernsteinPolynomial to compute the Bernstein Polynomial of the function fx (f(x)),but when i use it in mathematica,there are something wrong: In[28]:= !(BernsteinPolynomial[x^2 + x, x, 8]) Out[28]= !(((1 - CAGD`Private`t))^8 ((x + x^2)) + 8 ((1 - CAGD`Private`t)) ^7 CAGD`Private`t ((x + x^2)) + 28 ((1 - CAGD`Private`t))^6 CAGD`Private`t^2 ((x + x^2)) + 56 ((1 - CAGD`Private`t))^5 CAGD`Private`t^3 ((x + x^2)) + 70 ((1 - CAGD`Private`t))^4 CAGD`Private`t^4 ((x + x^2)) + 56 ((1 - CAGD`Private`t))^3 CAGD`Private`t^5 ((x + x^2)) + 28 ((1 - CAGD`Private`t))^2 CAGD`Private`t^6 ((x + x^2)) + 8 ((1 - CAGD`Private`t)) CAGD`Private`t^7 ((x + x^2)) + CAGD`Private`t^8 ((x + x^2))) Why? how to correct it?? thank you? Andy 2004.1.5 ==== Many people already commented on Maxim Retin's strange example: subs = x->x^2 Plot[ x /. subs, {x, 0,1}, Compiled->...] produces different plots depending on the value used in the option Compiled. I think that the value of an example like this one is that it may help a user of Mathematica in getting a better understanding of the way Mathematica works. Nobody, not even Maxim himself, will ever try to make a plot of x^2 in this way. Here are some observations that I made about this example. In a command like Plot[f[x], {x, 0, 1}] the symbol x is a local variable. The way Mathematica deals with these local variables depends on the command in which it is used. I will shortly discuss three examples: Table, NIntegrate and Plot.. The output of the following command y:=x; Table[Information[x];Print[y]; x, {x, 1, 3}] shows that in the function Table in each step a value is assigned to the local variable x; no immediate substitution in the first argument takes place. The function NIntegrate behaves differently: y:=x; NIntegrate[Information[x];Print[y]; x, {x, 0,1}, Compiled[Rule]True] Both with Compiled->True and Compiled->False, no matter how many steps are used in the integration procedure, the first argument is called only once and no value has been assigned to the local variable x. (Mathematica 4 behaves differently). Using Trace in the next command, we see how Mathematica proceeds. It evaluates the first argument symbolically, taking into account global variables that may occur in the first argument, and uses the outcome in the numerical integration. This is Maxim's example: subs = x -> x^2; NIntegrate[ x /. subs, {x, 0, 1}, Compiled -> True] Compiled->False yields the same result. Now we turn to Plot: y:=x; Plot[Information[x];Print[y]; x, {x, 0,1}, PlotPoints->3, Compiled->True] With the option Compiled->True, the values for the local variable are substituted into the (compiled) first argument of Plot, no assignment to the local variable takes place. y:=x; Plot[Information[x];Print[y]; x, {x, 0,1}, PlotPoints->3, Compiled->False] Hence with Compiled->False, the values are assigned to the local variable and no immediate substitution into the (uncompiled) first argument occurs. Now the behaviour of Maxim's example(s) is easy to predict: subs=x[Rule]x^2; Plot[x/.subs, {x, 0, 1}, Compiled[Rule]True] The values of x are substituted (no assignment to x) into the (compiled) first argument. That (compiled) argument contains an unevaluated variable subs. Hence evaluation of subs results in x->x^2 and the plot is a straight line. subs=x[Rule]x^2; Plot[x/.subs, {x, 0, 1}, Compiled[Rule]False] In this situation, values are assigned to the local variable x and therefore evaluation of the first argument results in x^2 for any of these values. The plot is a parabola. subs=x[Rule]x^2; f[x_]:= x /. subs; Table[f[x], {x, 1, 5}] Table[f[t], {t, 1, 5}] In the last command, assignments are done to the local variable t and therefore subs remains symbolically. My final remark is that the first argument in Maxim's example can be compiled and that the result is a compiled function in which a global variable subs occurs. The above observations and conclusions remain valid also for a compiled first argument. I cannot find any reason why Mathematica would not compile the first argument when Compiled->True. But I cannot show that Mathematica indeed did compile. Fred Simons Eindhoven University of Technology ==== This seems correct and, I think, agrees with the observations I made in my last message on this topic. However, you do not refer to one point I made, which I think is somewhat intriguing. Compare the following two (long) outputs: Trace[Module[{subs = x -> x^2}, Plot[x /. subs, { x, 0, 1}, Compiled -> True]], TraceInternal -> True] // InputForm and Trace[Module[{subs = x -> x^(1/3)}, Plot[ x^3 /. subs, {x, 0, 1}, Compiled -> True]], TraceInternal -> True] // InputForm (InputForm is useful here). In the second example you will see the appearance of terms like: CompiledFunction[{_Real}, {{3, 0, 0}, {3, 0, 3}}, {0, 0, 4, 0, 0}, {{1, 5}, {29, 0, 0, 1}, {29, 0, 1, 2}, {21, Function[{x}, subs$20], 3, 0, 0, 3, 0, 1}, {22, ReplaceAll, 3, 0, 2, 3, 0, 1, 3, 0, 3}, {2}}, Function[{x}, x^3 /. subs$20], Evaluate][ 4.166666666666666*^-8] Note that this is a a badly compiled CompiledFunction (the thing to look is the fourth term which in a properly compiled CompiledFunction should contain only contains sublists of integers (and sometimes floating point numbers and Boolean variables). The remark you make at the end of your posting seems to apply to this case, if you consider this sort of thing as a compiled function (it is at best a badly compiled one). In the output of Maxim's example CompiledFunction does not appear, so it looks lie no compilation at all took place (?) Andrzej Kozlowski > Many people already commented on Maxim Retin's strange example: subs = x->x^2 > Plot[ x /. subs, {x, 0,1}, Compiled->...] produces different plots depending on the value used in the option > Compiled. I think that the value of an example like this one is that it may help > a > user of Mathematica in getting a better understanding of the way > Mathematica > works. Nobody, not even Maxim himself, will ever try to make a plot of > x^2 > in this way. Here are some observations that I made about this example. In a command like Plot[f[x], {x, 0, 1}] the symbol x is a local > variable. > The way Mathematica deals with these local variables depends on the > command > in which it is used. I will shortly discuss three examples: Table, > NIntegrate and Plot.. The output of the following command y:=x; > Table[Information[x];Print[y]; x, {x, 1, 3}] shows that in the function Table in each step a value is assigned to > the > local variable x; no immediate substitution in the first argument takes > place. The function NIntegrate behaves differently: y:=x; > NIntegrate[Information[x];Print[y]; x, {x, 0,1}, Compiled[Rule]True] Both with Compiled->True and Compiled->False, no matter how many steps > are > used in the integration procedure, the first argument is called only > once > and no value has been assigned to the local variable x. (Mathematica 4 > behaves differently). Using Trace in the next command, we see how > Mathematica proceeds. It evaluates the first argument symbolically, > taking > into account global variables that may occur in the first argument, > and uses > the outcome in the numerical integration. This is Maxim's example: subs = x -> x^2; > NIntegrate[ x /. subs, {x, 0, 1}, Compiled -> True] Compiled->False yields the same result. Now we turn to Plot: y:=x; > Plot[Information[x];Print[y]; x, {x, 0,1}, PlotPoints->3, > Compiled->True] With the option Compiled->True, the values for the local variable are > substituted into the (compiled) first argument of Plot, no assignment > to the > local variable takes place. y:=x; > Plot[Information[x];Print[y]; x, {x, 0,1}, PlotPoints->3, > Compiled->False] Hence with Compiled->False, the values are assigned to the local > variable > and no immediate substitution into the (uncompiled) first argument > occurs. Now the behaviour of Maxim's example(s) is easy to predict: subs=x[Rule]x^2; > Plot[x/.subs, {x, 0, 1}, Compiled[Rule]True] The values of x are substituted (no assignment to x) into the > (compiled) > first argument. That (compiled) argument contains an unevaluated > variable > subs. Hence evaluation of subs results in x->x^2 and the plot is a > straight > line. subs=x[Rule]x^2; > Plot[x/.subs, {x, 0, 1}, Compiled[Rule]False] In this situation, values are assigned to the local variable x and > therefore > evaluation of the first argument results in x^2 for any of these > values. The > plot is a parabola. subs=x[Rule]x^2; > f[x_]:= x /. subs; > Table[f[x], {x, 1, 5}] > Table[f[t], {t, 1, 5}] In the last command, assignments are done to the local variable t and > therefore subs remains symbolically. My final remark is that the first argument in Maxim's example can be > compiled and that the result is a compiled function in which a global > variable subs occurs. The above observations and conclusions remain > valid > also for a compiled first argument. I cannot find any reason why > Mathematica > would not compile the first argument when Compiled->True. But I cannot > show > that Mathematica indeed did compile. Fred Simons > Eindhoven University of Technology ==== As a pretense, I'm a programmer trying to understand practicle use of the Fibonacci search. What I am trying to understand is how exactly to use the following equation for intializing the Fibonacci search. Let x=a+(1-g_n)(b-a) and y=a+g_N(b-a) Evaluate f(x) and f(y) and set n=N Here's my delima, I don't understand where those variables come from or how to assign them. I appoligize for my ignorance with this situation but I'm trying to learn more. ==== David, As I understand it, when you save as EPS or other formats, some other programs are called to save the file. As is the creation of postscript for display in the frontend. The rendering in the FrontEnd is done (I guess, someone correct me if I'm wrong), by using these programs and the system stdout. In the case of exported files,EPS just happens to be a convenient format to work with when using Adobe Illustrator. In a nutshell, a graphic is made from a Mathematica defintion of points and lines which then gets converted to PS by some translation program for display to the screen or other device like a printer. After having understood the difference between Graphics primitives and directives, I can make basic 2D plots that are of acceptable publication quality from Mathematica directly. Alternately you can save the data and import it into graphing programs like SigmaPlot, ProFit etc which have the convenience of press-button features. But, if you have Mathematica and gain some proficiency in it, you don't need these relatively expensive programs. I also use your DrawGraphics package sometimes to save myself a headache. I have used DrawGraphics to make 3D vector diagrams and have managed to do most of the basic layout using Mathematica. Beyond this, I have always used Illustrator to clean up the graphic. If you Ungroup the graphic in Illustrator you will see many, many objects and you can zoom in, zoom out and clean up the graphic as you please. Usually, items that need cleaning up are lines which may have been rendered behind (before) a solid filled object (e.g a Polygon). Some of my other 3D graphics are built up from very large data sets and I have used Jens-Peers MathGL3D package to visualise these data sets. They can also be imported into Illustrator, but without sufficient memory and speed, they are cumbersome graphics to work with. convenience mainly). On a Mac running MacOS 10.3, Wolfram does not provide the programs athena or motif to render the graphics and have it displayed. In this instance, I used The GIMP (http://gimp.org) to visualise the graphic in preference to the program ghostscript by creating a temporary eps file that could be read by the GIMP. But I am just learning the basics of GIMP and so cannot give a full account of how it compares with commercial programs. Certainly looks good for artistic work and may not be all that science oriented. I have found Illustrator to be extremely useful in cleaning up Mathematica written EPS files. Another program is CorelDraw, but I jumped off that band wagon a long time ago. In so far as the Graphics Gallery on the WRI website is concerned, I don't think there has been an auxilliary program that the graphics have been run through apart from what they deliver already. It may be that there are some differences between the binaries delivered for different platforms and there could be any number of issues behind why Wolfram deliver what they have delivered. For myself, at least, I have found a good degree of graphics cards of various quality. Yas > Yas, I have often wondered about programs that would take Mathematica plot output > and allow improvements to be made on the plots. What programs are available, > what will they do for you and roughly how much do they cost? How well do > they work with 3D graphics? Are they worth it? One of the things I don't like about Mathematica 3D graphics is the poor > rendering. There are often extra lines and spots that shouldn't appear in > the graphics. Do programs like Illustrator solve these problems? When I look > at some of the sample 3D plots on the WRI web site, they look as if they had > been run through an auxiliary program. David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ > I usually Ungroup the entire graphic and you can use Shift+ObjectSelect > in Illustrator to select common graphics objects within the main graphic. > Alternately, you can use Prolog and Epilog to render graphics in order, in > Mathematica, which should convert to EPS accordinly. But I have only tried > this once or twice and I think I came to the conclusion that it was more a > hassle than anything. Yas > use Adobe Illustrator to edit the EPS files. Here's my problem: I > plot y = x^2 and open the EPS file in Illustrator, but when I click on > the curve, Illustrator only highlights (selects) a piece of the > parabola (and not the entire parabola). Sometimes it even selects a > piece of the curve and a piece of an axis, but I cannot select just > the curve, or just an axis. I've posted a similar question on the > Adobe Forums, but with little success. > > Any suggestions? I appreciate any help that's out there. > > R > > ==== I am trying to use NMaximize on a non-linear iterative function that conceptually looks like this: (*---------* ) variables = {x1, x2, <<96>>, x99, x100}; in1[[1]] = initial value; in2[[1]] = some other initial value; out[ previousIn_, variable_] := a nonlinear function f[100Variables_] := ( Do[ in1[[i+1]] = out[in1[[i]], 100variables[[i]] ]; in2[[i+1]] = out[in2[[i]], 100variables[[i]] ], {i, 1, Length[100variables]}; ]; Last[in1-in2] ); (*Then try and optimise for the last element produced by f*) NMaximize[{f[variables], simple constraints}, variables] (*---------* ) Mathematica tries to compute this, but it gets progressively slower and slower, so far it hasn't finished one Do loop given 12 hrs to run. If I abort the program and look at what it has already been produced, I see that Mathematica retains the whole nested function in an unevaluated form (i.e. expressed in terms of the variables), which very quickly becomes too large for my computer to handle. If I try to evaluate f[] using actual numbers, it generates an answer very quickly (approx. 0.3 secs). It looks as though I need some way for NMaximize to actually pass and immediately evaluate trial solutions, rather than trying to expand the entire expression before passing trial values (at least I think that's what's happening). The same thing happens using FindMaximum. Any suggestions as to how I can make this work? ==== replaced 1 with small L (l). The 2 buttons are 7 miles away in the keyboard so i'm wondering how? ==== > Can anyone point me to some sample code to model a > queue? a web search pulled this up: http://poisson.ecse.rpi.edu/~hema/qnat/ i had to fiddle around the site in non-obvious ways to actually get the package..... have tried it out yet, so i dunno how comprehensive it is... also from the web search, this seemed like a good page, with some links @ bottom: http://home.iitk.ac.in/~skb/qbook/qbook.html hth, cdj ==== the MS-DOS FrontEnd ?? Mathematica 1.x run with MS-DOS and was a Since version 2.2 for Windows Mathematica support MathLink and the kernel can call a console application. The FontEnd is desinged to communicate with a Mathematica kernel and your application must act like a kernel if the FontEnd should call it. Jens > I use Mathematica 5.0 on MS-Windows 2000. Is there any way to call > MS-DOS applications from either the MS-Windows Notebook Front End, or > from the MS-DOS Front End? I can find no documentation on this topic. Harold ==== I'm trying to make a simple function using subscripts and greek symbols instead of typing the English equivalent. Here is one function using Greek symbols and subscripts. It doesn't work. I've also pasted the corresponding cell expression below. !((x_2[(?_1) _] := 2 ?_1;)) Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ SubscriptBox[x, 2], [, RowBox[{ SubscriptBox[[Theta], 1], _}], ]}], :=, RowBox[{2, , SubscriptBox[[Theta], 1]}]}], ;}]], Input] Here is a similar function that works. It avoids using the symbols and subscripts. x3[theta1_] := 3 theta1; Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{x3, [, theta1_, ]}], :=, RowBox[{3, , theta1}]}], ;}]], Input] ==== David, I've used Macromedia Freehand for years, but I'm planning to switch to Adobe Illustrator. (You can find full information and download a 30-day trial version at www.adobe.com.) An application of that type is really indispensable in a number of ways. You can easily touch up Mathematica-generated graphics to get effects that would take a great deal of effort to get in Mathematica, if possible at all. (Anti-aliasing and color adjustments come to mind.) Moreover, technical drawings are quite easy to produce once you get used to things. ----- Selwyn Hollis http://www.math.armstrong.edu/faculty/hollis (edit reply-to to reply) > Yas, I have often wondered about programs that would take Mathematica plot > output > and allow improvements to be made on the plots. What programs are > available, > what will they do for you and roughly how much do they cost? How well > do > they work with 3D graphics? Are they worth it? One of the things I don't like about Mathematica 3D graphics is the > poor > rendering. There are often extra lines and spots that shouldn't appear > in > the graphics. Do programs like Illustrator solve these problems? When > I look > at some of the sample 3D plots on the WRI web site, they look as if > they had > been run through an auxiliary program. David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ To: mathgroup@smc.vnet.net I usually Ungroup the entire graphic and you can use > Shift+ObjectSelect > in Illustrator to select common graphics objects within the main > graphic. > Alternately, you can use Prolog and Epilog to render graphics in > order, in > Mathematica, which should convert to EPS accordinly. But I have only > tried > this once or twice and I think I came to the conclusion that it was > more a > hassle than anything. Yas >> use Adobe Illustrator to edit the EPS files. Here's my problem: I >> plot y = x^2 and open the EPS file in Illustrator, but when I click on >> the curve, Illustrator only highlights (selects) a piece of the >> parabola (and not the entire parabola). Sometimes it even selects a >> piece of the curve and a piece of an axis, but I cannot select just >> the curve, or just an axis. I've posted a similar question on the >> Adobe Forums, but with little success. >> Any suggestions? I appreciate any help that's out there. >> R > ==== A reboot in the secure modus or a utility like TweakUI may do this. Jens I have a problem with Mathematica 5 and Windows ME. After running for a > while the fonts in the notebooks displayed on screen become garbled. A while > later various other screen fonts (e.g. icon labels, etc) become garbled. > This problem does NOT occur with Mathematica 4.2.1. I have tried various > settings for the display (i.e. screen resolutions and colour depths) but > nothing seems to help. Has anyone else had this problem? Even better, has anyone got any > suggestions how to work around it. I would rather not go through the hassle > of upgrading to Windows XP. -- > Steve Luttrell > West Malvern, UK ==== Should Mathematica remember ALL open palettes from one session to the next? Or does it remember only those in the primary path? I'm asking because one of my palettes that resides in an Addons/Applications/ ... /FrontEnd/Palettes directory has stopped appearing when I start up Mathematica. Please don't tell me I need to do the cache-clearing startup thing, because last time I did that, it took me hours to get everything back to normal. ----- Selwyn Hollis http://www.math.armstrong.edu/faculty/hollis (edit reply-to to reply) ==== We are proud to announce that our new Combinatorica book: Computational Discrete Mathematics: Combinatorics and Graph Theory with Mathematica by S. Pemmaraju and S. Skiena, and published by Cambridge University Press, is *finally* available from Amazon at: http://www.amazon.com/exec/obidos/ASIN/0521806860/ref=nosim/thealgorithrepo A blurb for the book is given below, but we encourage you to visit http://www.combinatorica.com to learn more about the book and the wealth of resources for the new and greatly improved Combinatorica. --------- Computational Discrete Mathematics is the definitive guide to Combinatorica, perhaps the most widely used software for teaching and research in discrete mathematics. The Combinatorica user community ranges from students to engineers to researchers in mathematics, computer science, physics, economics, and the humanities. Combinatorica has received the grade school to graduate levels. Combinatorica is included with every copy of the popular computer algebra system Mathematica. Experimenting with Combinatorica provides an exciting new way to learn combinatorics and graph theory. This book provides examples of all 450 Combinatiorica functions in action, along with the associated mathematical and algorithmic theory. The book contains no formal proofs, but enough discussion to understand and appreciate all the algorithms and theorems contained within. We cover classical and advanced topics on the most important combinatorial objects: permutations, subsets, partitions, and Young tableaux. We also cover all important areas of graph theory: graph construction operations, invariants, and embeddings as well as algorithmic graph theory. This book can also serve as a unique textbook with enough material to teach or supplement full-semester, experimentally-enhanced courses in combinatorics and graph theory using Mathematica. Three interesting classes of exercises are provided -- theorem/proof, programming exercises, and experimental explorations, providing great flexibility in teaching and learning the material. ==== > Re Mathematica 5.0 running under WinXP Home. > Am using... > z = Regress[...RegressionReport->CovarianceMatrix]; > X = CovarianceMatrix /. z; ....to extract the given matrix. > However, when I use X[[k,k]] to access the k'th diagonal element, I get > a row instead! The culprit is that MatrixForm is the X-head (as > FullForm reveals). > How can I strip away this head and make X a list of lists? The key is to keep in mind all expressions in Mathematica can be treated as lists. So, to strip the head MatrixForm you could do X = First@CovarianceMatrix/.z; Alternatively, you could access the desired element without stripping the head MatrixForm using: X[[1,k,k]] -- ==== I can't WAIT to hear somebody explain why this is acceptable behavior!!! Bobby > Compare In[1]:= > Do[ f[k] = k, {k, 1., 17.} ] > f[1.`20] > Clear[f] Out[2]= > 1. and In[1]:= > Do[ f[k] = k, {k, 1., 18.} ] > f[1.`20] > Clear[f] Out[2]= > f[1.0000000000000000000] -- and the user's best bet to figure out how it'll work is probably to > flip a coin. The reason is probably just that the hashing mechanism breaks down, > because the result returned by Mathematica changes after it re-sorts > some internal table of DownValues for f (the 'boundary value' 17 is for > version 5.0 on my machine; if 17. and 18. don't work, try 2. and 100.). > But in general, my opinion is that it is only to be expected -- when we > don't even know for sure how the definitions for f can be reordered. Maxim Rytin ==== This is related to an ongoing thread on computing Transpose (and other functions) of MatrixForm objects. There should be a better answer, but here's one in the meantime: data = Array[{# + Random[], # - Random[]} &, {100}]; z = Regress[data, {1, x, x^2}, x, RegressionReport -> CovarianceMatrix] X = CovarianceMatrix /. (z /. MatrixForm -> Identity) X[[2, 2]] It's strange that THIS doesn't work: X = CovarianceMatrix /. z /. MatrixForm -> Identity Bobby > Re Mathematica 5.0 running under WinXP Home. Am using... z = Regress[...RegressionReport->CovarianceMatrix]; > X = CovarianceMatrix /. z; ...to extract the given matrix. However, when I use X[[k,k]] to access the k'th diagonal element, I get > a row instead! The culprit is that MatrixForm is the X-head (as > FullForm reveals). How can I strip away this head and make X a list of lists? > ==== : Here is an example which uses Extract to behead a MatrixForm. tb = Table[0, {i, 1, 10}, {j, 1, 10}] // MatrixForm; Extract[tb, {1}] It returns the List{List{ ...}...} structure from the MatrixForm{List{List{...}...}...} structure. Harold ==== This is related to an ongoing thread on computing Transpose (and other functions) of MatrixForm objects. There should be a better answer, but here's one in the meantime: data = Array[{# + Random[], # - Random[]} &, {100}]; z = Regress[data, {1, x, x^2}, x, RegressionReport -> CovarianceMatrix] X = CovarianceMatrix /. (z /. MatrixForm -> Identity) X[[2, 2]] This also works, but NOT when Ted Ersek's suggested fix for MatrixForm is installed: X = CovarianceMatrix /. z /. MatrixForm -> Identity Bobby > Re Mathematica 5.0 running under WinXP Home. Am using... z = Regress[...RegressionReport->CovarianceMatrix]; > X = CovarianceMatrix /. z; ...to extract the given matrix. However, when I use X[[k,k]] to access > the k'th diagonal element, I get a row instead! The culprit is that > MatrixForm is the X-head (as FullForm reveals). How can I strip away this head and make X a list of lists? > ==== Great work! But.... MatrixForm@m (when m is already MatrixForm) is an infinite loop. After some laborious sleuthing, I found that adding MatrixQ to the HeadTest list fixes that: Unprotect[MatrixForm]; HeadTest[func_] := Intersection[{func}, { If, List, Set, SetDelayed, UpSet, UpSetDelayed, TagSet, TagSetDelayed, Format, MakeBoxes, MakeExpression, ToBoxes, Shallow, Short, Hold, HoldForm, HoldComplete, HoldPattern, Verbatim, Blank, BlankSequence, BlankNullSequence, Alternatives, Pattern, Optional, Repeated, RepeatedNull, Condition, PatternTest, Rule, RuleDelayed, FullForm, InputForm, MatrixQ}] === {} MatrixForm /: (f_?HeadTest)[a1___, a2_MatrixForm, a3___] := Module[{ result}, result = Replace[{a1, a2, a3}, MatrixForm -> Identity, 2, Heads -> True]; result = f @@ result; If[MatrixQ@result, MatrixForm[result], result]] Protect[MatrixForm]; BUT... now MatrixQ@m isn't True, and that's not good, is it? Bobby On Mon, 5 Jan 2004 15:29:45 -0500, Ersek, Ted CIV NASPATUXENTRIVERMD > Recall the recent thread on how do ensure we can do math on matrices > wrapped in MatrixForm. > Apparently other solutions didn't quite do the trick. I think the code > below is better. > (*----------*) Unprotect[MatrixForm]; HeadTest[func_]:= Intersection[{func}, > {If,List,Set,SetDelayed,UpSet,UpSetDelayed,TagSet,TagSetDelayed,Format, > MakeBoxes,MakeExpression,ToBoxes,Shallow,Short,Hold,HoldForm,HoldComplete, > HoldPattern,Verbatim,Blank,BlankSequence,BlankNullSequence,Alternatives, > Pattern,Optional,Repeated,RepeatedNull,Condition,PatternTest,Rule, > RuleDelayed,FullForm,InputForm > }]==={} > MatrixForm/:(f_?HeadTest)[a1___, a2_MatrixForm, a3___]:= > Module[{result}, > result = Replace[ {a1,a2,a3}, MatrixForm->Identity, 2, Heads->True ]; > result = f@@result; > If[ MatrixQ@result, MatrixForm[result], result ] > ] > (*---------*) > Now we can do the following and get the output in MatrixForm. > m1=MatrixForm[{{2,3,4},{1,5,2},{6,3,1}}] Inverse[m1] MatrixPower[m1,4] m2={{2,0,4},{0,5,2},{0,3,1}}; > m1.m1.m1.m2 Det[m1] Part[m1,1,3] Ted Ersek http://www.verbeia.com/mathematica/tips/Tricks.html > ==== Recall the recent thread on how do ensure we can do math on matrices wrapped in MatrixForm. Apparently other solutions didn't quite do the trick. I think the code below is better. (*----------*) Unprotect[MatrixForm]; HeadTest[func_]:= Intersection[{func}, = {If,List,Set,SetDelayed,UpSet,UpSetDelayed,TagSet,TagSetDelayed,Format, = MakeBoxes,MakeExpression,ToBoxes,Shallow,Short,Hold,HoldForm,HoldComplete= , = HoldPattern,Verbatim,Blank,BlankSequence,BlankNullSequence,Alternatives, Pattern,Optional,Repeated,RepeatedNull,Condition,PatternTest,Rule, RuleDelayed,FullForm,InputForm }]==={} MatrixForm/:(f_?HeadTest)[a1___, a2_MatrixForm, a3___]:= Module[{result}, result = Replace[ {a1,a2,a3}, MatrixForm->Identity, 2, Heads->True ]; result = f@@result; If[ MatrixQ@result, MatrixForm[result], result ] ] (*---------*) Now we can do the following and get the output in MatrixForm. m1=MatrixForm[{{2,3,4},{1,5,2},{6,3,1}}] Inverse[m1] MatrixPower[m1,4] m2={{2,0,4},{0,5,2},{0,3,1}}; m1.m1.m1.m2 Det[m1] Part[m1,1,3] Ted Ersek http://www.verbeia.com/mathematica/tips/Tricks.html ==== Here's one way, X = FlattenAt[CovarianceMatrix/.z)/.MatrixForm->List,1] Yas Re Mathematica 5.0 running under WinXP Home. Am using... z = Regress[...RegressionReport->CovarianceMatrix]; > X = CovarianceMatrix /. z; ...to extract the given matrix. However, when I use X[[k,k]] to access the k'th diagonal element, I get > a row instead! The culprit is that MatrixForm is the X-head (as > FullForm reveals). How can I strip away this head and make X a list of lists?