A105 === Subject: Request for Collective Wisdom... (*Below is a request for suggestions for hints for beginners. The preface is a bit long-winded *) I am working on an applied math for physical scientists undergraduate text---I am using Mathematica as the engine to learn and solve problems quickly. I have an appendix that I have been creating (empirically) for a couple years: Common Mathematica Beginners' Errors. This wasn't difficult. I am now considering how to write another Appendix: Mathematica Usage Paradigms for Beginners. This one is not as straightforward because it will be a list of short sequences of Mathematica code. The size of the list should be a compromise between length, completeness, and orthogonality. Some topics are obvious to (subjective) me: work symbolically and with exact representations; scale to remove units when possible; visualize often and when in doubt evaluate as a number; pure functions are power; avoid the outdoors unless you have applied the documentation, lists are your friends... Nota bene, this is a book for undergraduates who have just received the physics, chemistry, and multivariable calculus catechism, and (typically) don't appreciate that there are common themes in their education (think back...). (* Punchline: *) I would sincerely appreciate thoughtful (bullet-type) suggestions for paradigms. (off-line or on- as you please). PS: Implicit in this is what a dear friend called The Homotopy Conjecture. Give me a small working example, and it can deformed into a complicated one for my own purposes. PPS: I expect a small fraction of snarky answers---I won't respond. -- W. Craig Carter === Subject: Re: Manipulate in HelpBrowser: Bug There are bugs in the older Help Browser such that dynamic displays often don't work. (There were worst problems in Version 5.2 with some animations that were generated by package code.) In Version 6 the result is that Manipulate and Animate expressions sometimes (but not always) just don't operate, i.e., the controls don't work. There are two fixes. One is to copy the output cell from the Help Browser window into a regular Mathematica notebook. Without any further evaluation it should then work properly. A second fix is to append CreateDialog@ to the Manipulate or Animate statement and evaluate. This brings it up in an outside window and again it will work properly. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > > I wanted to use the Manipulate command in some of my old help files, > i.e. HelpBrowser and not DocumentationCenter. > Thereby I noticed the following weird behavior: > > Open the HB with > FrontEndTokenExecute[HelpDialog]. > > Evaluate > Manipulate[Plot[Sin[k x], {x, 0, 1}], {k, 1, 2}]. > > It won't behave properly when moving the slider. Now strange is that > 1.) Animate works > 2.) Copying the output cell and pasting it again works. > > I used M6 in Windows, on Mac and Linux everything worked as expected. > > Can anyone explain this behavior or (even better) knows a (simple) > workaround. My best idea would be to use Animate instead. > > > Markus Huber > === Subject: Question on the Limiting Value of Ratios of Consecuative Primes... Is there some analytic limit to the ratio of consecuative primes? The expression Limit[Prime[i]/Prime[i+1],{i,->Infinity}] returns unevaluated. Plotting Table[ Prime[i]/Prime[i+1],{i,1,20000}] shows a lot of structure with a minimum of 3/5. -- Richard Palmer === Subject: Re: orthonormal eigenvectors] First, since m is not hermitian, its eigenvectors are not necessarily orthogonal with each other. In[17]:= res = Eigenvectors[m] Out[17]= {{0, 0, 1}, {(-I)*Sqrt[2], 1, 0}, {I/Sqrt[2], 1, 0}} Relatively to the usual euclidean scalar product, we can see that these vectors are not orthogonal : In[55]:= Outer[Dot, res, res, 1] // N Out[55]= {{1., 0., 0.}, {0., -1., 2.}, {0., 2., 0.5}} but notice that Dot is not an hermitian form for *complex vector spaces*! One should use instead a scalar product like : Scal[u_List, v_List] := Dot[u, Conjugate[v]] // ComplexExpand then we have orthogonality : In[58]:= Outer[Scal, res, res, 1] // N Out[58]= {{1., 0., 0.}, {0., 3., 0.}, {0., 0., 1.5}} Hope this helps... Claude -- ********************************* Claude Mant.8e UMR CNRS 6117 LMGEM http://www.com.univ-mrs.fr/LMGEM/ Centre d'Oc.8eanologie de Marseille Campus de Luminy, Case 901 13288 MARSEILLE Cedex 09 tel : (+33) 491 829 127 fax : (+33) 491 829 119 ********************************* === Subject: Calculations with Interpolating Functions Hi I obtain an Interpolating function as a solution of a differential equation with the command NDSolve, lets call it =93solution=94, which gives x(t). Next I want to use this solution for further calculations. With the commands =93result=Evaluate[x(t)/. First[solution]]=94 or =93result= x(t)/.solution, {t,0,tmax}=94 I do the plot x(t) without any problems. Now, with version 5.2 I manage to integrate x(t) or linear functions of it. But when I try to integrate non linear functions of x(t), like x(t)^2 or Sin[x(t)] (which is what I want), Mathematica is unable to give a numerical result, all I get is an integral saying that there is an InterpolatingFunction in the integrand. With Mathematica 6 the linear integration does not work either. Any help would be appreciated. Joao Paulo === Serdar -----Original Message----- === Subject: Re: Problem: is not a list of numbers with dimensions In both cases, use Exp rather than exp A = 1*10^(-4); k = 2/3; g = 1.12*10^(-11); Attenuation = 0.23026*0.475*10^(-3); L = 7200; Leff = (1 - Exp[-Attenuation*L])/Attenuation; FindRoot[x - A*Exp[k*g*x*Leff - Attenuation*L], {x, 0}] {x->0.0000454986} Bob Hanlon > When run the below code, > A=1*10^(-4); k=2/3; g=1.12*10^(-11); Attenuation= 0.23026*0.475*10^(-3); L=7200; Leff=(1-exp[-Attenuation*L])/Attenuation; FindRoot[x-A*exp[k*g*x*Leff-Attenuation*L],{x,0}] It executes the below solution, FindRoot::nlnum: The function value {0.-0.0001 exp[-0.787489+0. (1.+Times[<<2>>])]} is not a list of numbers with dimensions {1} at {x} = {0.}. I need your help about numerical and Alpha_numeric solution of this problem. > f(x)= x-A*exp[k*g*x*Leff-Attenuation*L Serdar === Subject: Re: LayeredGraphPlot without edge crossing. OK. I assume that Mathematica cannot plot a directed tree without edge crossing. I also assume that the position of elements within a layer (in the LayeredGraphPlot) depends on the original order of the displayed data. Is that true? If yes, what is the relation. If not, what defines the order of elements in the layer? === Subject: Re: Definite integral I'm not sure why Mathematica wouldn't do it, but the result of that unevaluated integral is (using 6.0.1.0 on Linux x86 -- 32-bit) Integrate[(3/2)*Sqrt[Sin[2*[Theta]]^2], {[Theta], 3*(Pi/2), t}, Assumptions -> Element[t, Reals] && 3*(Pi/2) < [Theta] < 2*Pi] -(3/(2*Sign[3*Pi - 2*t])) - (3/2)*Abs[Cos[t]]*Sin[t]*Tan[t] Hope that helps! C.O. > I don't understand Mathematica can't calculate the last definite > integral. For the first three integrals works fine, but for the last > one crush. You can see in this paper > >WysEERSilJsIeVif4THE-OC9pisLLDECe8l5BwmXXnNsFOempl8HAl8JkHsusoMR-tRlq_vv1lR g >eh&gsc=CGn5gQsAAABmIpg7U95zHJwjbRxzLtsD > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Definite integral On 5=D4=C25=C8=D5, =CF=C2=CE=E76=CA=B117=B7=D6, Miguel w= rote: > I don't understand Mathematica can't calculate the last definite > integral. For the first three integrals works fine, but for the last > one crush. You can see in this paper > > What I get is 3/2 + 1/2 (3 - 3 Abs[Cos[t]] Sin[t] Tan[t]) if your definition is s4[t_] = s2[Pi*3/2] + Integrate[...]. But I think it may be s4[t_] = s3[Pi*3/2] + Integrate[...], in this case the answer is 9/2+1/2 (3-3 Abs[Cos[t]] Sin[t] Tan[t]). U should add t > Pi*3/2 to the assumption. === Subject: Re: Definite integral > I don't understand Mathematica can't calculate the last definite > integral. For the first three integrals works fine, but for the last > one crush. You can see in this paper > This is because you typed [Epsilon] instead of [Element]. This works fine: Integrate[3/2 Sqrt[Sin[2 x]^2], {x, 3 Pi/2, t}, Assumptions -> 2 Pi > t > (3 Pi)/2] It is not necessary to separately specify that variables used in inequalities are reals. But if you do, use x [Element] Reals or Element[x, Reals], but *not* x [Epsilon] Reals. The two symbols have nothing to do with each other! So this is one more reason why the ugly lunate epsilon should not be used in mathematics ... I never understood why American/English textbooks were so fond of this symbol (never seen it in any Eastern European books). === Subject: Re: Problem/bug with ends of thick lines in graphics > Consider the following graph: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {AbsoluteThickness[20]}] > > When you plot it you will see that the line's ends are not > rectangular, whereas you would certainly want them to be so. =2E.. > Does anyone have any solutions to either or both of these issues? There are a couple of things you can do to alter the appearance of this graphic. In this specific case adding PlotPoints->3 to the Plot command is enough to do the trick. Another option is to manually remove a few (4-5) points from both the start and end of the Line primitive in the resulting graphic. This problem occurs when the points at the beginning/end of the line are so very close together that the OS graphics library gets a little confused about what angle to draw the line cap, and it's really only noticeable when the line is thick enough that the cap is clearly visible. -Rob === Subject: Re: Problem/bug with ends of thick lines in graphics Good try Jens! Alas it creates a series of points that create a jagged outer boundary where the disks of the points undulate. But an approach like this may work for the end points. I have communicated with the folks at WRI about this and the bug is known. --David On May 5, 6:18 am, Jens-Peer Kuska > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {AbsoluteThickness[20]}] /. > Line[pnts_] :> {AbsolutePointSize[20], Point[pnts]} > > may help in this case. But AFAIK Mathematica has no directive > to set the line ends. > > Jens > > In a quick search of things I haven't found a mention of the following > simple graphics issue and I'm checking in with the group to see if > there is a memory of its mention and if there is a simple fix (and > which is not a complicated hack) that I've not been able to come up > with. > > Consider the following graph: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {AbsoluteThickness[20]}] > > When you plot it you will see that the line's ends are not > rectangular, whereas you would certainly want them to be so. (An > alternative would be to have them be rounded, for example, but the > question will remain the same whatever your preference is.) Rather > they appear as polygonal in a way inconsistent with the line itself. > > One assums that this is an artifact of how the line is rendered based > on the individual line segments, and that that segmental rendering has > to do something with how a segment relates to the segments on either > side of it. The lack of a segment beyond the end segment presumably > runes the algorithm for rendering in a way that leads to this > appearance. > > I have two related questions here. The first is how, if at all > possible, to fix this in a general way through some specific options > settings for the graphics function. > > The second is how, when exporting this graphic as, say, a PDF, to make > it behave properly. > > There was a trick in pre version-6 Mathematica that would involve > adding an explicit postscript command to the PlotStyle option. Though= > this would not (I think) correct the screen appearance of the graphic, > it would properly fix it when the graphic was exported to PDF or EPS. > Here is an example of how it was done: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {{ PostScript[0 setlinecap],AbsoluteThickness[20]}}] > > This, however, no longer works in Mathematica 6+ presumably because of > the new way that graphics rendering is handled. > > Does anyone have any solutions to either or both of these issues? > > > --David === Subject: Re: Problem/bug with ends of thick lines in graphics > In a quick search of things I haven't found a mention of the following > simple graphics issue and I'm checking in with the group to see if > there is a memory of its mention and if there is a simple fix (and > which is not a complicated hack) that I've not been able to come up > with. > > Consider the following graph: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {AbsoluteThickness[20]}] > > When you plot it you will see that the line's ends are not > rectangular, whereas you would certainly want them to be so. (An > alternative would be to have them be rounded, for example, but the > question will remain the same whatever your preference is.) Rather > they appear as polygonal in a way inconsistent with the line itself. Obviously this is a bug. Unfortunately this bug is not fixed in version 6.02. And in version 5.2 this bug does not appear. Thus this is regression bug! Some graphical functionality was broken in version 6! === Subject: Solving on mathematica How would i go about solving this equaiton on mathematica (Xi -Ux)^2 + (Yi - Uy)^2 + (Zi - Uz) = (Ri - Cb) i = 1,2,3,4 where we need to find Ux, Uy, Uz, Cb tried a few things and they dont work. NSolve[ (Xi - U)^2 + (Yi - V)^2 + (Zi - W)^2 == (Ri - B)^2, {U, V, W, B}, { i = 1, 2, 3, 4} ] any ideas? === Subject: Re: Getting the size of the bounding box of a Graphics3D[] Hello David and Szabolcs, Yes it does appear to be a bug for the new primitives: PlotRange /. AbsoluteOptions[Graphics3D[Cylinder[]]] PlotRange /. AbsoluteOptions[Graphics3D[Cylinder[{{0, 0, 0}, {2, 1, 200}}, 1]]] Same incorrect bounding box.... > I think it's a bug for Sphere. > > It works for other things. > > plot1 = ParametricPlot3D[{Sin[u], Sin[u], Cos[u]} {Cos[v], Sin[v], > 1}, {u, 0, Pi}, {v, 0, 2 Pi}] > PlotRange /. AbsoluteOptions[plot1] > {{-1., 1.}, {-1., 1.}, {-1., 1.}} > > > > > > Is there a reliable way to get the coordinates and size of the bounding > > box of a Graphics3D object? > > PlotRange /. AbsoluteOptions[Graphics3D[Sphere[]]] > > > > but it gives {{0., 1.}, {0., 1.}, {0., 1.}}, whereas the correct answer > > should be {{-1., 1.}, {-1., 1.}, {-1., 1.}}. W. Craig Carter === Subject: Re: Wolfram Workbench user experiences Before Workbench existed, many times I used a very simple ASCII editor (Notepad for Windows) to create Mathematica packages. My personal reason for using an ASCII editor is that I like to have control on the exact code that is actually written, and I liked to have my code in a readable way, even if you do Not have Mathematica (if you used Mathematica 5.2 as your IDE, to write the packages, then .m file was not so easy to read, end-of-line characters were missing, weird characters would appear, etc. so that you actually needed the original .nb file from which the .m file was created, in order to be able to read -as a human- the package) That is my personal way of programming. Sometimes I do the same with HTML files, just use a simple ASCII editor, so I have all the control in the actual code. Now that I have Wolfram Workbench 1.0.0, I like it very much. For me, it is like a simple ASCII editor but it does know about Mathematica syntax, so I have syntax coloring, when I mouse-over a known Mathematica command, I get the message about the basic syntax of that command, etc. But at the same time, WHAT I WRITE IS WHAT I GET in the final .m file, which is something that I like very much. Furthermore, you also get syntax coloring when you print your program. That I love: many advantages without losing the control of the exact code that is written in the .m file of my packages. Therefore, for me, who used to program in simple ASCII editor (Notepad for Windows), the Workbench has been great. Of course I do a very basic use of all the possibilities of Workbench, so far I have Not written a package where different programming languages are used, neither have I used other advanced features of Workbench. I have written just plain Mathematica packages, like the one here: http://homepage.cem.itesm.mx/lgomez/quantum/index.htm Jose Mexico -----Mensaje original----- De: David Bailey [mailto:dave@Remove_Thisdbailey.co.uk] Enviado el: Viernes, 02 de Mayo de 2008 02:43 a.m. Para: mathgroup@smc.vnet.net Asunto: Wolfram Workbench user experiences I would be very interested in other people's experiences with the Wolfram Workbench. I must admit that I prefer to use the frontend as my 'IDE', and the workbench seemed fairly alien when I tried it. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: smart change of variables? I would like to change variables of a coupled system of ordinary differential equations F1(A,B,A',B',A'',B'',A''',A'''')=0 F2(A,B,A',B',A'',B'',A''',A'''')=0 A''',A'''' -third,fourth ord. deriv. of A. F1 and F2 are polynomials in their variables (first order in A'''',A''',B''; second order in A'',B',B; fourth order in A). We can substitute F2 by F3=F3(A,B,A',B',A'',B'') a second order polynomial. I am trying to find decoupling variables to the system. I expect that Groebner Basis of the polynomials can help in detecting such variables, however the derivatives make the problem a bit harder. Can anyone suggest a function or a package in Mathematica, which could help in determining good variables ? Artur Janda >> >> I have a arithmetic problem. >> I have an expression expr = (p1 + 2*p2)*(k1 + 2*k2) >> where p1 + p2 = k1 + k2 >> I wanna make the following change of variables, >> s = (p1 + p2)^2 >> t = (p1 - k1)^2 >> u = (p1 - k2)^2 >> >> Is it possible to tell Mathematica to express expr >> in terms of s, t, and u automatically? >> >> any ideas would be appreciated. > > More or less. You can create a Groebner basis out of the defining > polynomials, such that variables p1, p2, k1, and k2 are ordered higher > than s, t, and u. Then generalized division (aka polynomial reduction) > of expr will do what it can to make such a replacement. > > polys = {s-(p1+p2)^2,t-(p1-k1)^2,u-(p1-k2)^2,p1+p2-(k1+k2)}; > vars = {p1,p2,k1,k2,s,t,u}; > gb = GroebnerBasis[polys, vars]; > > In[19]:= InputForm[PolynomialReduce[(p1+2*p2)*(k1+2*k2), gb, vars][[2]]] > Out[19]//InputForm= 3*k2*p2 + (3*s)/2 + t/2 - u/2 > > In general the replacement will be dependent on variable and monomial > ordering. But I'm fairly certain that you will be stuck with some part > not replaced no matter waht orders are used, since this particular > variable/monomial ordering does not manage to reduce k2*p2. > > Daniel Lichtblau > Wolfram Research > > === Subject: Re: locator snap answers gave me a bit more insight in what is possible with dynamic and dynamic module. I also found a solution with manipulate, which not only gives a 'snapped result' as the solution below, but which also snaps the locator in the graphics: Manipulate[Column@{Graphics [{Disk[Round[p,0.1],0.05]},Axes->True,PlotRange->1],Round[p,0.1]}, {{p,{0,0}},Locator,Appearance-> }] I do not show the locator, but replace it with a graphics object at the rounded position of the locator. Maarten PS: the solution below is not jerking on my pc (6.0.2, windows xp) |--------+-----------------------> | | Kevin J. | | | McCann | | | | | | | | | 30/04/2008 | | | 13:03 | | | | |--------+-----------------------> >---------------------------------------------------------------------------- ----------------------------------------------------------------------| | | | cc: | === | Subject: Re: locator snap | >---------------------------------------------------------------------------- ----------------------------------------------------------------------| Hey Szabolcs, This works fine, but I notice that the graph jerks around a lot when you move the locator. I assume that Mathematica is redrawing everything on each move or ...? Anyway, does anyone know why? Kevin > > In the example below the locator can be moved to any position in the > graphic. > Can the locator be made to snap to multiples of say 0.1? > > Manipulate[Column@{Graphics[{}, Axes -> True], p}, {{p, {0, 0}}, > Locator}] > >> Hi Maarten, >> >> I am not aware of any way to do this directly with Manipulate. (Of >> course this does not mean that there doesn't exist a way!) >> >> Here is an example of doing it directly with Dynamic: >> >> Graphics[ >> Locator[Dynamic[{x, y}, ({x, y} = Round[#, 0.1]) &]], >> PlotRange -> 1, Frame -> True, >> GridLines -> {#, #} & @ >> Table[{x, If[Mod[x, 1/2] == 0, Black, Gray]}, {x, -1, 1, 1/10}] >> ] >> > > Sorry, I forgot to mention that x and y must be initialized before this= > will work: > > {x, y} = {0, 0} > > Also, the x in the Table is an unfortunate choice for a local variable > name---it has nothing to do with the x in the Dynamic. > -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: Want a general method to extract cases resulting from Reduce > Someone recently posted asking How to remove unneeded constraints. > I can see a general use for something perhaps related to this. > > Reduce often gives back fairly complicated nested boolean structures > of constraints. Consider the results from the following concrete > example: > > Reduce[{a x1^2 + b x1 + c == y1, a x2^2 + b x2 + c == y2, a( -b/ > (2a))^2+ b ( -b/(2a)) + c == y3, y1 < y3, y2 < y3, x1 < x2, > Element[Alternatives[x1,x2,x3,y1,y2,y3,a,b,c],Reals]}, {a,b,c}] =2E.. Here is another common example where the output of Reduce could be enhanced. I often find results of the form (x==y && ALongExpressionOfConditions) || (SomeLongExpressionOfConditions && x (List @@ #)] & /@ newlst], SelfLoopStyle -> None, VertexLabeling -> True] However, there are couple of issues with the above that I could not figure out: 1) Not all nodes are shown. For instance 12 is shown only once in the output. Whereas I would like to see all 3 instances of 12. 2) I would like the above to look like the following (this is sort of the representation I want): 13 
 13 14
 16
 16 
 15 12 12
 12 
 5 
16 is the maximum value in my lst and that is why it is in the center. The values in the cluster of 16 {16,16,15} are in the center. 15 is a little further away because of the distance of 1. The cluster of {13,13,14} appears to be closer than the {12,12,12,5} because the sum of 13+13+14 = 40 and 12+12+12+5=41. 
 _____________________________________________________________________________ _______ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ === Subject: FindClusters & BarCharts Hi everyone, I have the following list: list = {{2, 4, 2, 2, 9}, {7, 2, 8, 5, 4}, {2, 1, 4, 5, 3}} I would like to find clusters in the above list: tmpVal = 3; temp = FindClusters[Cases[Flatten[Sort[list]], Except[tmpVal]]] This gives me: {{2, 1, 2, 2, 2, 2}, {4, 4, 4}, {5, 5}, {9, 7, 8}} which is correct. However, I do want one of the clusters to include the value of 3 and get something as follows: {{2, 1, 2, 2, 2, 2}, {4, 4, 4}, {5, 5}, {9, 7, 8}, {3}} If I change tmpVal = 2 I get something that is not desired: tmpVal=2 temp = FindClusters[Cases[Flatten[list], Except[value]]] This gives me: {{4, 5, 4, 1, 4, 5, 3}, {9, 7, 8}}. However, I would like the output to be somewhat as the following (In other words {{1}, {2,2,2,2,2}, {3,4,5}, {7,8,9}} Similarly, if I change the variable value=8, I get: {{2, 2, 2, 2, 2, 1, 3}, {4, 5, 4, 4, 5}, {9, 7}} but would like the output to include: {{2, 2, 2, 2, 2, 1, 3}, {4, 5, 4, 4, 5}, {7}, {8}, {9}} In other words, split the list up at the value and then I would like to plot the above in a BarChart: Needs[BarCharts`] BarChart[Map[Length[#] &, temp]] I would like the bars to have the labels as the minimum and maximum for each of the lists. For instance: {{4, 5, 4, 1, 4, 5, 3}, {9, 7, 8}, {2,2,2,2,2}} The first bar would be labeled 1-5 === Subject: Re: root of complex function > I need to get a list of root intervals of a complex function. I tried > in vain to use the package IntervalRoots. However, this package seems > to work only with real functions. I appreciate it if someone can > provide me with a simple code that does the job. I also tried to > download the Rootsearch package by Ersek but the package is not > downloadable. I tried to access MathSource this morning and did not get any trouble to access the Ted Ersek's package web page. Just to be sure, I downloaded the package file and the sample file on my system. http://library.wolfram.com/infocenter/MathSource/4482/ [I have sent both files to your private email.] -- Jean-Marc === Subject: Re: root of complex function What is your complex function? I'm amazed at how often posters ask questions but don't give the example. Have you explored the function graphically? You should be able to download RootSearch from MathSource. http://library.wolfram.com/infocenter/MathSource/4482/ Just click the icons at the bottom far left. However, RootSearch is only for single variable real functions. For this it seems to be much better than FindRoot and in my opinion should be part of Mathematica proper. But it won't help with complex functions. (Except there is a method where you can find find contours where the real part of the function is zero and then use RootSearch to search along these lines for points where the imaginary part is zero.) -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > > I need to get a list of root intervals of a complex function. I tried > in vain to use the package IntervalRoots. However, this package seems > to work only with real functions. I appreciate it if someone can > provide me with a simple code that does the job. I also tried to > download the Rootsearch package by Ersek but the package is not > downloadable. > > > > HMQ > === Subject: Re: root of complex function I just now downloaded Ersek's RootSearch.m from library.wolfram.com/infocenter/MathSource. Do a search and you should find it. I need to get a list of root intervals of a complex function. I tried > in vain to use the package IntervalRoots. However, this package seems > to work only with real functions. I appreciate it if someone can > provide me with a simple code that does the job. I also tried to > download the Rootsearch package by Ersek but the package is not > downloadable. HMQ > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Problem: is not a list of numbers with dimensions In both cases, use Exp rather than exp A = 1*10^(-4); k = 2/3; g = 1.12*10^(-11); Attenuation = 0.23026*0.475*10^(-3); L = 7200; Leff = (1 - Exp[-Attenuation*L])/Attenuation; FindRoot[x - A*Exp[k*g*x*Leff - Attenuation*L], {x, 0}] {x->0.0000454986} Bob Hanlon > When run the below code, > A=1*10^(-4); k=2/3; g=1.12*10^(-11); Attenuation= 0.23026*0.475*10^(-3); L=7200; Leff=(1-exp[-Attenuation*L])/Attenuation; FindRoot[x-A*exp[k*g*x*Leff-Attenuation*L],{x,0}] It executes the below solution, FindRoot::nlnum: The function value {0.-0.0001 exp[-0.787489+0. (1.+Times[<<2>>])]} is not a list of numbers with dimensions {1} at {x} = {0.}. I need your help about numerical and Alpha_numeric solution of this problem. > f(x)= x-A*exp[k*g*x*Leff-Attenuation*L Serdar === Subject: Re: Fitting with a power embedded in a integration I don't know how to fit my data with a power embedded in > a integration, and can't find related answer in this forum. This is the function I want to fit > !( > *SubsuperscriptBox[([Integral]), (w), (R)](c* > SuperscriptBox[(x), (-p)] > FractionBox[(x), > SqrtBox[( > *SuperscriptBox[(x), (2)] - > *SuperscriptBox[(w), (2)])]] [DifferentialD]x)) w is variable, R is a parameter, and c, p is parameters should > be fitted. I can't find a way to simplified the power law to log form > so that can't avoid the trouble while fit the power law. > Lynn > Lynn, I believe you are using a version prior to 6.0, in this case you should use the _InputForm_ when copying an expression from a Mathematica notebook to an email client: select the cell(s) you want to include in your email, then within the *Cell* menu select either *Convert To* or *Display As* and choose *InputForm*. Finally, copy and paste as usual. As posted, the expression is rendered in a weird (nonsensical) way on my system when copied and pasted. -- Jean-Marc === Subject: Re: Dashing[{}] > If I invoke Dashed somewhere in my Graphics3D display code= , a > subsequent Dashing[{}], Line[...] is supposed to draw solid lines > thereafter. It seems to have no effect as everything after that is > still dashed. Might there be something simple I'm missing? Or a bug? You should post a code snippet that produces wrong results. I cannot reproduce the problem with this simple example: Graphics[ {Dashing[{.05, .05}], Line[{{0, 0}, {1, 1}}], Dashing[{}], Line[{{1, 1}, {2, 0}}]} ] Also note that Dashing[] will only have an effect inside the enclosing { }: Graphics[ {{Dashing[{.05, .05}], Line[{{0, 0}, {1, 1}}]}, Line[{{1, 1}, {2, 0}}]} ] === Subject: Re: Dashing[{}] > If I invoke Dashed somewhere in my Graphics3D display code, a > subsequent Dashing[{}], Line[...] is supposed to draw solid lines > thereafter. It seems to have no effect as everything after that is > still dashed. Might there be something simple I'm missing? Or a bug? Steve Gray > The following works as expected on my system. Table[Graphics3D[{Dashing[{r, 0.1 - r}], Line[{{0, 0, 0}, {2, 1, 1}}], Dashing[{}], Line[{{0, 1, 0}, {2, 0, 1}}]}], {r, {0.01, 0.03, 0.05, 0.08}}] See, http://homepages.nyu.edu/~jmg336/mathematica/dashing.pdf Since you did not provide an example of faulty code, it is hard to tell more about the possible issue you encountered. -- Jean-Marc === Subject: Re: Dashing[{}] Example? -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > If I invoke Dashed somewhere in my Graphics3D display code, a > subsequent Dashing[{}], Line[...] is supposed to draw solid lines > thereafter. It seems to have no effect as everything after that is > still dashed. Might there be something simple I'm missing? Or a bug? > > Steve Gray > === Subject: Re: Dashing[{}] $Version 6.0 for Mac OS X x86 (64-bit) (March 13, 2008) Show[Graphics3D[{ Blue, Thick, Dashing[{.05, .05}], Line[{{0, 0, 0}, {1, 1, 1}}], Red, Thick, Dashing[{}], Line[{{1, 1, 1}, {2, 2, 0}}]}]] This works as expected on my system. Bob Hanlon > If I invoke Dashed somewhere in my Graphics3D display code, a > subsequent Dashing[{}], Line[...] is supposed to draw solid lines > thereafter. It seems to have no effect as everything after that is > still dashed. Might there be something simple I'm missing? Or a bug? Steve Gray > === Subject: Re: orthonormal eigenvectors > I have a 3X3 matrix M: {1,-i(2^(1/2)),0} {i(2^(1/2)),0,0} {0,0,2} > And I am trying to find a set of orthonormal eigenvectors for M. You can find a set of eigenvectors by doing: In[54]:= m = {{1, -I (2^(1/2)), 0}, > {I (2^(1/2)), 0, 0}, > {0, 0, 2}}; In[55]:= ev = Eigenvectors[m] Out[55]= {{0, 0, 1}, {-I Sqrt[2], 1, 0}, {I/Sqrt[2], 1, 0}} Then it is easy to normalize these by doing: In[56]:= len = (#.#) & /@ ev; > ev /Sqrt[len] Out[57]= {{0, 0, 1}, {-Sqrt[2], -I, 0}, {I, Sqrt[2], 0}} But while all of these have unit length, they do not form an > orthonormal set since In[58]:= Dot @@ Rest[%] Out[58]= -2 I Sqrt[2] which is clearly not zero. That is for your matrix, a set of > orthonormal eigenvectors doesn't exist. > The matrix is Hermitian, i.e. m == Conjugate@Transpose[m], so a set of orthonormal eigenvectors is guaranteed to exist with respect to the dot product complexDot = #1 . Conjugate[#2] &. Even though one eigenvalue of the matrix is degenerate, the set of vectors returned by Eigenvectors are orthogonal to each other, but not normalized: In[16]:= ev = Eigenvectors[m] Out[16]= {{0, 0, 1}, {-I Sqrt[2], 1, 0}, {I/Sqrt[2], 1, 0}} In[17]:= Outer[complexDot, ev, ev, 1] Out[17]= {{1, 0, 0}, {0, 3, 0}, {0, 0, 3/2}} Normalize[] handles complex vectors correctly, so we can simply do the following: In[19]:= ev = Normalize /@ ev Out[19]= {{0, 0, 1}, {-I Sqrt[2/3], 1/Sqrt[3], 0}, {I/Sqrt[3], Sqrt[2/3], 0}} In[20]:= Outer[complexDot, ev, ev, 1] Out[20]= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} === Subject: Re: Hash Table for self avoiding random walks > Daniel Lichtblau: http://library.wolfram.com/infocenter/Conferences/321/ > , which shows how downvalues can be used in a similar way to hash > still the state of the art. The idea is simple. If I have a walk that took steps {{1,1},{1,2}, > {2,2}} then I make a function h: h[{1,1}] = True; > h[{1,2}] = True; > h[{2,2}] = True; My primary complaint with this technique is that it seems to require > giving your hash table a name with global scope. What if I want to > make 100 different walks? Do I have to give them all separate names? > I guess I could do something like h[10][1,1] = True;, but then I > always have to keep track of which walk I'm working on. I'd rather > just be able to let them all be anonymous and stick them in a list. Any ideas? Just an idea that pops up. You could use different contexts (with their names automatically generated/discarded during each run) to store the h[m,n] values. See *Contexts* http://reference.wolfram.com/mathematica/tutorial/Contexts.html *Manipulating Symbols and Contexts by Name* http://reference.wolfram.com/mathematica/tutorial/ManipulatingSymbolsAndCont extsByName.html HTH, -- Jean-Marc === Subject: Re: Hash Table for self avoiding random walks > Here's my current best effort: neighborhood[n_] := > With[{seed = ReplacePart[ConstantArray[0, n], 1 -> 1]}, > Join[Permutations[seed], Permutations[-seed]]] availableSteps[{points_, visitedFunction_}] := > With[{steps = (Last[points] + #) & /@ > neighborhood[Dimensions[points][[2]]]}, > Select[steps, visitedFunction[#] =!= True &]] takeStep[{points_, visitedFunction_}] := > With[{newStep = > RandomChoice[availableSteps[{points, visitedFunction}]]}, > visitedFunction[Last[points]] = True; > {Append[points, newStep], visitedFunction}] Clear[trail]; > {points, trail} = > NestWhile[ > takeStep, {{{0, 0, 0}}, trail}, (Length[availableSteps[#]] > 0) &]; The part that I really don't like is the Clear[trail] part. > Your code looks good to me. You can use Module[] to localize 'trail', this way it won't be necessary to use Clear[]. Here's a slight modification that runs ~4x faster on my machine: neighbourhood[n_] := neighbourhood[n] = With[{seed = ReplacePart[ConstantArray[0, n], 1 -> 1]}, Join[Permutations[seed], Permutations[-seed]]] step[visited_][pt_] := With[ {steps = Select[(pt + #) & /@ neighbourhood@Length[pt], ! ValueQ[visited[#]] &]}, If[steps =!= {}, With[{next = RandomChoice[steps]}, visited[next] = True; next ], Null] ] Module[{trail}, Most@NestWhileList[step[trail], {0, 0, 0}, # =!= Null &] I've thrown this together quickly, so it's a bit messy ... sorry about that (especially about merging takeStep and availableSteps, which serves no purpose in this case). The two main optimizations are caching the result of neighbourhood[], and using NestWhileList instead of NestWhile + Append. I have not timed the parts of the function separately, but I suspect that the speedup is due to the latter change. I hope this helps, Szabolcs === Subject: Re: Hash Table for self avoiding random walks > Hello JM, > > I may be misunderstanding your question completely, so I am sorry if > this suggestion is off target: > > atrail := Module[{trail}, NestWhile[takeStep, {{{0, 0, 0}}, trail}, > (Length[availableSteps[#]] > 0) &]] > > Table[atrail,{4}] This is exactly what I was looking for. I knew there was a simple step I was missing. About 5 minutes after posting, I came up with a similar solution: atrail = NestWhile[takeStep, {{{0, 0, 0}}, Unique[]}, (Length[availableSteps[#]] > 0) &] JM === Subject: Re: Hash Table for self avoiding random walks > Executive Summary: Can I make a bunch of things that work like hash tables without > polluting the global scope? Long winded Version: I've been playing around with self avoiding random walks. Generating > them efficiently requires a fast way of checking whether a given step > will intersect the set of previous steps, which is generally a sparse > subset of the underlying lattice. Using a list of the previous steps isn't so great because searching it > for collisions is order the size of the list. Using an array isn't so > great because it has predefined boundaries and because, as the > dimensionality increases, the size of the array goes like (side > length)^dimensions. I think the ideal data structure is a hash table. It takes constant > time to add new elements and constant time to check if a trial step > collides with a previous step, and there are no predefined > boundaries. But it seems Mathematica doesn't have a true hash table. > SparseArray doesn't qualify because it wraps negative values and > complains if you look for something outside the boundaries. Dispatch > doesn't qualify because (as far as I know) there's no way to add new > rules to an already created DispatchTables. Daniel Lichtblau: http://library.wolfram.com/infocenter/Conferences/321/ > , which shows how downvalues can be used in a similar way to hash > still the state of the art. The idea is simple. If I have a walk that took steps {{1,1},{1,2}, > {2,2}} then I make a function h: h[{1,1}] = True; > h[{1,2}] = True; > h[{2,2}] = True; My primary complaint with this technique is that it seems to require > giving your hash table a name with global scope. What if I want to > make 100 different walks? Do I have to give them all separate names? > I guess I could do something like h[10][1,1] = True;, but then I > always have to keep track of which walk I'm working on. I'd rather > just be able to let them all be anonymous and stick them in a list. Any ideas? Here's my current best effort: neighborhood[n_] := > With[{seed = ReplacePart[ConstantArray[0, n], 1 -> 1]}, > Join[Permutations[seed], Permutations[-seed]]] availableSteps[{points_, visitedFunction_}] := > With[{steps = (Last[points] + #) & /@ > neighborhood[Dimensions[points][[2]]]}, > Select[steps, visitedFunction[#] =!= True &]] takeStep[{points_, visitedFunction_}] := > With[{newStep = > RandomChoice[availableSteps[{points, visitedFunction}]]}, > visitedFunction[Last[points]] = True; > {Append[points, newStep], visitedFunction}] Clear[trail]; > {points, trail} = > NestWhile[ > takeStep, {{{0, 0, 0}}, trail}, (Length[availableSteps[#]] > 0) &]; The part that I really don't like is the Clear[trail] part. As an aside, although there is no documentation for HashTable, doing FullForm[Dispatch[Table[n -> 1, {n, 4}]]] gives Dispatch[List[Rule[1,1],Rule[2,1],Rule[3,1],Rule[4,1]],List[HashTable[1,4,1,L ist[List[1,2,3],List[],List[4]]]]] Is the feature set I want just hiding? > JM > Remember that the DownValue's in Daniel Lichtblau's technique can relate to a local variable: Module[{h}, h[{1,1}]=True; etc. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Hash Table for self avoiding random walks Hello JM, I may be misunderstanding your question completely, so I am sorry if this suggestion is off target: atrail := Module[{trail}, NestWhile[takeStep, {{{0, 0, 0}}, trail}, (Length[availableSteps[#]] > 0) &]] Table[atrail,{4}] > As an aside, although there is no documentation for HashTable, doing There is something, but not much, in the doc for Dispatch. I am not sure, but I don't think you will need to get to the guts of HashTable. > Can I make a bunch of things that work like hash tables without > polluting the global scope? : : > My primary complaint with this technique is that it seems to require > giving your hash table a name with global scope. What if I want to > make 100 different walks? Do I have to give them all separate names? > I guess I could do something like h[10][1,1] = True;, but then I > always have to keep track of which walk I'm working on. I'd rather > just be able to let them all be anonymous and stick them in a list. > > Any ideas? Here's my current best effort: > > neighborhood[n_] := > With[{seed = ReplacePart[ConstantArray[0, n], 1 -> 1]}, > Join[Permutations[seed], Permutations[-seed]]] > > availableSteps[{points_, visitedFunction_}] := > With[{steps = (Last[points] + #) & /@ > neighborhood[Dimensions[points][[2]]]}, > Select[steps, visitedFunction[#] =!= True &]] > > takeStep[{points_, visitedFunction_}] := > With[{newStep = > RandomChoice[availableSteps[{points, visitedFunction}]]}, > visitedFunction[Last[points]] = True; > {Append[points, newStep], visitedFunction}] > > Clear[trail]; > {points, trail} = > NestWhile[ > takeStep, {{{0, 0, 0}}, trail}, (Length[availableSteps[#]] > 0) &]; > > The part that I really don't like is the Clear[trail] part. > -- W. Craig Carter === Subject: Re: Hash Table for self avoiding random walks > > h[{1,1}] = True; > h[{1,2}] = True; > h[{2,2}] = True; > > My primary complaint with this technique is that it seems to require > giving your hash table a name with global scope. What if I want to > make 100 different walks? Do I have to give them all separate names? > I guess I could do something like h[10][1,1] = True;, but then I > always have to keep track of which walk I'm working on. I'd rather > just be able to let them all be anonymous and stick them in a list. > This is the approach that I'd recommend, too. h does not need to have global scope. You can always put it into a Module: Module[ {h}, ... ... h[{a,b}] = True ... ] Szabolcs === Subject: Re: StringMatchQ and Regular Expressions > Hi I'm running Mathematica v6.0.2 on Windows XP. I define a regex thus: doStmt = RegularExpression[do(?=s*w+=)]; and then execute: StringCases[doindex= , doStmt] which brings the response {do} I then execute StringMatchQ[doindex= , doStmt] which brings the response False I had expected that if StringCases found any cases, then StringMatchQ > would return True. Obviously this is not the case, but can anyone out > there throw light upon this. > Mark Westwood > See also StringFreeQ and the section Properties & Relations (3) in its homepage. hth, albert === Subject: Symbolic Optimization Problem I need to maximize [Pi] = R*[Alpha] (1/[Alpha] ([Beta]/R)^(1/( 1 - [Beta])) - (1 - [Gamma])*[Beta]^(2/( 1 - [Beta]))*[Alpha]^([Beta]/( 1 - [Beta]))) - (1/[Alpha] ([Beta]/R)^(1/( 1 - [Beta])) - (1 - [Gamma])*[Beta]^(2/( 1 - [Beta]))*[Alpha]^([Beta]/(1 - [Beta]))) with respect to R (R will be in terms of alpha, beta and gamma) under the assumption that beta, alpha and gamma will all be between 0 and 1. How can I solve this symbolic optimization with Mathematica? I tried to solve it but I am not very experienced with Mathematica and your help is greatly appreciated. Gonca Senel Bilkent University === Subject: Re: Finding the line that caused an error > Is there any way to display the specific line of code that caused > an error in Mathematica? > I'm used to working with C++ compilers that give you a line number > along with each error message, and I'm starting to get frustrated > with Mathematica. It'd be much simpler to immediately see the cause > of the error instead of sifting through many lines of code. If you are seeing an error message: TraceDialog[expr,Message[___]] will stop execution at the point of the error. You can then examine the execution stack to locate the origin of the problem. Ssezi === Subject: Re: Finding the line that caused an error > Is there any way to display the specific line of code that caused an error= in Mathematica? > I'm used to working with C++ compilers that give you a line number alon= g with each error message, and I'm starting to get frustrated with Mathemati= ca. It'd be much simpler to immediately see the cause of the error instead o= f sifting through many lines of code. The Front End does highlight parsing errors. This is analogous to the error messages of a C++ compiler (static checking). For messages generated while the program is running, you could try using the Break at messages feature of the debugger, which will highlight the part of code that generated the message. === Subject: Re: Interpolation with FourierTrigSeries with mathematica 6 tia sal2 I believe problem is your data and the request for periodic numeric interpolation. (The message window reveals the warning). data2 is not periodic: The following works, but has some difficulties with convergence of the numerical integration: lp = ListPlot[data3] f = Interpolation[data3, PeriodicInterpolation -> True] pf = Plot[f[x], {x, 0, 139}] fs = N[FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/139}]] fp = Plot[fs, {x, 0, 138}] Show[lp, fp, pf] > When I change different data points to the code example: > > data2 = {{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17, 6}, {19, -2}, > {25, -6}, {34, 6}, {41, 4}, {49, -6}, {56, -5}, {63, 4}, {69, 3}, {74, > -5}, {77, -3}, {86, 3}, {90, 7}, {95, -3}, {96, -8}, {103, 7}, {112, > 9}, {120, -8}, {129, -9}, {138, 9}}; > > f = Interpolation[data2, PeriodicInterpolation -> True]; > << FourierSeries` > > s[x_] = N[ > FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] > > my partial output becomes : > > 0.00729927 NIntegrate[ > Interpolation[{{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17, -- W. Craig Carter === Subject: Re: Interpolation with FourierTrigSeries with mathematica 6 tia sal2 > Interpolation with FourierTrigSeries with mathematica 6 tia sal2 > When I change different data points to the code example: data2 = {{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17, 6}, {19, -2}, > {25, -6}, {34, 6}, {41, 4}, {49, -6}, {56, -5}, {63, 4}, {69, 3}, {74, > -5}, {77, -3}, {86, 3}, {90, 7}, {95, -3}, {96, -8}, {103, 7}, {112, > 9}, {120, -8}, {129, -9}, {138, 9}}; The endpoint must have a y-value equals to the y-value of the start point. In your case, since the function starts with a value of zero, the last point must be {138, 0} because the function *must* be periodic. This is exactly what Mathematica complains about in the *error message* you have chosen to disregard. Needs[FourierSeries`] data2 = {{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17, 6}, {19, -2}, {25, -6}, {34, 6}, {41, 4}, {49, -6}, {56, -5}, {63, 4}, {69, 3}, {74, -5}, {77, -3}, {86, 3}, {90, 7}, {95, -3}, {96, -8}, {103, 7}, {112, 9}, {120, -8}, {129, -9}, {138, 9}}; f = Interpolation[data2, PeriodicInterpolation -> True]; s[x_] = N[ FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] Interpolation::per: In dimension 1 the data at the endpoints of the fundamental period are not equal. >> > f = Interpolation[data2, PeriodicInterpolation -> True]; > << FourierSeries` s[x_] = N[ > FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] my partial output becomes : 0.00729927 NIntegrate[ > Interpolation[{{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17, > 6}, {19, -2}, {25, -6}, {34, 6}, {41, > 4}, {49, -6}, {56, -5}, {63, 4}, {69, > 3}, {74, -5}, {77, -3}, {86, 3}, {90, > 7}, {95, -3}, {96, -8}, {103, 7}, {112, > 9}, {120, -8}, {129, -9}, {138, 9}}, > PeriodicInterpolation -> True][x], {x, -(137/2), 137/2}] + > 0.0145985 Cos[0.0458627 x] NIntegrate.......................... does anyone know why this no longer outputs in the form of just sin > and cos? > (which I really want) Therefore, using *periodic* data points, we get Needs[FourierSeries`] data2 = {{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17, 6}, {19, -2}, {25, -6}, {34, 6}, {41, 4}, {49, -6}, {56, -5}, {63, 4}, {69, 3}, {74, -5}, {77, -3}, {86, 3}, {90, 7}, {95, -3}, {96, -8}, {103, 7}, {112, 9}, {120, -8}, {129, -9}, {138, 0}}; f = Interpolation[data2, PeriodicInterpolation -> True]; s[x_] = N[ FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] [Warning messages about slow convergence discarded] -1.33366 - 1.93771 Cos[0.0455303 x] - 1.84218 Cos[0.0910607 x] - 0.915718 Cos[0.136591 x] + 1.96324 Cos[0.182121 x] + 1.32678 Cos[0.227652 x] + 0.178997 Cos[0.273182 x] - 1.85621 Cos[0.318712 x] + 1.24014 Cos[0.364243 x] + 2.53467 Cos[0.409773 x] + 0.178343 Cos[0.455303 x] - 0.597821 Cos[0.500834 x] + 0.59092 Cos[0.546364 x] - 0.129048 Cos[0.591894 x] - 0.377664 Cos[0.637425 x] + 0.303572 Cos[0.682955 x] + 1.10636 Cos[0.728485 x] + 0.234811 Cos[0.774016 x] - 0.339997 Cos[0.819546 x] - 0.247664 Cos[0.865076 x] + 0.136132 Cos[0.910607 x] - 0.0551202 Cos[0.956137 x] - 0.146821 Cos[1.00167 x] - 0.028917 Cos[1.0472 x] + 0.0668191 Cos[1.09273 x] - 0.0534889 Cos[1.13826 x] - 0.19826 Sin[0.0455303 x] + 0.823365 Sin[0.0910607 x] + 0.967715 Sin[0.136591 x] + 3.57456 Sin[0.182121 x] + 3.72198 Sin[0.227652 x] - 4.41631 Sin[0.273182 x] - 0.783889 Sin[0.318712 x] + 0.985987 Sin[0.364243 x] + 0.297933 Sin[0.409773 x] - 0.182527 Sin[0.455303 x] + 1.85795 Sin[0.500834 x] + 0.603078 Sin[0.546364 x] - 0.92085 Sin[0.591894 x] - 0.693979 Sin[0.637425 x] + 0.0286992 Sin[0.682955 x] + 0.0714767 Sin[0.728485 x] - 0.0838198 Sin[0.774016 x] + 0.284645 Sin[0.819546 x] + 0.296819 Sin[0.865076 x] - 0.138192 Sin[0.910607 x] - 0.320014 Sin[0.956137 x] + 0.0703057 Sin[1.00167 x] + 0.176853 Sin[1.0472 x] + 0.0718324 Sin[1.09273 x] - 0.10215 Sin[1.13826 x] -- Jean-Marc === Subject: Re: 32 or 64 bit front-end on 64-bit Mac > Just installed Mathematica 6.0.2.1 on a Mac Pro running OS X 10.5.2 > (Leopard). TThe system info (portions included below) reports that the > Mathematica kernel is 64 bit as expected, it says the front end is 32 > bit. Note that in that section, the processor type is reported as x86 > not x86-64. > SystemInformationData[{Kernel -> {Version - 6.0 for Mac OS X x86 (64-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009696), ... > MachineType -> PC, > OperatingSystem -> MacOSX, ProcessorType -> x86-64, > ..... > FrontEnd -> {Version - 6.0 for Mac OS X x86 (32-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009694), ... > MachineType -> PC, > OperatingSystem -> MacOSX, ProcessorType -> x86, > ..... Why doesn't the front end report as 64 bit and not 32 bit? Is this Jay, AFAIK, the front-end for Mac OS X is compiled and *shipped* by WRI only as a 32-bit application. So your installation is fine and what the command *SystemInformation[]* reports is correct. -- Jean-Marc === Subject: Re: 32-bit front-end on 64-bit machine > Just installed version 6.0.2.1 on a early 2008 mac pro running OS X 10.5.2. Though the Mathematica kernel version is reported as 64-bit, the front-end version is reported as 32-bit. Should I be getting 64 for that not 32? > SystemInformationData[{Kernel -> {Version - 6.0 for Mac OS X x86 (64-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009696), FrontEnd -> {Version - 6.0 for Mac OS X x86 (32-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009694), > AFAIK, the front-end for Mac OS X is compiled and *shipped* by WRI only as a 32-bit application. So your installation is fine and what the command *SystemInformation[]* reports is correct. -- Jean-Marc === Subject: Re: 32-bit front-end on 64-bit machine > Just installed version 6.0.2.1 on a early 2008 mac pro running OS X 10.5.2. Though the Mathematica kernel version is reported as 64-bit, the front-end version is reported as 32-bit. Should I be getting 64 for that not 32? > SystemInformationData[{Kernel -> {Version - 6.0 for Mac OS X x86 (64-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009696), FrontEnd -> {Version - 6.0 for Mac OS X x86 (32-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009694), I think the FE is always 32-bits - there would be no real advantage in having a 64-bit version, because if the kernel were to send it more than 2G bytes of data, think how long it would take, and what could the FE sensibly do with it! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: 32-bit front-end on 64-bit machine The response I got from WRI support on this was that indeed the Front End is 32-bit still (and there may be no great reason to modify this). HTH ... Syd Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com My System Mathematica 6.0.2.1 for Mac OS X x86 (64 - bit) (March 13, 2008) MacOS X V 10.5.2 > Just installed version 6.0.2.1 on a early 2008 mac pro running OS X > 10.5.2. > > Though the Mathematica kernel version is reported as 64-bit, the > front-end version is reported as 32-bit. Should I be getting 64 > for that not 32? > > > SystemInformationData[{Kernel -> {Version -> > 6.0 for Mac OS X x86 (64-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009696), > > FrontEnd -> {Version -> > 6.0 for Mac OS X x86 (32-bit) (March 13, 2008), > ReleaseID -> 6.0.2 (1009763, 1009694), > > === Subject: Re: Problem: is not a list of numbers with dimensions Hello Fikri, When beginning to use Mathematica, it is probably a good idea to leave off the trailing ; In this way, you will quickly see the syntax errors---this will lead you to start exploring some of the documentation. For this example, I would say this would be a good paradigm for those just getting started: (*Build up expressions with symbols, not numbers*) Leff = (1 - Exp[-Attenuation*L])/Attenuation GenExpr = x - A*Exp[k*g*x*Leff - Attenuation*L] (*use replace to create a particular instance of your expression*) Expr = GenExpr /. {A -> 10^(-4), k -> 2/3, g -> 1.12*10^(-11), L -> 7200, Attenuation -> 0.23026*0.475*10^(-3) } (*visualize what you intend to do*) Plot[Expr, {x, -1, 1}] (*Check the documentation and (if everything is fine) get your answer*) FindRoot[Expr, {x, 0}] > When run the below code, > > > A=1*10^(-4); > > k=2/3; > > g=1.12*10^(-11); > > Attenuation= 0.23026*0.475*10^(-3); > > L=7200; > > Leff=(1-exp[-Attenuation*L])/Attenuation; > > > > FindRoot[x-A*exp[k*g*x*Leff-Attenuation*L],{x,0}] > > > > It executes the below solution, > > > > FindRoot::nlnum: The function value {0.-0.0001 exp[-0.787489+0. > > (1.+Times[<<2>>])]} is not a list of numbers with dimensions {1} at > > {x} = {0.}. > > > > I need your help about numerical and Alpha_numeric solution of this problem. > > > > > f(x)= x-A*exp[k*g*x*Leff-Attenuation*L > > > > Serdar > > > -- W. Craig Carter === Subject: Re: Problem: is not a list of numbers with dimensions > When run the below code, A=1*10^(-4); k=2/3; g=1.12*10^(-11); Attenuation= 0.23026*0.475*10^(-3); L=7200; Leff=(1-exp[-Attenuation*L])/Attenuation; Must be Exp > FindRoot[x-A*exp[k*g*x*Leff-Attenuation*L],{x,0}] Must be Exp > It executes the below solution, FindRoot::nlnum: The function value {0.-0.0001 exp[-0.787489+0. (1.+Times[<<2>>])]} is not a list of numbers with dimensions {1} at {x} = {0.}. I need your help about numerical and Alpha_numeric solution of this problem. f(x)= x-A*exp[k*g*x*Leff-Attenuation*L Must be Exp Hi Serdar, You just made a typo when writing the exponential function. Keep in mind that every function names starts with a capital letter, i.e. *Exp* and not exp. In[1]:= A = 1*10^(-4); k = 2/3; g = 1.12*10^(-11); Attenuation = 0.23026*0.475*10^(-3); L = 7200; Leff = (1 - Exp[-Attenuation*L])/Attenuation; FindRoot[x - A*Exp[k*g*x*Leff - Attenuation*L], {x, 0}] Out[7]= {x -> 0.0000454986} -- Jean-Marc === Subject: Re: Problem: is not a list of numbers with dimensions > When run the below code, > > A=1*10^(-4); > > k=2/3; > > g=1.12*10^(-11); > > Attenuation= 0.23026*0.475*10^(-3); > > L=7200; > > Leff=(1-exp[-Attenuation*L])/Attenuation; > > FindRoot[x-A*exp[k*g*x*Leff-Attenuation*L],{x,0}] > > It executes the below solution, > > FindRoot::nlnum: The function value {0.-0.0001 exp[-0.787489+0. > > (1.+Times[<<2>>])]} is not a list of numbers with dimensions {1} at > > {x} = {0.}. > > I need your help about numerical and Alpha_numeric solution of this problem. > > f(x)= x-A*exp[k*g*x*Leff-Attenuation*L > > Serdar All Mathematica functions start with an uppercase letter, so exp[...] should be Exp[...] Bhuvanesh, Wolfram Research === Subject: Re: Wolfram User Interface Research? I am sorry, I was trying to be helpful. My copy of that book is at my office and I don't have access to it at the moment. Nevertheless, I am glad that you were able to find the list you were looking for. > > The Mathematica book has a list of such symbols in its table of > > contents . . . > > . . . under the name or title of ??? [The TOC is 6 pages full of quite > tiny type] > > [I think you may perhaps be referring to Appendix A.2.7, Operator Input > Forms --- ???] > > === Subject: Re: Integral wit Norm function alfa[t_] := {t^2, 4 t, 8 t^3} normt[t_] = Simplify[Norm[alfa[t]], t > 0] t*Sqrt[64*t^4 + t^2 + 16] Clear[int]; int[a_] = FullSimplify[Integrate[normt[t], {t, 1, a}, Assumptions -> {a > 0}]] (1/8192)*(16*Sqrt[64*a^4 + a^2 + 16]*(128*a^2 + 1) + 4095*ArcSinh[(128*a^2 + 1)/ (3*Sqrt[455])] - (9/2)*(4128 + 455*Log[91/5])) Plot[int[a], {a, 0, 2}] Bob Hanlon > How can I to calculate the integral of an expression which include > Norm function?. By example, Let the curve alfa[t_]:={t^2,4t, 8t^3}. Calculate > Integral[Norm[alfa[t]],{t,1,a}], where a is Real and >0. === Subject: Re: Coordinate readout from Graphics3D? >> I thought I saw somewhere that one could read out coordinates from a >> Graphics plot, according to the mouse position. I can't find it now, >> and I don't see how it would work with Graphics3D. But anything would >> >> Steve Gray > > So I have a simpler question. > > I know I can see the options that are set for a particular 3D object > typing Options[ ] around the object. This is particularly useful > when I have rotated the object with the mouse. > > But when I right click on the object and then use the object > inspector (ctrl-shift-o) and then choose Formatting, Expression > Formatting, Graphics3D Box Options, a change viewpoint (which has > lots of decimal places) is not completely visible.. Typing Options > when can use the mouse seems clunky, but not if you cannot view the > entire set of options. > > Any ideas? > You may try the following function: ExtrahiereViews[ll_]:= Flatten[Union[Extract[ll,Position[ll,#]]&/@ {ViewPoint->_, ViewCenter->_, ViewVertical->_, ViewAngle->_, ViewVector->_, ViewRange->_}]]; Call it and paste the graphics you moved with your mouse as argument. I use CMD+Shift+L (copy output from above) for that purpose Gruss Peter -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Does Mathematica really need more printed, introductory documentation? > I don't understand the problem here. The online documentation > open up in a window in the front end just like any notebook. If > you go to the menu bar and select Window->Magnification you will > get a menu list allowing you to select several different > magnification levels up to 300%. When you select one of these, > all of the text is re-scaled by that factor. Isn't this adequate? Yes --- except the enlargement doesn't stick: Close the doc window, come back to another one later, and the later one is not enlarged. Also, secondarily, doesn't enlarge the window itself --- you get enlarged text scrunched up in same size window. Would be nice if defaults for both of these could be changed. === Subject: Re: ChebyshevT command syntax and polynomial question using 21 - 10 x + x^2 I get zero for both answers 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x also gives me zero for both but when I do a TrigReduce In[148] := 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce I get Out[149]:= 1/2 (43 - 20 Cos[x] + Cos[2 x]) x=3 gives me 31.88 x=7 gives me 14.0293 Am I doing something wrong or leaving a part out? tia sal2 > > I execute the command and get the following output: > > In[83] := FunctionExpand[1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x] // Expand= > Out[83]:= 21 - 10 x + x^2 > > What would be the proper format to execute the polynomial using > ChebyshevT to do it in reverse order? > > Example: > I would input > In[83] := FunctionExpand[ChebyshevT[n, x]] > and it gives me > Out[83]:= Cos[n ArcCos[x]] > > How can I do a > In[83] := FunctionExpand[ChebyshevT[n, x]] > and it would give me > Out[83]:= 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x > > Use TrigReduce: > > 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce === Subject: Re: ContourPlot3D and positive contours > Hello everyone :) Using the ContourPlot3D, how can I plot only the positive contours (or > only the negative ones for that matter=85) > I would imagine an option like this : ContourPlot3D[f,Contours->{#>0&,10}] which would plot the first 10 positive contours. But that does not > exist=85 Right now, I'm plotting the contours of the positive part of my > function like this : ContourPlot3D[1/2*(f+Abs[f]),Contours->{10}] but that's not pretty=85 Is there a better way to do this ? You could try using RegionFunction. Here's is an example: ContourPlot[x^3 - 3 y^2 x, {x, -3, 3}, {y, -3, 3}, RegionFunction -> Function[{x, y, f}, f > 0], Contours -> 20] This should be applicable to 3D as well. === Subject: crosshatch shading I am preparing a graph for publication. I have been able to shade various areas in the graph different colors using the Filling option. However, for publication the paper will be in black and white. I would like to change the shaded areas to be filled in with crosshatches, parallel lines, etc. What are the options and commands to do this? I have looked online, but have not found an answer. === Subject: Re: crosshatch shading Yes, I think you can. Others may have a better way but here is a method using the Presentations package. I use it to hatch the positive lobe of a Sin curve. Basically I draw a set of slanted parallel lines and restrict their extent with a RegionFunction. Needs[Presentations`Master`] Draw2D[ {Draw[Sin[x], {x, 0, 2 [Pi]}], Line[{{0, 0}, {2 [Pi], 0}}], GrayLevel[.5], Draw[# + .5 x, {x, 0, 2 [Pi]}, PlotPoints -> 40, RegionFunction -> Function[{x, y, u}, 0 < y < Sin[x]]] & /@ Range[-1.6, 1, .1]}, PlotRange -> {-1.1, 1.1}, Frame -> True] Here is a method for a stand alone hatched plot without the package. RegionPlot[0 < y < Sin[x], {x, 0, [Pi]}, {y, 0, 1}, ColorFunction -> (White &), BoundaryStyle -> Black, Mesh -> 30, MeshFunctions -> {.5 #1 - #2 &}] And here is the way to combine RegionPlots with other plot elements using Presentations. Draw2D[ {Draw[Sin[x], {x, 0, 2 [Pi]}], Line[{{0, 0}, {2 [Pi], 0}}], RegionDraw[0 < y < Sin[x], {x, 0, [Pi]}, {y, 0, 1}, ColorFunction -> (White &), BoundaryStyle -> Black, Mesh -> 30, MeshFunctions -> {.5 #1 - #2 &}]}, PlotRange -> {-1.1, 1.1}, Frame -> True] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I am preparing a graph for publication. I have been able to shade > various areas in the graph different colors using the Filling option. > However, for publication the paper will be in black and white. I would > like to change the shaded areas to be filled in with crosshatches, > parallel lines, etc. What are the options and commands to do this? I > have looked online, but have not found an answer. > > === Subject: Re: crosshatch shading > I am preparing a graph for publication. I have been able to shade > various areas in the graph different colors using the Filling option. > However, for publication the paper will be in black and white. I would > like to change the shaded areas to be filled in with crosshatches, > parallel lines, etc. What are the options and commands to do this? I > have looked online, but have not found an answer. > > > had this problem in the past, regretfully found no such capability. gradient shading also not to be found. For bar charts, etc. I transferred the data back to Excel. === Subject: Looping in Mathematica Packages.m I know mathematica is a one line type software package but is there a way of looping in a Package.m file. You can use % sign or %%% for 3 lines back but is there a way to go 3 lines back and execute all the successive lines in a Package? === Subject: Re: Looping in Mathematica Packages.m > I know mathematica is a one line type software package but is there a way of looping in a Package.m file. You can use % sign or %%% for 3 lines back but is there a way to go 3 lines back and execute all the successive lines in a Package? > You have to be kidding - Mathematica supports looping in a whole range of styles - how do you think developers produce serious software with it? My general advice would be to go on a training course, but try looking up While, For, Map, MapIndexed, Nest, FixedPoint ..... in the help system and see what you find. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Question about OneIdentity > (Scroll down for the actual question) > > I never really understood Flat and OneIdentity, and unfortunately > documentation about them is scarce. > > OneIdentity is an attribute that can be assigned to a symbol f to > indicate that f[x], f[f[x]], etc. are all equivalent to x for the > purpose of pattern matching. > > OneIdentity has an effect only if f has attribute Flat. > ** Some comments: > > There is also an example, listing the Attributes of Times and showing > that Times[a] evaluates to a. However, this is misleading because this > behaviour cannot be caused by Times's attributes: > > In[1]:= Attributes[f] = Attributes[Times] > Out[1]= {Flat, Listable, NumericFunction, > OneIdentity, Orderless, Protected} > > In[2]:= f[a] > Out[2]= f[a] > > If we assign the same attributes to f, f[a] will not evaluate to a. Was= > the technical writer also confused, or is the example supposed to > illustrate something different than what I understood? > > ** And now the actual question: > > According to the text in the docs (f[x] is considered equivalent to x in > pattern matching) I would expect > > MatchQ[1, f[1]] > > to give True after evaluating SetAttributes[f, {Flat, OneIdentity}]. > But it gives False. > > ** The application: > > This came up in the following application: > > fun[HoldPattern@Plus[terms__]] := doSomething[{terms}] > > This function should handle a single term, too. Of course, there are > workarounds, but I couldn't come up with anything as simple as the > pattern above (which unfortunately does not work). This doesn't seem very logical to me, but it will work if you add a definition for Default: In[1]:= Attributes[f] = OneIdentity; Default[f] = 0; fun[f[terms_.]] := doSomething[List @@ terms] In[4]:= {fun[f[a, b]], fun[c]} Out[4]= {doSomething[{a, b}], doSomething[c]} Maxim Rytin m.r@inbox.ru === Subject: Re: Does Mathematica really need more printed, introductory documentation? >>Given it has only been a few months since Mathematica 6 was >>released and the time it takes to write any text and get it >>published it should not be surprising there are not any third party >>books on Mathematica yet. But given the number of books published >>for previous versions, it seems certain there will be books for >>version 6 in due time. >Bill, it's been for all practical purposes a _year_ now since >Mathematica 6 was released. Well, I was going to say I did not get version that long ago. But then I checked to see when I got version 6 and indeed it has been nearly a year. I had not realized I had been using version 6 that long. >And though I don't have a cite at hand, I'm sure I've read about how >major software companies, when they have a major emerging project or >upgrade under development, will invite a selected author or authors >with a good track record to come into their company and give them >substantial access to advance knowledge about the developing product >--- with appropriate nondisclosure agreements of course --- just so >their book or manual can appear on the shelves at the same instant >the product is released. >A software company may do this because they don't want to divert >in-house resources from product development to preparing an book for >the emerging product or upgrade --- or they may do this even though >they're developing their own manual also, on the grounds that the >more, the better so far as manuals go; they're in the software >business, not the manual business. >To be frank I just cannot imagine Wolfram Research not having done >the same. I've no idea whether Wolfram has done as you suppose above or not. It seems to me it might be equally reasonable to assume Wolfram made a decision not to support published documentation. But whether or not Wolfram did as you suppose above, there don't seem to be any third party books out yet that reflect version 6. So, either it takes longer than you expect to create and publish such books, no one started as long ago as you might think or no one feels it worthwhile to create such books. Given the number of books published for previous versions, I don't think the last possibility is credible. That is, I expect there will be books out for version 6 at some point. You simply have to wait. Meanwhile, you have access to the same documentation as everyone else. And while I agree, the online documentation doesn't fill every need I might have for documentation it does provide a list of new functions and sufficient information to allow me to use them. Perhaps, it will be necessary to do more work than you would prefer to get the information you want. But this is nothing more than anyone else has to do at this time. === Subject: Help with Manipulate Details of computations omitted; much too complicated, and irrelevant. After lots of computation, showit calls Graphics3D[{........}]. manip2[xyz_] := Module[{xr}, ptvertS[[5]] = xyz; finlist; sphrAll; allspt; setDisp; showit ] m1 = 100; m2 = {m1,m1,m1}; Manipulate[manip2[xyz], {{xyz, {-22, -92, +47}, V5, XYZ}, -m2, m2}] This works fine (at least some of the time), including the initial value and label. ptvertS[[1]],...,ptvertS[[5]] are each just numerical {x,y,z} coordinates. However the 3-part slider no longer has the little symbol which you can expand to see values and control them. Is there a way to see the values of a list in this situation? Currently I use Epilog to display them. *********************** BUT this one does not work, giving an error message something like indeterminate should be triple of numbers. But as an example, manip3[{11,22,33},{44,55,66}] by itself works. manip3[xyz1_, xyz2_] := Module[{xr}, ptvertS[[1]] = xyz1; ptvertS[[2]] = xyz2; finlist; sphrAll; allspt; setDisp; showit ] m1 = 100; m2 = {m1, m1, m1}; Manipulate[manip3[c1, c2], {c1, -m2, m2}, {c2, -m2, m2}] I will appreciate any help. Steve Gray === Subject: Exact Cover Hello All, Someone can help me with this function? ExactCover[matrix] finds all subsets of rows of the rectangular matrix which have exactly one nonzero element in each column. matr = {{0, 0, 1, 0, 1, 1, 0}, {1, 0, 0, 1, 0, 0, 1}, {0, 1, 1, 0, 0, 1, 0}, {1, 0, 0, 1, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 1}, {0, 0, 0, 1, 1, 0, 1}} ExactCover[matr] {{{1, 4}, {3, 5, 6}, {2, 7}}} Johum, === Subject: Re: Exact Cover > Hello All, > > Someone can help me with this function? > > ExactCover[matrix] > > finds all subsets of rows of the rectangular matrix which have exactly one nonzero element in each column. > > matr = {{0, 0, 1, 0, 1, 1, 0}, > {1, 0, 0, 1, 0, 0, 1}, > {0, 1, 1, 0, 0, 1, 0}, > {1, 0, 0, 1, 0, 0, 0}, > {0, 1, 0, 0, 0, 0, 1}, > {0, 0, 0, 1, 1, 0, 1}} > > ExactCover[matr] > > {{{1, 4}, {3, 5, 6}, {2, 7}}} > You did not say what the question was. If you're looking for an implementation, here's one: http://www.imtek.de/simulation//mathematica/IMSweb/imsTOC/Game%20Theory/Exac tCoverDocu.html === Subject: Re: Complex Plot > Hello Jean-Marc, > In 6.0, we can use ContourPlot for implicit equations, but the timing > seems much slower that what you are getting: > > Timing[cp1 = > ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, 23}];] > (*about 1 second my machine) > > cp1 > > Timing[cp2 = > > ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, > 23},PlotPoints-> 25];] > (*about 3 seconds my machine*) > > cp2 > > Timing[cp3 = > > ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, > 23},PlotPoints-> 50];] > (*about 15 seconds my machine*) > > Timing[cp3 = > > ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, 23}, > PlotPoints -> 75];] > (*about 36 seconds my machine*) > > The estimate is about 1/2 hour on my machine (if no swapping)... > > So, unless your machine is about 6 times faster than mine, the > implicit version is slower... > > However, PlotPoints->50, seems to be sufficient to see the lovely structure. Hi Graig, My machine is about 10% slower than yours, indeed. (I have just ran the test you provided.) The magic in my original code was to use a high number of points but to turn off the adaptive algorithm by setting the option MaxRecursion to zero. For instance, the fourth plot (75 points) took about 40 seconds with the default settings, while it took only 0.75 second with MaxRecursion->0. That explains the huge discrepancy in timing and why I could claim that it took only few minutes for Mathematica to draw the plot with a sampling of 500 points. (Note that the memory consumption is relatively slow too.) Timing[cp1 = ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, MaxRecursion -> 0, PlotPoints -> 25];] (*about 0.04 seconds my machine*) cp1 Timing[cp2 = ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, MaxRecursion -> 0, PlotPoints -> 25];] (*about 0.07 seconds my machine*) cp2 Timing[cp3 = ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, MaxRecursion -> 0, PlotPoints -> 50];] (*about 0.29 seconds my machine*) cp3 Timing[cp4 = ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, MaxRecursion -> 0, PlotPoints -> 75];] (*about 0.73 seconds my machine*) cp4 > > > > > > Can anyone tell me how I can re-express this > > > equation in terms of x for plotting? > > > > > > Sin[x^2*y]==Log[x/y] > > > > > ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > > ImageSize -> 500] > > > > ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > > ImageSize -> 500, ColorFunction -> (White &), ContourStyle -> Black, > > MaxRecursion -> 0, PlotPoints -> 500] > > > > Hope this helps, > > -- Jean-Marc > > > > > > > > -- > W. Craig Carter > -- Jean-Marc === Subject: Re: Complex Plot > >> Can anyone tell me how I can re-express this >> equation in terms of x for plotting? >> >> Sin[x^2*y]==Log[x/y] >> >> last sighted: http://tinyurl.com/3s4hfd > > Hi Chris, > > If you are interested in the graphical representation of this > function, > you may want to use *ContourPlot* and experiment with its various > options. For instance, > > ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > ImageSize -> 500] > > ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > ImageSize -> 500, ColorFunction -> (White &), ContourStyle -> Black, > MaxRecursion -> 0, PlotPoints -> 500] > > You can see the result at > > http://homepages.nyu.edu/~jmg336/mathematica/ > chrisdegnencomplexplot.pdf > > Note that the second plot may take several minutes to complete due to > the huge number of sampling points, but it should be very close to > what > you have seen on the Internet. > > Hope this helps, > -- Jean-Marc > I do not think this gives a realistic plot, due to numerous artifices caused by ContourPlot. Here is one way to get a realistic graph without using ContourPlot. We want to plot the set of solutions to: Sin[x^2*y] == Log[x/y] We first use a substitution: x == t y The equation that we get in terms of y and t can now be completely solved by Mathematica: Reduce[Sin[t^2*y^3] == Log[t], y, Reals] Element[C[1], Integers] && 1/E <= t <= E && (y == Root[-#1^3 - ArcSin[Log[t]]/t^2 + (2*Pi*C[1])/t^2 + Pi/t^2 & , 1] || y == Root[-#1^3 + ArcSin[Log[t]]/t^2 + (2*Pi*C[1])/t^2 & , 1]) We can use Plot to get a graph of this: g = Plot[Evaluate[Flatten[ Table[{Root[ -#1^3 - ArcSin[ Log[t]]/t^2 + (2*Pi*n)/t^2 + Pi/t^2 & , 1], Root[-#1^3 + ArcSin[Log[t]]/ t^2 + (2*Pi*n)/ t^2 & , 1]}, {n, -100, 100}]]], {t, 1/E, E}]; Now we can convert this graph into a graph of the relationship we want: Show[g1 = g /. {t_?NumberQ, y_?NumberQ} -> {t y, y}, AspectRatio -> Automatic, PlotRange -> All] This is rather different from the graph displayed at the link above but quite similar to: Show[ContourPlot[Sin[x^2*y] == Log[x/y], {x, -3, 3}, {y, -3, 3}], Axes -> True] Andrzej Kozlowski === Subject: Re: Complex Plot Hello Jean-Marc, In 6.0, we can use ContourPlot for implicit equations, but the timing seems much slower that what you are getting: Timing[cp1 = ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, 23}];] (*about 1 second my machine) cp1 Timing[cp2 = ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, 23},PlotPoints-> 25];] (*about 3 seconds my machine*) cp2 Timing[cp3 = ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, 23},PlotPoints-> 50];] (*about 15 seconds my machine*) Timing[cp3 = ContourPlot[Sin[x^2*y] == Log[x/y], {x, -12, 35}, {y, -8, 23}, PlotPoints -> 75];] (*about 36 seconds my machine*) The estimate is about 1/2 hour on my machine (if no swapping)... So, unless your machine is about 6 times faster than mine, the implicit version is slower... However, PlotPoints->50, seems to be sufficient to see the lovely structure. Craig > > > Can anyone tell me how I can re-express this > > equation in terms of x for plotting? > > > > Sin[x^2*y]==Log[x/y] > > ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > ImageSize -> 500] > > ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > ImageSize -> 500, ColorFunction -> (White &), ContourStyle -> Black, > MaxRecursion -> 0, PlotPoints -> 500] > Hope this helps, > -- Jean-Marc > > -- W. Craig Carter === Subject: Re: Complex Plot Chris, I think Jean-Marc has what you need if you just use the Contours->{0} option, then it will show you the answer. It is interesting that the larger you make PlotPoints, the more solutions there are. There is probably some sort of relationship to chaotic functions here. The code below takes a while on my reasonably fast machine, Jean-Marc's original code set PlotPoints to 500 and it took a really long time. Kevin Here is a slight mod on Jean-Marc's code: ContourPlot[Sin[x^2 y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, ImageSize -> 500, ContourShading -> None, ContourStyle -> Red, MaxRecursion -> 0, PlotPoints -> 250, Contours -> {0}, FrameLabel -> {x, y}, PlotLabel -> Contours of Sin[!(*SuperscriptBox[x, 2]) y]-Log[!(*FractionBox[x, y])] = 0, BaseStyle -> {FontFamily -> Arial, FontWeight -> Bold, FontSize -> 14}, FrameStyle -> AbsoluteThickness[2]] > Can anyone tell me how I can re-express this >> equation in terms of x for plotting? >> >> Sin[x^2*y]==Log[x/y] >> >> last sighted: http://tinyurl.com/3s4hfd Hi Chris, If you are interested in the graphical representation of this function, > you may want to use *ContourPlot* and experiment with its various > options. For instance, ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > ImageSize -> 500] ContourPlot[Sin[x^2*y] - Log[x/y], {x, -12, 35}, {y, -8, 23}, > ImageSize -> 500, ColorFunction -> (White &), ContourStyle -> Black, > MaxRecursion -> 0, PlotPoints -> 500] You can see the result at http://homepages.nyu.edu/~jmg336/mathematica/chrisdegnencomplexplot.pdf Note that the second plot may take several minutes to complete due to > the huge number of sampling points, but it should be very close to what > you have seen on the Internet. Hope this helps, > -- Jean-Marc > -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: Complex Plot ContourPlot[Sin[x^2*y] == Log[x/y], {x, -4, 4}, {y, -4, 4}, Exclusions -> {y == 0}] Bob Hanlon > Can anyone tell me how I can re-express this > equation in terms of x for plotting? Sin[x^2*y]==Log[x/y] last sighted: http://tinyurl.com/3s4hfd > === Subject: Re: Old Toolbar from 5.2 to 6.0.2 The command is still on the menu, just in a different place: Window > Show Toolbar (It seems to me to be a more logical place to put it than in the old Format menu, but I did have to break an old habit of looking there for it.) This might sound a bit silly, but I really miss the toolbar that > Mathematica 5.2 used to have under the Format > Show Toolbar menu. > Now in current 6.0.2 there doesn't seem to be this simple option. > However, if I open an old Mathematica notebook which was originally > created with 5.2 with a toolbar from within the new 6.0.2, then the > toolbar remains. > Is that the only way to have it? Must I start every notebook in > Mathematica 5.2, assign a toolbar to it, and then open it with > Mathematica 6? Surely not! Can someone help? > Gideon > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Old Toolbar from 5.2 to 6.0.2 >> >> This might sound a bit silly, but I really miss the toolbar that >> Mathematica 5.2 used to have under the Format > Show Toolbar menu. >> Now in current 6.0.2 there doesn't seem to be this simple option. >> However, if I open an old Mathematica notebook which was originally >> created with 5.2 with a toolbar from within the new 6.0.2, then the >> toolbar remains. >> Is that the only way to have it? Must I start every notebook in >> Mathematica 5.2, assign a toolbar to it, and then open it with >> Mathematica 6? Surely not! > > The Show Toolbar and Show Ruler otpions have been moved to the Window m= enu. You can also set the Toolbar to be turned on by default in the OptionsInspector. Under Global Preferences, open up Notebook Options, then Display Options, and set the WindowToolbars to EditBar. It would be nice if this option were in the Preferences, perhaps on the Interface tab. -- Helen Read University of Vermont === Subject: Re: diff equation [resent a more readable form - moderator] I have an differential equation. I can not solve in mathematica. Would you help me, please? dM/d t =D[d^2 M//dr^2 +(2/r) (dM/dr)]-kM Boundary conditions are: 1-) at t=0, M= Mo 2-) r = 0, dM/dr=0 3-) at r = R, M = Ms .85[CapitalYAcute]r.G.9ar. Ali YILDIRIM Gaziantep .86niversitesi Nizip Meslek Y.9fksekokulu Gàda Teknolojisi Programà 27700-Nizip-Gaziantep/T.9frkiye ayildirim@gantep.edu.tr === Subject: Re: diff equation > [resent a more readable form - moderator] > I have an differential equation. I can not solve in mathematica. > Would you help me, please? dM/d t =D[d^2 M//dr^2 +(2/r) (dM/dr)]-kM -----------!!!----!!!! Not sure for what this D stands here. I discarded it in the example below. Also you have a spurious backslash. So you could write your equation as D[M[r, t], t] == D[M[r, t], r, r] + 2/r D[M[r, t], r] - k M[r, t] > Boundary conditions are: 1-) at t=0, M= Mo M[r, 0] == M0 > 2-) r = 0, dM/dr=0 D[M[0, t], t] == 0 > 3-) at r = R, M = Ms M[R, t] == Ms Then you can use DSolve or NDSolve as in DSolve[{D[M[r, t], t] == D[M[r, t], r, r] + 2/r D[M[r, t], r] - k M[r, t], M[r, 0] == M0, D[M[0, t], t] == 0, M[R, t] == Ms}, M, {r, t}] -- Jean-Marc === Subject: Bilateral cell problem w/ Manipulate Although AuthorTools is considered legacy code for Mathematica 6, I've still been using the bilateral cells palette because I don't know of any other better alternative. Although it still works well, I've found that it sometimes breaks ÷ but sometimes not ÷ when using Manipulate, and I don't know why. The following, for example, can be converted into a bilateral cell (assuming that the three cells are suitably inserted into a notebook): (* This is the text on the left. *) Cell[This is an example of Manipulate., MathCaption] (* Put this in an Input cell *) Manipulate[ Graphics[ Raster[ Table[Block[{r = Random[]}, If[r < t, 1 - r, 1]], {100}, {100}] ] ], {t, 0, 1} ] (* Evaluate the above to get the Output cell. *) (* ... *) However, suppose that the object of the Manipulate isn't a simple graphic, but the output of a Plot like the following: (* Put this in an Input cell. *) Manipulate[ Plot[Sin[a x], {x, 0, 2 Pi}], {a, 0, 10} ] If you try to convert that Manipulate into a bilateral cell, you get an error. On my machine (an Intel Mac), I just get a grey rectangle inside the Manipulate construct (in the bilateral cell). If I position the mouse over the grey rectangle, I get the message: This dynamic content could not be displayed because dynamic updating has been disabled in the Evaluation menu. Except, dynamic updating hasn't actually been disabled in the evaluation menu ÷ other dynamic objects can still be manipulated in the notebook. However, if you save the notebook containing the broken bilateral cell, restart Mathematica, and then load the notebook, the bilateral cell works! Any suggestions as to what might be going wrong would be appreciated. I find the cell manipulations performed by MakeBilateralCell a bit mysterious, to say nothing of the magic that happens with Manipulate! Jason Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm === Subject: Re: Bilateral cell problem w/ Manipulate > Although AuthorTools is considered legacy code for Mathematica 6, > I've still been using the bilateral cells palette because I don't know = > of any other better alternative. Although it still works well, I've > found that it sometimes breaks =97 but sometimes not =97 when using > Manipulate, and I don't know why. You might consider trying the new Grid, Row, Column, and GraphicsGrid, GraphicsRow, GraphicsColumn instead of the bilateral cells. -- Helen Read University of Vermont === Subject: Mathematica student certification now available Mathematica Student Certification Now Available Wolfram Research is pleased to announce the Mathematica Student Certification Program to support our student users. Mathematica Student Certification can give student resum.8es the competitive edge needed in many career fields. Many businesses are looking for employees who can solve problems in a quick, efficient manner--which is something Mathematica users can do. Students who want to demonstrate and receive recognition for their Mathematica skills are invited to take the Certification test. More details are available at the Mathematica Student Certification Program: http://www.wolfram.com/services/certification === Subject: Re: Mathematica student certification now available It would be fun for the community to develop a professional version of such a test, with questions taken from this group that show up over and over, year after year. question #1: what does @@@ do? question #2: how to get a high-resolution publication-quality pdf question #3: is Sqrt[] broken? question #4: how do you get Solve[] to product results using litzghoff-weitzerstrauss notation ( trick question ) < your contribution here.. > > Mathematica Student Certification Now Available > > Wolfram Research is pleased to announce the Mathematica Student > Certification Program to support our student users. Mathematica > Student Certification can give student resum=E9s the competitive > edge needed in many career fields. Many businesses are looking > for employees who can solve problems in a quick, efficient > manner--which is something Mathematica users can do. Students who > want to demonstrate and receive recognition for their Mathematica > skills are invited to take the Certification test. > > More details are available at the Mathematica Student > Certification Program: > http://www.wolfram.com/services/certification > > === Subject: Re: Assigning multiple variables within a Block[] statement (e.g. > What I'm trying to do: > I have a list of parameters that I am using across several functions. I am > trying to come up with a good way to avoid copying/pasting these parameter > assignments everywhere. Here is an example code that sort of accomplishes > this goal: (Suppose my parameters are a,b, and c) paramlist = {a -> 1, b -> 4, c -> 8}; > paramlistnames = First /@ paramlist; foobar2[x_] := Block[Evaluate[Flatten[{paramlistnames, {d, e, f}}]], > {a, b, c} = paramlistnames /. paramlist; > {d,e,f} = {1,1,1}; > x*a*b*c*d*e*f > ] The line > {a, b, c} = paramlistnames /. paramlist; > effectively sets a, b, and c to their values, at which point I can proceed > with the rest of the function. Questions: > 1. Is this the most effective way to accomplish the task at hand? If no, > what is? I think you are fooling yourself. Using Block (or Module) mainly serves the purpose of scoping, which doesn't work if you do it this way. To see what I mean evaluate the following: foobar2[5] a=2 foobar2[5] You need to be more careful about evaluation when doing this. One possibility would be: foobar3[x_] := Block @@ Join[ Replace[Hold[Evaluate@Join[ Flatten[ Extract[OwnValues[paramlistnames], {1, 2}, Hold] /. List -> Hold], Hold[d, e, f] ]], Hold -> List, {2}, Heads -> True], Hold[ {a, b, c} = List @@ paramlistnames /. List @@ paramlist; {d, e, f} = {1, 1, 1}; x*a*b*c*d*e*f ] ] As you can note, there is extra effort necessary to avoid early evaluation. Maybe this can be done more elegant than what I have come up with. Note that you need to access the ownvalue of paramlistnames directly to avoid early evaluation of the parameternames and you have to take care to define your parameters before any of their names get any definition. This can be avoided by e.g. wrapping your parameterlist with Hold instead of List, which also can make the later handling easier. However you achieve to avoid early evaluation at the various stages, you might want to define something like: SetAttributes[ParameterBlock, HoldRest] ParameterBlock[params_, {vardefs___}, body_] := Apply[ Block, Join[ Replace[ Hold[Evaluate@Join[params /. Rule -> Set, Hold[vardefs]]], Hold -> List, {2}, Heads -> True ], Hold[body] ] ] which will make possible to define your parameters and functions as e.g.: $parameter = Hold[a -> 1, b -> 4, c -> 8] foobar4[x_] := ParameterBlock[$parameter, {d = 1, e = 1, f}, f = 1; x*a*b*c*d*e*f ] > 2. Note that I still have to explicitly use {a, b, c} = paramlistnames /. > paramlist; something like Hold[paramlistnames] = paramlistnames /. > paramlist; results in an error message. Is there a way to do the assignment > but use the paramlistnames somehow so that I don't have to name the > variables explicitly? the above definition of ParameterBlock solves this, too. If you want to understand what it does it is best to replace the Block with Hold, then you will see the (held) expression which Block is applied to and can check that it basically is what you want (I think you want) it to be... A last remark: you probably should look into how Options work for Mathematica functions, which is the standard way of handling what seems to be part of your problem... hth, albert === Subject: Re: Assigning multiple variables within a Block[] statement (e.g. Hi Leo, For question 2, you could use a line like: Set[Evaluate[paramlistnames], paramlistnames /. paramlist] Good luck! > What I'm trying to do: > I have a list of parameters that I am using across several functions. I am > trying to come up with a good way to avoid copying/pasting these parameter > assignments everywhere. Here is an example code that sort of accomplishes > this goal: (Suppose my parameters are a,b, and c) > > paramlist = {a -> 1, b -> 4, c -> 8}; > paramlistnames = First /@ paramlist; > > foobar2[x_] := Block[Evaluate[Flatten[{paramlistnames, {d, e, f}}]], > {a, b, c} = paramlistnames /. paramlist; > {d,e,f} = {1,1,1}; > x*a*b*c*d*e*f > ] > > The line > {a, b, c} = paramlistnames /. paramlist; > effectively sets a, b, and c to their values, at which point I can proceed > with the rest of the function. > > Questions: > 1. Is this the most effective way to accomplish the task at hand? If no, > what is? > > 2. Note that I still have to explicitly use {a, b, c} = paramlistnames /. > paramlist; something like Hold[paramlistnames] = paramlistnames /. > paramlist; results in an error message. Is there a way to do the assignment > but use the paramlistnames somehow so that I don't have to name the > variables explicitly? > > > --Leo === Subject: Re: Assigning multiple variables within a Block[] statement (e.g. {a,b} = {c,d}) Why not define your functions with the list of parameters? currentparms = {1, 4, 8}; foobar3[parmlist : {_, _, _}][x_] := Module[{a, b, c, d, e, f}, {a, b, c} = parmlist; {d, e, f} = {1, 1, 1}; x a b c d e f] foobar3[currentparms][x] 32 x -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > What I'm trying to do: > I have a list of parameters that I am using across several functions. I > am > trying to come up with a good way to avoid copying/pasting these parameter > assignments everywhere. Here is an example code that sort of accomplishes > this goal: (Suppose my parameters are a,b, and c) > > paramlist = {a -> 1, b -> 4, c -> 8}; > paramlistnames = First /@ paramlist; > > foobar2[x_] := Block[Evaluate[Flatten[{paramlistnames, {d, e, f}}]], > {a, b, c} = paramlistnames /. paramlist; > {d,e,f} = {1,1,1}; > x*a*b*c*d*e*f > ] > > The line > {a, b, c} = paramlistnames /. paramlist; > effectively sets a, b, and c to their values, at which point I can proceed > with the rest of the function. > > Questions: > 1. Is this the most effective way to accomplish the task at hand? If no, > what is? > > 2. Note that I still have to explicitly use {a, b, c} = paramlistnames /. > paramlist; something like Hold[paramlistnames] = paramlistnames /. > paramlist; results in an error message. Is there a way to do the > assignment > but use the paramlistnames somehow so that I don't have to name the > variables explicitly? > > > --Leo > > > === Subject: ExtraAxes for Plot[] maybe this is valuable for some of you. Below you can find a Mathematica Package containing 2 Functions one for additional X-Axes generation and one for Y-Axes. The additional Axes are included in the Epilog of Plot. Plot[......, Epilog -> {..., ExtraXAxes[......], ...} ] Multiple Axes in both directions can be specifyed. Standard Mathematica Axes Options such as TicksStyle or AxesStyle can be used. Below the Package you can find an example (* start of package code *) BeginPackage[ExtraAxes`] {InsertStartPos,InsertEndPos},YInsertPos]<>n<> step TickStep.<>n<> tThe additional Axes is inserted from x: InsertStartPos to InsertEndPos at y: YInsertPos.<>n<> tOptions can be passed e.g. TicksStyle- >Directive[{Blue,Thick}]<>n<> tInclude the additional Axes by means of Epilog->ExtraXAxes[] {InsertStartPos,InsertEndPos},XInsertPos]<>n<> step TickStep.<>n<> tThe additional Axes is inserted from y: InsertStartPos to InsertEndPos at x: XInsertPos.<>n<> tOptions can be passed e.g. TicksStyle- >Directive[{Blue,Thick}]<>n<> tInclude the additional Axes by means of Epilog->ExtraYAxes[] Begin[`Private`] ExtraXAxes[{from_,to_,step_},{xpos_,xend_},ypos_,opts_:{}]:= Graphics[{},AspectRatio->Full,ImagePadding->0,Axes- >{True,False},Sequence@opts, PlotRange->{{from-1/2 step,to+1/2 step},0{-1,1}},Ticks->{Table[i, {i,from,to,step}],None}]//Inset[#,{xpos,ypos},{from,0},((step (xend- xpos))/(to-from)+xend-xpos){1,1}]& ExtraYAxes[{from_,to_,step_},{ypos_,yend_},xpos_,opts_:{}]:= Graphics[{},AspectRatio->Full,ImagePadding->0,Axes- >{False,True},Sequence@opts, PlotRange->{0{-1,1},{from-1/2 step,to+1/2 step}},Ticks->{None,Table[i, {i,from,to,step}]}]//Inset[#,{xpos,ypos},{0,from},((step (yend-ypos))/ (to-from)+yend-ypos){1,1}]& End[] EndPackage[] (* start sample test code *) Plot[{Sin[x],2+Cos[x]},{x,0[Pi],3[Pi]},ImageSize->600,PlotRange- >All,PlotStyle->{Black,Blue}, Epilog->{ExtraXAxes[{1/2[Pi],3/2[Pi],[Pi]/8},{1/2[Pi],3/2[Pi]}, 2,TicksStyle->Directive[Darker@Magenta,Italic, Bold]],ExtraYAxes[{-150,350,50},{-1.5,3.5},8,{TicksStyle- >Directive[Blue,Large],AxesStyle->Directive[Orange,Thick]}]}] === Subject: Convert funcion Hello Group, Someone could help me with this function? fConver[cmatrix], this function will find all subsets of rows of the rectangular matrix which have exactly one nonzero element in each column. For example: cmatrix=({{0,0,1,0,1,1,0},{1,0,0,1,0,0,1},{0,1,1,0,0,1,0}, {1,0,0,1,0,0,0},{0,1,0,0,0,0,1},{0,0,0,1,1,0,1}}); fConvert[cmatrix] the out put will be {{{1,4},{3,5,6},{2,7}}} Johum, === Subject: Re: Convert funcion > > Hello Jean-Marc, > > Yes, I am try to solve the Latin Square Puzzle problem, therefore I need > this function. Do you know how to implement this function?. > > > Johum S. > > Since you seem to have taken your example from the documentation of > the Imtek`ExactCover` function, available at > > http://www.imtek.de/simulation//mathematica/IMSweb/imsTOC/Game%20Theory/Exact CoverDocu.html > > it is not clear why you would not use it as it is? Dis you try it? Did > you face any difficulty or get any erroneous results? What would you do > with such a function? Perhaps solving the Latin Square Puzzle or the > Height Queens Puzzle? I do not know (and I do not bother to know) how to write such a function since the function has already been implemented (nicely) in the IMS (IMTEK Mathematica Supplement) package, which is an *open source* package. *Open source* means that the source code is available free of charge. Therefore, if I were you, I would download the IMS package, install it on my machine, then I would play around with the function *ExactCover* to get acquainted with it (the documentation have some examples about Latin squares) and I would look at its code (which is provided with package) if I wish. The IMS main web page contains links to the download area as well as directions to install the package. http://www.imtek.uni-freiburg.de/simulation/mathematica/IMSweb/ -- Jean-Marc === Subject: Re: Convert funcion > Someone could help me with this function? fConver[cmatrix], this function will find all subsets of rows of the rectangular matrix which have exactly one nonzero element in each column. For example: cmatrix=({{0,0,1,0,1,1,0},{1,0,0,1,0,0,1},{0,1,1,0,0,1,0}, > {1,0,0,1,0,0,0},{0,1,0,0,0,0,1},{0,0,0,1,1,0,1}}); > fConvert[cmatrix] the out put will be > {{{1,4},{3,5,6},{2,7}}} Since you seem to have taken your example from the documentation of the Imtek`ExactCover` function, available at http://www.imtek.de/simulation//mathematica/IMSweb/imsTOC/Game%20Theory/Exac tCoverDocu.html it is not clear why you would not use it as it is? Dis you try it? Did you face any difficulty or get any erroneous results? What would you do with such a function? Perhaps solving the Latin Square Puzzle or the Height Queens Puzzle? -- Jean-Marc === Subject: Inverse of symbolic matrix The expressions a and b below seem reasonable. However when I assemble them into a matrix and take the inverse I get the message Inverse::sing :Matrix...is singular. However the determinant seems fine. If I rationalize the matrix and then take its inverse then everything seems fine and I can almost get the unit matrix by multiplying back onto the original matrix. Is there a problem with approximate numbers in symbolic matrices? Is this a bug? Is Rationalize the best method for working around this problem? Hugh Goyder a = -((4.739*^-6 - 0.0008*I)/((0.0122 + 1.544*I) + s)) - (4.7395*^-6 + 0.00088*I)/ ((0.0122 - 1.544*I) + s); b = -((0.000015 - 0.00022*I)/((0.0122 + 1.544*I) + s)) - (0.000015 + 0.000226*I)/ ((0.0122 - 1.544*I) + s); mat = {{a, 0}, {0, b}}; Inverse[mat] Det[mat] matr = Rationalize[mat, 0]; inv = Inverse[matr] Rationalize[Factor[Together[mat . inv]], 1.*^-8] === Subject: Re: Inverse of symbolic matrix > The expressions a and b below seem reasonable. However when I assemble > them into a matrix and take the inverse I get the message > Inverse::sing :Matrix...is singular. However the determinant seems > fine. If I rationalize the matrix and then take its inverse then > everything seems fine and I can almost get the unit matrix by > multiplying back onto the original matrix. Is there a problem with > approximate numbers in symbolic matrices? The issue is whenever you mix machine-size numbers with symbolic or exact arithmetic entries, the machine-size numbers poison the symbolic/exact matrix, which is not symbolic anymore. So 1.0 is not the same as 1 w.r.t. the accuracy of each entry and the numeric stability that result of different algorithms in use with each computational model. > Is this a bug? No. > Is Rationalize the best method for working around this problem? Rationalize as early as possible (see below). Note the given matrix is not invertible for s == -0.0122 - 1.544 I or s == -0.0122 + 1.544 I > Hugh Goyder a = -((4.739*^-6 - 0.0008*I)/((0.0122 + 1.544*I) + > s)) - (4.7395*^-6 + 0.00088*I)/ > ((0.0122 - 1.544*I) + s); b = -((0.000015 - 0.00022*I)/((0.0122 + 1.544*I) + > s)) - (0.000015 + 0.000226*I)/ > ((0.0122 - 1.544*I) + s); mat = {{a, 0}, {0, b}}; Inverse[mat] Det[mat] matr = Rationalize[mat, 0]; inv = Inverse[matr] Rationalize[Factor[Together[mat . inv]], 1.*^-8] Here is an example of how to deal with your matrix so exact arithmetic is use all along the computations. In[1]:= a = Simplify[ Map[Rationalize[#, 0] &, -((4.739*^-6 - 0.0008*I)/((0.0122 + 1.544*I) + s)) - (4.7395*^-6 + 0.00088*I)/((0.0122 - 1.544*I) + s), Infinity]] b = Simplify[ Map[Rationalize[#, 0] &, -((0.000015 - 0.00022*I)/((0.0122 + 1.544*I) + s)) - (0.000015 + 0.000226*I)/((0.0122 - 1.544*I) + s), Infinity]] mat = {{a, 0}, {0, b}} inv = Inverse[mat] Factor[Together[mat.inv]] Reduce[Denominator[Simplify[Det[mat]]] == 0] % // N Out[1]= (-25938043623 + 9767720 I) + (94785000 + 800000000 I) s -(-------------------------------------------------------) 2 400000 (59602121 + 610000 s + 25000000 s ) Out[2]= (-1720645 + 183 I) + (75000 + 15000 I) s -(----------------------------------------) 2 100 (59602121 + 610000 s + 25000000 s ) Out[3]= (-25938043623 + 9767720 I) + (94785000 + 800000000 I) s {{-(-------------------------------------------------------), 0}, 2 400000 (59602121 + 610000 s + 25000000 s ) (-1720645 + 183 I) + (75000 + 15000 I) s {0, -(----------------------------------------)}} 2 100 (59602121 + 610000 s + 25000000 s ) Out[4]= 2 400000 (59602121 + 610000 s + 25000000 s ) {{-(-------------------------------------------------------), 0}, (-25938043623 + 9767720 I) + (94785000 + 800000000 I) s 2 100 (59602121 + 610000 s + 25000000 s ) {0, -(----------------------------------------)}} (-1720645 + 183 I) + (75000 + 15000 I) s Out[5]= {{1, 0}, {0, 1}} Out[6]= 61 193 I 61 193 I s == -(----) - ----- || s == -(----) + ----- 5000 125 5000 125 Out[7]= s == -0.0122 - 1.544 I || s == -0.0122 + 1.544 I -- Jean-Marc === Subject: Re: For help about NSolve Hello xxhai, It does give a solution (perhaps not unique), but not a very interesting one: ode = D[y[x], {x, 2}] + y[x] (1 + D[y[x], x]^(3/2)) nsol = NDSolve[{ode == 0, y[0] == 0, y[1] == 0}, y[x], x] Plot[y[x] /. nsol, {x, 0, 1}] Table[y[x] /. nsol, {x, 0, 1, .1}] However ode = D[y[x], {x, 2}] + y[x] (1 + D[y[x], x]^(3/2)) nsol = NDSolve[{ode == 0, y[0] == 0, y[1] == 1}, y[x], x] Plot[y[x] /. nsol, {x, 0, 1}] is more interesting---perhaps the question is in regard to your boundary conditions? If not, take a look at the option Method and the final example in NDSolve (6.0 Documentation) Best Wishes, Craig > Differential Equation: > y[x]''+y[x]*{(1+y[x]'^2)}^(3/2)=0 > > aboundery condition: y[0]=0, y[1]=0 > > For Numerical Solution ? > > why Mathematica can't solve the Equation with the initial condition ? > > please give the correct program for differential equation. > > > thank you a lot. > > > -- W. Craig Carter === Subject: For help about NSolve Differential Equation: y[x]''+y[x]*{(1+y[x]'^2)}^(3/2)=0 aboundery condition: y[0]=0, y[1]=0 For Numerical Solution ? why Mathematica can't solve the Equation with the initial condition ? please give the correct program for differential equation. thank you a lot. === Subject: Re: For help about NSolve > Differential Equation: > y[x]''+y[x]*{(1+y[x]'^2)}^(3/2)=0 aboundery condition: y[0]=0, y[1]=0 For Numerical Solution ? why Mathematica can't solve the Equation with the initial condition ? please give the correct program for differential equation. > thank you a lot. (* Here is an example of how to use NDSolve and its result *) nsol = NDSolve[{y''[x] + y[x]*((1 + y'[x]^2))^(3/2) == 2, y[0] == 0, y[1] == 0}, y, {x, 0, 1}] Plot[y[x] /. nsol[[1]], {x, 0, 1}] Table[y[x] /. nsol[[1]], {x, 0, 1, 0.1}] (* As given, your original equation has y(x) = 0 as solution *) nsol = NDSolve[{y''[x] + y[x]*((1 + y'[x]^2))^(3/2) == 0, y[0] == 0, y[1] == 0}, y, {x, 0, 1}] Plot[y[x] /. nsol[[1]], {x, 0, 1}] Table[y[x] /. nsol[[1]], {x, 0, 1, 0.1}] -- Jean-Marc === Subject: Re: For help about NSolve 2008/5/2 wtpdrj <45417003@163.com>: > > > This is the result. > > > why ? [Cross-posted to comp.soft-sys.math.mathematica aka MathGroup] ode = y''[x] + y[x]*(1 + y'[x])^(3/2) nsol = NDSolve[{ode == 0, y[0] == 0, y[1] == 0}, y, {x, 0, 1}] Plot[y[x] /. nsol[[1]], {x, 0, 1}] Table[y[x] /. nsol[[1]], {x, 0, 1, 0.1}] Works fine on my system. $Version 6.0 for Mac OS X x86 (64-bit) (February 7, 2008) See http://homepages.nyu.edu/~jmg336/mathematica/helpaboutndsolve.pdf I suspect that you are using a version prior 6.0 and that NDSolve has been improved meanwhile. > > .8c[Thorn]¬2008-05-01.95.b9ÔJean-Marc Gulliet .8cºú.8eªã.95.b9û > > > > > Differential Equation: > y[x]''+y[x]*{(1+y[x]'^2)}^(3/2)=0 > > aboundery condition: y[0]=0, y[1]=0 > > For Numerical Solution ? > > why Mathematica can't solve the Equation with the initial condition ? > > please give the correct program for differential equation. > > > thank you a lot. > > (* Here is an example of how to use NDSolve and its result *) > nsol = NDSolve[{y''[x] + y[x]*((1 + y'[x]^2))^(3/2) == 2, y[0] == 0, > y[1] == 0}, y, {x, 0, 1}] > Plot[y[x] /. nsol[[1]], {x, 0, 1}] > Table[y[x] /. nsol[[1]], {x, 0, 1, 0.1}] > > (* As given, your original equation has y(x) = 0 as solution *) > nsol = NDSolve[{y''[x] + y[x]*((1 + y'[x]^2))^(3/2) == 0, y[0] == 0, > y[1] == 0}, y, {x, 0, 1}] > Plot[y[x] /. nsol[[1]], {x, 0, 1}] > Table[y[x] /. nsol[[1]], {x, 0, 1, 0.1}] > > -- Jean-Marc > > -- Jean-Marc === Subject: Locator Hi Everyone, Very recently I started using Mathematica with the hopes of accomplishing the following. I have had some progress by using extensively the documentation center, however, any help will be really appreciated. I have 2 questions in particular and have described them below: I have created 3 notebooks with the following command: lst = Table[ NotebookCreate[WindowSize -> {240, 240}, WindowTitle -> new, WindowMargins -> {{RandomInteger[{0, 100}], Automatic}, { Automatic, RandomInteger[{0, 50}]}}], {3}]; newlst=Map[WindowMargins /. Options@# &, Select[Notebooks[], StringMatchQ[(WindowTitle /. NotebookInformation[#]), new] &]] I then retrieve the notebook locations for the 3 notebooks. coord = Map[({#[[1, 1]], #[[2, 2]] }) &, newlst] Finally, I want to create locators for each of the above notebooks, such that when I move the locators the notebooks are moved. In other words, the {x,y} position of the locators is mapped to the WindowMargins of that particular notebook. I have successfully created the locators but I have no clue how to map the locators such that the notebooks are moved. Below is the code for it: DynamicModule[{pt = new1}, LocatorPane[Dynamic[pt], Dynamic@ ListPlot[pt, AxesOrigin -> {0, 0}, PlotRange -> {{0, 100}, {0, 50}}]]] I can move the locators, but with the moving of locators I need to the move corresponding notebook. Any help would be of great help Ekta === Subject: plot a function I have X=f(Y) (i know the analytical form, but this isn't easy to invert) how do i plot Plot[ Y, {x, xmin, xmax} ] === Subject: Re: plot a function > I have > > X=f(Y) (i know the analytical form, but this isn't easy to > invert) > > how do i plot > > Plot[ Y, {x, xmin, xmax} ] ParametricPlot[{f[y], y}, {y, ymin, ymax}] You will have to figure out ymin and ymax on your own, but that should be easy using Solve/NSolve. === Subject: list of dates I have a list of dates in the format YYYY-MM-DD and I want to convert them to a decimal value, so 1963-01-01 goes to 63.0 and 1985-07-01 goes roughly to 85.5. Any suggestions on the best way to do this? Roger === Subject: Re: list of dates > I have a list of dates in the format YYYY-MM-DD and I want to convert them > to a decimal value, so 1963-01-01 goes to 63.0 and 1985-07-01 goes roughly > to 85.5. Any suggestions on the best way to do this? It is not possible to do this in a precise way because years don't pass linearly. Leap years are longer than non-leap years. So we have to make a compromise: if y1, y2, y3, and y4 are the floating point numbers you use to represent dates, it will either not be true that if (y2-y1) == (y4 - y3) then the time interval between y1 and y2 has the same length as the interval between y3 and y4; or the date 19AB-01-01 might not be converted to the exact integer AB. dateToFloat[date_String] := dateToFloat[1963-01-01] 62.9997 dateToFloat[1985-07-01] 85.4972 If you use different anchors than 1900-01-01 and 2000-01-01, then you'll get slightly different results. I hope this helps, Szabolcs === Subject: Re: list of dates > I have a list of dates in the format YYYY-MM-DD and I want to convert them > to a decimal value, so 1963-01-01 goes to 63.0 and 1985-07-01 goes roughly > to 85.5. Any suggestions on the best way to do this? To help you started, the following function assume an input date as a string and that a year as 360 days (i.e. 12 months of 30 days). yy = yy - 1900; td = 30 (mm - 1) + dd; yy + Rescale[td, {1, 360}] // N ] Out[79]= 63. Out[80]= 85.5014 -- Jean-Marc === Subject: DSolve Issues I am solving the following Differential Equation Phi''[r]+2*r^(-1)Phi'[r]+0.104479*Phi[r]==0 and Phi[0]==K (some constant) ; kinda has a cos/sin solution 2.71828^(-0.323232 [ImaginaryI] r) ((0.+ 0. [ImaginaryI]) + (0.+ 0. [ImaginaryI]) 2.71828^( 0.646465 [ImaginaryI] r) + (0.+ 1.54687 [ImaginaryI]) K - (0.+ 1.54687 [ImaginaryI]) 2.71828^(0.646465 [ImaginaryI] r) K) all divided by r. My problem is that Mathematica is not treating those zeros.... as well zeros. Thus, the solution cannot really be used. In fact, if I manually reproduce the solution and remove those zeros, then the solution is fine. I have another similar ODE Anyone have any ideas. Phi''[r]+2*r^(-1)Phi'[r]- 287.31*Phi[r]==0 and Phi[3R]==0(some constant) ; kinda has a cosh/sinh solution As you might have notice I need to match these two solutions and their derivatives at some point. The ratio of which gives me what I desire the value of R. Yet, Mathematica treats those zeros as something else. === Subject: Wolfram Workbench user experiences I would be very interested in other people's experiences with the Wolfram Workbench. I must admit that I prefer to use the frontend as my 'IDE', and the workbench seemed fairly alien when I tried it. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: partial differential equation of diffusion > > > > > When I was clear my equation, the resulting one is bellow. > > > dM/d t =a[d^2 M//dr^2 +(2/r) (dM/dr)]-kM > The differentials are partial differentials. > a and k are constants. > > >Could you write now, please? [Note that it is better to ask/post questions directly to MathGroup rather than to send it to a specific person.] Do you mean that you do not know how to multiply expressions with Mathematica? If this is the case you should familiarize yourself with the basis of Mathematica syntax, this will really help you and be a time saver in the future. D[M[r, t], t] == a*(D[M[r, t], r, r] + (2/r)*D[M[r, t], r]) - k*M[r, t] > > > ÌöÄÄr.GÌ.a6r. Ali YILDIRIM > Gaziantep Ì[Thorn]niversitesi > Nizip Meslek YÌ.b9ksekokulu > Gıda Teknolojisi Programı > 27700-Nizip-Gaziantep/TÌ.b9rkiye > ayildirim@gantep.edu.tr > -----------!!!----!!!! > Not sure for what this D stands here. I discarded it in the example > below. Also you have a spurious backslash. So you could write your > equation as > > D[M[r, t], t] == D[M[r, t], r, r] + 2/r D[M[r, t], r] - k M[r, t] > >> Boundary conditions are: >> >> 1-) at t=0, M= Mo > > M[r, 0] == M0 > >> 2-) r = 0, dM/dr=0 > > D[M[0, t], t] == 0 > >> 3-) at r = R, M = Ms > > M[R, t] == Ms > > Then you can use DSolve or NDSolve as in > > DSolve[{D[M[r, t], t] == > D[M[r, t], r, r] + 2/r D[M[r, t], r] - k M[r, t], M[r, 0] == M0, > D[M[0, t], t] == 0, M[R, t] == Ms}, M, {r, t}] > > > > -- Jean-Marc === Subject: Axes at the origin, for 3D plots/graphs Does anyone know of a way to move the axes from the outside of the box and have it centered at the origin instead? I know you can draw lines using the graphics function to do this but it looks bad. I am looking for something similar to how you can move the axes using AxisOrigin for 2D plots. === Subject: Re: function to check if array is empty Your array is hardly empty: it's full of zeros! If what you want to do is test to see whether every entry is 0, the following will do it: And @@ Thread[0 == Flatten @ X] ] this probably already exists, but I can't find it anywhere: is there a function that will check if an array is empty? i'm looking for a function to return either True (or 1), or False (or 0) when it checks an array. eg: X = Array[0 &, {3, 3}] then test with function (called ArrayEmpty, for example) In: ArrayEmpty[X] Out: True best wishes, Will > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: function to check if array is empty Will, a null row is a list of one or more 0's {(0)..} and a null matrix is a list of one or more null rows {{(0)..}..}, so In[4]:= MatchQ[X, {{(0) ..} ..}] Out[4]= True and ArrayEmpty=MatchQ[#, {{(0) ..} ..}]& If you want to match both exact and approximate 0's replace (0).. with (0|0.).. Adriano Pascoletti > > this probably already exists, but I can't find it anywhere: > > is there a function that will check if an array is empty? > > i'm looking for a function to return either True (or 1), or False (or 0) > when it checks an array. eg: > > X = Array[0 &, {3, 3}] > > then test with function (called ArrayEmpty, for example) > > In: ArrayEmpty[X] > > Out: True > > best wishes, > > Will > > === Subject: function to check if array is empty this probably already exists, but I can't find it anywhere: is there a function that will check if an array is empty? i'm looking for a function to return either True (or 1), or False (or 0) when it checks an array. eg: X = Array[0 &, {3, 3}] then test with function (called ArrayEmpty, for example) In: ArrayEmpty[X] Out: True best wishes, Will === Subject: Re: function to check if array is empty > is there a function that will check if an array is empty? i'm looking for a function to return either True (or 1), or False (or 0) when it checks an array. eg: X = Array[0 &, {3, 3}] then test with function (called ArrayEmpty, for example) In: ArrayEmpty[X] Out: True If you deal only with m x n rectangular arrays (matrices) you could use ArrayEmptyQ[arr_List] := MatrixQ[arr, (# == 0 &)] A more general function would be ArrayEmptyQ[arr_List] := If[Count[arr, x_ /; x != 0, -1] != 0, False, True] For instance, X = Array[0 &, {3, 3}] ArrayEmptyQ[arr_List] := MatrixQ[arr, (# == 0 &)] ArrayEmptyQ[X] X[[1, 2]] = 1; X ArrayEmptyQ[X] {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} True {{0, 1, 0}, {0, 0, 0}, {0, 0, 0}} False -- Jean-Marc === Subject: Re: Transforming a polynomial into a trigonometric format tia sal2 I think what you want is this function: Chebyshev[f_, x_] := With[{n = Exponent[f, x]}, Sum[a[i]*Cos[i ArcCos[x]], {i, 0, n}] /. SolveAlways[f == Sum[a[i]*ChebyshevT[i, x], {i, 0, n}], x][[1]]] So now, for example: Chebyshev[21 - 10*x + x^2, x] -10*x + (1/2)*Cos[2*ArcCos[x]] + 43/2 TrigExpand[%] x^2 - 10*x + 21 Chebyshev[21 - 10*x + x^2 + 3*x^3, x] -((31*x)/4) + (1/2)*Cos[2*ArcCos[x]] + (3/4)*Cos[3*ArcCos[x]] + 43/2 and so on. Andrzej Kozlowski > I'm sorry if I didn't explain myself better I hope this clarifies it > better > > when I test for x =3 x= 7 for equation: > 21 - 10 x + x^2 I get zero for both answers > > I used another math program using the ChebyshevT command and I > got this > 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x I tested with x=3 and x=7 and I > also got zero for both > > but when I do a TrigReduce > > In[148] := 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce > > I get > > Out[149]:= 1/2 (43 - 20 Cos[x] + Cos[2 x]) > x=3 gives me 31.88 > x=7 gives me 14.0293 > > I would like to use the ChebyshevT in mathematica 6 because I prefer > that software but I'm not sure > how to get the 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x answer in > mathematica 6 > > Am I doing something wrong with the TrigReduce function or leaving a > part out why are the answers not even close? > > tia sal2 > >> Transforming a polynomial into a trigonometric format tiasal2 >> >> >> I'm using mathematica 6 and I have a polynomial and would like to >> convert it into >> a Trigonometric format. Is this possible? >> >> Example: >> I have a polynomial >> 0.00154991- 4.01371 x + 1.81197 x^2 + 8.00183 x^3 - 9.3462 x^4 >> >> How can I transform this into a trigonometric format >> Example: >> 0.00596679 Cos[6.98132 x] + 0.00358397 Cos[7.21403 x] + >> 2.25013 Sin[0.232711 x] - 4.51511 Sin[0.465421 x] >> >> Note: these aren't correct answers I just wanted to include and >> example >> >> tiasa > === Subject: Re: Transforming a polynomial into a trigonometric format tia sal2 Actually the TrigReduce approach I posted does the same thing, one just has to substitute ArcCos[x] for the y variable. Here's a complete function: chebyshev2[f_, x_] := Module[{y}, Expand@TrigReduce[f /. x -> Cos[y]] /. y -> ArcCos[x]] (Applying Expand is not really necessary. In this case it ensures that chebyshev[] will give the result in the same form as Chebyshev[].) Szabolcs > It is slightly better to localize the symbol a: > > Chebyshev[f_, x_] := > Module[{a, n = Exponent[f, x]}, > > Sum[a[i]*Cos[i ArcCos[x]], {i, 0, n}] /. > SolveAlways[f == Sum[a[i]*ChebyshevT[i, x], {i, 0, n}], x][[1]]] > > Andrzej Kozlowski > > > > > > I think what you want is this function: > > > Chebyshev[f_, x_] := > With[{n = Exponent[f, x]}, > Sum[a[i]*Cos[i ArcCos[x]], {i, 0, n}] /. > SolveAlways[f == Sum[a[i]*ChebyshevT[i, x], {i, 0, n}], x][[1]]] > > So now, for example: > > Chebyshev[21 - 10*x + x^2, x] > -10*x + (1/2)*Cos[2*ArcCos[x]] + 43/2 > > TrigExpand[%] > x^2 - 10*x + 21 > > Chebyshev[21 - 10*x + x^2 + 3*x^3, x] > -((31*x)/4) + (1/2)*Cos[2*ArcCos[x]] + (3/4)*Cos[3*ArcCos[x]] + 43/2 > > > and so on. > > Andrzej Kozlowski > > > > > I'm sorry if I didn't explain myself better I hope this clarifies it > better > > when I test for x =3 x= 7 for equation: > 21 - 10 x + x^2 I get zero for both answers > > I used another math program using the ChebyshevT command and I > got this > 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x I tested with x=3 and x=7 and I > also got zero for both > > but when I do a TrigReduce > > In[148] := 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce > > I get > > Out[149]:= 1/2 (43 - 20 Cos[x] + Cos[2 x]) > x=3 gives me 31.88 > x=7 gives me 14.0293 > > I would like to use the ChebyshevT in mathematica 6 because I prefer > that software but I'm not sure > how to get the 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x answer in > mathematica 6 > > Am I doing something wrong with the TrigReduce function or leaving a > part out why are the answers not even close? > > tia sal2 > > > Transforming a polynomial into a trigonometric format tiasal2 > > > I'm using mathematica 6 and I have a polynomial and would like to > convert it into > a Trigonometric format. Is this possible? > > Example: > I have a polynomial > 0.00154991- 4.01371 x + 1.81197 x^2 + 8.00183 x^3 - 9.3462 x^4 > > How can I transform this into a trigonometric format > Example: > 0.00596679 Cos[6.98132 x] + 0.00358397 Cos[7.21403 x] + > 2.25013 Sin[0.232711 x] - 4.51511 Sin[0.465421 x] > > Note: these aren't correct answers I just wanted to include and > example > > tiasa > > > > > > > === Subject: Re: Transforming a polynomial into a trigonometric format tia sal2 It is slightly better to localize the symbol a: Chebyshev[f_, x_] := Module[{a, n = Exponent[f, x]}, Sum[a[i]*Cos[i ArcCos[x]], {i, 0, n}] /. SolveAlways[f == Sum[a[i]*ChebyshevT[i, x], {i, 0, n}], x][[1]]] Andrzej Kozlowski > I think what you want is this function: > > > Chebyshev[f_, x_] := > With[{n = Exponent[f, x]}, > Sum[a[i]*Cos[i ArcCos[x]], {i, 0, n}] /. > SolveAlways[f == Sum[a[i]*ChebyshevT[i, x], {i, 0, n}], x][[1]]] > > So now, for example: > > Chebyshev[21 - 10*x + x^2, x] > -10*x + (1/2)*Cos[2*ArcCos[x]] + 43/2 > > TrigExpand[%] > x^2 - 10*x + 21 > > Chebyshev[21 - 10*x + x^2 + 3*x^3, x] > -((31*x)/4) + (1/2)*Cos[2*ArcCos[x]] + (3/4)*Cos[3*ArcCos[x]] + 43/2 > > > and so on. > > Andrzej Kozlowski > > > >> I'm sorry if I didn't explain myself better I hope this clarifies it >> better >> >> when I test for x =3 x= 7 for equation: >> 21 - 10 x + x^2 I get zero for both answers >> >> I used another math program using the ChebyshevT command and I >> got this >> 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x I tested with x=3 and x=7 and I >> also got zero for both >> >> but when I do a TrigReduce >> >> In[148] := 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce >> >> I get >> >> Out[149]:= 1/2 (43 - 20 Cos[x] + Cos[2 x]) >> x=3 gives me 31.88 >> x=7 gives me 14.0293 >> >> I would like to use the ChebyshevT in mathematica 6 because I prefer >> that software but I'm not sure >> how to get the 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x answer in >> mathematica 6 >> >> Am I doing something wrong with the TrigReduce function or leaving a >> part out why are the answers not even close? >> >> tia sal2 >> > Transforming a polynomial into a trigonometric format tiasal2 > > > I'm using mathematica 6 and I have a polynomial and would like to > convert it into > a Trigonometric format. Is this possible? > > Example: > I have a polynomial > 0.00154991- 4.01371 x + 1.81197 x^2 + 8.00183 x^3 - 9.3462 x^4 > > How can I transform this into a trigonometric format > Example: > 0.00596679 Cos[6.98132 x] + 0.00358397 Cos[7.21403 x] + > 2.25013 Sin[0.232711 x] - 4.51511 Sin[0.465421 x] > > Note: these aren't correct answers I just wanted to include and > example > > tiasa >> > === Subject: Re: Transforming a polynomial into a trigonometric format tia sal2 I'm sorry if I didn't explain myself better I hope this clarifies it better when I test for x =3 x= 7 for equation: 21 - 10 x + x^2 I get zero for both answers I used another math program using the ChebyshevT command and I got this 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x I tested with x=3 and x=7 and I also got zero for both but when I do a TrigReduce In[148] := 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce I get Out[149]:= 1/2 (43 - 20 Cos[x] + Cos[2 x]) x=3 gives me 31.88 x=7 gives me 14.0293 I would like to use the ChebyshevT in mathematica 6 because I prefer that software but I'm not sure how to get the 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x answer in mathematica 6 Am I doing something wrong with the TrigReduce function or leaving a part out why are the answers not even close? tia sal2 > Transforming a polynomial into a trigonometric format tiasal2 > > > I'm using mathematica 6 and I have a polynomial and would like to > convert it into > a Trigonometric format. Is this possible? > > Example: > I have a polynomial > 0.00154991- 4.01371 x + 1.81197 x^2 + 8.00183 x^3 - 9.3462 x^4 > > How can I transform this into a trigonometric format > Example: > 0.00596679 Cos[6.98132 x] + 0.00358397 Cos[7.21403 x] + > 2.25013 Sin[0.232711 x] - 4.51511 Sin[0.465421 x] > > Note: these aren't correct answers I just wanted to include and > example > > tiasa === Subject: Re: Transforming a polynomial into a trigonometric format tia sal2 > I'm sorry if I didn't explain myself better I hope this clarifies it > better when I test for x =3 x= 7 for equation: > 21 - 10 x + x^2 I get zero for both answers I used another math program using the ChebyshevT command and I > got this > 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x I tested with x=3 and x=7 and I > also got zero for both but when I do a TrigReduce In[148] := 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce I get Out[149]:= 1/2 (43 - 20 Cos[x] + Cos[2 x]) > x=3 gives me 31.88 > x=7 gives me 14.0293 I would like to use the ChebyshevT in mathematica 6 because I prefer > that software but I'm not sure > how to get the 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x answer in > mathematica 6 Am I doing something wrong with the TrigReduce function or leaving a > part out why are the answers not even close? The function you obtain by the replacement rule x -> cos[y] (Note that whether TrigReduce is applied or not does not change the overall result) is equivalent neither to the original polynomial nor to the Chebyshev polynomial. Below, you can easily see that the graph of the original polynomial p[x] intersects the graph of the approximation tt[x] only in two points. Note that former is a quadratic whereas the latter is a sinusoid! So the transformation does not work. In[1]:= p[x_] = 21 - 10 x + x^2 t[x_] = 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x // Simplify tt[x_] = (21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce) /. y -> x Plot[{p[x], t[x], tt[x]}, {x, -10, 10}, PlotStyle -> {Red, Blue, Orange}] FindRoot[p[x] == tt[x], {x, 1}] FindRoot[p[x] == tt[x], {x, 10}] Out[1]= 2 21 - 10 x + x Out[2]= 1 - (43 - 20 x + Cos[2 ArcCos[x]]) 2 Out[3]= 1 - (43 - 20 Cos[x] + Cos[2 x]) 2 Out[4]= [... plot deleted ...] Out[5]= {x -> 0.739085} Out[6]= {x -> 10.487} -- Jean-Marc === Subject: Re: Does Mathematica really need more printed, To quote from a related thread: You and I, I'm afraid, just think differently. ;-) To my mind, all software manuals are boring. Why I find them so, it would take too long to tell, but the reason is somewhat similar to why I find all mathematics books authored by the notorious Bourbaki terribly boring. Wolfram's giant book was perhaps the most boring of them all (except, to some extent, the first edition, which I still have, both because Mathematica was brand new then and because it revealed some interesting information that can't be found in later editions). It was so boring that trying to read it even for 5 minutes would cause me immediately to go and make a cup of coffee or find some more urgent engagement. The result is that I have never read any of it, so its many editions must count as the worst space-time wasters in my possession. On the other hand I read lots of interesting books about Mathematica, beginning, I think, with Roman Maeder's Programming in Mathematica (of which I own three versions) and ending with Michael Trott's excellent Guide Books. Wolfram's book only began to be useful for me when it appeared as part of Mathematica's on-line documentation, and in this form it has almost made up for all the waste of time and space caused by the appalling paper edition. So, for myself, I can only say (to the paper edition) good riddance. Andrzej Kozlowski > Ideally you want a book *and* the interactive help pages side by > side. In > some circumstances there just is no substitute for the printed word. > Paper > is far easier to read [ sorry, but it just is ] . They should never > have > done away with Wolfram's printed manual - it was superb. > P Lindsay > >> >> Each Mathematica 6 Documentation Center page is a Mathematica >> notebook, >> and when it appears it includes the usual control for magnifying >> everything, up to 300%. Surely that suffices. >> >> And I believe the default is configurable by means of the Options >> Inspector: you use the Global category; search for Magnification; >> then >> change that from the default value 1 to something higher. >> >> Unless you need severely compensating assistive technology, that >> should >> suffice. >> >> > I have an additional concern regarding current on-line >> documentation. Some > of it does not have a resizable font. That makes it difficult for >> people > like me that have glasses and use portable computers with smaller >> screens. > I hope that can be fixed in a subsequent release. > >> > > >> In response to Andrzej Kozlowski's comment >> >>> Judging by quite many ordinary users I known, the views you >>> have >> been >>> expressing, particularly those on the need for printed software >> manuals >>> rather make you a memeber of a minority, and moreover a rather >>> rapidly declining one. I for one, . . . >> >> Does Mathematica really need printed, more introductory level >> documentation (aka books, or manuals) to add to its excellent, >> but less >> readable, online documentation? >> >> Let's take an experimental or reality-based approach to this >> question >> (however much that approach may be out of favor with our current >> administration in Washington . . .) >> >> Adobe Illustrator is, in my opinion anyway, an excellent piece of >> technical software, comparable in quality and usefulness and at >> least >> somewhat comparable in technical complexity, to Mathematica. >> >> There's probably a sizable overlap --- or at very least, a very >> sizable >> _potential_ market overlap --- between Illustrator and Mathematica >> users >> (new graphics commands that are very Illustrator-like have in >> fact been >> added in 6.0). >> >> Both programs have something of an initial learning curve for >> ordinary >> users; both have excellent detailed online reference >> documentation. >> >> Mathematica is, I would judge, actually substantial more complex >> and >> requires more learning for an average individual than does >> Illustrator. >> On my Mac, Illustrator 11 is 75 MB for the app itself, plus >> another 75 >> MB of supplemental stuff. I didn't try to dig inside the >> Mathematica >> package, but it's over 1 GB in my Applications folder, plus >> whatever >> additional material is stuffed away elsewhere on my HD. >> Illustrator >> manuals tend to be 300 to 500 pages; the Mathematica Book for v5 >> was >> just under 1500. Mathematica users, especially less experienced >> ones, >> might need more forms and varieties of documentation, that >> Illustrator >> users. >> >> So, to get some idea what sort of introductory printed books and >> manuals >> might be useful for Mathematica, we might ask: what sort of >> introductory >> printed books and manuals are readily available, right now, for >> Illustrator? (Noting again that Illustrator also has good, well >> organized, readily accessible online documentation, Help files, and >> tutorials --- along with helpful user forums on its web site.) >> >> A quick look at amazon.com then brings up a list of at least twelve >> (12) >> such introductory books or manuals on Illustrator (list appended >> below). >> All of these books are currently available in stock on amazon (and >> three >> are on my bookshelf) --- as compared to _none_ (as yet, anyway) for >> Mathematica 6. >> >> At least half of these Illustrator manuals can be identified as >> current >> editions of earlier versions that were published for earlier >> versions >> of >> Illustrator. In other words, earlier versions apparently sold well >> enough that authors were willing to write and publishers were >> willing >> to >> bring out 2nd, 3rd, even 4th editions of these manuals, updated >> for the >> current version of Illustrator. >> >> Or in other words, for me anyway: The experimental evidence is >> that >> these books _clearly meet user needs_, sufficiently so that >> authors >> are >> willing to invest their energies in writing them; publishers >> publish >> them; and users buy them, including more than once; >> >> Should Wolfram maybe recognize this point? >> >> >> * Adobe Illustrator CS3 Classroom in a Book by Adobe Creative Team >> (2007) $35 >> >> * The Adobe Illustrator CS3 Wow! Book by Sharon Steuer (2007) $24 >> >> * Adobe Illustrator CS3 How-Tos: 100 Essential Techniques by >> Karlins >> and Hopkins (2007) $10 >> >> * Real World Adobe Illustrator CS3 by Mordy Golding (2007) $20 >> >> * Illustrator CS3 Bible by Ted Alspach ( 2007) $25 >> >> * Adobe Illustrator for Fashion Design by Susan Lazear (2008) $35 >> >> * Fashion Designer's Handbook for Adobe Illustrator by Centner and >> Vereker (2007) $50 >> >> * Illustrator CS3 for Windows and Macintosh (Visual QuickStart >> Guide) >> by Weinmann and Lourekas (2007) $20 >> >> * Adobe Illustrator CS3 Revealed by Chris Botello (Aug 31, 2007) >> $45 >> >> * Best Practice: The Pros On Adobe Illustrator by Toni Toland >> (Aug 16, >> 2006) $35 >> >> * Adobe Illustrator CS2 Revealed, Education Edition by Chris >> Botello >> (2005) $40 >> >> >> >> > > >> >> >> -- >> Murray Eisenberg murray@math.umass.edu >> Mathematics & Statistics Dept. >> Lederle Graduate Research Tower phone 413 549-1020 (H) >> University of Massachusetts 413 545-2859 (W) >> 710 North Pleasant Street fax 413 545-1801 >> Amherst, MA 01003-9305 >> >> > > > -- > peter lindsay > computing officer > mathematical institute > university of st andrews > ky16 9ss > phone: 01334463756 > > The University of St Andrews is a charity registered in Scotland : No > SC013532 > > === Subject: Re: Does Mathematica really need more printed, Ideally you want a book *and* the interactive help pages side by side. In some circumstances there just is no substitute for the printed word. Paper is far easier to read [ sorry, but it just is ] . They should never have done away with Wolfram's printed manual - it was superb. P Lindsay > > Each Mathematica 6 Documentation Center page is a Mathematica notebook, > and when it appears it includes the usual control for magnifying > everything, up to 300%. Surely that suffices. > > And I believe the default is configurable by means of the Options > Inspector: you use the Global category; search for Magnification; then > change that from the default value 1 to something higher. > > Unless you need severely compensating assistive technology, that should > suffice. > > > I have an additional concern regarding current on-line > documentation. Some > of it does not have a resizable font. That makes it difficult for > people > like me that have glasses and use portable computers with smaller > screens. > I hope that can be fixed in a subsequent release. > > > > >> In response to Andrzej Kozlowski's comment >> > Judging by quite many ordinary users I known, the views you have >> been > expressing, particularly those on the need for printed software >> manuals > rather make you a memeber of a minority, and moreover a rather > rapidly declining one. I for one, . . . >> >> Does Mathematica really need printed, more introductory level >> documentation (aka books, or manuals) to add to its excellent, but less >> readable, online documentation? >> >> Let's take an experimental or reality-based approach to this question >> (however much that approach may be out of favor with our current >> administration in Washington . . .) >> >> Adobe Illustrator is, in my opinion anyway, an excellent piece of >> technical software, comparable in quality and usefulness and at least >> somewhat comparable in technical complexity, to Mathematica. >> >> There's probably a sizable overlap --- or at very least, a very sizable >> _potential_ market overlap --- between Illustrator and Mathematica > users >> (new graphics commands that are very Illustrator-like have in fact been >> added in 6.0). >> >> Both programs have something of an initial learning curve for ordinary >> users; both have excellent detailed online reference documentation. >> >> Mathematica is, I would judge, actually substantial more complex and >> requires more learning for an average individual than does Illustrator. >> On my Mac, Illustrator 11 is 75 MB for the app itself, plus another 75 >> MB of supplemental stuff. I didn't try to dig inside the Mathematica >> package, but it's over 1 GB in my Applications folder, plus whatever >> additional material is stuffed away elsewhere on my HD. Illustrator >> manuals tend to be 300 to 500 pages; the Mathematica Book for v5 was >> just under 1500. Mathematica users, especially less experienced ones, >> might need more forms and varieties of documentation, that Illustrator >> users. >> >> So, to get some idea what sort of introductory printed books and > manuals >> might be useful for Mathematica, we might ask: what sort of > introductory >> printed books and manuals are readily available, right now, for >> Illustrator? (Noting again that Illustrator also has good, well >> organized, readily accessible online documentation, Help files, and >> tutorials --- along with helpful user forums on its web site.) >> >> A quick look at amazon.com then brings up a list of at least twelve > (12) >> such introductory books or manuals on Illustrator (list appended > below). >> All of these books are currently available in stock on amazon (and > three >> are on my bookshelf) --- as compared to _none_ (as yet, anyway) for >> Mathematica 6. >> >> At least half of these Illustrator manuals can be identified as current >> editions of earlier versions that were published for earlier versions > of >> Illustrator. In other words, earlier versions apparently sold well >> enough that authors were willing to write and publishers were willing > to >> bring out 2nd, 3rd, even 4th editions of these manuals, updated for the >> current version of Illustrator. >> >> Or in other words, for me anyway: The experimental evidence is that >> these books _clearly meet user needs_, sufficiently so that authors > are >> willing to invest their energies in writing them; publishers publish >> them; and users buy them, including more than once; >> >> Should Wolfram maybe recognize this point? >> >> >> * Adobe Illustrator CS3 Classroom in a Book by Adobe Creative Team >> (2007) $35 >> >> * The Adobe Illustrator CS3 Wow! Book by Sharon Steuer (2007) $24 >> >> * Adobe Illustrator CS3 How-Tos: 100 Essential Techniques by Karlins >> and Hopkins (2007) $10 >> >> * Real World Adobe Illustrator CS3 by Mordy Golding (2007) $20 >> >> * Illustrator CS3 Bible by Ted Alspach ( 2007) $25 >> >> * Adobe Illustrator for Fashion Design by Susan Lazear (2008) $35 >> >> * Fashion Designer's Handbook for Adobe Illustrator by Centner and >> Vereker (2007) $50 >> >> * Illustrator CS3 for Windows and Macintosh (Visual QuickStart Guide) >> by Weinmann and Lourekas (2007) $20 >> >> * Adobe Illustrator CS3 Revealed by Chris Botello (Aug 31, 2007) $45 >> >> * Best Practice: The Pros On Adobe Illustrator by Toni Toland (Aug 16, >> 2006) $35 >> >> * Adobe Illustrator CS2 Revealed, Education Edition by Chris Botello >> (2005) $40 >> >> >> >> > > > > > -- > Murray Eisenberg murray@math.umass.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone 413 549-1020 (H) > University of Massachusetts 413 545-2859 (W) > 710 North Pleasant Street fax 413 545-1801 > Amherst, MA 01003-9305 > > -- peter lindsay computing officer mathematical institute university of st andrews ky16 9ss phone: 01334463756 The University of St Andrews is a charity registered in Scotland : No SC013532 === Subject: Re: Problem: is not a list of numbers with dimensions replace exp by Exp..and everything will work fine Please remember..in Mathematica..all functions starts with capital letters In[36]:= A = 1*10^(-4); k = 2/3; g = 1.12*10^(-11); Attenuation = 0.23026*0.475*10^(-3); L = 7200; Leff = (1 - Exp[-Attenuation*L])/Attenuation; FindRoot[x - A*Exp[k*g*x*Leff - Attenuation*L], {x, 0}] Out[42]= {x -> 0.0000454986} _____________________________________________________________________________ _______ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ === Subject: Re: Question about alignment in Grid and TableForm > I wish text objects in Grid would be aligned at center of column and > numbers in ScientificForm aligned at .. I have tried to use the > following constructions as elements of the Grid but the text objects > are not centered at the centers of columns: Item[some text, Alignment -> Center] > and > Item[1000*Pi // ScientificForm, Alignment -> .]. The code I have tried (it is just example): TableForm[ > Insert[Table[ > Item[N[Pi a^10] // ScientificForm, Alignment -> .], {a, 1, > 5}, {b, 1, 3}], {Item[First Column text, Alignment -> Center], > Item[Second Column text, Alignment -> Center], > Item[Third Column text, Alignment -> Center]}, 3]] Grid[Insert[ > Table[Item[N[Pi a^10] // ScientificForm, Alignment -> .], {a, 1, > 5}, {b, 1, 3}], {Item[First Column text, Alignment -> Center], > Item[Second Column text, Alignment -> Center], > Item[Third Column text, Alignment -> Center]}, 3]] How to place text objects at the centers of the columns? Is this a bug > in Alignment option? > I don't think so, it is usually a good idea to use the Dividers->All option when constructing tables so you can see what really happens. As you can see, the text _is_ centered, it's the dot-alignment which causes the look of the table to be different from what you expect: Grid[ Insert[Table[ Item[N[Pi a^10] // ScientificForm, Alignment -> .], {a, 1, 5}, {b, 1, 3}], {Item[First Column text, Alignment -> Center], Item[Second Column text, Alignment -> Center], Item[Third Column text, Alignment -> Center]}, 3], Dividers -> All ] you might want to experiment with the ItemSize option to get more appealing tables... hth, albert === Subject: Re: Locator nice to hear. > I was also wondering if you can recommend some tutorials for the > interactive component of 6.0. I have been going through the > documentation slowly as well. Is there anything else? AFAIK (unfortunatly) not. The tutorials on Dynamic and Advanced Dynamic Functionality along with some tips from this group and some experimenting got me to a point where I think I can get things done pretty quickly. The tutorials are in a rather condensed form and probably only digestable if you are familiar with the regular mathematica functionality, including an basic understanding of mathlink/JLink/NETLink and how the frontend and kernel interact. So this is probably something you want to look at, and where you can find a lot more information in the documentation and elsewhere. Unlike others I also think that mostly any documentation about older versions is still valid and useful, especially if you don't look for verbatim option names but for an understandig of how mathematica works. albert === Subject: Matrix of big dimensions Hi. Anyone here already tried to implement calculus on mathematica using a 500*500 dimension matrix? Do you know if it works? GGuerreiro === Subject: Intersection of surfaces How to find the space curve formed by intersecting 3D patches in simple cases like: TUBE = {.6 Cos[V], 2 U + 3, .6 Sin[V] + 2}; tube = ParametricPlot3D[TUBE, {U, -1.2, .2}, {V, 0, 2 Pi}, PlotPoints - > {10, 25}] BOWL = {p Cos[q], p^2/2, p Sin[q]}; bowl = ParametricPlot3D [ BOWL, {p, 1, 2.75}, {q, 0, 2 Pi}, PlotPoints -> {20, 35}] Show[bowl, tube] or in slightly more complicated surface cases like: terr = ParametricPlot3D[{Cos[u + 1] Cos[v + 2.1], 0.6 + u^2/3,Exp[-v/ 4] }, {v, -3, 3}, {u, -3, 3}, PlotPoints -> {45, 30}] Show[terr, tube] How to solve for x,y and z from {0.6 Cos[V] == p Cos[q], 3 + 2 U == p^2/2, 2 + 0.6 Sin[V] == p Sin[q]} obtaining t as a function of (U,V,p and q) so as to be able to Show with ParametricPlot3D[{x[t], y[t], z[t]},{t,tmin,tmax}]? Narasimham === Subject: Antialising of 3D graphics on MacBook Pro Has anyone been able to get Mathematica's 3d graphics to render with anti-aliasing on a MacBook Pro? === Subject: Trouble computing conjugates I'm having trouble getting mathematica to compute complex conjugates of some fairly simple expressions: If I type the following: $Assumptions = {g [Element] Reals, f [Element] Reals} u1 = f + [ImaginaryI] g u2 = f - [ImaginaryI] g Then the command: Refine[Conjugate [c1 u1]] returns: f - [ImaginaryI] g) Conjugate[c1] and the command: Refine[Conjugate[c1 u1 + u2]] returns: f + [ImaginaryI] g + (f - [ImaginaryI] g) Conjugate[c1] as I would expect. But the command: Refine[Conjugate[c1 u1 + c2 u2]] returns: Conjugate[c2 (f - [ImaginaryI] g) + c1 (f + [ImaginaryI] g)] i.e. it refuses to distribute the complex conjugate throughout the expression. What I would like it to tell me is: (f + [ImaginaryI] g) Conjugate[c2] + (f - [ImaginaryI] g) Conjugate[c1] The closest I have been able to come to getting what I want is by using: ComplexExpand[Refine[Conjugate[ c1 u1 + c2 u2]], {c1, c2}] but this separates c1 and c2 into their real and imaginary parts. The above expressions are much simpler than the ones I REALLY want Mathematica's help in simplifying. If I use this ComplexExpand command, then I'm going to have to recombine them into complex numbers again, which would be very very bad. Roy === Subject: Pattern matching problem Hi all, Here is my problem: Given a polynomial in the variables u[x,t] and its spatial derivatives (for example, the polynomial could be 1 + u + u_xx*u_xxx^2), count the number of spatial derivatives with multiplicity. That is, after writing the above polynomial as 1 + u + u_xx * u_xxx * u_xxx the output should be 2 + 3 + 3 (basically, you count the number of x's). I have tried implementing this using a pattern matching approach. Here is what I tried: f[equation_ ] := Sum[ k * j * Count[ equation , D[ u[x, t], {x, j} ] ^ k , {0, infinity} ], {j, 1, 50}, {k, 1, 50}] This fails to work on, for example, the input u_xx^2, because it outputs 6 when it should output 4. This is because the u_xx is counted (+2 to the sum), and the u_xx^2 is counted (+4 to the sum). This is because the u_xx is nested inside the Power[ , 2] in its representation in Mathematica and so it gets counted too many times in my formula. I can't seem to figure out a way to use the provided that operator /; to make this formula work. I've also tried doing some replacement methods, but to no success. -Charlie === Subject: FrameLabels in ContourPlot The vertical frame labels in Version 6.0 are so far away from the Contour Plot and so close to the border that they are partially obscured if one asks for anything larger than about a 12 point font. Someone asked about this back in October without a reply. Is there some solution? Does Wolfram try to fix these things? === Subject: Definite integral problem Does anybody know any tricks to do the following definite integral? J0part=(1/Sqrt[const/(Rvt^2 + Rx^2*Sin[theta]^2)^3] + (3*Dc*Sec[theta]^2*(Rvt^2 + Rx^2*Sin[theta]^2)^3)/ (const*Rx^2))^(-1) IntJ0term = Integrate[J0part, {theta, 0, Pi/2}, Assumptions -> {Rx > 0, Rvt > 0, const > 0, Dc > 0}] The integrand seems to be well behaved -- temporarily making some simple numerical substitutions eg. Rx = 1; Rvt = 2; const = 3; Dc = 4; enables it to plotted over the range of the integration limits and also integrated with NIntegrate. Plot[J0part, {theta, 0, Pi/2}] reveals a simple smooth curve. J0part can be split into two partial fractions, neither of which will symbolically integrate. Curiously, different versions of Mathematica and trivially different versions of the integrand get different responses from Integrate[] -- some give up almost immediately, other rack up hours of CPU time without producing a result. Any ideas? Tom Crane. Ps. I am running Mathematica 4.0. -- Tom Crane, Dept. Physics, Royal Holloway, University of London, Egham Hill, Egham, Surrey, TW20 0EX, England. Email: T.Crane at rhul dot ac dot uk Fax: +44 (0) 1784 472794 === Subject: Re: StringMatchQ and Regular Expressions Ahh, I think I understand now I had crafted my forward-looking regex to match the whole string, but was being sloppy in my thinking about what is being matched. My regex was intended to match the letters d,o immediately followed by any number of space characters followed by one or more word- constituent characters followed by an equals sign. Used in StringCases this finds the first two letters of the text searched. However, used in StringMatchQ, it fails, because the whole search text does not match the expression. Further, it seems that StringMatchQ will never return True if the regex uses lookahead; when attempting to match the whole search text there is nothing for the regex engine to look ahead to, and never will be. shown me how to solve the problem without lookahead anyway. Mark > > > > > Hi > > I'm running Mathematica v6.0.2 on Windows XP. > > I define a regex thus: > > doStmt = RegularExpression[do(?=s*w+=)]; > > and then execute: > > StringCases[doindex= , doStmt] > > which brings the response > > {do} > > I then execute > >StringMatchQ[doindex= , doStmt] > > which brings the response > > False > I had expected that if StringCases found any cases, thenStringMatchQ > would return True. Obviously this is not the case, but can anyone out > there throw light upon this. > > > Mark Westwood > > See also StringFreeQ and the section > Properties & Relations (3) in its homepage. > > hth, > > albert === Subject: Re: Request for Collective Wisdom... > (*Below is a request for suggestions for hints for beginners. The > preface is a bit long-winded *) I am working on an applied math for physical scientists undergraduate > text---I am using Mathematica as the engine to learn and solve > problems quickly. I have an appendix that I have been creating (empirically) for a > couple years: Common Mathematica Beginners' Errors. This wasn't > difficult. I am now considering how to write another Appendix: Mathematica Usage > Paradigms for Beginners. This one is not as straightforward because > it will be a list of short sequences of Mathematica code. The size of > the list should be a compromise between length, completeness, and > orthogonality. Some topics are obvious to (subjective) me: work symbolically and with > exact representations; scale to remove units when possible; visualize > often and when in doubt evaluate as a number; pure functions are > power; avoid the outdoors unless you have applied the documentation, > lists are your friends... Nota bene, this is a book for undergraduates who have just received > the physics, chemistry, and multivariable calculus catechism, and > (typically) don't appreciate that there are common themes in their > education (think back...). (* Punchline: *) > I would sincerely appreciate thoughtful (bullet-type) suggestions for > paradigms. (off-line or on- as you please). > PS: Implicit in this is what a dear friend called The Homotopy > Conjecture. Give me a small working example, and it can deformed > into a complicated one for my own purposes. PPS: I expect a small fraction of snarky answers---I won't respond. > Hi Graig, I would suggest the following to be added to your list: 1. Learn to see Mathematica expressions in FullForm (it is incredible how many bugs or weird behaviors or unexpected results can be avoided or explained just by looking at the FullForm of the incriminated expressions). 2. Everything is an expression (at least in Mathematica :-) 3. Do not trust blindly, check the results (differentiate back an integral, check the limits on both sides, plug the solution to an equation into the original equation). 4. Everything is an expression (reloaded :-) -- Jean-Marc === Subject: Re: Request for Collective Wisdom... A few additional items: 1) Use localization of parameters and variables. 2) Be prepared to write definitions and specifications as needed to make the development easy and clear. 3) Write many Text cells to explain what the objects are and what you are doing. (Otherwise the poor professor will be clueless.) Also use Sectional grouping when appropriate. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > (*Below is a request for suggestions for hints for beginners. The > preface is a bit long-winded *) > > I am working on an applied math for physical scientists undergraduate > text---I am using Mathematica as the engine to learn and solve > problems quickly. > > I have an appendix that I have been creating (empirically) for a > couple years: Common Mathematica Beginners' Errors. This wasn't > difficult. > > I am now considering how to write another Appendix: Mathematica Usage > Paradigms for Beginners. This one is not as straightforward because > it will be a list of short sequences of Mathematica code. The size of > the list should be a compromise between length, completeness, and > orthogonality. > > Some topics are obvious to (subjective) me: work symbolically and with > exact representations; scale to remove units when possible; visualize > often and when in doubt evaluate as a number; pure functions are > power; avoid the outdoors unless you have applied the documentation, > lists are your friends... > > Nota bene, this is a book for undergraduates who have just received > the physics, chemistry, and multivariable calculus catechism, and > (typically) don't appreciate that there are common themes in their > education (think back...). > > (* Punchline: *) > I would sincerely appreciate thoughtful (bullet-type) suggestions for > paradigms. (off-line or on- as you please). > > > > > > > PS: Implicit in this is what a dear friend called The Homotopy > Conjecture. Give me a small working example, and it can deformed > into a complicated one for my own purposes. > > PPS: I expect a small fraction of snarky answers---I won't respond. > > -- > W. Craig Carter > === Subject: Re: Question on the Limiting Value of Ratios of Consecuative Primes... > Is there some analytic limit to the ratio of consecuative primes? The > expression Limit[Prime[i]/Prime[i+1],{i,->Infinity}] returns unevaluated. > Plotting Table[ Prime[i]/Prime[i+1],{i,1,20000}] shows a lot of structure > with a minimum of 3/5. You could use something like the expression below to explore numerically the limit on a wider range of prime numbers. (Table build a list, i.e. consume more and more memory, whereas For will just iterate and change only one value when required.) In[142]:= Timing@ Module[{rat, lowest = 1}, For[i = 1, i <= 10^7, i++, rat = Prime[i]/Prime[i + 1]; If[rat < lowest, lowest = rat]]; lowest] Out[142]= {139.046, 3/5} -- Jean-Marc === Subject: Re: Symbolic Optimization Problem > I need to maximize [Pi] = R*[Alpha] (1/[Alpha] ([Beta]/R)^(1/( ==!!!!! Although it looks nice in the front end, tt is a very bad idea indeed to use the Creek symbol pi here, i.e. on the left hand side of an assignment, since this symbol has already a built in meaning (and is protected against modification: you will get an error message if you evaluate the above expression: Set::wrsym: Symbol [Pi] is Protected...) > 1 - [Beta])) - (1 - [Gamma])*[Beta]^(2/( > 1 - [Beta]))*[Alpha]^([Beta]/( > 1 - [Beta]))) - (1/[Alpha] ([Beta]/R)^(1/( > 1 - [Beta])) - (1 - [Gamma])*[Beta]^(2/( > 1 - [Beta]))*[Alpha]^([Beta]/(1 - [Beta]))) with respect to R (R will be in terms of alpha, beta and gamma) under the > assumption that beta, alpha and gamma will all be between 0 and 1. How can > I solve this symbolic optimization with Mathematica? I tried to solve it > but I am not very experienced with Mathematica and your help is greatly > appreciated. To get a symbolic answer, you should try *Maximize[]*, though I strongly doubt that you will be able to get a symbolic answer out of the box for your expression. f = R*[Alpha] (1/[Alpha] ([Beta]/ R)^(1/(1 - [Beta])) - (1 - [Gamma])*[Beta]^(2/(1 - [Beta]))*[Alpha]^([Beta]/(1 - [Beta]))) - (1/[Alpha] ([Beta]/ R)^(1/(1 - [Beta])) - (1 - [Gamma])*[Beta]^(2/(1 - [Beta]))*[Alpha]^([Beta]/(1 - [Beta]))) Maximize[{f, 0 < [Alpha] < 1, 0 < [Beta] < 1, 0 < [Gamma] < 1}, R] [returned unevaluated] You should experiment with some numeric values first, just to get a feel of what is going on; then you should try to simplify the expression by eliminating some of the parameters, grouping them into some more linear/polynomial forms. -- Jean-Marc === Subject: Stop cell tags propagating to generated cells Is there a way to stop cell tags that have been manually added to an input cell from being automatically assigned to the generated output cell? I ask because I have been creating interactive panels for controlling Java models (using J/Link) and would like to be able to programmatically toggle the CellOpen status of the lengthy DynamicModule[...] code. Jason -- Dr J. McKenzie Alexander Department of Philosophy, Logic and Scientific Method London School of Economics and Political Science Houghton Street, London WC2A 2AE Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm === Subject: ListDensityPlot with irregular data and InterpolationOrder This is not explicitly documented (or at least I could not find any mention of it), but from looking at the plots it seems to me that with ListDensityPlot (and related functions), an InterpolationOrder higher than 1 only work with data that lies on a regular grid. So for example the following data cannot be plotted with InterpolationOrder higher than 1: data = {#1, #2, Sin[#1] Sin[#2]} & @@@ RandomReal[2 Pi, {100, 2}]; Is this correct? === Subject: Re: Dashing[{}] > If I invoke Dashed somewhere in my Graphics3D display code, a > subsequent Dashing[{}], Line[...] is supposed to draw solid lines > thereafter. It seems to have no effect as everything after that is > still dashed. Might there be something simple I'm missing? Or a bug? this works as documented for me: Graphics3D[{Dashing[0.01], Line[{{0, 0, 0}, {2, 1, 0}}], Dashing[{}], Line[{{2, 1, 0}, {1, 1, 1}}]}] whether you are doing something wrong is hard to tell if you don't post what you have done... albert === Subject: Re: Solving on mathematica and where is the dependence on i ? Or do you think that the symbol Xi depend on i like Chris depend on s ?? And NSolve[] is for the case where you have numerical values. And to find the variables U, V, W, B you need 4 (four) equations and not only a single one, otherwise you may have an infinite number of equations and the print out of all the solutions would take a bit longer. Jens > How would i go about solving this equaiton on mathematica (Xi -Ux)^2 + (Yi - Uy)^2 + (Zi - Uz) = (Ri - Cb) > i = 1,2,3,4 where we need to find Ux, Uy, Uz, Cb tried a few things and they dont work. NSolve[ (Xi - U)^2 + (Yi - V)^2 + (Zi - W)^2 == (Ri - B)^2, {U, V, W, > B}, { i = 1, 2, 3, 4} ] any ideas? > === Subject: Re: Solving on mathematica > How would i go about solving this equaiton on mathematica (Xi -Ux)^2 + (Yi - Uy)^2 + (Zi - Uz) = (Ri - Cb) > i = 1,2,3,4 where we need to find Ux, Uy, Uz, Cb tried a few things and they dont work. NSolve[ (Xi - U)^2 + (Yi - V)^2 + (Zi - W)^2 == (Ri - B)^2, {U, V, W, > B}, { i = 1, 2, 3, 4} ] any ideas? Below, we assume that the Xi, Yi, etc., are some kind of indexed variables or arrays that hold some values. (* First, we generate some random data. *) Do[{X[i], Y[i], Z[i], R[i]} = RandomInteger[{-5, 5}, 4], {i, 4}] (* Then, we build the system of equations. *) eqns = Table[(X[i] - U)^2 + (Y[i] - V)^2 + (Z[i] - W)^2 == (R[i] - B)^2, {i, 1, 4}] (* Now we solve it. *) sols = NSolve[eqns, {U, V, W, B}] (* Finally, we check the results. *) eqns /. sols Out[139]= {(3 - U)^2 + (2 - V)^2 + (-3 - W)^2 == (-4 - B)^2, (5 - U)^2 + (1 - V)^2 + (-5 - W)^2 == (-2 - B)^2, (5 - U)^2 + (5 - V)^2 + (4 - W)^2 == (-3 - B)^2, (4 - U)^2 + (-2 - V)^2 + (1 - W)^2 == (-3 - B)^2} Out[140]= {{U -> 41.8099, V -> -1.64395, W -> -2.60076, B -> 34.9827}, {U -> 4.23504, V -> 2.48516, W -> 0.289612, B -> -7.54715}} Out[141]= {{True, True, True, True}, {True, True, True, True}} -- Jean-Marc === Subject: Re: Solving on mathematica Hi Chris, there is not enough information in your equations to distinguish Uz from Cb. In your equation they appear always as Uz-Cb. Therefore, either your equations are wrong or you need to replace the 2 independent variables Uz and Cb by a single variable and reduce the number of equations to 3. hope this helps, Daniel > How would i go about solving this equaiton on mathematica (Xi -Ux)^2 + (Yi - Uy)^2 + (Zi - Uz) = (Ri - Cb) > i = 1,2,3,4 where we need to find Ux, Uy, Uz, Cb tried a few things and they dont work. NSolve[ (Xi - U)^2 + (Yi - V)^2 + (Zi - W)^2 == (Ri - B)^2, {U, V, W, > B}, { i = 1, 2, 3, 4} ] any ideas? > === Subject: Re: Calculations with Interpolating Functions Hi Joao, you can always re-interpolate a function of an interpolating function. Therefore, write your function Sin[...] as an interpolationg function. Here is an example: t=FunctionInterpolation[x^2,{x,0,2}]; ts=FunctionInterpolation[Sin[t[x]],{x,0,2}]; Integrate[ts[x],{x,0,2}] hope this helps, Daniel > Hi I obtain an Interpolating function as a solution of a differential equation > with the command NDSolve, lets call it =93solution=94, which gives x(t). Next I > want to use this solution for further calculations. With the commands > =93result=Evaluate[x(t)/. First[solution]]=94 or =93result= x(t)/.solution, > {t,0,tmax}=94 I do the plot x(t) without any problems. Now, with version 5.2 I > manage to integrate x(t) or linear functions of it. But when I try to > integrate non linear functions of x(t), like x(t)^2 or Sin[x(t)] (which is > what I want), Mathematica is unable to give a numerical result, all I get > is an integral saying that there is an InterpolatingFunction in the > integrand. With Mathematica 6 the linear integration does not work either. Any help would be appreciated. > Joao Paulo > === Subject: Re: Calculations with Interpolating Functions and add your functions to the list of differential equations, i.e., Join[yourODES, 0}] does not help ? Jens > Hi > > > > I obtain an Interpolating function as a solution of a differential equa= tion > with the command NDSolve, lets call it =93solution=94, which gives = x(t). Next I > want to use this solution for further calculations. With the commands > =93result=Evaluate[x(t)/. First[solution]]=94 or =93result= = x(t)/.solution, > {t,0,tmax}=94 I do the plot x(t) without any problems. Now, with vers= ion 5.2 I > manage to integrate x(t) or linear functions of it. But when I try to > integrate non linear functions of x(t), like x(t)^2 or Sin[x(t)] (which= is > what I want), Mathematica is unable to give a numerical result, all I = get > is an integral saying that there is an InterpolatingFunction in the > integrand. With Mathematica 6 the linear integration does not work eith= er. > > Any help would be appreciated. > > > > > > > Joao Paulo > > > === Subject: Re: Calculations with Interpolating Functions > Hi > > I obtain an Interpolating function as a solution of a differential equation > with the command NDSolve, lets call it =93solution=94, which gives x(t). Next I Your solution is of form solution = {x->InterpolatingFunction[...]} The expression 'Integrate' performs a *symbolic, exact* integral, which can be done on interpolating functions since their form is known. It cannot be done in general. So try this: xSol[t_] := (x[t]/.solution) NIntegrate[ Sin[xSol[t]], {t,0, tmax}]; > want to use this solution for further calculations. With the commands > =93result=Evaluate[x(t)/. First[solution]]=94 or =93result= x(t)/.solution, > {t,0,tmax}=94 I do the plot x(t) without any problems. Now, with version 5.2 I > manage to integrate x(t) or linear functions of it. But when I try to > integrate non linear functions of x(t), like x(t)^2 or Sin[x(t)] (which is > what I want), Mathematica is unable to give a numerical result, all I get > is an integral saying that there is an InterpolatingFunction in the > integrand. With Mathematica 6 the linear integration does not work either. > > Any help would be appreciated. > > > Joao Paulo === Subject: Re: Calculations with Interpolating Functions > I obtain an Interpolating function as a solution of a differential equation > with the command NDSolve, lets call it =93solution=94, which gives x(t). Next I > want to use this solution for further calculations. With the commands > =93result=Evaluate[x(t)/. First[solution]]=94 or =93result= x(t)/.solution, > {t,0,tmax}=94 I do the plot x(t) without any problems. Now, with version 5.2 I > manage to integrate x(t) or linear functions of it. But when I try to > integrate non linear functions of x(t), like x(t)^2 or Sin[x(t)] (which is > what I want), Mathematica is unable to give a numerical result, all I get > is an integral saying that there is an InterpolatingFunction in the > integrand. With Mathematica 6 the linear integration does not work either. You message is difficult to read, but have you tried *NIntegrate[]*? For instance, sol = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}] y[x_] = y[x] /. sol[[1]] Plot[y[x], {x, 0, 30}] Integrate[y[x], {x, 5, 10}] NIntegrate[y[x]^2, {x, 5, 10}] {{y->InterpolatingFunction[{{0.,30.}},<>]}} InterpolatingFunction[{{0.,30.}},<>][x] 1.13807 0.327983 -- Jean-Marc === Subject: Re: Problem/bug with ends of thick lines in graphics Alas, though this approach may work for this particular example the example was a distillation to show the bug though it arose in a more complicated case where choosing, for example, PlotPoints->3 would not be the right thing to do. Also removing points from the end of a line (or curve) changes the curve to something else, so this, as a general approach, would not serve well. The problem originally arouse in some work where there was a curve and it needed to be exported to PDF to then be included in a printed text book. The curve was not terribly thick, but it was noticeable in the PDF export that the ends of the curve were not up to the quality standards needed. The original fix was to include the explicit PostScript command in the PlotStyle option. But I know that this bug is being worked on by the folks at WRI for a future version of Mathematica... --David > > Consider the following graph: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {AbsoluteThickness[20]}] > > When you plot it you will see that the line's ends are not > rectangular, whereas you would certainly want them to be so. > > =2E.. > > Does anyone have any solutions to either or both of these issues? > > There are a couple of things you can do to alter the appearance of > this graphic. In this specific case adding PlotPoints->3 to the Plot > command is enough to do the trick. Another option is to manually > remove a few (4-5) points from both the start and end of the Line > primitive in the resulting graphic. This problem occurs when the > points at the beginning/end of the line are so very close together > that the OS graphics library gets a little confused about what angle > to draw the line cap, and it's really only noticeable when the line is > thick enough that the cap is clearly visible. > > -Rob === Subject: Re: Problem/bug with ends of thick lines in graphics Actually a version of the bug does appear n 5.2 when exporting as PDF... --David > > > > In a quick search of things I haven't found a mention of the following > simple graphics issue and I'm checking in with the group to see if > there is a memory of its mention and if there is a simple fix (and > which is not a complicated hack) that I've not been able to come up > with. > > Consider the following graph: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {AbsoluteThickness[20]}] > > When you plot it you will see that the line's ends are not > rectangular, whereas you would certainly want them to be so. (An > alternative would be to have them be rounded, for example, but the > question will remain the same whatever your preference is.) Rather > they appear as polygonal in a way inconsistent with the line itself. > > Obviously this is a bug. Unfortunately this bug is not fixed in > version 6.02. And in version 5.2 this bug does not appear. Thus this > is regression bug! Some graphical functionality was broken in version > 6! === Subject: Re: Intersection of surfaces if you got the same result all is ok. Jens > On May 8, 3:29 am, Jens-Peer Kuska >> >> TUBE = {.6 Cos[V], 2 U + 3, .6 Sin[V] + 2}; >> tube = ParametricPlot3D[TUBE, {U, -1.2, .2}, {V, 0, 2 Pi}, >> PlotPoints -> {10, 25}]; >> BOWL = {p Cos[q], p^2/2, p Sin[q]}; >> bowl = ParametricPlot3D[BOWL, {p, 1, 2.75}, {q, 0, 2 Pi}, >> PlotPoints -> {20, 35}]; >> >> and >> >> eqn = Eliminate[{TUBE == {x, y, z} // Thread, >> BOWL == {x, y, z} // Thread} // Flatten, {p, q, U}]; >> >> and >> sol = Solve[eqn, {x, y, z}]; >> >> gives >> >> {{y -> 0.02 (100.+ 9. Cos[V]^2 + 60. Sin[V] + 9. Sin[V]^2), >> x -> 0.6 Cos[V], z -> 0.2 (10.+ 3. Sin[V])}} >> >> and >> >> ll = ParametricPlot3D[{x, y, z} /. sol[[1]], {V, 0, 2 Pi}]; >> >> Show[bowl, tube, >> ll /. l_Line :> {AbsoluteThickness[4], RGBColor[1, 0, 0], l}] >> >> show that the result is right. >> >> Jens >> > How to find the space curve formed by intersecting 3D patches in > simple cases like: > TUBE = {.6 Cos[V], 2 U + 3, .6 Sin[V] + 2}; > tube = ParametricPlot3D[TUBE, {U, -1.2, .2}, {V, 0, 2 Pi}, PlotPoints - >> {10, 25}] > BOWL = {p Cos[q], p^2/2, p Sin[q]}; > bowl = ParametricPlot3D [ BOWL, {p, 1, 2.75}, {q, 0, 2 Pi}, PlotPoints > -> {20, 35}] > Show[bowl, tube] > or in slightly more complicated surface cases like: > terr = ParametricPlot3D[{Cos[u + 1] Cos[v + 2.1], 0.6 + u^2/3,Exp[-v/ > 4] }, {v, -3, 3}, {u, -3, 3}, PlotPoints -> {45, 30}] > Show[terr, tube] > How to solve for x,y and z from {0.6 Cos[V] == p Cos[q], 3 + 2 U == > p^2/2, 2 + 0.6 Sin[V] == p Sin[q]} obtaining t as a function of (U,V,p > and q) so as to be able to Show with > ParametricPlot3D[{x[t], y[t], z[t]},{t,tmin,tmax}]? > Narasimham > So saw this post and found if useful for something I was doing. But as I looked at the suggested code, I was not sure why thread and > flatten were used in this particular case. > So I deleted them one at a time and still got the same answer. What is the difference then between. TUBE = {.6 Cos[V], 2 U + 3, .6 Sin[V] + 2}; > tube = ParametricPlot3D[TUBE, {U, -1.2, .2}, {V, 0, 2 Pi}, > PlotPoints -> {10, 25}]; > BOWL = {p Cos[q], p^2/2, p Sin[q]}; > bowl = ParametricPlot3D[BOWL, {p, 1, 2.75}, {q, 0, 2 Pi}, > PlotPoints -> {20, 35}]; eqn = Eliminate[{TUBE == {x, y, z} // Thread, > BOWL == {x, y, z} // Thread} // Flatten, {p, q, U}] > eqn1 = Eliminate[{TUBE == {x, y, z}, BOWL == {x, y, z}} // > Flatten, {p, q, U}] > eqn2 = Eliminate[{TUBE == {x, y, z}, BOWL == {x, y, z}}, {p, q, U}] sol = Solve[eqn, {x, y, z}] > sol1 = Solve[eqn1, {x, y, z}] > sol2 = Solve[eqn2, {x, y, z}] ll = ParametricPlot3D[{x, y, z} /. sol[[1]], {V, 0, 2 Pi}]; > l11 = ParametricPlot3D[{x, y, z} /. sol1[[1]], {V, 0, 2 Pi}]; > l12 = ParametricPlot3D[{x, y, z} /. sol2[[1]], {V, 0, 2 Pi}]; > Show[bowl, tube, > ll /. l_Line :> {AbsoluteThickness[4], RGBColor[1, 0, 0], l}] Show[bowl, tube, > l11 /. l_Line :> {AbsoluteThickness[4], RGBColor[1, 0, 0], l}] Show[bowl, tube, > l12 /. l_Line :> {AbsoluteThickness[4], RGBColor[1, 0, 0], l}] > === Subject: Re: Error messages from FunctionInterpolation (bug?) No error on my system (Mathematica 5.2 on Win XP) -- enzo === Subject: Re: graphic text style setting BaseStyle ma help: Plot[Sin[x], {x, 0, 2 Pi}, Frame -> True, FrameLabel -> {x, Sin[x]}, PlotLabel -> A Label, BaseStyle -> {Large, FontFamily -> Times, Italic}] Jens before v6 I set the text style for all the graphics and plots in a > notebook with one command at the beginning of the notebook, e.g. > $TextStyle[{FontFamily -> Arial, FontSize -> 16}]; In v6, that does not work anymore. How can I do such a thing in v6? > joerg > === Subject: Testing TOC sidebar palette Hi group, Sometimes ago there was question about creating TOC of the notebook. David Reiss gave a hint of using CellID for these purposes. Based on this idea I have developed a sidebar TOC palette where I also include several tasks typical for my work. Could you please inform me if it is convenient to use it and what kind of extra tasks should be added to the palette? Main properties of palette include: - Generation of Table of Contents for any currently selected notebook - Additional selection instrument for extra tasks. Current version supports locking/unlocking cells to block cells from accidental editing and deleting - Tracing graphics coordinates. (It also launches an additional tool GraphicsCoordinates. Note, the Graphics object must be selected to activate this button) - Tracing evaluation time - Running everyday notebooks in save mode (with cell options Delatable and Editable set to False) - Few additional actions: comparing two cells in the notebook, evaluating the whole section etc. The files can be downloaded from: http://www.spinalgebra.com/sidebar/graphicscoordinates.zip http://www.spinalgebra.com/sidebar/sidebar.zip -- Yuri Kandrashkin, PhD http://spinalgebra.com - Mathematica based applications: - Magnetic Resonance with SpinAlgebra - Work with systems of Units - Interactive tools: ViewPoint selector, Options explorer, etc === Subject: Region for ListPlot3D Below I give a set of 3D points and attempt to plot them as a surface using ListPlot3D. I also plot the points directly using Graphics3D. The data fill a region that is approximately a trapezium except that one side is concave. ListPlot3D extrapolates the concave side out to the convex hull of the x -y coordinates thus giving a false impression of the surface. How can I make the plotting region conform to the data and exclude the extrapolation? Hugh Goyder pp = {{{0, 0, 0}, {5, 0, 0}, {10, 0, 0}, {14, 0, 0}, {19, 0, 0}, {24, 0, 0}, {29, 0, 0}, {33, 0, 0}, {38, 0, 0}, {43, 0, 0}, {48, 0, 0}}, {{0, 53, 3}, {5, 53, 3}, {10, 53, 3}, {14, 53, 3}, {19, 53, 3}, {24, 53, 3}, {29, 53, 3}, {33, 53, 3}, {38, 53, 3}, {43, 53, 3}, {48, 53, 3}}, {{0, 107, 18}, {5, 107, 19}, {10, 107, 19}, {14, 107, 19}, {19, 107, 19}, {24, 107, 18}, {29, 107, 18}, {33, 107, 18}, {38, 107, 18}, {43, 107, 18}, {48, 107, 18}}, {{0, 160, 81}, {5, 160, 81}, {10, 160, 81}, {15, 160, 80}, {20, 160, 80}, {25, 160, 80}, {30, 160, 80}, {35, 160, 79}, {40, 160, 79}, {45, 160, 79}, {50, 160, 79}}, {{0, 213, 142}, {6, 213, 142}, {12, 213, 141}, {18, 213, 141}, {25, 213, 140}, {31, 213, 140}, {37, 213, 140}, {43, 213, 139}, {49, 213, 139}, {56, 213, 138}, {62, 213, 138}}, {{0, 267, 93}, {9, 267, 93}, {18, 267, 93}, {27, 267, 93}, {36, 267, 93}, {45, 267, 93}, {54, 267, 92}, {63, 267, 92}, {72, 267, 91}, {82, 267, 91}, {91, 267, 90}}, {{0, 320, 60}, {13, 320, 60}, {26, 320, 60}, {40, 320, 60}, {53, 320, 59}, {66, 320, 59}, {79, 320, 58}, {92, 320, 58}, {105, 320, 58}, {118, 320, 58}, {132, 320, 57}}, {{0, 373, 40}, {18, 373, 40}, {36, 373, 40}, {54, 373, 40}, {72, 373, 40}, {90, 373, 40}, {108, 373, 40}, {126, 373, 40}, {144, 373, 40}, {162, 373, 40}, {180, 373, 40}}, {{0, 427, 29}, {23, 427, 29}, {47, 427, 29}, {70, 427, 29}, {93, 427, 29}, {116, 427, 29}, {140, 427, 29}, {163, 427, 28}, {186, 427, 28}, {210, 427, 28}, {233, 427, 28}}, {{0, 480, 22}, {29, 480, 22}, {58, 480, 22}, {87, 480, 22}, {116, 480, 22}, {145, 480, 22}, {174, 480, 22}, {203, 480, 22}, {232, 480, 22}, {260, 480, 22}, {289, 480, 22}}, {{0, 533, 17}, {35, 533, 17}, {70, 533, 17}, {104, 533, 17}, {139, 533, 17}, {174, 533, 17}, {209, 533, 17}, {244, 533, 17}, {278, 533, 17}, {313, 533, 17}, {348, 533, 17}}}; g1 = Graphics3D[{Point[Flatten[pp, 1]]}, PlotRange -> All] g2 = ListPlot3D[Flatten[pp, 1]] Show[g1, g2] === Subject: SetOptions[Plot, BaseStyle :> myBaseStyle] does not work Why doesn't the following work? myBaseStyle = {FontFamily -> Helvetica}; SetOptions[Plot, BaseStyle :> myBaseStyle]; Plot[Sin[x], {x, 0, 10}] It seems that myBaseStyle does not get evaluated before plotting. Is this a bug? Using Plot[Sin[x], {x, 0, 10}, BaseStyle :> myBaseStyle] does work. The old TextStyle option used exactly this pattern, and PerformanceGoal and DisplayFunction still use it. === Subject: Linking EventHandler to a Control Object Hi folks, Have any of you tried to use the new (V6)EventHandler command to excute a series of actions based on input to a control object such as SetterBar? I have had success getting Mathematica to update a displayed list every time the displayed list is clicked on, but not when I want a control object to be clicked on to update the displayed list. Probably an example would help clarify: Example 1: WORKS on my computer test1 = {Phe, Ser, Leu, Ser, Val}; color = Black; trak = Ser; EventHandler[ Dynamic[test1], {MouseClicked :> (color = color /. {Black -> Red, Red -> Green, Green -> Black}; temp1 = Position[test1, trak]; test1 = ReplacePart[test1, temp1 -> Style[trak, color]];)}] Example 2: Does NOT work trak2 = SetterBar[ Evaluate[Dynamic[trak2]], {Phe -> Phe, Ser -> Ser, Leu -> Leu, Val -> Val}] test2 = {Phe, Ser, Leu, Ser, Val}; color = Black; EventHandler[{Dynamic[trak2], Dynamic[test2]}, {MouseClicked :> (color = color /. {Black -> Red, Red -> Green, Green -> Black}; temp2 = Position[test2, trak2]; test2 = ReplacePart[test2, temp2 -> Style[trak2, color]]; test2)}] Notice how the SetterBar in example 2 is updated, but the corresponding list that should be updated is not. Its as though the EventHandler command is actually not seeing the mouse click. Would you have any thoughts on how to link the input at the control object to the desired response of updating a displayed list? Todd _____________________________________________________________________________ _______ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ === Subject: Re: Request for Collective Wisdom... Here is a second tip. If a calculation is going very slowly, don't jump to the conclusion that you need to use a more functional programming style - at least without a little investigation. A spectacular way to consume machine time is to create an algorithm - say an iterative approximation to a square root - that is meant for real data, and then give it an argument such as Sqrt[3]/2. If the algorithm does not use explicit real numbers, and does not use N for example, it will build up a huge expression involving roots and fractions. This is particularly subtle if you simply give the output to Plot - which will apply N - your calculation will run extremely slowly and yet appear to work (if it ever terminates). David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Request for Collective Wisdom... > This tip is more important than it might at first seem: Many Mathematica > novices mistakenly believe that evaluations are localized to the > particular notebook in which they are working, rather than to the > session and, where relevant, the context. (This misconception may be due to a difference in the way some other > mathematical software handles this situation.) >> When defining a new function, have two windows open: >> one for building up the new function, and the other for trying out code to make sure it works before adding it to the function window. Don't try to do everything in one window. Seems wasteful at first but it's an enormous time saver in the long run. >> > I came across someone with exactly this misconception. He was using a whole mass of flaky code, finishing with SelectionEvaluate to run stuff from a second notebook! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: HoldForm, TraditionalForm Bug? >Here is a polynomial. Mathematica rearranges the order of the terms. > >x y - x^3 - 1 >-1 - x^3 + x y > >I would like to display the polynomial without rearranging the order. So I >use a HoldForm. > >HoldForm[x y - x^3 - 1] >x y-x^3-1 > >But then I would also like to display it with TraditionalForm to obtain the >single character italics. So I use: > >HoldForm[x y - x^3 - 1] // TraditionalForm >-x^3+y x-1 (actually TraditionalForm but the terms rearranged) > >I regard it as a bug that Mathematica rearranges the order of the terms in >this expression. Furthermore, if the expression were used in a Plot label, >TraditionalForm is now automatically used and the terms will be rearranged. > >A workaround is to use: > >Style[HoldForm[x y - x^3 - 1], SingleLetterItalics -> True, > FontFamily -> Times] >x y-x^3-1 (looks like TraditionalForm) > >If I try to use this in a plot it is quite convoluted! > >ContourPlot[x y - x^3 + 1 == 0, {x, -5, 5}, {y, -10, 15}, > Exclusions -> {x == 0}, > PlotLabel -> (Style[HoldForm[V[x y - x^3 - 1]], > SingleLetterItalics -> True, FontFamily -> Times] // > StandardForm)] > > > > You could use: PolynomialForm[HoldForm[V[x y - x^3 - 1]], TraditionalOrder -> False] to prevent TraditionalForm rearrangement. Carl Woll Wolfram Research === Subject: Re: Does Mathematica really need more printed, introductory > > Is it really reality based to be comparing books about Adobe > about version 6 of Mathematica ? Sounds to me more like a reflection > in a distorting mirror masquerading as reality (something > unfortunately very common these days in the media and in large > sections of the Academia). > > Andrzej, it's Wolfram itself has portrayed version 6 > as a massive and major upgrade --- Wolfram reinvents > Mathematica! --- 500 major new features --- a > revolutionary new version --- which also involves > significant features of previous versions being > removed, replaced, or changed in major ways. > > And of the 12 Illustrator manuals I listed, nine of them have > publication dates in 2007 and are (or at least claim to be) > updated for Illustrator's current versions as of those dates > --- for a product whose upgrades have been, I think it's fair > to say, much more gradual and evolutionary in character > than Mathematica's v5 to v6 upgrade. > > for historical interest, since they apparently hadn't --- yet, > anyway --- been updated. I think my amazon search on the > string Adobe Illustrator actually brought up something > over 2000 hits (though of course there have nowhere that > many actual earlier books). > > Beyond these facts, I think I'll let the remainder of your > comments speak for themselves. > > Why don't you perform a search for books about Mathematica (all > versions) and compare your findings with your list of books about > Illustrator? The picture will become very different and much closer to > reality. The fact is, that the vast majority of essential features > of Mathematica are described in these earlier versions and that any > one who has mastered them should be able to update his knowledge to > version 6 without a huge extra effort. > > As I already expained earlier: I would not buy any printed manual > style book about Mathematica and I remain highly skeptical that such > a book would be successful enough to justify the effort of writing it. > However, this only one person's view based on mere speculation. > However, I am (of course) very interested in any books *applying* the > new features of Mathematica 6, but that is an entirely different matter. > > Andrzej Kozlowski For what it's worth, the following book was written using Mathematica 6 and uses Mathematica 6 examples. Dynamical Systems with Applications using Mathematica It is available at Amazon. === Subject: CurrentValue CurrentValue[SelectionData] works for selections in the evaluation notebook: Button[label, With[{repeated = ToString@CurrentValue@SelectionData}, NotebookApply[EvaluationNotebook[], f[ <> repeated <> , <> repeated <> ]]]] How to use CurrentValue for other notebooks than the evaluation notebook? CurrentValue[NotebookSelection[nb]] does not work. Hannes Kesler === Subject: Re: Flashing Graphs With Manipulate This is curious, if you don't use the plotlabel: Manipulate[ With[{func = b x + c}, Module[{rts}, rts = NSolve[func == 0, x]; ListPlot[{Re[x], Im[x]} /. rts, PlotStyle -> PointSize[0.03], PlotRange -> {{-10, 10}, {-10, 10}}, ImageSize -> {300, 300}, AspectRatio -> 1(*,PlotLabel->func*)]]], {{b, -1, coefficient of x}, -9, 9, .1, Appearance -> Labeled}, {{c, 3, constant term}, -10, 10, .1, Appearance -> Labeled}] The flashing goes away. Further if you wrap the label in ToString Manipulate[ With[{func = b x + c}, Module[{rts}, rts = NSolve[func == 0, x]; ListPlot[{Re[x], Im[x]} /. rts, PlotStyle -> PointSize[0.03], PlotRange -> {{-10, 10}, {-10, 10}}, ImageSize -> {300, 300}, AspectRatio -> 1, PlotLabel -> ToString[func]]]], {{b, -1, coefficient of x}, -9, 9, .1, Appearance -> Labeled}, {{c, 3, constant term}, -10, 10, .1, Appearance -> Labeled}] The flashing goes away. That's a solution, but I don't understand the cause... WCC > If the coefficient of x is < 0 and the constant term is > 0, > this graph flashes as you drag the sliders. > > Why? NSolve can't be taking that much longer in this case. > > What can be done to prevent the flashing? > > Manipulate[ === Subject: Re: Flashing Graphs With Manipulate This appears to be a formatting issue with the PlotLabel. One quick way to make it go away I found is to wrap a TextCell around func: PlotLabel -> TextCell[func] I didn't test this much, but it seems to fix your issue... --David > If the coefficient of x is < 0 and the constant term is > 0, > this graph flashes as you drag the sliders. > > Why? NSolve can't be taking that much longer in this case. > > What can be done to prevent the flashing? > > Manipulate[ > With[ { func = b x + c }, > Module[ { rts }, > rts = NSolve[func == 0, x]; > ListPlot[ > {Re[x], Im[x]} /. rts, > PlotStyle -> PointSize[0.03], > PlotRange -> {{-10, 10}, {-10, 10}}, ImageSize -> {300, 300}, > AspectRatio -> 1, PlotLabel -> func] > ] > ], > { {b, -1, coefficient of x}, -9, 9, .1, Appearance -> Labeled}, > { {c, 3, constant term}, -10, 10, .1, Appearance -> Labeled} > ] === Subject: Re: Flashing Graphs With Manipulate > If the coefficient of x is < 0 and the constant term is > 0, > this graph flashes as you drag the sliders. > > Why? NSolve can't be taking that much longer in this case. > > What can be done to prevent the flashing? > > Manipulate[ > With[ { func = b x + c }, > Module[ { rts }, > rts = NSolve[func == 0, x]; > ListPlot[ > {Re[x], Im[x]} /. rts, > PlotStyle -> PointSize[0.03], > PlotRange -> {{-10, 10}, {-10, 10}}, ImageSize -> {300, 300}, > AspectRatio -> 1, PlotLabel -> func] > ] > ], > { {b, -1, coefficient of x}, -9, 9, .1, Appearance -> Labeled}, > { {c, 3, constant term}, -10, 10, .1, Appearance -> Labeled} > ] This is a bug that was largely fixed in version 6.0.2: in some instances, objects inside a Manipulate would flash when sliders were dragged. A workaround here is to replace PlotLabel -> func with PlotLabel -> ToString[func] Christopher Carlson User Interface Group Wolfram Research, Inc === Subject: Re: Parameter conditions On 5=D4=C212=C8=D5, =CF=C2=CE=E74=CA=B147=B7=D6, Szabolcs Horv=A8=A2t I'm just curious why the simple code below is not working. > > Why is happy[4] not returning the number 200 > > In[1]:= happy[p_?PrimeQ] = 100; > happy[p_?Not[PrimeQ]] = 200; > > In[3]:= Inhappy[4] > Out[3]:= happy[4] > > In[4]:= happy[5] > Out[4]:= 100 > > The correct code is > > happy[p_? PrimeQ] = 100; > happy[p_? (Not[PrimeQ[#]]&) ] = 200; > > PatternTest (the ? operator) should be followed by a function. > Not[PrimeQ] is not a function, but we can build a suitable function > easily: Not[PrimeQ[#]]&. Now we just have to pay attention to use > proper bracketing around it (because happy[p_? Not[PrimeQ[#]]& ] is > equivalent to happy[(p_?Not[PrimeQ[#]]&)], which does not make sense). > > But in this simple case > > happy[p_? PrimeQ] = 100; > happy[p_] = 200; > > will do the same thing. elegant === Subject: Re: FullForm OK but StandardForm fails On 5=D4=C212=C8=D5, =CF=C2=CE=E76=CA=B141=B7=D6, Fiona H Evans Hi all, > > I'm wondering if this is a bug in 6.0.2.0 or whether anyone can see my > problem here. I'm running a model that updates an object called 'data' > using a module with the HoldFirst attribute. After I run the module, I > can see the Head of data, and its FullForm, but when I try to view its > StandardForm, I get a $RecursionLimit error as follows. If I try to > Print data, the kernel crashes. However, if I copy the FullForm of > data (Out[76]) into a new object, it Prints perfectly. Any ideas? > > In[75]:= Head[data] > > Out[75]= localState > > In[76]:= FullForm[data] > > Out[76]//FullForm= > localState[community[List[population[canola,genotypeInfo[],cohortList[Li= s-t[]],cohortList[List[]], > cohortList[List[]],cohortList[List[]]],population[lupin,genotypeInfo[],c= o-hortList[List[]],cohortList[List[]], > cohortList[List[]],cohortList[List[]]],population[ryegrass,genotypeInfo[= L-ist[Rule[List[1,1], > 0.9993453217507997`],Rule[List[Blank[Integer],Blank[Integer]], > 1]],List[major],List[dominant], > List[glyphosate],List[Rational[1,1000000000]],List[0.1`]],cohortList[Lis= t-[cohort[time[3502828800], > hashedMSet[ruleSet[List[Rule[List[List[1],List[1]], > 1],Rule[List[List[1],List[2]],2],Rule[List[List[2], > List[1]],3],Rule[List[List[2],List[2]], > 4]]],List[499345536052604696,327124822795158, > 327124822795158,214301804988],List[info[List[]],info[List[]],info[List[]],= i-nfo[List[]]]]]]], > cohortList[List[]],cohortList[List[]],cohortList[List[]]],population[whea= t-,genotypeInfo[], > cohortList[List[cohort[time[3502828800],hashedMSet[ruleSet[List[Rule[List[= L-ist[1],List[1]], > 1]]], > List[160000000000000000],List[info[List[]]]]]]],cohortList[List[]],cohortL= i-st[List[]],cohortList[List[]]], > population[wildradish,genotypeInfo[],cohortList[List[]],cohortList[List[= ]-],cohortList[List[]], > cohortList[List[]]]]],herbicideResidueList[]] > > In[77]:= StandardForm[data] > > During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= General::stop: Further output of > $RecursionLimit::reclim will be suppressed during this calculation. >> modify the $RecursionLimit 's value as big as possible and try StandardForm again whatisgood === Subject: Re: FullForm OK but StandardForm fails >Hi all, > >I'm wondering if this is a bug in 6.0.2.0 or whether anyone can see my >problem here. I'm running a model that updates an object called 'data' >using a module with the HoldFirst attribute. After I run the module, I >can see the Head of data, and its FullForm, but when I try to view its >StandardForm, I get a $RecursionLimit error as follows. If I try to >Print data, the kernel crashes. However, if I copy the FullForm of >data (Out[76]) into a new object, it Prints perfectly. Any ideas? > > This is the kind of behavior I sometimes see with badly written MakeBoxes rules. Are you using any such rules? Carl Woll Wolfram Research > >In[75]:= Head[data] > >Out[75]= localState > >In[76]:= FullForm[data] > >Out[76]//FullForm= >localState[community[List[population[canola,genotypeInfo[],cohortList[L ist[]],cohortList[List[]], >cohortList[List[]],cohortList[List[]]],population[lupin,genotypeInfo[], cohortList[List[]],cohortList[List[]], >cohortList[List[]],cohortList[List[]]],population[ryegrass,genotypeInfo [List[Rule[List[1,1], >0.9993453217507997`],Rule[List[Blank[Integer],Blank[Integer]], >1]],List[major],List[dominant], >List[glyphosate],List[Rational[1,1000000000]],List[0.1`]],cohortList[Li st[cohort[time[3502828800], >hashedMSet[ruleSet[List[Rule[List[List[1],List[1]], >1],Rule[List[List[1],List[2]],2],Rule[List[List[2], >List[1]],3],Rule[List[List[2],List[2]], >4]]],List[499345536052604696,327124822795158, >327124822795158,214301804988],List[info[List[]],info[List[]],info[List[]],i nfo[List[]]]]]]], >cohortList[List[]],cohortList[List[]],cohortList[List[]]],population[whea t,genotypeInfo[], >cohortList[List[cohort[time[3502828800],hashedMSet[ruleSet[List[Rule[List[L ist[1],List[1]], >1]]], >List[160000000000000000],List[info[List[]]]]]]],cohortList[List[]],cohortLi st[List[]],cohortList[List[]]], >population[wildradish,genotypeInfo[],cohortList[List[]],cohortList[List []],cohortList[List[]], >cohortList[List[]]]]],herbicideResidueList[]] > >In[77]:= StandardForm[data] > >During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth >of 1024 exceeded. >> >During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth >of 1024 exceeded. >> >During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth >of 1024 exceeded. >> >During evaluation of In[77]:= General::stop: Further output of >$RecursionLimit::reclim will be suppressed during this calculation. >> > > > > === Subject: Re: FullForm OK but StandardForm fails Hi all, Carl Woll advised me to check my use of MakeBoxes and Format. He I'm assuming that you are using StandardForm as your default output format, and that: data; doesn't generate any messages, while data does generate messages. If true, this suggests that rendering is a problem. Rendering is controlled by MakeBoxes and Format statements. You could try: ?MakeBoxes and FormatValues /@ symbols where symbols is a list of symbols in data to see whether any formatting statements have been defined. That's about all I can say with the information you've provided. After carefully checking each use of Format in my code, I found a bug in a Module called by one of my Format uses. === Subject: Re: FullForm OK but StandardForm fails > Hi all, I'm wondering if this is a bug in 6.0.2.0 or whether anyone can see my > problem here. I'm running a model that updates an object called 'data' > using a module with the HoldFirst attribute. After I run the module, I > can see the Head of data, and its FullForm, but when I try to view its > StandardForm, I get a $RecursionLimit error as follows. If I try to > Print data, the kernel crashes. However, if I copy the FullForm of > data (Out[76]) into a new object, it Prints perfectly. Any ideas? > In[75]:= Head[data] Out[75]= localState In[76]:= FullForm[data] Out[76]//FullForm= > localState[community[List[population[canola,genotypeInfo[],cohortList[Lis t[]],cohortList[List[]], > cohortList[List[]],cohortList[List[]]],population[lupin,genotypeInfo[],co hortList[List[]],cohortList[List[]], > cohortList[List[]],cohortList[List[]]],population[ryegrass,genotypeInfo[L ist[Rule[List[1,1], > 0.9993453217507997`],Rule[List[Blank[Integer],Blank[Integer]], > 1]],List[major],List[dominant], > List[glyphosate],List[Rational[1,1000000000]],List[0.1`]],cohortList[List [cohort[time[3502828800], > hashedMSet[ruleSet[List[Rule[List[List[1],List[1]], > 1],Rule[List[List[1],List[2]],2],Rule[List[List[2], > List[1]],3],Rule[List[List[2],List[2]], > 4]]],List[499345536052604696,327124822795158, > 327124822795158,214301804988],List[info[List[]],info[List[]],info[List[]],inf o[List[]]]]]]], > cohortList[List[]],cohortList[List[]],cohortList[List[]]],population[wheat ,genotypeInfo[], > cohortList[List[cohort[time[3502828800],hashedMSet[ruleSet[List[Rule[List[Lis t[1],List[1]], > 1]]], > List[160000000000000000],List[info[List[]]]]]]],cohortList[List[]],cohortList [List[]],cohortList[List[]]], > population[wildradish,genotypeInfo[],cohortList[List[]],cohortList[List[] ],cohortList[List[]], > cohortList[List[]]]]],herbicideResidueList[]] In[77]:= StandardForm[data] During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= General::stop: Further output of > $RecursionLimit::reclim will be suppressed during this calculation. >> > Sorry - my previous reply only made partial sense, because you had indeed posted a FullForm expression, but for me, this expression displayed OK in StandardForm. This makes me even more suspicious that you are using some code with MakeBoxes (or possible Format) to set up layout rules for this expression. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: FullForm OK but StandardForm fails > Hi all, I'm wondering if this is a bug in 6.0.2.0 or whether anyone can see my > problem here. I'm running a model that updates an object called 'data' > using a module with the HoldFirst attribute. After I run the module, I > can see the Head of data, and its FullForm, but when I try to view its > StandardForm, I get a $RecursionLimit error as follows. If I try to > Print data, the kernel crashes. However, if I copy the FullForm of > data (Out[76]) into a new object, it Prints perfectly. Any ideas? > In[75]:= Head[data] Out[75]= localState In[76]:= FullForm[data] Out[76]//FullForm= > localState[community[List[population[canola,genotypeInfo[],cohortList[Lis t[]],cohortList[List[]], > cohortList[List[]],cohortList[List[]]],population[lupin,genotypeInfo[],co hortList[List[]],cohortList[List[]], > cohortList[List[]],cohortList[List[]]],population[ryegrass,genotypeInfo[L ist[Rule[List[1,1], > 0.9993453217507997`],Rule[List[Blank[Integer],Blank[Integer]], > 1]],List[major],List[dominant], > List[glyphosate],List[Rational[1,1000000000]],List[0.1`]],cohortList[List [cohort[time[3502828800], > hashedMSet[ruleSet[List[Rule[List[List[1],List[1]], > 1],Rule[List[List[1],List[2]],2],Rule[List[List[2], > List[1]],3],Rule[List[List[2],List[2]], > 4]]],List[499345536052604696,327124822795158, > 327124822795158,214301804988],List[info[List[]],info[List[]],info[List[]],inf o[List[]]]]]]], > cohortList[List[]],cohortList[List[]],cohortList[List[]]],population[wheat ,genotypeInfo[], > cohortList[List[cohort[time[3502828800],hashedMSet[ruleSet[List[Rule[List[Lis t[1],List[1]], > 1]]], > List[160000000000000000],List[info[List[]]]]]]],cohortList[List[]],cohortList [List[]],cohortList[List[]]], > population[wildradish,genotypeInfo[],cohortList[List[]],cohortList[List[] ],cohortList[List[]], > cohortList[List[]]]]],herbicideResidueList[]] In[77]:= StandardForm[data] During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= $RecursionLimit::reclim: Recursion depth > of 1024 exceeded. >> > During evaluation of In[77]:= General::stop: Further output of > $RecursionLimit::reclim will be suppressed during this calculation. >> > I suggest you post the simplest possible data object (in FullForm) that exhibits this problem. Have you perhaps inherited some code that uses MakeBoxes to format code in a particular way - this could generate the symptoms you describe. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: vehicle routing problem hi, i want to solve a VRP problem with mathematica.... i want to solve it in two phase 1) a set covering problem 2) assigning one vehicle for each set and useing TSP(travelling salesman problem) to route the vehicle... i neep help..is there any way to solve VRP directly or how do i solve these 2 phases. i have a depot and nearly 500 demand points.. any suggestion/help =D6m=FCR.. === Subject: Re: Null Return for a Module Hello Dave the Funkatron, I believe you have a missing ; Try Test[] := Module[{i, thesum}, thesum = 0; For[i = 1, i <= 3, i++, thesum = thesum + i] ; Return[thesum]] Test[] > Hi all, > > I'm getting strange output and am trying to track down what might be > causing it. I have the following code in my .nb file: > > (* begin code *) > > Test[ ] := Module[ {i, thesum}, > thesum = 0; > For[ i = 1, i <= 3, i++, > thesum = thesum + i > ] > Return[ thesum ] > ] > > Test[ ] > > (* end code *) === Subject: Re: Null Return for a Module > Hi all, I'm getting strange output and am trying to track down what might be > causing it. I have the following code in my .nb file: (* begin code *) Test[ ] := Module[ {i, thesum}, > thesum = 0; > For[ i = 1, i <= 3, i++, > thesum = thesum + i > ] > Return[ thesum ] > ] Test[ ] (* end code *) > The output I would expect would be simply 6 But, I get Null Return[6] You are missing a semi-colon. Try this: Test[] := Module[{i, thesum}, thesum = 0; For[i = 1, i <= 3, i++, thesum = thesum + i]; Return[thesum]] -- Helen Read University of Vermont === Subject: Re: Display commands in a package > You can do the following: > > << BarCharts` > > ?BarCharts`* > >> >> V6.02 XP machine. >> >> With a fresh kernel this works ok - no error messages. >> << BarCharts` >> >> But in response to this line >> ?BarCharts`* >> >> I get: >> >> Syntax::sntxf: ? cannot be followed by BarCharts`*. >> >> Syntax::tsntxi: BarCharts`* is incomplete; more input is >> needed. >> >> Syntax::sntxi: Incomplete expression; more input is needed. >> >> Do you have any thoughts on why my machine won't respond >> > > > << BarCharts`* > > or > > Information[BarCharts`*] > > instead. > work either. But I stumbled into a line that does work: Needs[BarCharts`] This is just one of the peculiar things about my installation; no idea why commands others use don't work === Subject: Filling problem in Plot3D consider the following 3D graphic in v6, with two surfaces: Plot3D[{.3, .7}, {x, 0, 1}, {y, 0, 1}, BoxRatios -> 1, Mesh -> False, PlotStyle -> RGBColor[0, 1, 0, .5], PlotRange -> {{0, 1}, {0, 1}, {0, 1}}, FillingStyle -> {RGBColor[1, 0, 0, .5]}, Filling -> {1 -> {2}} ] There should be some filling between the two surfaces, but no filling is displayed at all. Of course I can fill with Filling -> {1 -> .7}, but what if the target surface is not planar? Any suggestions? Version: 6.0 for Microsoft Windows (32-bit) Istvan Zachar === Subject: Re: need help Hi Tomi, for random numbers, see RandomInteger or RandomReal in the manual. They can generates lists. The function can be written e.g. as: FourSumf[n_]:=Module[{eq}, eq={x1^2+x2^2+x3^3+x4^2==n, 0<=x1<=x2<=x3<=x4, Element[{x1,x2,x3,x4},Integers]}; {x1,x2,x3,x4}/.ToRules[Reduce[eq]] ] here we used that the sum of squares is n, that 0<=xi, we sorted xi ascending and we request that x must be integers. Finally Reduce does the actual work. hope this helps, Daniel > Hello All, I need help with two pure functions 1) Li[Ranlist,x] that return a list of x element selected at random from Ranlist. (Is there any way to gennerate random from Ranlist? For example I have RanList=Range[-100,100]) 2) the function 4Sumf[x] is computing the sum of 4 squares of x. If I have x=1, this function will gennerate 1^2+0^2+0^2+0^2, if x=4 then 2^2+0^2+0^2+0^2, if x=7 then 2^2+1^2+1^2+1^2 Is anyone out there have any ideas? > Tomi > === Subject: Import .xlsx files Is Import capable of reading Excel files stored in the new MSXML file format (.xslx)? A quick trial shows that it is not, but maybe I am not doing something right. I am aware that I could write a function to dig into the .xslx as a zip archive, retrieve the .xml files, and try to extract the cell values, but I am lazy and hoping somebody else did that for me already. === Subject: Re: RegionPlot color rp = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}] clr = Cases[rp, RGBColor[__], Infinity][[1]] Graphics[{clr, Rectangle[{0, 0}]}] Bob Hanlon > > Mathematica 6 produces a region and fills it with default color in RegionPlot (drawing 2D inequality). I wish to use the color elsewhere in graphics applications. I could not recognize the color and the scheme associated with it. kindly guide me on locating this color among mathematica 6 color schemes. > === Subject: Re: need help ri = RandomInteger[{-100, 100}, 10] {-19,-96,85,-6,-60,-21,40,78,-4,-82} ri[[RandomInteger[Length[ri]]]] 78 sumf[x_Integer] := FindInstance[ a^2 + b^2 + c^2 + d^2 == x, {a, b, c, d}, Integers][[1]] sumf /@ {1, 4, 7} {{a->0,b->0,c->1,d->0},{a->0,b->0,c->2,d->0},{a->1,b->1,c->2,d->1}} Bob Hanlon > Hello All, I need help with two pure functions 1) Li[Ranlist,x] that return a list of x element selected at random from Ranlist. (Is there any way to gennerate random from Ranlist? For example I have RanList=Range[-100,100]) 2) the function 4Sumf[x] is computing the sum of 4 squares of x. If I have x=1, this function will gennerate 1^2+0^2+0^2+0^2, if x=4 then 2^2+0^2+0^2+0^2, if x=7 then 2^2+1^2+1^2+1^2 Is anyone out there have any ideas? > Tomi > === Subject: Re: A small syntax error causing Kernel crash, Version 6.0.1 Hi Nasser, this also happens with version 6.0.2 Daniel > Fyi; This below causes Kernel crash Solve[Integrate[f[x]*Exp[x], {x}] == 1, r] Mathematica 6.0.1, on XP (the {x} is the problem). Nasser === Subject: Bug in ExportString? I expect from ImportString[ExportString[ , PDF], PDF] not {}. Is this a bug? with friendly greetings, P_ter === Subject: Re: Bug in ExportString? using FullForm on ImportString[ExportString[{1,1}, PDF], PDF] //FullForm it is clear that the output is quite different from the input: {1,1}. Is any documetation available or is this a bug? Daniel > I expect from ImportString[ExportString[ , PDF], PDF] not {}. > Is this a bug? > with friendly greetings, > P_ter > === Subject: Bug in ExportString? I did not formulate a good question about: ImportString[ExportString[ , PDF], PDF] My point is that this gives an image, while ImportString[ExportString[t, PDF], PDF] gives with Inputform a polygon. I think a space is also text ( ). It has an ASCII place. So, there should be no difference in structure with the letter t. with friendly greetings, P_ter === Subject: basic questions hi everyone! first of all i would like to introduce myself to the list: i work as artist and would describe myself as mathematica noob. being an artist i am mainly engaged in visualizing chaotic systems, such as iterated function systems or time series from experimental data. now, here comes the mathematica bit for which i hope to find some information on this list (at the moment i do not own mathematica but have the chance to use it on one of the machines at the local university (mathematica 6)). i would be very happy to find some tips for those basic noob questions: - how can i import a 3 column (x,y,z) file into mathematica an do a 3d plot? ps: i managed the 2d version with something like data=Import[file, List] and ListPlot ... or so ... - is there an expression that colors certain values from the list with a color of my choice? (eg: the mean values from the list are rendered red) - and number three: how can i tell mathematica to do the following: take an irrational number such as PI. now create a list according to the following rule: 3.14159265 ....-> x,y,z 3,1,4 1,5,9 2,6,5 .,.,. looking forward to your tips! thank you for your time markus www.humanchaos.net === Subject: Re: basic questions Hi Markus, see below. Daniel > hi everyone! first of all i would like to introduce myself to the list: i work as artist and would describe myself as mathematica noob. being an artist i am mainly engaged in visualizing chaotic systems, such as iterated function systems or time series from experimental data. now, here comes the mathematica bit for which i hope to find some information on this list (at the moment i do not own mathematica but have the chance to use it on one of the machines at the local university (mathematica 6)). i would be very happy to find some tips for those basic noob questions: - how can i import a 3 column (x,y,z) file into mathematica an do a 3d plot? ps: i managed the 2d version with something like data=Import[file, List] and ListPlot ... or so ... Imoprting 3D works the same as 2D. To plot colored points you may e.g. define a function that takes a point and returns a color and a point, e.g.: getColor[{x_,y_,z_}]:={Hue[z],Point[{x,y,z}]}; Graphics3D@(getColor/@{{1,1,1},{1,1,0},{0,1,1/2},{1/2,1/2,1/3},{0,1/2,1/2}}) > - is there an expression that colors certain values from the list with a color of my choice? (eg: the mean values from the list are rendered red) - and number three: how can i tell mathematica to do the following: take an irrational number such as PI. now create a list according to the following rule: 3.14159265 ....- x,y,z > 3,1,4 > 1,5,9 > 2,6,5 > .,.,. to get triples of digits of Pi you may use RealDigits and Partition: Partition[RealDigits[Pi,10,30][[1]] ,3] looking forward to your tips! > thank you for your time markus www.humanchaos.net > === Subject: Re: Poisson equation with boundary conditions on rectangle Hi Michael, >> I'm currently trying to solve the following pde with rectangle boundary (I better already use mathematica code here): >> The equation (Poisson equation): >> D[u[y, z], y, y] + D[u[y, z], z, z] + 1 == 0 >> The boundary conditions on the rectangle(y in [0,0.1] and z in [-0.4,0.4]): >> u[y, 0.4] == 0, u[y, -0.4] == 0, u[0, z] == 0, >> Derivative[1, 0][u][0.1, z] == 0 >> I tried the following in mathematica: >> eqn = D[u[y, z], y, y] + D[u[y, z], z, z] + 1 == 0; //defining equation >> NDSolve[{eqn, u[y, 0.4] == 0, u[y, -0.4] == 0, u[0, z] == 0, Derivative[1, 0][u][0.1, z] == 0 }, u, {y, 0, 0.1}, {z, -0.4, 0.4}] //using NDSolve to solve the boundary problem >> But, as you might guess, I get an error using NDSolve the way above: NDSolve::ivone: Boundary values may only be specified for one independent variable. Initial values may only be specified at one value of the other independent variable. >> When I lookup the description of that error I realize that in my example the following error condition matches: This input generates a message because the equations specify values for the solution on all sides of the solution region. >> Does this mean, that mathematica can't approximate the solution to my problem with NDSolve or am I doing something wrong? >> So overall question is: How can I solve my problem using mathematica without writing my own numerical pde solver for my problem? I too have a problem like yours...I found this link which may help > you: > http://documents.wolfram.com/mathematica/Built-inFunctions/AdvancedDocumentat ion/LinearAlgebra/LinearAlgebraInMathematica/Examples/AdvancedDocumentationLi nearAlgebra6.3.html > It uses a finite difference method..even tough I don't really know how > it works lol! If you are interested in how the FDM works have a look at a tutorial i http://www.imtek.uni-freiburg.de/simulation/mathematica/IMSweb/imsTOC/Lectur es%20and%20Tips/Simulation%20I/index.html Oliver Oliver Ruebenkoenig, === Subject: Re: reaction diffusion equation ! Hi Khaled, Your problem is a non-linear variant of the classic fisher equations.There are local fixed-point schemes that can guarantee convergence but global solutions cannot be guaranteed to exist. (i) I have used Mathematica to work out the steady state solution and in that case you just eliminate the derivative in t and it becomes a standard laplace equation. (ii) I highly doubt that this kind of problem would have travelling wave solution because in Poincare phase plane only one critical point exists. In such scenarios you would need to use a finite-difference scheme that achieves stable results.Since,Mathematica does have finite-difference notebooks available check those out over the web. Best of luck! Nabeel > Can NDSolve in Mathematica solves the nonlinear reaction diffusion > equation in two dimensions > (Tt-Uxx-Uyy=f(U) with Drichlit B.C.). I ask u kindly to send me the > mathematica program solves the transient heat equation in two dimension or > the heat diffusion equation if u already have it. > khaled sayed > Khaled Sayed Mahmoud Ibrahim Department of MathematicsFaculty of > ScienceHelwan University Helwan, Cairo, EgyptTel.: (+20)18-25-35-272 > Fax: (+20)-2-25588-586k_s_mahmoud@hotmail.com -- We have not succeeded in answering all our problems.The answers we have found only serve to raise a whole set of new questions.In some ways we feel that we are as confused as ever,but we believe we are confused on a higher level and about more important things. Nabeel Butt UWO,London Ontario, Canada === Subject: Re: What is @@@? >> I have seen several references to the command @@@ in this newsgroup, >> but a query of the online Documentation Center just refers me to >> Apply (@@). What does it do and where can I read about it? > More broadly: * Do all the _non-alphabetical_ commands (or symbols, or operators, > or abbreviations, or whatever is their proper appellation) like > /., //., ->, =>, @, etc, etc, etc, have a unique > appellation _as a class_? * Does each of these non-alphabetical constructs also have a unique > individual name? * Suppose one wanted to get a complete (complete!) list of all of > these non-alphabetical constructs, their names, and maybe a brief > description of their meaning, to use maybe as a reference list, a crib > sheet, or just to see which of them one hasn't learned yet. Where > would one go? > I remembered that there was a table in the documentation listing all >> operators in order of decreasing *precedence*. It is very easy to find >> by searching for precedence in the hand compiled master index of the >> v5 documentation. But after having searched for 10 minutes, I just >> don't have any more patience to look it up in the v6 documentation ... >> So here's the v5 doc link: >> http://documents.wolfram.com/mathematica/book/section-A.2.7 Well, it's no wonder I didn't find it. It is under > Core Language -> Appendix: Language Structure -> Input Syntax - Operator Input Forms in the Virtual Book, but it turns out that the > files are missing! Clicking on the Input Syntax link takes you to the right document, at which point you have to scroll down about a third of the way through (i.e., if the links were functioning correctly, they would have opened the Input Syntax document and scrolled it to the right location). the problem. For what it's worth, I've had the same problem locating this document using the search system myself (I also find it exceedingly useful). I think the document responds so poorly to searches because of its length and diversity. I have on my computer a development version where the document has been split up, and searching for precedence points right to this table (no need for scrolling, even) as the second hit. I can't offer ironclad guarantees on precisely what the behavior will be in the next version, but I think it's moving in the right direction. In the mean time, the best key term to search on would be Input syntax. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: noob questions :) hi everyone! first of all i would like to introduce myself. being an artist i am mainly engaged in the visualization of chaotic systems such as iterated function systems or strange attractors from experimental data. i consider myself a completely mathematica noob (willing to learn ::)) i got introduced to mathematica by a friend who works in the math institute at our local university (hence, that's where i spent most of my recent time ... lol). to get myself started with the project i have in mind i could use some help, which i have not found in the databases yet: - how can i tell mathematica to import a three-column (x,y,z) txt file and do a 3d plot from the values. i already messed with the ListPlot3D command , unfortunately to no avail. the file containing the experimental data looks something like this: point,x,y,z 1,34,21,45 2,32,53,76 3,12,23,43 4,45,21,87 5,65,76,87 etc - how can i then tell mathematica to color certain values from this data list with a color from my choice? eg: color the values X red (X could be something like the mean value of the entire list) - is the a function that makes a list from an irrational number such as PI according to the above list format? something like 3.14159265... x,y,z 1,4,1 5,9,2 6,5,. .,.,.,. etc looking really forward to get the hang of it and then get the program at my own place to integrate it in my work. looking forward to your help & thank you for your time :) markus www.humanchaos.net === Subject: Re: RegionPlot color I evaluated a RegionPlot command, and then applied FullForm to the RGB colorscale as: RGBColor[0.798413061722744`, 0.824719615472648`, 0.968322270542458`]. Hope that helps! C.O. Mathematica 6 produces a region and fills it with default color in > RegionPlot (drawing 2D inequality). I wish to use the color elsewhere in > graphics applications. I could not recognize the color and the scheme > associated with it. kindly guide me on locating this color among > mathematica 6 color schemes. > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: RegionPlot color rp = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}] clr = Cases[rp, RGBColor[__], Infinity][[1]] Graphics[{clr, Rectangle[{0, 0}]}] Bob Hanlon > > Mathematica 6 produces a region and fills it with default color in RegionPlot (drawing 2D inequality). I wish to use the color elsewhere in graphics applications. I could not recognize the color and the scheme associated with it. kindly guide me on locating this color among mathematica 6 color schemes. > === Subject: Re: Printing Mathematica stuff via KPrinter I just looked (I have the same config as you). It seems to me that the printer selection offered by Math is taken as- is by CUPS. But I don't think it makes much sense to add kprinter to the list, since it is kprinter that uses CUPS, not the other way round. alessandro > (This message was originally sent to the list about eight months ago. On the > off-chance that anyone has some new input, I'm sending it again.) > I usually use Mathematica (6.0.1) from linux, specifically, the KDE WM. I > would like to use the kprinter program to print notebooks directly, but > kprinter is not listed as a possible printer (though it is in many other > programs; I suppose these other programs might be tied more closely to KDE's > libraries or something). Is there a way of adding a printer manually (via a configuration file?) > or of making Mathematica notice that pseudoprinters are available to the > system? Curtis O. > -- > Curtis Osterhoudt > cfo@remove_this.lanl.and_this.gov > PGP Key ID: 0x4DCA2A10 > Please avoid sending me Word or PowerPoint attachments > Seehttp://www.gnu.org/philosophy/no-word-attachments.html === Subject: REMINDER--Advanced Mathematica Summer School This is a reminder that you can still apply for our first Advanced Mathematica Summer School. Taking place July 6-18, 2008, in Champaign, Illinois, the Summer School is intended for students and professionals with significant Mathematica projects. Attendees will work directly with senior developers and managers at Wolfram Research to advance those projects. Applications are being accepted now; a limited number of slots are available. For more details and to apply, see: http://www.wolfram.com/summerschool === Subject: Re: What determines #1 and #2 values (with &) for values {x1,y1},... are generated so that I can adjust them appropriately. For example, the automatic label often puts the labels out of range, so I might want to use {#1+2,#2-2} as my arguments, but to choose the adjustments properly I first need to understand what values #1 and #2 will take. > You are applying your function to the list of automatic labels. That list is of the form {{x1, y1, label1}, {x2, y2, label2}, ...} Your function converts each of them to Text[label, {x, y}]; this is the same as would occur if you used ContourLabels -> Automatic Bob Hanlon Here's the example of a ContourPlot: {i = 0, j = 0}; ContourPlot[{x == 4 + y/4, y == 2 + x/2}, {x, 0, 10}, {y, 0, 10}, > ContourLabels -> (Text[#3, {val1[i += 1] = #1, val2[j += 1] = #2}] > &)] Print[{val1[1], val2[1], val1[2], val2[2]}] The output is a basic plot with two lines, and I've set it to record > and print the values of #1 and #2 arguments, which are: > val1[1] = 6.4857 > val2[1] = 9.9429 > val1[2] = 0.095238 > val2[2] = 2.0476 I'd like to know where those values came from so that I can apply the > #1 and #2 arguments intelligibly. > === Subject: Special Characters in Vista It seems so strange that you literally have to adjust system permissions in order save Special Language Characters in Windows Vista. Yes, I know some people have grown weary of the all of the fretting over the Vista Operating System: http://www.youtube.com/watch?v=Vje5LVSJYQI But Still!!! Sylvia Hobbs === Subject: Just primitive ColorFunction I think, that it must be something very simple, but I cannot find the solution.... I need to fill the Plot so, that area above the axis will be red and area below the axis will be blue. I tried it in a such way: Plot[Sin[x], {x, 0, 4 Pi} , AxesOrigin -> {0, 0}, Axes -> {True, True}, PlotStyle -> Thick, ColorFunction -> If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]], Filling -> Axis, ImageSize -> {380, 280}] But Mathematica says, that If is not a valid Color. If I try it with Function (according to examples in ColorFunction help), ColorFunction -> Function[x, If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]], it is working, but the color of Filling is red allover the range. Jakub === Subject: Re: Just primitive ColorFunction Hi Jakub, you may e.g. try: Plot[Sin[x], {x, 0, 4 Pi}, Filling -> Axis, FillingStyle -> {Red, Blue}] hope this helps, Daniel > I think, that it must be something very simple, but I cannot find the > solution.... I need to fill the Plot so, that area above the axis will be red and area > below the axis will be blue. I tried it in a such way: Plot[Sin[x], {x, 0, 4 Pi} , > AxesOrigin -> {0, 0}, > Axes -> {True, True}, > PlotStyle -> Thick, > ColorFunction - If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]], > Filling -> Axis, > ImageSize -> {380, 280}] But Mathematica says, that If is not a valid Color. If I try it with Function (according to examples in ColorFunction help), ColorFunction - Function[x, If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]], it is working, but the color of Filling is red allover the range. > Jakub === Subject: Re: Just primitive ColorFunction > I think, that it must be something very simple, but I cannot find the > solution.... I need to fill the Plot so, that area above the axis will be red and area > below the axis will be blue. I tried it in a such way: Plot[Sin[x], {x, 0, 4 Pi} , > AxesOrigin -> {0, 0}, > Axes -> {True, True}, > PlotStyle -> Thick, > ColorFunction - If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]], > Filling -> Axis, > ImageSize -> {380, 280}] But Mathematica says, that If is not a valid Color. If I try it with Function (according to examples in ColorFunction help), ColorFunction - Function[x, If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]], it is working, but the color of Filling is red allover the range. > Jakub Jakub, for this particular example the following works: Plot[Sin[x], {x, 0, 4 Pi}, AxesOrigin -> {0, 0}, Axes -> {True, True}, PlotStyle -> Thick, Filling -> Axis, FillingStyle -> {Blue, Red}, ImageSize -> {380, 280}] Gruss Peter -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Dynamic Hi! I am trying to learn how the new Dynamic features work. The following two Manipulate expressions give outputs that make perfect intuitive sense to me: Manipulate[q = p + 1; q, {p, 0, 1}] Manipulate[q = p + 1; FullForm@q, {p, 0, 1}] (don't keep both outputs active at the same time if you are short on battery power!) When I try to reproduce similar effects with DynamicModule, I get all sorts of different behaviours. Compare the following: DynamicModule[{p = 0, q}, q = p + 1; {Slider[Dynamic@p], q}] DynamicModule[{p = 0, q}, q = p + 1; {Slider[Dynamic@p], Dynamic@q}] DynamicModule[{p = 0, q}, q = Dynamic[p] + 1; {Slider[Dynamic@p], q}] DynamicModule[{p = 0, q}, q = Dynamic[p] + 1; {Slider[Dynamic@p], FullForm@q}] DynamicModule[{p = 0, q}, q = Dynamic[p] + 1; {Slider[Dynamic@p], FullForm@Dynamic@q}] DynamicModule[{p = 0, q}, q = Dynamic[p] + 1; {Slider[Dynamic@p], Dynamic@FullForm@q}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], q}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], q[[1, 1]]}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], q[[1, 2]]}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], Dynamic@q}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], Dynamic[q[[1, 1]]]}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], Dynamic[q[[1, 2]]]}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], FullForm@q}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], Dynamic@FullForm@q}] DynamicModule[{p = 0, q}, q = Dynamic[p + 1]; {Slider[Dynamic@p], FullForm@Dynamic@q}] Right now all I need is a few kind words of encouragement from somebody who has already mastered dynamic interactivity... Gianluca === Subject: question on player pro I have a simple question on the new Mathematica player pro. If person X, who has Mathematica, makes a Mathematica notebook (.nb file), what are then the steps needed so that person Y can run the same notebook if Y do not have Mathematica? Does Y need to buy player pro to run X's notebook? Or is it that only X needs to buy player pro, and use it to 'convert' or 'compile' the notebook to a new file (what is the extension?) which I assume will contain the Mathematica kernel in it, and send that file to person Y. But then how will Y run it if they do not have player pro nor Mathematica? use the free player? What about any licensing issue in sending playerpro files to someone else to run? Nasser === Subject: Re: Text does not show up in vertices of GraphPlot3D Hi When I tried this I found that the settings for VertexRenderingFunction over-rode those for VertexLabeling. If I excluded the setting of VertexRenderingFunction and set VertexLabeling -> True, the labels were indeed shown. and that the two cannot simultaneously apply. Mark > when I take the last example in the documentation of GraphPlot3D (basic examples: the rendering) and use the following graph the labels do not show up. (the text comes from an application of Formal Concept Analysis to a consumer table for mobile phones). Anyway, they do now show up there with VertexLabeling-> True. Any idea? gr1 = {Gesprekken -> Gebruik-+, Gesprekken -> Duurzaamheid-+, Gebruik-+ -> Draagbaarheid++,Gebruik-+ -> SMS-+, > Gebruik-+ -> Lege knoop, Duurzaamheid-+ -> Accu++, > Duurzaamheid-+ -> Lege knoop, > Draagbaarheid++ -> Duurzaamheid++, > Draagbaarheid++ -> SMS--, Lege knoop -> SMS--, > SMS-+ -> Duurzaamheid++, SMS-+ -> 9, Lege knoop -> 9, > Accu++ -> 9, Accu++ -> Gebruik+, Duurzaamheid++ -> Earth, > SMS-- -> Earth, 9 -> Earth, Gebruik+ -> Earth}; > with friendly greetings, > P_ter === Subject: Re: need help 1.) I think you need the function RandomChoice: RandomChoice[Range[-100,100],20] RandomChoice[list,n] 2.) I have written this little function for you: Sumf4[x_] := ( s = x; s1 = x; While[MatchQ[Sqrt[s1], _Integer] == False, s1--]; s -= s1; s2 = s; While[MatchQ[Sqrt[s2], _Integer] == False, s2--]; s -= s2; s3 = s; While[MatchQ[Sqrt[s3], _Integer] == False, s3--]; s -= s3; s4 = s; While[MatchQ[Sqrt[s4], _Integer] == False, s4--]; s -= s4; Print[Sqrt[s1]^2, +, Sqrt[s2]^2, +, Sqrt[s3]^2, +, Sqrt[s4]^2, Remainder=, s] ) If you want to have the 4 squares for 91 for example, you have to type the following: Sumf4[91] 9^(2)+3^(2)+1+0^(2) Remainder=0 But the problem is, that for some numbers you need more than 4 squares: 96=9^2+3^2+2^2+1^2+1^2 I think I will give you the solution to this problem in some days, when I have more time, if then it has not been answered. But first of all, think of a solution by yourself and post it. I am really interested. I hope I could help you. Patrick Klitzke email:philologos14@gmx.de === Subject: Re: RegionPlot color Mathematica 6 produces a region and fills it with default color in = RegionPlot (drawing 2D inequality). I wish to use the color elsewhere in g= raphics applications. I could not recognize the color and the scheme associa= ted with it. kindly guide me on locating this color among mathematica 6 colo= r schemes. > The color they use is RGBColor[0.798413061722744`, 0.824719615472648`, 0.968322270542458`] although I'm not sure if this comes from some pre-defined palette or what. It doesn't appear to be in any of the indexed color palettes. -Daniel === Subject: Re: RegionPlot color > Mathematica 6 produces a region and fills it with default color in RegionPlot (drawing 2D inequality). I wish to use the color elsewhere in graphics applications. I could not recognize the color and the scheme associated with it. kindly guide me on locating this color among mathematica 6 color schemes. I tried replicating this colour once (not very hard) and decided it was too hard :) It's not exactly a shade of blue, although it's too far from Nest[Lighter,Blue,4]: Show@{RegionPlot[x < 0.5, {x, 0, 1}, {y, 0, 1}], RegionPlot[x > 0.5, {x, 0, 1}, {y, 0, 1}, PlotStyle -> Nest[Lighter, Blue, 4]]} Which is, now that I look at it, the same as {Opacity[0.2],Blue}: Show@{RegionPlot[x < 0.33, {x, 0, 1}, {y, 0, 1}], RegionPlot[0.33 < x < 0.66, {x, 0, 1}, {y, 0, 1}, PlotStyle -> {Opacity[0.2], Blue}], RegionPlot[x > 0.66, {x, 0, 1}, {y, 0, 1}, PlotStyle -> Nest[Lighter, Blue, 4]]} Usually I just apply my own colours :) but it would be nice to know exactly which ones Mathematica uses. I suppose it wouldn't be hard just to figure it out by inspecting the plot that get drawn by default and extracting the colour information. By the way, on the offchance you're outputting EPS graphics, this would be a convenient time to shamelessly plug my FakeRegionPlot package: Will === Subject: Problems with recursive function I'm in trouble with a recursive function. the functios looks similar to test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an argument of test. for any calculation i need to tell mathematica the first value of the function, e.g. test[0, 5]=5. The problem is the following: the first object is independent of b. does anyone know a way to tell mathematica the following thing: test[0,b]=5 => test[0]=5 regardless to b. Frank === Subject: Re: Problems with recursive function Hello Frank, try this: test[0, _] = test[0] = test0 test[0, foo] I'm in trouble with a recursive function. the functios looks similar to > test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an > argument of test. > for any calculation i need to tell mathematica the first value of the > function, e.g. test[0, 5]=5. The problem is the following: the first > object is independent of b. does anyone know a way to tell mathematica > the following thing: test[0,b]=5 => test[0]=5 regardless to b. > Frank -- W. Craig Carter === Subject: Re: Problems with recursive function Hi Frank, if I understand correctly, you need to define a recursion with a stop criterion. You can do this by e.g.: test[0,_]:=5; test[n_,b_]:=test[n-1,b] b; test[10,5] if you have many calculations, it may be advantageously to store intermediate results: test[n_,b_]:=test[n-1,b]=test[n-1,b] b; hope this helps, Daniel I'm in trouble with a recursive function. the functios looks similar to > test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an > argument of test. > for any calculation i need to tell mathematica the first value of the > function, e.g. test[0, 5]=5. The problem is the following: the first > object is independent of b. does anyone know a way to tell mathematica > the following thing: test[0,b]=5 => test[0]=5 regardless to b. > Frank > === Subject: ListCorrelate on lists with different sampling rates I've been beating my head against this problem (only half an hour at a time, though, which may well be my mistake) for a little while now, and was wondering if people had some input. I'm basically looking at the cross-correlation (or sliding dot-product) of two sampled (discrete) signals---one a drive signal and one a received signal---to pick out various features. I'm doing this using Mathematica's ListCorrelate, which is working admirably, and I can easily pick out echoes and so on. However, my question concerns what to do when the sampled signals have different time scales. As I understand it, the ListCorrelate function really only works (for this application) when the input lists are one-dimensional. If the sampling rates are different, I can go ahead and (for example) resample the higher-sample-rate signal (via interpolation) to the same rate as the lower-sample-rate signal, and then perform the ListCorrelation. It seems to me, though, that I'm sort of throwing away some information that I don't need to in the resampling procedure. Is that the recommended procedure, or is there something more clever I can do? Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: CreateDialog Pecularity > I often like to use CreateDialog as an easy way to put material up in a > window even through there is no active 'dialog'. However there is a strange > feature in which if one makes the window floating then it also appears to > become Modal, even if Modal is set to False. CreateDialog[ > Does Modal depend on the WindowFloating option?nThis has > WindowFloating [Rule] FalsenTry to evaluate another cell in the > notebook, > WindowFrame -> Normal, > WindowElements -> {MagnificationPopUp, HorizontalScrollBar, > VerticalScrollBar}, > WindowFrameElements -> {CloseBox, ZoomBox, MinimizeBox, > ResizeArea}, > WindowTitle -> Create Dialog Test, > WindowFloating -> False]; CreateDialog[ > Does Modal depend on the WindowFloating option?nThis has > WindowFloating [Rule] TruenTry to evaluate another cell in the > notebook, > WindowFrame -> Normal, > WindowElements -> {MagnificationPopUp, HorizontalScrollBar, > VerticalScrollBar}, > WindowFrameElements -> {CloseBox, ZoomBox, MinimizeBox, > ResizeArea}, > WindowTitle -> Create Dialog Test, > WindowFloating -> True, > Modal -> False]; 1 + 1 Try to evaluate the last statement with the two different CreateDialog > statements. FWIW, David, I did not encounter any problem with the code above. Indeed, I created several instances of both type of dialog boxes, going back and forth to the notebook and the windows and evaluation some other expressions. I used Mathematica 6.0.2 for Mac OS X 10.5.2 64-bit. I would bet that the issue is platform and version dependent, though this is not of great help! -- === Subject: Re: CreateDialog Pecularity I found the same as Curtis below, running 6.0.2.1 on iMac OS X 10.4.11.Peter Though I'm not quite sure I understand Modal, I tried both of your > examples ( 6.0.1.0 on 32-bit Linux ). They both displayed the floating > windows, and in both cases I could evaluate other cells (even if I > put Modal ->True. --C.O. > I often like to use CreateDialog as an easy way to put material up in a > window even through there is no active 'dialog'. However there is a > strange > feature in which if one makes the window floating then it also appears > to > become Modal, even if Modal is set to False. CreateDialog[ > Does Modal depend on the WindowFloating option?nThis has > WindowFloating [Rule] FalsenTry to evaluate another cell in the > notebook, > WindowFrame -> Normal, > WindowElements -> {MagnificationPopUp, HorizontalScrollBar, > VerticalScrollBar}, > WindowFrameElements -> {CloseBox, ZoomBox, MinimizeBox, > ResizeArea}, > WindowTitle -> Create Dialog Test, > WindowFloating -> False]; CreateDialog[ > Does Modal depend on the WindowFloating option?nThis has > WindowFloating [Rule] TruenTry to evaluate another cell in the > notebook, > WindowFrame -> Normal, > WindowElements -> {MagnificationPopUp, HorizontalScrollBar, > VerticalScrollBar}, > WindowFrameElements -> {CloseBox, ZoomBox, MinimizeBox, > ResizeArea}, > WindowTitle -> Create Dialog Test, > WindowFloating -> True, > Modal -> False]; 1 + 1 Try to evaluate the last statement with the two different CreateDialog > statements. -- > Curtis Osterhoudt > cfo@remove_this.lanl.and_this.gov > PGP Key ID: 0x4DCA2A10 > Please avoid sending me Word or PowerPoint attachments > See http://www.gnu.org/philosophy/no-word-attachments.html -- peter lindsay Computing Officer Mathematical Institute University of St Andrews KY16 9SS 01334463756 === Subject: Re: CreateDialog Pecularity > This problem appears to be version dependent. With 6.0 for Mac OS X x86 (64-bit), I did not have any problem executing another cell with the dialog open in either case. Bob Hanlon > I often like to use CreateDialog as an easy way to put material up in a > window even through there is no active 'dialog'. However there is a strange > feature in which if one makes the window floating then it also appears to > become Modal, even if Modal is set to False. CreateDialog[ > Does Modal depend on the WindowFloating option?nThis has > WindowFloating [Rule] FalsenTry to evaluate another cell in the > notebook, > WindowFrame -> Normal, > WindowElements -> {MagnificationPopUp, HorizontalScrollBar, > VerticalScrollBar}, > WindowFrameElements -> {CloseBox, ZoomBox, MinimizeBox, > ResizeArea}, > WindowTitle -> Create Dialog Test, > WindowFloating -> False]; CreateDialog[ > Does Modal depend on the WindowFloating option?nThis has > WindowFloating [Rule] TruenTry to evaluate another cell in the > notebook, > WindowFrame -> Normal, > WindowElements -> {MagnificationPopUp, HorizontalScrollBar, > VerticalScrollBar}, > WindowFrameElements -> {CloseBox, ZoomBox, MinimizeBox, > ResizeArea}, > WindowTitle -> Create Dialog Test, > WindowFloating -> True, > Modal -> False]; 1 + 1 Try to evaluate the last statement with the two different CreateDialog > statements. -- > David Park > djmp...@comcast.net >http://home.comcast.net/~djmpark/ I had the same problem you report using Version 6.0.2.0 on Windows XP. === Subject: Re: pure function > Hello All, I need help with two pure functions 1) Li[Ranlist,x] that return a list of x element selected at random > from Ranlist. (Is there any way to gennerate random from Ranlist? I > have RanList=Range[-100,100]) 2) the function 4Sumf[x] is computing the sum of 4 squares of x. If > I have x=1, this function will gennerate 1^2+0^2+0^2+0^2, if x=4 > then 2^2+0^2+0^2+0^2, if x=7 2^2+1^2+1^2+1^2 Is anyone out there have any idea? > Tomi > With Mathematica 6: 1) Selections with replacement or without replacement? With replacement: RandomChoice[Range[-100, 100], 6] {58, 13, -51, 66, -40, -69} without replacement: RandomSample[Range[-100, 100], 6] {-38, 67, 83, 79, 3, -3} (2). PowersRepresentations[1, 4, 2] {{0, 0, 0, 1}} PowersRepresentations[7, 4, 2] {{1, 1, 1, 2}} All this has to be (and can be) done quite differently with earlier versions of Mathematica but as you do not specify your version I assume you have the latest. Andrzej Kozlowski === Subject: pure function Hello All, I need help with two pure functions 1) Li[Ranlist,x] that return a list of x element selected at random from Ranlist. (Is there any way to gennerate random from Ranlist? I have RanList=Range[-100,100]) 2) the function 4Sumf[x] is computing the sum of 4 squares of x. If I have x=1, this function will gennerate 1^2+0^2+0^2+0^2, if x=4 then 2^2+0^2+0^2+0^2, if x=7 2^2+1^2+1^2+1^2 Is anyone out there have any idea? Tomi