A132 === Subject: Histograms and Iterators - Beginner Question Hello everyone: I am a new Mathematica user and have been teaching myself the program using real-world examples and reverse-engineering the code. This approach has worked well for the last few months since I began, but I have run into a roadblock and was hoping someone will help me out. I am currently trying to import financial data and generate a histogram of the daily volume for a given security. Ultimately I am going to make this into a sparkline (very useful in my work). Use of the options to create the sparkline is clear. Where I am getting stuck is the importing and formatting of the data. I think setting up the iterators is my problem, but I have tried about every option and have not found the answer yet. I have been using the default examples in the online documentation of Histogram[Table[FinancialData[IBM,Volume,i],{i,March Any suggestions, Jon === Subject: Re: Histograms and Iterators - Beginner Question > Hello everyone: I am a new Mathematica user and have been teaching myself the program > using real-world examples and reverse-engineering the code. This > approach has worked well for the last few months since I began, but I > have run into a roadblock and was hoping someone will help me out. I am currently trying to import financial data and generate a > histogram of the daily volume for a given security. Ultimately I am > going to make this into a sparkline (very useful in my work). Use of > the options to create the sparkline is clear. Where I am getting stuck = > is the importing and formatting of the data. I think setting up the > iterators is my problem, but I have tried about every option and have > not found the answer yet. I have been using the default examples in the online documentation of Histogram[Table[FinancialData[IBM,Volume,i],{i,March Any suggestions, > Jon To get the volume data: 2009}, Value]; Then just plot it: Histogram[volume] === Subject: Re: Histograms and Iterators - Beginner Question Hi Jon, A few remarks: 1. A histogram is probably not the kind of plot you're looking for. This counts nd displays the numbers of occurences of a countable set of objects. What you actually need is just a simple x-y plot. 2. FinancialData has ways to deliver data for a given date or a range of dates. No need for iterations in a Table. 3. Examining examples is fine and reverse engineering is not bad either, but reading the manual can be very educating. Everything you needed to know was on the FinancialData doc homepage. Just click on the More Information bar right below the yellow syntax box. Joined -> True] will do the trick. > Hello everyone: I am a new Mathematica user and have been teaching myself the program > using real-world examples and reverse-engineering the code. This > approach has worked well for the last few months since I began, but I > have run into a roadblock and was hoping someone will help me out. I am currently trying to import financial data and generate a > histogram of the daily volume for a given security. Ultimately I am > going to make this into a sparkline (very useful in my work). Use of > the options to create the sparkline is clear. Where I am getting stuck = > is the importing and formatting of the data. I think setting up the > iterators is my problem, but I have tried about every option and have > not found the answer yet. I have been using the default examples in the online documentation of Histogram[Table[FinancialData[IBM,Volume,i],{i,March Any suggestions, > Jon === Subject: Re: Online Graphic Output Therefore I reduced the problem to a simple code example: Do[{ x = Random[], y = Random[], p = Point[{x, y}], > Graphics[{PointSize[0.1], p}, GridLines -> Automatic, > Frame -> True, PlotRange -> { {-1, 1}, {-1, 1}}]} , > {n, 1, 5}] I would like to receive a single graphic with 5 points plotted. > The statements within the Do loop show nothing, not even a error > message with the Mathematica version 7. > A Do loop does not generate output. If you want to see results you have to explicitly print them using Print[ ]. This works for values and graphics alike. In your case, the loop doesn't generate a single graph with 5 points, but 5 graphs with each a single point. Furthermore, you are using commas to make a compound statement whereas Mathematica requires a semicolon (;) for that purpose. Also, you are probably confusing Do and Table. You would like to have a list of points. A minimal modification of your code that works would then be: Graphics[ Prepend[ Table[ x = Random[]; y = Random[]; Point[{x, y}], {n, 1, 5} ], PointSize[0.1] ], GridLines -> Automatic, Frame -> True, PlotRange -> {{-1, 1}, {-1, 1}} ] However, this is still pretty ugly. It can be written much more elegantly: Graphics[ { PointSize[0.1], Point[RandomReal[{0, 1}, {5, 2}]] }, GridLines -> Automatic, Frame -> True, PlotRange -> {{-1, 1}, {-1, 1}} ] This uses the fact that Point is listable, i.e. can work on a list of points. It also uses the efficient RandomReal that is able to generate multi-dimensional list of random numbers. One final remark: The range of the random points and your choice for PlotRange do not coincide. You should change PlotRange or the RandomReal statement (in RandomReal[{-1, 1}, {5, 2}]) > Normally Mathematica uses data sets that are collected before plotting. I= receive a data stream from internet and I would like to display these data= points immediately. A typical application of this kind could be a online c= hart of changing prices. Although I am an experienced user of Mathematica 2= -7 for many years, I do not know, how to program this application type. Cou= ld anybody help out ? === Subject: SetDelayed::write ... [x_] is protected I have solution of equations which is dependend on one parameter lets say: sol={{i1->220/x}, {i2 -> 100+x}} and I need to define function based on this solution with the x as argument lets say: myfun[x_]:=50*220/x + 2 (100+x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is protected. Does anybody know what's the problem and how to define such function? Jakub === Subject: Re: SetDelayed::write ... [x_] is protected I don't get that error. Anyway, I woulden't use SetDelayed (:=) in this case, but Set (=) as the replacement in the former case is not performed until after the function is called with an actual value. > I have solution of equations which is dependend on one parameter lets say= : > sol={{i1->220/x}, {i2 -> 100+x}} and I need to define function based on= this > solution with the x as argument lets say: myfun[x_]:=50*220/x + 2 (100+= x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is protected= . Does anybody know what's the problem and how to define such function? > Jakub === Subject: Mathematica Tools Blog: FunctionsWithOption I have added a new item, FunctionsWithOption, on the Mathematica Tools Blog: http://www.scientificarts.com/mathematicatools/ FunctionsWithOption is a simple tool that allows you to find functions that have a particular option. In a way it is the inverse of Mathematica's Options[...] function. As in the case of the NotebookStateSaver Palette, the free tools that I am posting are supported through the (small bits of ) advertising revenue that I get when users click on the Google ads on my site. Enjoy! --David http://scientificarts.com/worklife http://alpha-tips.com/alphatips === Subject: Re: Problem using a dialog and dynamic > The following code should show a button and a text field. When I click the > button, i should get a system dialog allowing me to select a folder, and the > folder's file and pathname should then be displayed in the text field. Panel[Grid[{{Button[Select/Change Project > Directory,sourcedir=SystemDialogInput[Directory,C:]]},{Column[{ Curre > nt Project Directory:,InputField[Dynamic[sourcedir],String]}]}}]] Unfortunately, the performance is erratic! If I click the button, then select a folder of the C drive, say C:first, > and click open, the textfield display C:first as expected. But if I then > click the button again, and select, say, folder off the C:firstsecond and > click open, the textfield does not change, nor does it for any subsequent > clicks. However, if I select the desktop, it works as expected, and if I > select the C: drive again it also works. To summarise, if i want to change the folder selection, I have to select the > C: drive once, then click again and select the subfolder I want, and if I > want to change the subfolder, I have to select the c: drive again, before I > can select the new subfolder. Is this a bug, or am I doing something stupid? I am using V7 on Windows > Vista Home Premium. you will need to use: Method -> Queued for the button. Otherwise whenever it takes you too long to select something, the button action will timeout and the assignement to sourcedir will never happen. For the default method Preemptive there is a timeout for the button action of about 5 seconds. hth, albert === Subject: FindMinimum KKT results Would someone be able to suggest if Kuhn Karush Tucker (KKT) results are available from FindMinimum? KKT residuals are indeed calculated as I sometimes see when my optimisations fail to converge. Just as a guide to the size of my task, FindMinimum sometimes takes around 100 hours of hard work to find the minimum I need (and I am in awe of what it does). Lagrange multipliers for linear constraints can be output from Linear Programming with the DualLinearProgramming function. So what I am looking for is a sort of undocumented DualFindMinimum to show the KKT nonlinear constraint equivalents of Lagrange multipliers. It is possible to calculate the KKT from fundamentals but this takes a long time for very large problems and there is no guarantee that the KKT multipliers I locate with FindInstance are actually the ones finally settled on by FindMinimum. Look forward to any thoughts on the topic! Stuart -- UTS CRICOS Provider Code: 00099F DISCLAIMER: This email message and any accompanying attachments may contain confidential information. If you are not the intended recipient, do not read, use, disseminate, distribute or copy this message or attachments. If you have received this message in error, please notify the sender immediately and delete this message. Any views expressed in this message are those of the individual sender, except where the sender expressly, and with authority, states them to be the views the University of Technology, Sydney. Before opening any attachments, please check them for viruses and defects. === Subject: Re: NDSolve error nlnum Please post your ODEs and/or your code... > Hi everybody Hope all are doing good. Well, I'm trying to solve a cyctem of two coupled ODEs and keep > getting this error nlnum. Can someone guide me how to resolve... > Puneet === Subject: Re: NDSolve error nlnum >Well, I'm trying to solve a cyctem of two coupled ODEs and keep >getting this error nlnum. >Can someone guide me how to resolve... Try posting the Mathematica code that generates the error. Then there should be no difficulty in determining the issue. Until then, all anyone can do is guess which is unlikely to be productive. === Subject: Re: utterly confused by Lightweight Grid On Mar 21, 10:17 am, Sjoerd C. de Vries premier licensee I got to download the Lightweight Grid Manager for > free. Cool! The documentation and the announcement were a bit > confusing as to what precisely I could do with it, but it seemed that > I would be able to run parallel calculations on my computers running > v7. So, I downloaded a PC and mac version of the Lightweight Grid > Manager and installed it on a mac and two PCs. One PC and the mac are > laptops which connect by WLAN, the other PC is wired into the LAN. Using the web browser interface I could interact with all three > machines. So, networking seemed to be OK. The PCs can share files and > ping ok. Lightweight Grid is enabled. In Mathematica's Parallel kernel > configuration I can see two of the three servers, one PC and one mac. > The other PC remains hidden even after switching off all firewalls. > And again, the web interface runs fine, therefore I don't think that > was a factor after all. I did not suceeded in launching any remote kernel. ParallelEvaluate > [$MachineName] returns {}. Anyone else done some testing? Is my interpretation of Lightweight > Grid Manager's functionality mistaken and do I need some additional > stuff like the Grid server? > Wolfram Lightweight Grid provides a mechanism for broadcasting the availability of a computer, and managing remote launching and connection of available Mathematica Kernels. But it does not, itself, include any additional Mathematica licenses. If you have a network license of Mathematica available to you, configure those Wolfram Lightweight Grid installations to request licenses from your existing MathLM server. If you do not have any available Mathematica licenses to run on those machines, you will need to purchase some. Either a regular Mathematica network license, or gridMathematica Server, depending on whether you want them to also work standalone or just want them for parallel computations. Jon McLoone === Subject: Re: utterly confused by Lightweight Grid > Licenses aside, three related questions: 1. Does Wolfram Lightweight Grid contain a copy of Mathematica 7.0.1? Yes. > 2. If so, is that the media it uses to provide a computation kernel? Yes. You can also configure it to launch kernels from other Mathematica installations on the same computer. Under the Kernel Settings tab in the web interface, change the path in KernelCommand to another installation, e.g. a Mathematica 7.0.0 installation. > 3. If so, can this be incompatible with a master kernel and/or other > computation kernels at version 7.0.0? We recommend you use 7.0.1 for the master kernel, but you can also use 7.0.0 for that. On the server side, Lightweight Grid Manager will happily launch kernels from 6.0, 7.0.0, or 7.0.1. === Subject: Re: utterly confused by Lightweight Grid > Licenses aside, three related questions: 1. Does Wolfram Lightweight Grid contain a copy of Mathematica 7.0.1? Yes. It includes the binaries of Mathematica 7.0.1. > 2. If so, is that the media it uses to provide a computation kernel? By default, yes. But there is a way to configure it launch from another path, which might, for example be your 7.0.0 install. > 3. If so, can this be incompatible with a master kernel and/or other > computation kernels at version 7.0.0? I don't beleive that there should be any problems. Except, of course, if you distribute a problem where there was a fix/change in 7.0.1, the result that you got might be somewhat non-deterministic depending on which kernel performed the calculation. For example ParallelEvaluate[$ReleaseNumber] Would give a somewhat unpredicable list of 0s and 1s if you had a mixed grid of 7.0.1 and 7.0.0 binaries. In general, I would recommend upgrading all of your installs to 7.0.1 anyway. Jon === Subject: Re: utterly confused by Lightweight Grid > On Mar 21, 10:17 am, Sjoerd C. de Vries Hi all, I read the announcement about the new gridMathematica stuff. As a > premier licensee I got to download the Lightweight Grid Manager for > free. Cool! The documentation and the announcement were a bit > confusing as to what precisely I could do with it, but it seemed that > I would be able to run parallel calculations on my computers running > v7. So, I downloaded a PC and mac version of the Lightweight Grid > Manager and installed it on a mac and two PCs. One PC and the mac are > laptops which connect by WLAN, the other PC is wired into the LAN. Using the web browser interface I could interact with all three > machines. So, networking seemed to be OK. The PCs can share files and > ping ok. Lightweight Grid is enabled. In Mathematica's Parallel kernel > configuration I can see two of the three servers, one PC and one mac. > The other PC remains hidden even after switching off all firewalls. > And again, the web interface runs fine, therefore I don't think that > was a factor after all. I did not suceeded in launching any remote kernel. ParallelEvaluate > [$MachineName] returns {}. Anyone else done some testing? Is my interpretation of Lightweight > Grid Manager's functionality mistaken and do I need some additional > stuff like the Grid server? > Wolfram Lightweight Grid provides a mechanism for broadcasting the > availability of a computer, and managing remote launching and > connection of available Mathematica Kernels. But it does not, itself, > include any additional Mathematica licenses. If you have a network license of Mathematica available to you, > configure those Wolfram Lightweight Grid installations to request > licenses from your existing MathLM server. If you do not have any available Mathematica licenses to run on those > machines, you will need to purchase some. Either a regular Mathematica > network license, or gridMathematica Server, depending on whether you > want them to also work standalone or just want them for parallel > computations. Jon McLoone- Hide quoted text - - Show quoted text - Licenses aside, three related questions: 1. Does Wolfram Lightweight Grid contain a copy of Mathematica 7.0.1? 2. If so, is that the media it uses to provide a computation kernel? 3. If so, can this be incompatible with a master kernel and/or other computation kernels at version 7.0.0? Vince Virgilio === Subject: Re: Wavelet Denoising using Wavelet Explorer package >Just wondering if anyone has experience out there with Wavelet >Denoising using Mathematica. I have the Wavelet Explorer package, >but the thresholding/shrinkage rules are the two simplest cases: >hard and soft thresholding. >I am hoping to do something more sophisticated, i.e., use Stein's >Unbiased Risk Estimator, or the SURE method to denoise some signals. >Any thoughts where I should start? I've implemented several more sophisticated methods for smoothing data using wavelets based on that package. The following is how I have coded the SURE method: Options[RemoveNoise] = {WaveletFilter -> DaubechiesFilter@5}; RemoveNoise[data_, opts___Rule] := Module[{wt = WaveletTransform[data, WaveletFilter /. {opts} /. Options[RemoveNoise], Sequence @@ FilterRules[Flatten[{opts}], Options[WaveletTransform]]], sigma}, sigma = ( MedianDeviation[Last[wt]] Sqrt[2 Log[Length[data]]])/0.6745`; InverseWaveletTransform[ WaveletCompress[wt, sigma, Sequence @@ FilterRules[Flatten[{Flatten[{opts, Threshold -> True}]}], Options[WaveletCompress]]], WaveletFilter /. {opts} /. Options[RemoveNoise], Sequence @@ FilterRules[Flatten[{opts}], Options[InverseWaveletTransform]]]] === Subject: Re: Got a tip ? >I want to write a function that translates its argument (which is a >letter of the alphabet) into a numerical value. >f[a] = 1 f[b] = 2 Use the built-in function ToCharacterCode, i.e., In[2]:= First@ToCharacterCode[a] Out[2]= 97 === Subject: Unexpected behavior of Floor and IntegerPart I'm sure this is a result of non-infinite-precision arithmetic, but it would be nice to have a more consistent behavior: In[26]:= IntegerPart[0.29*100] Out[26]= 28 In[25]:= Floor[0.29*100] Out[25]= 28 In[27]:= Floor[(29/100)*100] Out[27]= 29 In[32]:= (Floor[#1*100] & ) /@ Range[0, 1, 0.01] Out[32]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} In[33]:= Differences[%] Out[33]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} An interesting hint as to what may be happening is obtained by: ListPlot[Differences[(Floor[#1*100] & ) /@ Range[0, 100, 0.01]]] C.O. -- 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: Unexpected behavior of Floor and IntegerPart Hi Curtis, look at: Table[{i, i 100 - Round[100 i]}, {i, 0, 1, 0.01}] and you will see that 0.29 (and 0.58 as well) is a little bit smaller in the binary machine representation than in the decimal input representation. Daniel I'm sure this is a result of non-infinite-precision arithmetic, but it would be nice to have a more consistent behavior: In[26]:= IntegerPart[0.29*100] Out[26]= 28 In[25]:= Floor[0.29*100] Out[25]= 28 In[27]:= Floor[(29/100)*100] Out[27]= 29 In[32]:= (Floor[#1*100] & ) /@ Range[0, 1, 0.01] Out[32]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, > 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 30, 31, 32, 33, > 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, > 51, 52, 53, 54, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, > 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, > 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} In[33]:= Differences[%] Out[33]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} An interesting hint as to what may be happening is obtained by: ListPlot[Differences[(Floor[#1*100] & ) /@ Range[0, 100, 0.01]]] C.O. > === Subject: Re: Unexpected behavior of Floor and IntegerPart Actually, 0.29*100 is internally represented in binary: RealDigits[0.29*100, 2] {{1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 5} Bobby > 0.29*100 is internally represented as 28.999999999999996`. IntegerPart > makes it 28 as it should. If you write IntegerPart[0.29`5*100] you get 29. > I'm sure this is a result of non-infinite-precision arithmetic, bu= > t it would be nice to have a more consistent behavior: >> In[26]:= IntegerPart[0.29*100] >> Out[26]= 28 >> In[25]:= Floor[0.29*100] >> Out[25]= 28 >> In[27]:= Floor[(29/100)*100] >> Out[27]= 29 >> In[32]:= (Floor[#1*100] & ) /@ Range[0, 1, 0.01] >> Out[32]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, >> 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 30, 31, 32, 33, >> 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, >> 51, 52, 53, 54, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, >> 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, >> 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} >> In[33]:= Differences[%] >> Out[33]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, >> 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, >> 1, >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, = > >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} >> An interesting hint as to what may be happening is obtained by: >> ListPlot[Differences[(Floor[#1*100] & ) /@ Range[0, 100, 0.01]]] >> C= > .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 -- DrMajorBob@bigfoot.com === Subject: Re: Unexpected behavior of Floor and IntegerPart 0.29*100 is internally represented as 28.999999999999996`. IntegerPart makes it 28 as it should. If you write IntegerPart[0.29`5*100] you get 29. I'm sure this is a result of non-infinite-precision arithmetic, bu= t it would be nice to have a more consistent behavior: In[26]:= IntegerPart[0.29*100] Out[26]= 28 In[25]:= Floor[0.29*100] Out[25]= 28 In[27]:= Floor[(29/100)*100] Out[27]= 29 In[32]:= (Floor[#1*100] & ) /@ Range[0, 1, 0.01] Out[32]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, > 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 30, 31, 32, 33, > 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, > 51, 52, 53, 54, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, > 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, > 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} In[33]:= Differences[%] Out[33]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, = > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} An interesting hint as to what may be happening is obtained by: ListPlot[Differences[(Floor[#1*100] & ) /@ Range[0, 100, 0.01]]] C= .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: Re: Unexpected behavior of Floor and IntegerPart C.O. > The observed behavior is consistent. If you want the functions to behave > based on the apparent values rather than the machine numbers, then use > Rationalize or Round to whatever precision level that you want. This > will probably just shift the unexpected behavior to some other > condition. myIntegerPart[x_] := > IntegerPart[Rationalize[x]] myFloor[x_] := Floor[Rationalize[x]] myIntegerPart[0.29*100] 29 myFloor[0.29*100] 29 Bob Hanlon I'm sure this is a result of non-infinite-precision arithmetic, but > it would be nice to have a more consistent behavior: In[26]:= IntegerPart[0.29*100] Out[26]= 28 In[25]:= Floor[0.29*100] Out[25]= 28 In[27]:= Floor[(29/100)*100] Out[27]= 29 In[32]:= (Floor[#1*100] & ) /@ Range[0, 1, 0.01] Out[32]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, > 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 30, 31, 32, 33, > 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, > 51, 52, 53, 54, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, > 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, > 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} In[33]:= Differences[%] Out[33]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, > 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} An interesting hint as to what may be happening is obtained by: ListPlot[Differences[(Floor[#1*100] & ) /@ Range[0, 100, 0.01]]] > -- > 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 > -- 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: Unexpected behavior of Floor and IntegerPart I'm sure this is a result of non-infinite-precision arithmetic, bu= t it would be nice to have a more consistent behavior: In[26]:= IntegerPart[0.29*100] Out[26]= 28 In[25]:= Floor[0.29*100] Out[25]= 28 In[27]:= Floor[(29/100)*100] Out[27]= 29 In[32]:= (Floor[#1*100] & ) /@ Range[0, 1, 0.01] Out[32]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, > 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 30, 31, 32, 33, > 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, > 51, 52, 53, 54, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, > 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, > 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} In[33]:= Differences[%] Out[33]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, = > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} An interesting hint as to what may be happening is obtained by: ListPlot[Differences[(Floor[#1*100] & ) /@ Range[0, 100, 0.01]]] C= .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 Cooooooooooooooooooooooool === Subject: Re: Unexpected behavior of Floor and IntegerPart I'm sure this is a result of non-infinite-precision arithmetic, = bu= t it would be nice to have a more consistent behavior: > It is consistent, consistent between different functions, that is: Try these: Rationalize[0.29*100, 0] Rationalize[0.29*100, 0] < 29 === Subject: Re: Orthogonazlie with Method->Householder > What do you think about starting the famous bugs and caveats site > with this post? Well, we have to decide were are we going to host it. I have not properly investigated these possibilities yet, but I am thinking about one of the following two: http://www.mathematica-users.org/ ~Maris Ozols~ p.s. After my post Maintaining a Mathematica bug list I got an e-mail from WRI (regarding the bugs I mentioned). I sent a replay with the following questions: > Thus, I would be very happy if you could comment on the WRI plans on (1) making Mathematica bug information more publicly available and > (2) improving the communication between Mathematica users and WRI, and > also among the users themselves. I promise that I won't disclose your answers if you intend so. I would really like to know their plans (but I promised that I will not disclose them) before we decide to set up our own bug list -- who knows, maybe next day they start an official one. I'm still waiting for the reply... p.p.s. If anybody is still interested, the singular values of M are: {44.4484, 44.4484, 27.0427, 17.7007, 8.90436, 8.90436} > Maris, I did the following computations also using the Rationalize > version of your matrix: In[1]:= ClearAll[M, oM, MR, oMR]; In[2]:= M = {...}; (* deleted from the post *) In[3]:= MR = Rationalize[M, 10^(-16)]; > oMR = Orthogonalize[MR]; In[5]:= methods = {GramSchmidt, ModifiedGramSchmidt, > Householder, Reorthogonalization}; In[6]:= (oM[#] = Orthogonalize[M, Method -> #]) & /@ methods; In[7]:= MatrixRank[oMR] Out[7]= 6 In[8]:= MatrixRank[oM[#]] & /@ methods Out[8]= {6,6,12,6} In[9]:= Chop@Max@Abs@(oM[#] - oMR) & /@ methods Out[9]= {0,0,1.23961912632296,0} In[10]:= $Version Out[10]= 7.0 for Microsoft Windows (32-bit) (February 18, 2009) > that Householder is not working properly. If it is a feature, it is > a discount feature: you get 12 at the price of 6. What do you think about starting the famous bugs and caveats site > with this post? ADL > Maris Ozols ha scritto: > I have a large numeric matrix M (see below), whose rank is 6. Clearly, >> the rank of Orthogonalize[M] must be the same (in particular, it >> should not increase). However, if I execute the following code on my >> matrix M: >> MatrixRank@M >> MatrixRank@Orthogonalize[M] >> MatrixRank@Orthogonalize[M,Method->Householder] >> I get 6, 6, and 12. So it appears to me that Householder's method has >> doubled the rank of M. I am using Mathematica 7.0 in Linux. >> Is this a bug or a feature? >> ~Maris Ozols~ === Subject: Re: writing a function that would print the Hi Bobby & Maxim, I have modified it a little below and hope the changes will motivate a more robust solution from you or the group. The desire is to get TraditionalForm output for LHS & RHS in the case of an integral as discussed by Maxim Rytin in: Snip **************************************************************************** * === Subject: Re: How to deal with this integral It's not as fun when you know the answer, but you can evaluate the integral by making the change of variables u == a + b, v == a b. The (u, v) region is given by In[1]:= Reduce[t > 0 && b > a > 0 && 1/a + 1/b < 4 t && a + b == u && a b == v, {u, v}, {a, b}, Reals] Out[1]= t > 0 && u > 1/t && u/(4 t) < v < u^2/4 (we're integrating over b > a, where the substitution function is one- to-one). In[2]:= Assuming[t > 0, 2 Integrate[v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]] /. HoldPattern@ MeijerG[{{}, {a_}}, {{b_, c_}, {}}, z_] :> z^b E^-z HypergeometricU[a - c, b - c + 1, z] // FullSimplify Out[2]= (E^(-(1/(2 t))) (BesselK[1, 1/(2 t)] + (1 + 2 t) BesselK[2, 1/ (2 t)]))/(16 t^3) Maxim Rytin m.r@inbox.ru End Snip **************************************************************************** * The two variants on echo are: Clear[sydecho] SetAttributes[sydecho, HoldFirst] sydecho[x_] := TraditionalForm@Print[TraditionalForm@HoldForm@x, = , x] & Clear[sydechotrad] SetAttributes[sydechotrad, HoldFirst] sydechotrad[x_] := TraditionalForm@ Print[TraditionalForm@HoldForm@x, = , TraditionalForm[x]] I hope it will be clear from the following cases what I would like to achieve but cannot yet get quite to my satisfaction. 1) sydecho[2 Integrate[ v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]] 2) sydechotrad[ 2 Integrate[ v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]] and for the full integral with assumptions and conditions on the form of the solution: 3) sydecho[Assuming[t > 0, 2 Integrate[ v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]] /. HoldPattern@MeijerG[{{}, {a_}}, {{b_, c_}, {}}, z_] :> z^b E^-z HypergeometricU[a - c, b - c + 1, z] // FullSimplify] 4) sydechotrad[ Assuming[t > 0, 2 Integrate[ v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]] /. HoldPattern@MeijerG[{{}, {a_}}, {{b_, c_}, {}}, z_] :> z^b E^-z HypergeometricU[a - c, b - c + 1, z] // FullSimplify] I cannot paste the TraditionalForm outputs to completely illustrate the results I want but evaluating the cases above should indicate what I am looking for. PS With so many people having rich text editors now would it be possible to include formatted output and graphs in posts to the group in the near future? Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com Mathematica 7.0.1 for Mac OS X x86 (64 - bit) (18th February 2009) MacOS X V 10.5.6 > Clear[echo] > SetAttributes[echo, HoldFirst] > echo[x_] := Print[ToString@HoldForm@x, = , x] === Subject: Re: Commutators with boson operators > For the creation and annihilation operators you could use their matrix = > form, you can find it in The Quantum Theory of Fields Vol. 1 by Weinberg > I need some help. I want to write code that Mathematica would calculate commutators > [A,B], [A,[B,C]] and so on..., where A,B,C,D,... are functions like A = a+ b*creat + c*annih + d*creat**annih + e*annih**creat + > f*creat^2+g*annih^2+... where a,b,c,d,... are usual complex numbers; and annih & creat are boson noncommutative operators > that satisfy commutation relation: > [annih, creat] = 1. > You could define a function com[a_,b_] and make it bilinear and satisfy the Jacobi identity and make it a derivation, [a,bc]=[a,b]c+b[a,c], so that it recursively reduces any expression down to the basic commutators [a,a]=0=[a^dag,a^dag] , [a^dag,a]=1. Simon === Subject: Re: Commutators with boson operators Make some definitions to tell Mathematica how to do your operator algebra: comm[x_, y_] := opprod[x, y] - opprod[y, x]; opprod[u___, ann, cre, v___] := opprod[u, v] + opprod[u, cre, ann, v]; opprod[u___, (f_: 1) opprod[v___], w___] := f opprod[u, v, w]; opprod[u___, {v___}, w___] := opprod[u, v, w]; opprod[u___, (f_: 1) (x_ + y_), v___] := f opprod[u, x, v] + f opprod[u, y, v]; opprod[] := opprod[id]; opprod[u___, a_?NumberQ, v___] := a opprod[u, v]; opprod[u___, a_ v_, w___] /; FreeQ[a, opprod] := a opprod[u, v, w]; opprod[u__, id, v___] := opprod[u, v]; opprod[u___, id, v__] := opprod[u, v]; I copied these definitions from an operator algebra problem that I solved many years ago, so some of the definitions may not actually be necessary to solve your problem. It would probably be a good idea to work up a fresh set of definitions that suit your particular type of problem. Define a function for building the operator expressions that interest you: func[{a_, b_, c_, d_, e_, f_, g_}] := a opprod[id] + b opprod[cre] + c opprod[ann] + d opprod[cre, ann] + e opprod[ann, cre] + f opprod[cre, cre] + g opprod[ann, ann]; You could make this definition more general than the one I have given. Create 3 operator expressions to play with: func1 = func[{a1, b1, c1, d1, e1, f1, g1}]; func2 = func[{a2, b2, c2, d2, e2, f2, g2}]; func3 = func[{a3, b3, c3, d3, e3, f3, g3}]; Evaluate and simplify a commutator of the form [A,B]: comm[func1, func2] // Collect[#, opprod[___], Simplify] & (-c2 (d1+e1)+c1 (d2+e2)+2 b2 g1-2 b1 g2) opprod[ann]+(b2 (d1+e1)-b1 (d2+e2)-2 c2 f1+2 c1 f2) opprod[cre]+(b2 c1-b1 c2+2 f2 g1-2 f1 g2) opprod[id]+2 (d2 g1+e2 g1-(d1+e1) g2) opprod[ann,ann]+(4 f2 g1-4 f1 g2) opprod[cre,ann]+2 (-d2 f1-e2 f1+(d1+e1) f2) opprod[cre,cre] Evaluate and simplify a commutator of the form [A,[B,C]]: comm[func1, comm[func2, func3]] // Collect[#, opprod[___], Simplify] & (c3 (d2 e1+e1 e2+d1 (d2+e2)-4 f2 g1)-c2 (d3 e1+e1 e3+d1 (d3+e3)-4 f3 g1)-2 (b3 (-d2 g1-e2 g1+(d1+e1) g2)+b2 (d3 g1+e3 g1-(d1+e1) g3)+2 (-c1 f3 g2+c1 f2 g3+b1 (d3 g2+e3 g2-(d2+e2) g3)))) opprod[ann]+(b3 (d2 e1+e1 e2+d1 (d2+e2)-4 f1 g2)-b2 (d3 e1+e1 e3+d1 (d3+e3)-4 f1 g3)-2 (c3 (-d2 f1-e2 f1+(d1+e1) f2)+c2 (d3 f1+e3 f1-(d1+e1) f3)+2 (c1 (d3 f2+e3 f2-d2 f3-e2 f3)+b1 (f3 g2-f2 g3)))) opprod[cre]+(-b2 c1 d3-b2 c1 e3-2 c1 c3 f2+2 c1 c2 f3-4 d3 f2 g1-4 e3 f2 g1+4 d2 f3 g1+4 e2 f3 g1-4 d3 f1 g2-4 e3 f1 g2+b3 (c1 (d2+e2)-2 b1 g2)+4 d2 f1 g3+4 e2 f1 g3+b1 (c3 (d2+e2)-c2 (d3+e3)+2 b2 g3)) opprod[id]+4 (-d3 e1 g2-e1 e3 g2+2 f3 g1 g2+d2 e1 g3+e1 e2 g3-2 f2 g1 g3+d1 (-d3 g2-e3 g2+(d2+e2) g3)) opprod[ann,ann]+8 (-d3 (f2 g1+f1 g2)-e3 (f2 g1+f1 g2)+(d2+e2) (f3 g1+f1 g3)) opprod[cre,ann]+4 (-d3 e1 f2-e1 e3 f2+d2 e1 f3+e1 e2 f3+d1 (-d3 f2-e3 f2+(d2+e2) f3)-2 f1 f3 g2+2 f1 f2 g3) opprod[cre,cre] -- Stephen Luttrell West Malvern, UK > I need some help. I want to write code that Mathematica would calculate commutators [A,B], > [A,[B,C]] and so on..., where A,B,C,D,... are functions like A = a+ b*creat + c*annih + d*creat**annih + e*annih**creat + > f*creat^2+g*annih^2+... where a,b,c,d,... are usual complex numbers; and annih & creat are boson noncommutative operators > that satisfy commutation relation: > [annih, creat] = 1. === Subject: solving nonlinear simultaneous equations I'm using mathematica5.2 to solving 4 complex nonlinear simultaneous equations I'm only need to know the approximate answers,but FindRoot keeps showing FindRoot::nlnum error messages. How can I solve this problem? I provides my final_2.nb file by website link. http://awin.cs.ccu.edu.tw/~dooma/final_2.nb === Subject: Re: solving nonlinear simultaneous equations According to the notebook, p0, p1, p2, and p3 have no values AND you're not solving for them. And so, of course, FindRoot has nothing to work with. Bobby > I modify my equations by Input form style,replace all square brackets. And it still showing FindRoot::nlnum error How can I get approximate values of t0~t3? (t0~t3 are probabilities , so I bound the results between 0 - 1) > I put my new .nb file link as below : http://awin.cs.ccu.edu.tw/~dooma/final_1_2.nb > -- DrMajorBob@bigfoot.com === Subject: Re: solving nonlinear simultaneous equations > I'm using mathematica5.2 to solving 4 complex nonlinear simultaneous > equations I'm only need to know the approximate answers,but FindRoot keeps > showing FindRoot::nlnum error messages. How can I solve this problem? I provides my final_2.nb file by website link. http://awin.cs.ccu.edu.tw/~dooma/final_2.nb You are using some of the unknowns as functions. In Mathematica, t3[1 - t0] means t3 at 1-t0. === Subject: Re: solving nonlinear simultaneous equations I modify my equations by Input form style,replace all square brackets. And it still showing FindRoot::nlnum error How can I get approximate values of t0~t3? (t0~t3 are probabilities , so I bound the results between 0 - 1) I put my new .nb file link as below : http://awin.cs.ccu.edu.tw/~dooma/final_1_2.nb === Subject: Re: solving nonlinear simultaneous equations My guess is that you have been playing with StandardForm and TarditionalForm formatting. Parts of the expressions like t1(1 - t0) are internally represented as t1[1 - t0], i.e. t1 is the name of a function. You can see that if you change the format to InputForm (using the Cell/Convert tomenu). So, what you must do is change the square brackets in parenthesis using Finf and Replace. Additionally, the syntax of your FindRoot is wrong. You cannot have to starting values. If you rfepaired that and you tweak the starting values and WorkingPrecision somewhat you get: FindRoot[{eq0, eq1, eq2, eq3}, {{t0, 0.5}, {t1, 0.6}, {t2, 0.4}, {t3, 0.8}}, WorkingPrecision -> 50] {t0 -> 0.042950144337512339004069005918555574390189195213080, t1 -> 0.020794416091072412934056566904308358806687991905694, t2 -> 0.014356830943135308919996619330315956865348280462553, t3 -> -0.29047823800632023417669910887671278352651919604465} > I'm using mathematica5.2 to solving 4 complex nonlinear simultaneous > equations I'm only need to know the approximate answers,but FindRoot keeps > showing FindRoot::nlnum error messages. How can I solve this problem? I provides my final_2.nb file by website link. http://awin.cs.ccu.edu.tw/~dooma/final_2.nb === Subject: Re: solving nonlinear simultaneous equations How should I decide the staring values as you gaves 0.5, 0.6, 0.4, 0.8 And these results are only answers? Because in this model, answers should be t0 0.042950144337512339004069005918555574390189195213080, t1 -> 0.020794416091072412934056566904308358806687991905694, t2 -> 0.014356830943135308919996619330315956865348280462553, t3 -> -0.29047823800632023417669910887671278352651919604465} BR. Dooma Casper On 3=A4=EB25=A4=E9, =A4U=A4=C86=AE=C942=A4=C0, Sjoerd C. de Vries TarditionalForm formatting. Parts of the expressions like t1(1 - t0) > are internally represented as t1[1 - t0], i.e. t1 is the name of a > function. You can see that if you change the format to InputForm > (using the Cell/Convert tomenu). So, what you must do is change the > square brackets in parenthesis using Finf and Replace. Additionally, the syntax of your FindRoot is wrong. You cannot have to > starting values. If you rfepaired that and you tweak the starting > values and WorkingPrecision somewhat you get: FindRoot[{eq0, eq1, eq2, eq3}, > {{t0, 0.5}, {t1, 0.6}, {t2, 0.4}, {t3, 0.8}}, WorkingPrecision -> 50] {t0 -> 0.042950144337512339004069005918555574390189195213080, > t1 -> 0.020794416091072412934056566904308358806687991905694, > t2 -> 0.014356830943135308919996619330315956865348280462553, > t3 -> -0.29047823800632023417669910887671278352651919604465} > I'm using mathematica5.2 to solving 4 complex nonlinear simultaneous > equations I'm only need to know the approximate answers,but FindRoot keeps > showing FindRoot::nlnum error messages. How can I solve this problem? I provides my final_2.nb file by website link. http://awin.cs.ccu.edu.tw/~dooma/final_2.nb- =C1=F4=C2=C3=B3Q=A4=DE=A5= =CE=A4=E5=A6r - - =C5=E3=A5=DC=B3Q=A4=DE=A5=CE=A4=E5=A6r - === Subject: Re: Commutators with boson operators Hi there, This is precisely the type of problems that the symbolic matrix capabilities of my EDC package (http://www.inp.demokritos.gr/~sbonano/EDC/) can handle. It is rather slow but does what you want. Download the code (matrixEDC.m), put it in an appropriate directory, and evaluate the attached notebook. Sotirios Bonanos I need some help. I want to write code that Mathematica would calculate commutators [A,B], [A,[B,C]] and so on..., where A,B,C,D,... are functions like A = a+ b*creat + c*annih + d*creat**annih + e*annih**creat + f*creat^2+g*annih^2+... where a,b,c,d,... are usual complex numbers; and annih & creat are boson noncommutative operators > that satisfy commutation relation: > [annih, creat] = 1. > CreatAnnih.nb CreatedBy='Mathematica 5.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 4792, 174]*) (*NotebookOutlinePosition[ 5449, 197]*) (* CellTagsIndexPosition[ 5405, 193]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ (<< matrixEDC.m)], Input], Cell[BoxData[ (DeclareMatrixForms[{0, annih[_], annih[_]}, {0, creat[_], creat[_]}])], Input], Cell[BoxData[ (annih[n] and creat[ n] will denote the nth powers of your operators . [IndentingNewLine]Wedge (([Wedge])) is used to denote non - commutative multiplication)], Text, FontFamily->Times], Cell[BoxData[ (Wedge[creat[1], annih[1]])], Input], Cell[< Give rules for simplifying Wedge products of powers of creat, annih >, Text], Cell[BoxData[ (creat[0] = 1; annih[0] = 1;)], Input], Cell[BoxData[ (Wedge[creat[m_], creat[n_]] := creat[m + n])], Input], Cell[BoxData[ (Wedge[annih[m_], annih[n_]] := annih[m + n])], Input], Cell[BoxData[ (Wedge[creat[m_], annih[n_]] := Wedge[creat[m - 1], annih[1][Wedge]creat[1] - h0, annih[n - 1]] /; m > 0 && n > 0)], Input], Cell[< The last rule implements the commutator creat[1][Wedge]annih[1]-annih[1][Wedge]creat[1] = -h0; (h0 = 1 in your case) to put annih[] operators before creat[] ones. If you prefer to have creat[] before annih[] use: Wedge[annih[m_],creat[n_]]:=Wedge[annih[m-1], creat[1][Wedge]annih[1]+h0, creat[n-1]]/;m>0&&n>0 >, Text], Cell[BoxData[ (h0 = 1)], Input], Cell[BoxData[ ([IndentingNewLine])], Input], Cell[Examples, Text], Cell[BoxData[ (Wedge[creat[1], annih[1]])], Input], Cell[BoxData[ (Wedge[creat[1], annih[2]])], Input], Cell[BoxData[ (Wedge[creat[2], annih[1]])], Input], Cell[BoxData[], Input], Cell[BoxData[ (A = Sum[aa[i, j] Wedge[creat[i], annih[j]], {i, 0, 2}, {j, 0, 2}])], Input], Cell[< The function reWrite collects identical annih, creat powers / products >, Text], Cell[BoxData[ (A = reWrite[A])], Input], Cell[BoxData[ (B = reWrite[Sum[ bb[i, j] Wedge[creat[i], annih[j]], {i, 0, 2}, {j, 0, 3}]])], Input], Cell[BoxData[ (((CC)(=)(reWrite[ Sum[cc[i, j] Wedge[creat[i], annih[j]], {i, 0, 3}, {j, 0, 2}]])( (*(*)( )() **) )))], Input], Cell[BoxData[ ([IndentingNewLine])], Input], Cell[Define commutator, Text], Cell[BoxData[ (comm[x_, y_] := reWrite[x[Wedge]y - y[Wedge]x])], Input], Cell[BoxData[ (comm[A, B])], Input], Cell[BoxData[ (comm[A, CC])], Input], Cell[BoxData[ (((comm[A, comm[B, CC]])( (*(*)( )(This)( )(takes)( )(long!) **) )))], Input], Cell[BoxData[ ([IndentingNewLine])], Input], Cell[Define Jacobi, Text], Cell[BoxData[ (Jacobi[x_, y_, z_] := reWrite[comm[x, comm[y, z]] + comm[y, comm[z, x]] + comm[z, comm[x, y]]])], Input], Cell[BoxData[ (((Jacobi[A, B, CC])( (*(*)( )(This)( )(takes)( )(long!) **) )))], Input] }, FrontEndVersion->5.2 for Macintosh, ScreenRectangle->{{43, 1152}, {0, 842}}, WindowSize->{910, 719}, WindowMargins->{{4, Automatic}, {Automatic, 1}}, Magnification->1.25 ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 47, 1, 33, Input], Cell[1804, 54, 110, 2, 33, Input], Cell[1917, 58, 256, 5, 54, Text], Cell[2176, 65, 58, 1, 33, Input], Cell[2237, 68, 93, 3, 36, Text], Cell[2333, 73, 60, 1, 33, Input], Cell[2396, 76, 76, 1, 33, Input], Cell[2475, 79, 76, 1, 33, Input], Cell[2554, 82, 162, 3, 52, Input], Cell[2719, 87, 351, 7, 74, Text], Cell[3073, 96, 39, 1, 33, Input], Cell[3115, 99, 52, 1, 52, Input], Cell[3170, 102, 24, 0, 36, Text], Cell[3197, 104, 58, 1, 33, Input], Cell[3258, 107, 58, 1, 33, Input], Cell[3319, 110, 58, 1, 33, Input], Cell[3380, 113, 26, 0, 33, Input], Cell[3409, 115, 116, 3, 33, Input], Cell[3528, 120, 96, 3, 36, Text], Cell[3627, 125, 47, 1, 33, Input], Cell[3677, 128, 138, 4, 33, Input], Cell[3818, 134, 201, 4, 52, Input], Cell[4022, 140, 52, 1, 52, Input], Cell[4077, 143, 33, 0, 36, Text], Cell[4113, 145, 81, 1, 33, Input], Cell[4197, 148, 43, 1, 33, Input], Cell[4243, 151, 44, 1, 28, Input], Cell[4290, 154, 132, 3, 28, Input], Cell[4425, 159, 52, 1, 47, Input], Cell[4480, 162, 29, 0, 36, Text], Cell[4512, 164, 145, 3, 52, Input], Cell[4660, 169, 128, 3, 33, Input] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************) === Subject: Re: DirectSum (feature request) A solution based on ArrayPad (new in v. 7):given a list of k square matrices {A_1,A_2,...,A_k} of order {n_1, n_2,...,n_k} respectively, in the direct sum the rows of Ai are padded with n_1+...+n_{i-1} zeros on the left and n_{i+1}+...+n_k on the right: MatDirSum[sqMatrices_] := Module[{t, dims, rowPaddings}, dims = Prepend[Length /@ sqMatrices, 0]; t = Total[dims]; rowPaddings = Rest[FoldList[#1 + {#2[[1]], -#2[[2]]} & , {0, t}, Partition[dims, 2, 1]]]; Join @@ MapThread[ArrayPad[#1, {{0}, #2}] & , {sqMatrices, rowPaddings}]]; Test: In[6]:= sqMatrices = {Array[a1[#1, #2] & , {3, 3}], Array[a2[#1, #2] & , {4, 4}], Array[a3[#1, #2] & , {1, 1}], Array[a4[#1, #2] & , {2, 2}]}; In[8]:= MatDirSum[sqMatrices] Out[8]= {{a1[1, 1], a1[1, 2], a1[1, 3], 0, 0, 0, 0, 0, 0, 0}, {a1[2, 1], a1[2, 2], a1[2, 3], 0, 0, 0, 0, 0, 0, 0}, {a1[3, 1], a1[3, 2], a1[3, 3], 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, a2[1, 1], a2[1, 2], a2[1, 3], a2[1, 4], 0, 0, 0}, {0, 0, 0, a2[2, 1], a2[2, 2], a2[2, 3], a2[2, 4], 0, 0, 0}, {0, 0, 0, a2[3, 1], a2[3, 2], a2[3, 3], a2[3, 4], 0, 0, 0}, {0, 0, 0, a2[4, 1], a2[4, 2], a2[4, 3], a2[4, 4], 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, a3[1, 1], 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, a4[1, 1], a4[1, 2]}, {0, 0, 0, 0, 0, 0, 0, 0, a4[2, 1], a4[2, 2]}} Adriano Pascoletti 2009/3/21 Maris Ozols (unless you are a quantum physicist and use only KroneckerProduct). > Unfortunately there is no built-in function (that I know of) for doing > this in Mathematica. The closest thing we have is ArrayFlatten. So I > usually do something like this to compute a direct sum: DirectSum[Ms_] := Module[{n = Length[Ms], z, i}, > z = ConstantArray[0, n]; > ArrayFlatten@Table[ReplacePart[z, i -> Ms[[i]]], {i, 1, n}] > ]; Is there a better way of doing this? Note: A nice way to implement it would be DirectSum[Ms_] := ArrayFlatten@DiagonalMatrix[Ms]; Unfortunately this gives DiagonalMatrix::vector error, since > DiagonalMatrix is not flexible enough to accept a list of matrices. > The way DiagonalMatrix is used in the above code might cause some > confusion for beginners, but in general I don't see why DiagonalMatrix > should be limited in this way. ~Maris Ozols~ === Subject: Re: Help x-y pairs with rules > Please, help with this: I have list like this, but bigger: > With one expression (function), always go one or more points (rules) {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} I would like results like this (pairs of x-y) but grouped in lists > according to expression(function): > {{2,2^2},{3,3^2}},{5^3}} > {x, #1} /. (List /@ #2) & @@@ {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} === Subject: Re: Help x-y pairs with rules > Please, help with this: I have list like this, but bigger: > With one expression (function), always go one or more points (rules) {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} I would like results like this (pairs of x-y) but grouped in lists > according to expression(function): > {{2,2^2},{3,3^2}},{5^3}} Please help with expression that compute this. THX Your example appears bugged, if I am extrapolating correctly. The proper result should be: {{{2, 4}, {3, 9}}, {{5, 125}}} ? If so, the simplest solution would be: replacements = {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} Function[$, {Last[$], #1 /. $}] /@ #2 & @@@ replacements Additionally, you could apply Join to the result, to get a flatter result list. === Subject: Re: Help x-y pairs with rules Thread over lists of rules In[1]:= (Thread[#1] & ) /@ {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} Out[1]= {{{x^2, x -> 2}, {x^2, x -> 3}}, {{x^3, x -> 5}}} and map {x, #[[1]]} /. #[[2]] & at the second level In[2]:= Map[{x, #1[[1]]} /. #1[[2]] & , (Thread[#1] & ) /@ {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}}, {2}] Out[2]= {{{2, 4}, {3, 9}}, {{5, 125}}} Adriano Pascoletti 2009/3/23 dragec With one expression (function), always go one or more points (rules) {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} I would like results like this (pairs of x-y) but grouped in lists > according to expression(function): > {{2,2^2},{3,3^2}},{5^3}} Please help with expression that compute this. THX > === Subject: Re: Help x-y pairs with rules data = {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}}; ({x, First[#]} /. Partition[Last[#], 1]) & /@ data {{{2, 4}, {3, 9}}, {{5, 125}}} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Please, help with this: I have list like this, but bigger: With one expression (function), always go one or more points (rules) {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} I would like results like this (pairs of x-y) but grouped in lists according to expression(function): {{2,2^2},{3,3^2}},{5^3}} Please help with expression that compute this. THX === Subject: Online Graphic Output > Therefore I reduced the problem to a simple code example: Do[{ x = Random[], y = Random[], p = Point[{x, y}], > Graphics[{PointSize[0.1], p}, GridLines -> Automatic, > Frame -> True, PlotRange -> { {-1, 1}, {-1, 1}}]} , > {n, 1, 5}] I would like to receive a single graphic with 5 points plotted. > The statements within the Do loop show nothing, not even a > error message with the Mathematica version 7. The output of Do is always Null. Thus, the code generates no graphic. You can examine the values of x, y, and p to see that something has happened. Also, you're writing over the value of p every time through anyway so the final graphic has only one point. How about points = {}; Do[x = RandomReal[{-1, 1}]; y = RandomReal[{-1, 1}]; AppendTo[points, {x, y}]; p = Point[points], {5}]; Graphics[{PointSize[0.1], p}, GridLines -> Automatic, Frame -> True, PlotRange -> {{-1, 1}, {-1, 1}}] My understanding from the MathGroup discussion was that you would like the images to be updated dynamically. You can achieve this effect as follows. p = {}; points = {}; Graphics[{PointSize[0.1], Dynamic[p]}, GridLines -> Automatic, Frame -> True, PlotRange -> {{-1, 1}, {-1, 1}}] Do[x = RandomReal[{-1, 1}]; y = RandomReal[{-1, 1}]; AppendTo[points, {x, y}]; p = Point[points]; Pause[1], {5}]; Note that that is two separate cells. The first sets up the graph with a dynamic variable and the second adjusts that variable. As I mentioned in my MathGroup post, I don't really like AppendTo for this purpose. The list in this example is short though and the AppendTo is very simple. Hope that helps, Mark McClure === Subject: Re: Question about how to graph the vector field for the Clear[y] y[c_][x_] = y[x] /. DSolve[y'[x] == 2 x - y[x], y[x], x][[1]] /. C[1] :> c c E^-x+2 (x-1) D[y[c][x], x] == 2 x - y[c][x] // Simplify True Plot[ Evaluate[ Table[ Tooltip[y[c][x]], {c, -3, 5}]], {x, -1/2, 3}] Plot3D[y[c][x], {x, -1/2, 3}, {c, -3, 5}] Manipulate[ Plot[y[c][x], {x, -1/2, 3}, PlotRange -> {-8, 5}], {c, -3, 5}] Bob Hanlon > i need to graph the vector field and the family of solutions for the > DE: dy/dx=2x-y > and i tried the graph the vector field, but while i tried to use the > VectorFieldPlot it show up some kind of wierd graph... > and i cannot even get start on the family of Solutions > graph...searched online but still cannot figure out. > hope some pros can help me out on this...thx alot~!! > Bluefly === Subject: Re: Question about how to graph the vector field for the StreamPlot[{x, 2 x - y}, {x, -3, 3}, {y, -3, 3}] ? Jens > Clear[y] y[c_][x_] = > y[x] /. > DSolve[y'[x] == 2 x - y[x], y[x], x][[1]] /. > C[1] :> c c E^-x+2 (x-1) D[y[c][x], x] == 2 x - y[c][x] // Simplify True Plot[ > Evaluate[ > Table[ > Tooltip[y[c][x]], > {c, -3, 5}]], > {x, -1/2, 3}] Plot3D[y[c][x], {x, -1/2, 3}, {c, -3, 5}] Manipulate[ > Plot[y[c][x], {x, -1/2, 3}, > PlotRange -> {-8, 5}], > {c, -3, 5}] Bob Hanlon > >> i need to graph the vector field and the family of solutions for the >> DE: dy/dx=2x-y >> and i tried the graph the vector field, but while i tried to use the >> VectorFieldPlot it show up some kind of wierd graph... >> and i cannot even get start on the family of Solutions >> graph...searched online but still cannot figure out. >> hope some pros can help me out on this...thx alot~!! >> Bluefly > === Subject: Re: Got a tip ? f[x_String] := ToCharacterCode[x][[1]] - 96 f[a] 1 f[A] -31 f /@ CharacterRange[a, h] {1,2,3,4,5,6,7,8} f /@ CharacterRange[A, H] {-31,-30,-29,-28,-27,-26,-25,-24} Bob Hanlon I want to write a function that translates its argument (which is a > letter of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 === Subject: Re: Wolfram/Alpha > I just read the latest intriguing blog entry on the Wolfram site. > It reports the May 09 opening of the the Wolfram/Alpha site: a sort of Does anybody knows a bit more (and is willing to speak :-) ) ? What I find also amazing is that this project must have engaged a > considerable amount of WRI resources, financial time and human, yet > they managed to keep all this very quiet. Exciting isn't it? In the wolframalpha.com site it is now possible to register for updates and news. Also in http://www.initialsingularity.com/alphatips/ (but the wikipedia page is missing). === Subject: Re: Got a tip ? I presume your arguments are strings (and not symbols). Also, I assume that you wish ultimately to return a list of numbers (not strings). So, for example, f[a] gives {1} (not {1}) and f[za] gives {26,1} (not {26,1}), in which case, the following might be what you are after. With[ {rules = Thread[CharacterRange[a, z] -> Range[26]]}, f[input_String] := List @@ StringReplace[input, rules] ]; The With and rules = are to avoid having to evaluate the rules every time you call the function. If you look at Information[f] after having evaluated my line of code, you will see what I mean. The main part of the function is a string replace, which converts all letters between a and z to the integers 1 through 26. Note that StringReplace will return either a String or a StringExpression, so you need to change the head to List if that is what you ultimately want (this only works if there really was at least one letter from a to z in the input). Note that capitals will not get transformed. You can change the StringReplace to be StringReplace [input,rules,IgnoreCase->True] if you want to include capitals. Any other characters will just be returned in the list as strings. You can add rules to cover them if you wish. For example, if you wanted all other characters to be returned as the integer 0, then you could define the function as: With[ { rules = Join[ Thread[CharacterRange[a, z] -> Range[26]] , {_- >0} ] }, f[input_String] := List @@ StringReplace[input, rules,IgnoreCase- >True] ]; Hope that helps, Derek === Subject: Re: Got a tip ? f[s_]:=First@ToCharacterCode[ToLowerCase[s]]-96/;StringQ[s]&&StringLength[s] ==1 Gerry F I want to write a function that translates its argument (which is a letter of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 > === Subject: Re: Got a tip ? I want to write a function that translates its argument (which is a letter of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 > > . If this small module is finished, i want to expand the function by giving as an argument; a string of letters (or a text), but i have no clue which functions i have to use to define the smaller part (only letters) first. What functions can i use for all of this and how do i handle the variables ? Does the difference between Module and Block come into play ? Or . . .any help is much appreciated. > I think you need to be a bit more specific - for example, what should these return: f[foo] f[] f[nnnnn[Breve]] You might want to explore the function ToCharacterCode. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Got a tip ? Try ToCharacterCode[any text you want] -Francesco I want to write a function that translates its argument (which is a letter of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 > > . If this small module is finished, i want to expand the function by giving as an argument; a string of letters (or a text), but i have no clue which functions i have to use to define the smaller part (only letters) first. What functions can i use for all of this and how do i handle the variables ? Does the difference between Module and Block come into play ? Or . . .any help is much appreciated. > === Subject: Re: Got a tip ? You have stated what you want to do; since, it is not clear what problem you are trying to solve I point to the Mathematica built in function ToCharacterCode[] Plus[Plus[ToCharacterCode[ToLowerCase[abcdefghijklmnopqrstuvwxyz]], -32] -64] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26} For uppercase Plus[ToCharacterCode[ABCDEFGHIJKLMNOPQRSTUVWXYZ], -32] {33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58} Hans I want to write a function that translates its argument (which is a letter > of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 . If this small module is finished, i want to expand the function by giving > as an argument; a string of letters (or a text), but i have no clue which > functions i have to use to define the smaller part (only letters) first. > What functions can i use for all of this and how do i handle the variables > ? Does the difference between Module and Block come into play ? Or . . > .any help is much appreciated. > === Subject: Re: Got a tip ? singleCharToNumber[string_] := First[ToCharacterCode[ToString[string]] - 96] singleCharToNumber[a] singleCharToNumber[b] singleCharToNumber[z] Out[21]= 1 Out[22]= 2 Out[23]= 26 Of course, that will treat capitalized characters strangely, but I'm sure you can cope with that case :) --C.O. I want to write a function that translates its argument (which is a letter of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 > > -- 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: Got a tip ? ToCharacterCode[ ] returns the ASCII values of the characters that make up the string that it gets as argument. If you only use lowercase characters, you then subtract 96 to end up with values starting at 1. Another function that may be useful to you is Characters[ ], which splits a string in a list of characters. Module and Block are totally irrelevant in this context. I want to write a function that translates its argument (which is a lette= r of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 . If this small module is finished, i want to expand the function by giving= as an argument; a string of letters (or a text), but i have no clue which = functions i have to use to define the smaller part (only letters) first. Wh= at functions can i use for all of this and how do i handle the variables ? = Does the difference between Module and Block come into play ? Or . . .any h= elp is much appreciated. === Subject: Re: Got a tip ? Something like this? f[c_String] := First[ToCharacterCode[c] - ToCharacterCode[a] + 1] /; gives In[11]:= f[z] Out[11]= 26 Adriano Pascoletti 2009/3/23 Fabrizio I want to write a function that translates its argument (which is a letter > of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 > === Subject: Re: Got a tip ? A mapping for all your assignments: $CharMap = Dispatch@Join[ Thread[CharacterRange[a, z] -> Range[1, 26]], Thread[CharacterRange[A, Z] -> Range[27, 52]], {_ :> Throw[Unknown]} ]; A function which takes a string, and applies the mapping: convert[s_String] := Replace[Characters[s], $CharMap, {1}]; === Subject: Re: Got a tip ? If you're willing to allow your inputs to be one-character strings: alf=abcdefghijklmnopqrstuvwxyz; f[ltr_]:= First@First@StringPosition[alf,ltr] f[b] 2 If you _really_ want plain, unadorned single-letter symbols as inputs, replace alf above by alf=ToExpression@Characters[alf] g[char_] := First@First@Position[letters, char] g[b] 2 I want to write a function that translates its argument (which is a letter of the alphabet) into a numerical value. f[a] = 1 > f[b] = 2 > > -- 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: Recursive algorithm >> hello all, >> i am having headaches trying to produce this recursive >> algorithm in mathematica: >> the algorithm devides a reduced fraction r where r > 1 into n steps >> in the form (k+1)/k >> 1) try the largest step (k+1)/k (say s) that will fit in r; >> 2) find out how to divide r/s into n-1 steps; >> 3) try the next biggest step, etc; >> 4) until the first step is small enough that n of them are smaller >> than r, then you are done. >> so for r=8 and n=3 >> the result is >> (2/1,2/1,2/1) >> and for r=7/5, n=2 >> the result is >> (4/3,21/20),(6/5,7/6) >> i have found this algorithm written in another system but attempt to >> translate it fails for n>2 >> below is the code; >> athanase >> [...] Below is an improvement on what I last posted. No need to memoize intermediate results, and it does not spawn (potentially huge) lists that later require pruning. Also it has no explicit iterator, hence does not run afoul of size limitations there. spsubdiv[a_,b_] := spsubdiv[a,b,Infinity] spsubdiv[2,1,_] = {{2}}; spsubdiv[r_Rational,1,_] /; Numerator[r]==Denominator[r]+1 := {{r}} spsubdiv[_,1,_] = {}; spsubdiv[r_Rational|r_Integer, n_Integer /; n>1, k_] := Module[ {i, min=Max[Floor[1/(r-1)]+1,Floor[1/(k-1)]], max=Floor[1/(r^(1/n)-1)]}, Flatten[Reap[For[i = min, i <= max, i++, With[{j=1+1/i}, Sow[Map[Join[{j},#]&,spsubdiv[r/j,n-1,j]]]] ]][[-1,1,All]],1]] If the goal is simply to count how many ways this can be done, we can boost speed a bit as follows. spsubCount[a_,b_] := spsubCount[a,b,Infinity] spsubCount[2,1,_] = 1; spsubCount[r_Rational,1,_] /; Numerator[r]==Denominator[r]+1 := 1 spsubCount[_,1,_] = 0; spsubCount[r_Rational|r_Integer, n_Integer /; n>1, k_] := Module[ {tot=0, i, min=Max[Floor[1/(r-1)]+1,Floor[1/(k-1)]], max=Floor[1/(r^(1/n)-1)]}, For[i = min, i <= max, i++, tot += With[{j=1+1/i},spsubCount[r/j,n-1,j]] ]; tot ] In[17]:= Timing[spsubCount[2,4]] Out[17]= {0.007999, 43} In[18]:= Timing[spsubCount[2,5]] Out[18]= {0.065989, 876} In[19]:= Timing[spsubCount[2,6]] Out[19]= {15.3317, 49513} The {2,7} case has been running overnight, and has yielded no result thus far. But neither has it run out of memory. Daniel Lichtblau Wolfram Research === Subject: Re: Recursive algorithm > hello all, i am having headaches trying to produce this recursive > algorithm in mathematica: the algorithm devides a reduced fraction r where r > 1 into n steps > in the form (k+1)/k 1) try the largest step (k+1)/k (say s) that will fit in r; > 2) find out how to divide r/s into n-1 steps; > 3) try the next biggest step, etc; > 4) until the first step is small enough that n of them are smaller > than r, then you are done. > so for r=8 and n=3 the result is (2/1,2/1,2/1) and for r=7/5, n=2 the result is (4/3,21/20),(6/5,7/6) > i have found this algorithm written in another system but attempt to > translate it fails for n>2 below is the code; > athanase > spsubdiv := proc(r:rational,n:integer) > local i,j,l,s; > if n=1 > then > if numer(r)=denom(r)+1 > then [r] > else ( NULL ) > fi; > else > s := NULL; > for i from floor(1/(r-1))+1 while (1+1/i)^n >= r do > l := [spsubdiv( r/(1+1/i), n-1 )]; > for j to nops(l) do > if op(1,op(j,l)) <= (1+1/i) > then s := s, [(1+1/i),op(op(j,l))]; > fi > od; > od; > s; > fi; > end: One way (probably among many possibilities): spsubdiv[2,1] = {fractionSequence[2]}; spsubdiv[r_Rational,1] /; Numerator[r]==Denominator[r]+1 := {fractionSequence[r]} spsubdiv[_,1] = {}; spsubdiv[r_Rational|r_Integer, n_Integer /; n>1] := Union[Map[Sort,Flatten[Table[With[{j=1+1/i}, Map[Join[fractionSequence[j],#]&,spsubdiv[r/j,n-1]]] ,{i,Floor[1/(r-1)]+1,Floor[1/(r^(1/n)-1)]}]]]] Examples: In[64]:= InputForm[spsubdiv[8,3]] Out[64]//InputForm= {fractionSequence[2, 2, 2]} In[65]:= InputForm[spsubdiv[7/5,2]] Out[65]//InputForm= {fractionSequence[4/3, 21/20], fractionSequence[6/5, 7/6]} In[66]:= InputForm[spsubdiv[7/5,3]] Out[66]//InputForm= {fractionSequence[441/440, 22/21, 4/3], fractionSequence[231/230, 23/22, 4/3], fractionSequence[161/160, 24/23, 4/3], fractionSequence[126/125, 25/24, 4/3], fractionSequence[126/125, 10/9, 5/4], fractionSequence[105/104, 26/25, 4/3], fractionSequence[91/90, 27/26, 4/3], fractionSequence[81/80, 28/27, 4/3], fractionSequence[63/62, 31/30, 4/3], fractionSequence[56/55, 33/32, 4/3], fractionSequence[56/55, 11/10, 5/4], fractionSequence[51/50, 35/34, 4/3], fractionSequence[49/48, 36/35, 4/3], fractionSequence[49/48, 8/7, 6/5], fractionSequence[42/41, 41/40, 4/3], fractionSequence[36/35, 7/6, 7/6], fractionSequence[28/27, 9/8, 6/5], fractionSequence[26/25, 14/13, 5/4], fractionSequence[21/20, 16/15, 5/4], fractionSequence[21/20, 10/9, 6/5], fractionSequence[21/20, 8/7, 7/6], fractionSequence[16/15, 9/8, 7/6], fractionSequence[14/13, 13/12, 6/5], fractionSequence[12/11, 11/10, 7/6]} As per comments at URL below, if you do large examples and speed becomes an issue, you might want to memoize values using the construct spsubdiv[r_Rational|r_Integer, n_Integer /; n>1] := spsubdiv[r,n] = ... https://home.comcast.net/~dcanright/super/app.htm This makes around a factor of three speed difference for In[77]:= Timing[Length[spsubdiv[2,6]]] Out[77]= {54.0718, 49513} That is, with the alteration spsubdiv[r_Rational|r_Integer, n_Integer /; n>1] := spsubdiv[r,n] = Union[Map[Sort,Flatten[Table[With[{j=1+1/i}, Map[Join[fractionSequence[j],#]&,spsubdiv[r/j,n-1]]] ,{i,Floor[1/(r-1)]+1,Floor[1/(r^(1/n)-1)]}]]]] this instead is around 18 seconds. I will point out that this version of the code will not handle spsubdiv[2,7] because iterators become too large. Daniel Lichtblau Wolfram Research === Subject: Re: Recursive algorithm > hello all, i am having headaches trying to produce this recursive > algorithm in mathematica: the algorithm devides a reduced fraction r where r > 1 into n steps > in the form (k+1)/k 1) try the largest step (k+1)/k (say s) that will fit in r; > 2) find out how to divide r/s into n-1 steps; > 3) try the next biggest step, etc; > 4) until the first step is small enough that n of them are sma= ller > than r, then you are done. so for r=8 and n=3 the result is (2/1,2/1,2/1) and for r=7/5, n=2 the result is (4/3,21/20),(6/5,7/6) i have found this algorithm written in another system but attempt to > translate it fails for n>2 below is the code; > athanase spsubdiv := proc(r:rational,n:integer) > local i,j,l,s; > if n=1 > then > if numer(r)=denom(r)+1 > then [r] > else ( NULL ) > fi; > else > s := NULL; > for i from floor(1/(r-1))+1 while (1+1/i)^n >= r do > l := [spsubdiv( r/(1+1/i), n-1 )]; > for j to nops(l) do > if op(1,op(j,l)) <= (1+1/i) > then s := s, [(1+1/i),op(op(j,l))]; > fi > od; > od; > s; > fi; > end: athanase[r_, n_Integer] := Join @@ Last@Reap@athanaseAux[n, r]; athanaseAux[1, r_, a___] := If[Numerator[r] == Denominator[r] + 1, So= w [{a, r}]]; athanaseAux[n_Integer, r_, a___] := Block[{i = Floor[1/(r - 1)], s}, While[s = 1 + 1/++i; s^n >= r, athanaseAux[n - 1, r/s, a, s]]]; You could add some conditions on athanase[...] to ensure r > 1 and n > 0. Given Examples: athanase[8, 3] => {{2, 2, 2}} athanase[7/5, 2] => {{4/3, 21/20}, {6/5, 7/6}} Generic Test: SameQ @@ Times @@@ athanase[9/7, 3] === Subject: Re: Help x-y pairs with rules Please, help with this: I have list like this, but bigger: With one expression (function), always go one or more points (rules) {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}} I would like results like this (pairs of x-y) but grouped in lists according to expression(function): {{2,2^2},{3,3^2}},{5^3}} Please help with expression that compute this. THX try this: In[212]:= lst = {{x^2, {x -> 2, x -> 3}}, {x^3, {x -> 5}}}; myRewrite[lst_] := Module[{lst1}, lst1 = (lst /. t_Rule -> {t}) /. t_^a_ :> {t, t^a}; Table[ First[lst1[[i]]] /. Last[lst1[[i]]], {i, 1, Length[lst1]}] ] myRewrite[lst] Out[214]= {{{2, 4}, {3, 9}}, {{5, 125}}} -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Different results with FourierTransform[] > [...] > Unfortunately, there appears to be a bug in Mathematica's calculation > of > InverseFourierTransform of Tanh[x], as the original poster pointed > out. The fact that the answer obtained is wrong can be seen from the > fact that the answer is not odd, which contradicts the fact that the > FourierTransform and InverseFourierTransform of odd functions are odd. Sorry if some people see this message twice; when I originally posted > it via thunderbird my message showed up in thunderbird on my local Steve Moderated group, takes maybe a day for messages to go out. Devendra Kapadia located the bug in a special case handler (applicable when we have integral convergence at infinity, modulo a constant) and fixed it in the development Mathematica. Turns out to be a missplaced (ExpToTrig[-Exp[$FFC*I*s*t] should be ExpToTrig[Exp[-$FFC*I*s*t]) Was my bug from 4-5 years ago. [Steve should not be surprised; he may recall me taking an occasional snooze in physics 112, where we covered Fourier transforms.] Daniel Lichtblau Wolfram Research === Subject: Re: Different results with FourierTransform[] In accordance with the theory of distributions, FourierTransform and InverseFourierTransform are defined on a wider class of objects than those for which their direct definition in terms of Integrate converges. For example, In[1]:= FourierTransform[1, x, k, FourierParameters -> {1, -1}] Out[1]= 2 Pi DiracDelta[k] More relevant here is the example In[2]:= FourierTransform[Sign[x], x, k, FourierParameters -> {1, -1}] Out[2]= -2 I/k Since Tanh[x] differs from Sign[x] by an integrable function, its FourierTransform differs from that of Sign[x] by a bounded function. (When the distributions given by the FourierTransform of Sign[x] and of Tanh[x] are used in integrals those integrals must be understood using principal values.) Mathematica calculates the FourierTransform correctly: In[3]:= FourierTransform[Tanh[x], x, k, FourierParameters -> {1, -1}] Out[3]= -I Pi Csch[k Pi/2] To verify that this is correct we can use the identity FourierTransform [u'[x],x,k]==I k FourierTransform[u[x],x,k], which is valid for distributions as well as functions. Taking into account that the solution of the equation k d [k]==0 for distributions d[k] is d[k]->C DiracDelta[k], we can rewrite the above identity as FourierTransform[u[x],x,k] == FourierTransform [u'[x],x,k]/(I k) + C DiracDelta[k] When, as here, u is odd then C must vanish, which yields FourierTransform[u[x],x,k] == FourierTransform[u'[x],x,k]/(I k) (* for odd u *) The derivative of Tanh[x] is Sech[x]2, which is integrable and so has a FourierTransform in the ordinary sense. And the FourierTransform of Tanh[x] and of Tanh'[x] indeed satisfy the above identity: In[4]:= FourierTransform[Tanh'[x], x, k, FourierParameters -> {1, -1}] Out[4]=k Pi Csch[k Pi/2] Unfortunately, there appears to be a bug in Mathematica's calculation of InverseFourierTransform of Tanh[x], as the original poster pointed out. The fact that the answer obtained is wrong can be seen from the fact that the answer is not odd, which contradicts the fact that the FourierTransform and InverseFourierTransform of odd functions are odd. Sorry if some people see this message twice; when I originally posted it via thunderbird my message showed up in thunderbird on my local Steve On Mar 17, 12:00 pm, Jens-Peer Kuska and more surprising I have a third one, and this is the > correct one Integrate[Tanh[x]*Exp[I*x*p], {x, -Infinity, Infinity}] gives Integrate::idiv:Integral of E^(I*p*x) Tanh[x] does not converge on > {-Infinity,Infinity} Jens I somewhat stumbled over the following behaviour of mathematica: I trie= d > to calculate thefouriertransformof Tanh[x]. I did this in two ways: 1. Directly: > InverseFourierTransform[Tanh[x], x, p] 2. Indirectly: > InverseFourierTransform[Tanh[B x], x, p] where I set B -> 1 in the end. However, the result between the two approaches differs: Whereas in the > first approach I get a complex number (with both real and imaginary par= t > being non-zero for almost all values of p), the result in the second > approach yields NO real part; the imaginary part however is the same as > in the first approach. Is there any explanation for this behaviour? Wieland === Subject: help^please There are 3 small problems. 1)Using the functions: Position, ReplacePart, Take, Drop, Part, Rest, First and Last I have to get { { 1 } , { 2 , 3 , 4 , 5 , 6 } } out of Range[ 6 ] 2) Using the functions: Table, Random, Range I have to get { {0} , { 0 , 2 } , { 0 , 2 , 4 } , { 0 , 2 , 4 , 6 } , { 0 , 2 , 4 , 6 , 8 } } in TWO ways. ---> I found for this second problem: Table[ 2 * j - 2 , { i , 5 } , { j , i } ] but another method using the same functions ? 3)using the functions as in problem 1: Use the lists { a , b , c , d } and { 3 , 2 , 4 , 1 } to create the list { c , b , d , a } in one step. complete moron === Subject: Re: help^please > There are 3 small problems. 1)Using the functions: Position, ReplacePart, Take, Drop, Part, Rest, First and Last I have to get { { 1 } , { 2 , 3 , 4 , 5 , 6 } } out of Range[ 6 ] > 2) Using the functions: Table, Random, Range I have to get { {0} , { 0 , 2 } , { 0 , 2 , 4 } , { 0 , 2 , 4 , 6 } , { 0 , 2 , 4 , 6 , 8 } } in TWO ways. ---> I found for this second problem: Table[ 2 * j - 2 , { i , 5 } , { j , i } ] but another method using the same functions ? 3)using the functions as in problem 1: Use the lists { a , b , c , d } and { 3 , 2 , 4 , 1 } to create the list { c , b , d , a } in one step. complete moron > The only way you could be faced with a requirement like that, is as a college exercise! If you get help to solve your exercises, that will leave you no more skilled than before - so there would not be any point, would there? David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: help^please > There are 3 small problems. 1)Using the functions: Position, ReplacePart, Take, Drop, Part, Rest, First and Last I have to get { { 1 } , { 2 , 3 , 4 , 5 , 6 } } out of Range[ 6 ] 2) Using the functions: Table, Random, Range I have to get { {0} , { 0 , 2 } , { 0 , 2 , 4 } , { 0 , 2 , 4 , 6 } , { 0= , 2 , 4 , 6 , 8 } } in TWO ways. ---> I found for this second problem: Table[ 2 * j - 2 , { i , 5 } , { j , i } ] but another method using the same functions ? 3)using the functions as in problem 1: Use the lists { a , b , c , d } and { 3 , 2 , 4 , 1 } to create the list = { c , b , d , a } in one step. complete moron This seems like homework? :p 1. {Take[Range[6],1], Drop[Range[6],1]} 2a. 2*Table[j, {i, 0, 4}, {j, 0, i}] 2b. 2*Table[Range[0, i], {i, 0, 4}] 3. {a, b, c, d}[[{3, 2, 4, 1}]] === Subject: Re: help^please look like a home work 1) Range[6] /. {a_, b__} :> {{a}, {b}} 2) Table[2*j, {i, 4}, {j, 0, i - 1}] 3) Part[{a, b, c, d}, #] & /@ {3, 2, 4, 1} Jens > There are 3 small problems. 1)Using the functions: Position, ReplacePart, Take, Drop, Part, Rest, First and Last I have to get { { 1 } , { 2 , 3 , 4 , 5 , 6 } } out of Range[ 6 ] > 2) Using the functions: Table, Random, Range I have to get { {0} , { 0 , 2 } , { 0 , 2 , 4 } , { 0 , 2 , 4 , 6 } , { 0 , 2 , 4 , 6 , 8 } } in TWO ways. ---> I found for this second problem: Table[ 2 * j - 2 , { i , 5 } , { j , i } ] but another method using the same functions ? 3)using the functions as in problem 1: Use the lists { a , b , c , d } and { 3 , 2 , 4 , 1 } to create the list { c , b , d , a } in one step. complete moron > === Subject: Re: help^please Homework alert!!! > There are 3 small problems. 1)Using the functions: Position, ReplacePart, Take, Drop, Part, Rest, First and Last I have to get { { 1 } , { 2 , 3 , 4 , 5 , 6 } } out of Range[ 6 ] 2) Using the functions: Table, Random, Range I have to get { {0} , { 0 , 2 } , { 0 , 2 , 4 } , { 0 , 2 , 4 , 6 } , { 0= , 2 , 4 , 6 , 8 } } in TWO ways. ---> I found for this second problem: Table[ 2 * j - 2 , { i , 5 } , { j , i } ] but another method using the same functions ? 3)using the functions as in problem 1: Use the lists { a , b , c , d } and { 3 , 2 , 4 , 1 } to create the list = { c , b , d , a } in one step. complete moron === Subject: Re: Got a tip ? I want to write a function that translates its argument (which is a letter of the alphabet) into a numerical value. f[a] = 1 f[b] = 2 Try this: myCrypt[x_] := Module[{lst}, lst = CharacterRange[a, z] // ToExpression; (Position[lst, x] // Flatten)[[1]] ]; -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Incompatible units? > I use Convert very often and it's annoying. As an example: The result of > the multiplication of a frequency and a time has to be dimensionless. > Anyway, the shown result is always in Hertz Second. Only with > Convert[...,1] the units are avoided. The same applies for Watt/(Volt > Amp), Kilo/Milli etc. > Any idea what goes wrong here? The problem may lie in the fact that units that may have the same dimensions sometimes should not be equated. Take, for instance, the Newton Meter (N m), which occurs in moment of force expressions. It is dimensional equivalent to a Joule. Nevertheless, in many cases you wouldn't like the N m to be simplified to J. BTW I actually never use units in calculations. As long as you keep track of what the numbers mean there's never a problem. === Subject: Re: Incompatible units? > Hi Mathias, Your example is a bit incomplete, or so it seems. What are the > definitions of Tau p and l case? Yes, I know. It wasn't the complete calculation. That is because the complete one is endless ;) You helped me anyway... And what is the slash in Convert doing? And why are you using Convert > for this particular conversion? The division of the two variables is > dimensionless, so no need for Convert. No idea about the slash. In StandardForm I typed Convert[]. Must have been input during the copy&paste into my newsreader. I use Convert very often and it's annoying. As an example: The result of the multiplication of a frequency and a time has to be dimensionless. Anyway, the shown result is always in Hertz Second. Only with Convert[...,1] the units are avoided. The same applies for Watt/(Volt Amp), Kilo/Milli etc. Any idea what goes wrong here? Anyways, your problem is not the Units package, but the use of > Dynamic. Dynamic is a wrapper, much like InputForm or TableForm. It's > used for display in the FrontEnd, but not for calculations in the > kernel. Try for instance this definition: g[x_Numeric] := x^2 Now enter g[Dynamic[p]]. It displays as g[p]. Now set p to 5 (p=5). > You see the old g[p] change to g[5] and not to 25. This is because the > function doesn't see the number 5, but the object Dynamic[p] which > only displays as 5 in the FrontEnd. It does not represent the value 5 > to the kernel. The same happens with your conversion. Because the units are hidden > within the Dynamic wrapper they can't be simplified by the kernel. The > error message is displayed by the FrontEnd and this exposes the units, > but (it should be clear) this is not what the kernel sees! Read more about this in the section Where Should Dynamic Be Placed in > an Expression? in the tutorial tutorial/IntroductionToDynamic. Dynamic in this equation Mathematica works as expected. > situation but it's a good advice anyway. I will follow it. Mathias > >> Hi >> Today I struggled with the units package - again... >> Let me show you what I did: >> Dynamic[Subscript[[Tau], p]] >> Subscript[l, case] >> [Lambda] = Convert[Subscript[l, case]/Dynamic[Subscri= > pt[[Tau], p]], 1] >> This input results in: >> 27.4889 Meter Milli >> 281 Meter Milli >> Convert::incomp : Incompatible units in (281 Meter Milli)= > /(27.4889 >> Meter Milli) and 1. >> (281 Meter Milli)/(27.4889 Meter Milli) >> If I don't use dynamic but constant tau_p everything is fine... >> So Mathematica isn't able to to reduce this fraction? What's the reason >> for this behaviour and what can I do about it? >> Mathias === Subject: Plot - Filling area that is above more curves Is there any way to fill area that is (in the same time) above more curves in Plot function? So that filled area is not crossed with any regarded function. How to construct function from other functions that returns the biggest value from all functions in question? THX === Subject: Re: Plot - Filling area that is above more curves > Is there any way to fill area that is (in the same time) above more > curves in Plot function? So that filled area is not crossed with any > regarded function. How to construct function from other functions that returns the > biggest value from all functions in question? > You can use Max[] for that. Plot[{Sin[x], 1/3 (1 + Sin[2 x]), Max[Sin[x], 1/3 (1 + Sin[2 x])]}, {x, 0, 6 Pi}, Filling -> {3 -> Top}, PlotStyle -> {Red, Blue, None}] === Subject: Re: Plot - Filling area that is above more curves > Is there any way to fill area that is (in the same time) above more > curves in Plot function? So that filled area is not crossed with any > regarded function. Plot the curves and filled region separately and join them using Show: Show[Plot[{Sin[x], Cos[x]}, {x, 0, 6}], RegionPlot[y > Max[Sin[x], Cos[x]], {x, 0, 6}, {y, -1, 1}]] > > How to construct function from other function s that returns the > biggest value from all functions in question? f3[x_]:=Max[f1[x],f2[x]] > > THX > === Subject: Re: SetDelayed::write ... [x_] is protected >parameter lets say: sol={{i1->220/x}, {i2 -> 100+x}} and I need to >define function based on this solution with the x as argument lets >say: myfun[x_]:=50*220/x + 2 (100+x); >I'm trying to do it like this: >myfun[x_]:=50 * i1 + 2 * i2 /. sol >But it prints the error message: SetDelayed::write ... [x_] is >protected. >Does anybody know what's the problem and how to define such >function? I don't get an error when using your code above. That is: In[1]:= sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] := 50*i1 + 2*i2 /. sol myfun[y] Out[3]= {2 i2+11000/x,50 i1+2 (x+100)} However, I think you probably didn't want a list as a result. So, I think this is more likely to be what you wanted: In[4]:= Clear[myfun] myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] myfun[y] Out[6]= 2 (x+100)+11000/x I note using global variables in a function definition isn't good programming practice. It is far to easy to assign values to those variables which will cause the function to return something other than what was intended. And when this occurs, it is often difficult to find the problem. === Subject: Re: Unexpected behavior of Floor and IntegerPart >I'm sure this is a result of non-infinite-precision arithmetic, but >it would be nice to have a more consistent behavior: >In[26]:= IntegerPart[0.29*100] >Out[26]= 28 Yes, the behavior you are seeing is due to using machine precision numbers. If by consistent you mean you want consistency between the results obtained using machine precision numbers and exact numbers that isn't possible. The difference is an aspect of the way computers are designed and work. This difference can be overcome by Mathematica either by converting the machine precision numbers to exact numbers or increasing the precision beyond machine precision. Of course there is a cost to increasing precision in terms of performance time. === Subject: Re: Unexpected behavior of Floor and IntegerPart >I'm sure this is a result of non-infinite-precision arithmetic, but >it would be nice to have a more consistent behavior: >In[26]:= IntegerPart[0.29*100] >Out[26]= 28 Yes, the behavior you are seeing is due to using machine precision numbers. If by consistent you mean you want consistency between the results obtained using machine precision numbers and exact numbers that isn't possible. The difference is an aspect of the way computers are designed and work. This difference can be overcome by Mathematica either by converting the machine precision numbers to exact numbers or increasing the precision beyond machine precision. Of course there is a cost to increasing precision in terms of performance time. === Subject: Re: solving nonlinear simultaneous equations Look at your equations in InputForm rather than TraditionalForm. You have many terms that look like t1[1 - t0] that is you have square brackets rather than parentheses. You also have the wrong syntax for FindRoot. Look in the Documentation Center for the proper syntax. Bob Hanlon > I'm using mathematica5.2 to solving 4 complex nonlinear simultaneous > equations I'm only need to know the approximate answers,but FindRoot keeps > showing FindRoot::nlnum error messages. How can I solve this problem? I provides my final_2.nb file by website link. http://awin.cs.ccu.edu.tw/~dooma/final_2.nb === Subject: Re: Problem using a dialog and dynamic - problem sorted something I'll be able to keep an eye out for in the future. Paul. -----Original Message----- === Subject: Problem using a dialog and dynamic The following code should show a button and a text field. When I click the button, i should get a system dialog allowing me to select a folder, and the folder's file and pathname should then be displayed in the text field. Panel[Grid[{{Button[Select/Change Project Directory,sourcedir=SystemDialogInput[Directory,C:]]},{Column[ {Curre nt Project Directory:,InputField[Dynamic[sourcedir],String]}]}}] Unfortunately, the performance is erratic! If I click the button, then select a folder of the C drive, say C:first, and click open, the textfield display C:first as expected. But if I then click the button again, and select, say, folder off the C:firstsecond and click open, the textfield does not change, nor does it for any subsequent clicks. However, if I select the desktop, it works as expected, and if I select the C: drive again it also works. To summarise, if i want to change the folder selection, I have to select the C: drive once, then click again and select the subfolder I want, and if I want to change the subfolder, I have to select the c: drive again, before I can select the new subfolder. Is this a bug, or am I doing something stupid? I am using V7 on Windows Vista Home Premium. Paul Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: Installation question whether it's possible to keep the previous version (v6) that I have already installed on my machine. I have an Intel Mac. Daniele === Subject: Re: Installation question On my PC I don't have any problems, some settings are shared though (like whether or not the welcome screen is present, no big deal). This question has been asked before. Look in the archive to find out how to make separate settings. > whether it's possible to keep the previous version (v6) that I have > already installed on my machine. I have an Intel Mac. Daniele === Subject: Re: Installation question > whether it's possible to keep the previous version (v6) that I have > already installed on my machine. I have an Intel Mac. Daniele I think you can. I do the following on my mac. Just rename the old application to Mathematica-6.0.3.app (or whatever is the real version or whatever you like actually) before installing the new version 7. You probably should also need to separate them the library folders that Mathematica uses so you might want to keep two versions of the two folders: /Library/Mathematica -- rename to /Library/mathematica-6 ~/Library/Mathematica -- rename to ~/Library/Mathematica-6 before doing the install - make sure Mathematica is not running when doing this renaming. Then do the install and name the new App and libraries /Applications/Mathematica.app -> /Applications/ Mathematica-7.0.1.app /Library/Mathematica -> /Library/Mathematica-7 ~/Library/Mathematica -> ~/Library/Mathemtica-7 And then you need to create a couple of small shell scripts that switch between the two versions. Something like: # Script to go from 6 to 7 in a file called switch-to-7 # # We are switching from Mathematica 6 to Mathematica 7, so we need to # # first move the current generic /Library/Mathematica to the specific # then move the current generic ~/Library/Mathematica to the specific # mv /Library/Mathematica /Library/Mathematica-6 mv ~/Library/Mathematica ~/Library/Mathematica-6 # # Then need to move the 7.0.1 directories to the generic name # mv /Library/Mathematica-7.0.1 /Library/Mathematica mv ~/Library/Mathematica_7.0.1 ~/Library/Mathematica and the other script to go from 7 to 6 would look something like: # Script to go from 7 to 6 in a file called switch-to-6 # # We are switching from Mathematica 7 to Mathematica 6, so we need to # # first move the current generic /Library/Mathematica to the specific # then move the current generic ~/Library/Mathematica to the specific # mv /Library/Mathematica /Library/Mathematica-7 mv ~/Library/Mathematica ~/Library/Mathematica-7 # # Then need to move the 6 directories to the generic name # mv /Library/Mathematica-6 /Library/Mathematica mv ~/Library/Mathematica_6 ~/Library/Mathematica Then to switch back and forth run one script and do work in that version. Then exit Mathematica, run the other script and do your work in that version. Make sure you don't accidently run the same script twice in a row. You can always tell what version you currently have setup by just looking at the names, ie if there is a /Library/Mathematica-7 then you are currently setup for Mathematica 6, and if you see /Library/ Mathematica-6 then you are currently setup for Mathematica 7. If you do run the same script twice you might/will have problems!!! Would suggest having a backup of both just in case of accidents. Or just make a spare copy in some other folder. Each one of the Hope that helps. The reason for switching all the names is to help minimize the chance of putting some version 7 stuff into the version 6 and vice versa, like palette names and other stuff that can be version specific. I can't promise this will prevent any problems but I have been doing this for a while to do some testing with both versions and have not had any problems yet. Your mileage may vary so be careful and have a backup just in case. You will also have to be carefull of what version of Mathematica was used to create your notebooks, but you will always get a warning if you try and open a 7 notebook in version 6, but not the other way around. This also ensures that both versions have their own init.m file (which is located in the ~/Library/ Mathematica/FrontEnd folder). You could conceivably have several versions, but I wouldn't think you need to do this except for major versions, ie 5, 6, or 7, as replacing 7.0 with 7.0.1 should not be any big deal, but that is just my opinion, and is not based on anything other than intuition, so it's very likely in error ;-) You might want to run this by Wolfram to see if there is any problems in doing this. I make no guarantee that this wont cause problems, so do a little more investigating if you need to be certain. So far, I have not had problems doing this, but it's possible I have had em and just have not noticed em ;-) The extra overhead for keeping two copies of the libraries is just a couple of megabytes typically (that's what I see for my setup) plus the extra 1.4 GB for the Mathematica.app application (1.4 GB for 7.0.1, and about 1.1 GB for 6.0.3) This all assumes you are comfortable with using the Terminal app on your Mac and several other things. If that is not the case, then you might just want to ignore everything I have talked about, or learn about using these aspects of you Mac system. DON'T FORGET -- MAKE SURE YOU HAVE A BACKUP BEFORE STARTING JUST IN CASE SOMETHING ODD HAPPENS!!! Any whatever you do, don't try and run two versions at the same time. I don't have any reason for this, but don't think it's a good thing to try unless someone with a lot of Mathematica expertise says it's no problem. I would not consider myself an expert at Mathematica by any stretch of the imagination!!! If anyone on the group sees any problems with doing this, please let us know. -Bob === Subject: Re: Installation question > whether it's possible to keep the previous version (v6) that I have > already installed on my machine. I have an Intel Mac. > On Windows it's certainly possible to have several versions installed, so probably it's possible on a Mac as well. === Subject: Re: Installation question > whether it's possible to keep the previous version (v6) that I have > already installed on my machine. I have an Intel Mac. Yes, it is possible. -Rob === Subject: Re: Unexpected behavior of Floor and IntegerPart The observed behavior is consistent. If you want the functions to behave based on the apparent values rather than the machine numbers, then use Rationalize or Round to whatever precision level that you want. This will probably just shift the unexpected behavior to some other condition. myIntegerPart[x_] := IntegerPart[Rationalize[x]] myFloor[x_] := Floor[Rationalize[x]] myIntegerPart[0.29*100] 29 myFloor[0.29*100] 29 Bob Hanlon > I'm sure this is a result of non-infinite-precision arithmetic, but > it would be nice to have a more consistent behavior: In[26]:= IntegerPart[0.29*100] Out[26]= 28 In[25]:= Floor[0.29*100] Out[25]= 28 In[27]:= Floor[(29/100)*100] Out[27]= 29 In[32]:= (Floor[#1*100] & ) /@ Range[0, 1, 0.01] Out[32]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, > 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 30, 31, 32, 33, > 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, > 51, 52, 53, 54, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, > 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, > 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} In[33]:= Differences[%] Out[33]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, > 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} An interesting hint as to what may be happening is obtained by: ListPlot[Differences[(Floor[#1*100] & ) /@ Range[0, 100, 0.01]]] > -- > 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: SetDelayed::write ... [x_] is protected Jakub, You'll probably get several better solutions than this one. However,. . . In[25]:= sol={{i1->220/x},{i2->100+x}}; (* [[..]] is the Part function *) myfun[x_]:=50*sol[[1,2]]+2*sol[[2,2]] (* If want to see what Flatten does, evaluate this line without the ; *) sol = Flatten@sol ; myfun[x] Out[28]= 11000/x + 2(100+x) Richard Hofler ________________________________ === Subject: is protected I have solution of equations which is dependend on one parameter lets say: sol={{i1->220/x}, {i2 -> 100+x}} and I need to define function based on this solution with the x as argument lets say: myfun[x_]:=50*220/x + 2 (100+x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is protected. Does anybody know what's the problem and how to define such function? Jakub === Subject: Re: SetDelayed::write ... [x_] is protected sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] 2*(x + 100) + 11000/x Bob Hanlon > I have solution of equations which is dependend on one parameter lets > say: > sol={{i1->220/x}, {i2 -> 100+x}} and I need to define function based > on this > solution with the x as argument lets say: myfun[x_]:=50*220/x + 2 > (100+x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is > protected. Does anybody know what's the problem and how to define such function? > Jakub === Subject: Cycling through windows with a keyboard shortcut CTRL+F6 can be used to cycle through notebook windows (at least on Windows), but it is not a very convenient keyboard shortcut. To use it, one either has to use both hands, or move one hand from the normal position. I'd like to associate a more accessible keyboard shortcut with this function. Is there a front end token for cycling through windows? If no, is there any other way one can implement cycling through windows (both notebooks and documentation) without using the kernel? === Subject: Read data structure from binary file I have a binary file which I would like to read into a data structure. The data structure contains some simple data types like Integer16 and Integer32, but also a byte array of length 255. How can I read this byte array into mathematica along with the other data types as a complete data structure, without having to use BinaryReadList(file, {Integer32, Byte, Byte, Byte, Byte, Byte, ..., Byte, Integer16}) ? === Subject: p-value ANOVA Tukey? Hello everybody, ..does anyone here know if it's possible to get the p-value of a Tukey PostHoc-Test? One can define the SignificanceLevel but I haven't find a way yet to see its p-value. Have a nice day! Volkito === Subject: Re: Plot - Filling area that is above more curves func = {x, x^2, Sqrt[x]}; Show[Plot[func, {x, 0, 2}], Plot[Max[func], {x, 0, 2}, Filling -> 4]] func = {-3 x^2 - 2 x + 1, -6 x^2 - 4 x - 9}; m = FindMaximum[Max[func], x] {1.33333,{x->-0.333333}} Plot[func, {x, -2, 1}, Epilog -> {Red, AbsolutePointSize[3], Point[{m[[2, 1, 2]], m[[1]]}]}] Bob Hanlon Is there any way to fill area that is (in the same time) above more curves in Plot function? So that filled area is not crossed with any regarded function. How to construct function from other functions that returns the biggest value from all functions in question? THX === Subject: Re: Kernel is quitting on me yours was a very useful answer. I was also afraid that there could be > a memory leak somewhere. However, I don't know how to track down the > offending code. Any ideas? Sorry, I don't have any clever ideas on how to approach the problem. In my specific case my code looked like this: nfft[f_,w_,opts___?OptionQ] := Module[{m,a,psi,c,n,g,l,dims,ret}, (*deleted for clarity*) g = Fourier[ RotateLeft[ PadLeft[ PadRight[ (*Step 1: Compute ghat=f/c*) Fold[Transpose[#1/#2,Prepend[Range [1,ArrayDepth[#]-1], ArrayDepth[#]]] &,f, [n,nfft`approximationWidth->m, nfft`oversamplingFactor->a],c]], Quotient[n,2]+Quotient[Dimensions[f],2]+Mod [n,2]],n], Quotient[n,2]], FourierParameters->{1,-1}]; ret=(*deleted for clarity*); Remove[g];Return[ret]] And g turned out to be the problematic variable. This was discovered with the help of Wolfram Technical Support. Including the deleted code the module isn't particularly large but it is complex. Looking back at my conversation with technical support it seems I narrowed down the problem as follows: I had code that crashed at random times as you do, I started checking the amount of memory used before and after calls to routines I found suspicious and noticed that the module above (without the remove) caused MemoryInUse to grow rapidly after each call. I then sent the problematic code to technical support who identified g as the variable that caused the memory leak. So to remove the leak I only had to Remove[g], your case may be different. > I Remove-d all variables from my modules (which were all properly > defined as local anyway), except the one that gets returned as the > output of the module. How could I do that? You can't, originally my code didn't have a variable to return the results, but I had to introduce one since I could free the memory associated with g before returning. > There are also hidden > variables created inside each Module when computations are made, I > guess I have to pray for those to be disposed of. At this point I think you'd need to refer to technical support, they have the tools to inspect more deeply where the memory is being leaked, but as you pointed out earlier they are unlikely to comb through large amounts of code for you, so if you can narrow the leak location(s) down at least in my experience they can be helpful. > Do you think that renaming all variables from all modules so that > there are no two variables named the same could help? I mean, even if > they are local to the module, could they collide and cause the leak? My problem didn't seem to arise from name collision, there were no variables named g in a scope level outside of the module. Good luck, Ssezi === Subject: Re: Kernel is quitting on me > Hi all, I am testing a very long worksheet, and all the pieces seem to be > working (separately). When I use the loop that puts them all together, > the kernel quits after a few seconds (or at least, the equivalent of > the kernel quitting: everything goes undefined and in a weird color). > I've tried following the computation step by step and everything seems > normal until it just hangs. Also it seems to hang at different places > everytime, but that *could* be that I am testing with a different > random initial condition every time. > I=B4ve checked if it is memory usage, it shouldn't be since the > MaxMemoryUsed never goes above 15MB. I tried with $HistoryLength=0 > just in case. The kernel in Debugger mode also just quits. > There is almost no symbolic manipulation either, just operations on > lists with numeric values. > I can't reproduce the error with simpler algorithms, and submitting > the whole worksheet for other to find a bug seems too much. My question is then: What kind of things can cause this behavior?? I > have really no clue since there are no error or warning messages, just > an ugly quit. I would appreciate at any pointers to where can I start > looking at... I suspect you have a memory leak in a Module. I know Mathematica is supposed to be garbage collected but in my experience I have found routines that leak, my recommendation is to use Remove on any variables created in modules. I don't know what kind of code you are writing but I have also been able to cause some Mathematica routines to crash on input that doesn't seem particularly special, in particular I've seen SingularValueDecomposition fail on seemingly innocuous numeric input. Hope this helps, Ssezi === Subject: Re: Kernel is quitting on me yours was a very useful answer. I was also afraid that there could be a memory leak somewhere. However, I don't know how to track down the offending code. Any ideas? I Remove-d all variables from my modules (which were all properly defined as local anyway), except the one that gets returned as the output of the module. How could I do that? There are also hidden variables created inside each Module when computations are made, I guess I have to pray for those to be disposed of. Do you think that renaming all variables from all modules so that there are no two variables named the same could help? I mean, even if they are local to the module, could they collide and cause the leak? Fernando >> Hi all, >> I am testing a very long worksheet, and all the pieces seem to be >> working (separately). When I use the loop that puts them all >> together, >> the kernel quits after a few seconds (or at least, the equivalent of >> the kernel quitting: everything goes undefined and in a weird color). >> I've tried following the computation step by step and everything >> seems >> normal until it just hangs. Also it seems to hang at different places >> everytime, but that *could* be that I am testing with a different >> random initial condition every time. >> I=B4ve checked if it is memory usage, it shouldn't be since the >> MaxMemoryUsed never goes above 15MB. I tried with $HistoryLength=0 >> just in case. The kernel in Debugger mode also just quits. >> There is almost no symbolic manipulation either, just operations on >> lists with numeric values. >> I can't reproduce the error with simpler algorithms, and submitting >> the whole worksheet for other to find a bug seems too much. >> My question is then: What kind of things can cause this behavior?? I >> have really no clue since there are no error or warning messages, >> just >> an ugly quit. I would appreciate at any pointers to where can I start >> looking at... I suspect you have a memory leak in a Module. I know Mathematica is = > supposed to be garbage collected but in my experience I have found > routines that leak, my recommendation is to use Remove on any > variables created in modules. I don't know what kind of code you > are writing but I have also been able to cause some Mathematica > routines to crash on input that doesn't seem particularly special, > in particular I've seen SingularValueDecomposition fail on seemingly = > innocuous numeric input. Hope this helps, Ssezi === Subject: Re: Kernel is quitting on me On Mar 24, 6:28 am, Fernando Cucchietti working (separately). When I use the loop that puts them all together, > the kernel quits after a few seconds (or at least, the equivalent of > the kernel quitting: everything goes undefined and in a weird color). > I've tried following the computation step by step and everything seems > normal until it just hangs. Also it seems to hang at different places > everytime, but that *could* be that I am testing with a different > random initial condition every time. > I=B4ve checked if it is memory usage, it shouldn't be since the > MaxMemoryUsed never goes above 15MB. I tried with $HistoryLength=0 > just in case. The kernel in Debugger mode also just quits. > There is almost no symbolic manipulation either, just operations on > lists with numeric values. > I can't reproduce the error with simpler algorithms, and submitting > the whole worksheet for other to find a bug seems too much. My question is then: What kind of things can cause this behavior?? I > have really no clue since there are no error or warning messages, just > an ugly quit. I would appreciate at any pointers to where can I start > looking at... Fernando Wild guess. Consider moving the code from a notebook to a package file, where you have more control over the content given to the parser. Be careful of 'special characters' in any copy/paste operations. Vince Virgilio === Subject: Kernel is quitting on me Hi all, I am testing a very long worksheet, and all the pieces seem to be working (separately). When I use the loop that puts them all together, the kernel quits after a few seconds (or at least, the equivalent of the kernel quitting: everything goes undefined and in a weird color). I've tried following the computation step by step and everything seems normal until it just hangs. Also it seems to hang at different places everytime, but that *could* be that I am testing with a different random initial condition every time. I=B4ve checked if it is memory usage, it shouldn't be since the MaxMemoryUsed never goes above 15MB. I tried with $HistoryLength=0 just in case. The kernel in Debugger mode also just quits. There is almost no symbolic manipulation either, just operations on lists with numeric values. I can't reproduce the error with simpler algorithms, and submitting the whole worksheet for other to find a bug seems too much. My question is then: What kind of things can cause this behavior?? I have really no clue since there are no error or warning messages, just an ugly quit. I would appreciate at any pointers to where can I start looking at... Fernando === Subject: Detecting CD driver availability I want Mathematica check the DVD presence into the CD-ROM driver and execute myFunction[] when it become available, so I try something like SetDirectory[NotebookDirectory[]]; Off[SetDirectory::cdir]; Print[Start]; While[SetDirectory[d:] == $Failed, Pause[1]]; Print[Stop]; but it's an unsuccessful trick, because it makes the Retry, Abort, Continue message box rise, invoking the user's act, just exactly what I want to avoid. Any way out? Ignacio Plazeta === Subject: How do I hide all input in a Mathematica notebook? Hi I am using Mathematica to prepare a report for my boss. It has lots of tables and pie charts - the sort of things bosses love. It also has a lot of Mathematica commands which scares the wossname out of him. At the moment I am hiding the input cell by cell but this is a pain. Is there a one click/one command solution? Mike www.walkingrandomly.com === Subject: Re: Bug in D (or Derivative) ( Was: Re: DSolve bug) >> The source of this bug seems to be the following bug in in D (or >> Derivative): According to Mathematica, D[u',u] yields u''. However, >> the correct answer is u''/u' >> (Homework for Calculus 1: use the chain rule to prove this.) Not really. According to Mathematica's notion of derivative, D[u',u] > ought to be 0, since u' does not involve u explicitly. Actually, I was wrong here since, of course, u' is Derivative[1][u] and this does involve u explicitly. Of course in this case D[Derivative[1][u],u] does not make any mathematical sense (unless we wanted this to mean the derivative in some functional sense, but then what Mathematica does with it makes no sense anyway). This: D[derivative[1][u], u] Derivative[1][derivative[1]][u] does make sense, as long as derivative is undefined, but this: % /. derivative -> Derivative Derivative[2][u] doesn't. Still, for Mathematica to be consistent and still make mathematical sense, D[u',u] ought to return 0, as it in the example below. Andrzej Kozlowski > In fact, D[u'', u'] > 0 which, of course, is much the same thing. The only way I know to get > the answer you have in mind with Mathematica is: Dt[Derivative[1][u][x], u[x]] > Derivative[2][u][x]*Dt[x, u[x]] >> The way Mathematica obtains its incorrect result is quite amusing, As >> Trace shows, Mathematica evaluates D[u',u] by noting that the >> FullForm >> of u' is Derivative[1][u], whose derivative with respect to u is (of >> course ;) ) Derivative[1]'[u]. >> Mathematica then decides that Derivative[1]' is Derivative[2], >> yielding Derivative[2][u], i.e., u''. > > Indeed, this is right, and has been mentioned on this forum several > times in the past (at least twice by me). > See, for example, http://forums.wolfram.com/mathgroup/archive/2008/Jul/msg00801.html > Andrzej Kozlowski > === Subject: Re: Bug in D (or Derivative) ( Was: Re: DSolve bug) > The source of this bug seems to be the following bug in in D (or > Derivative): According to Mathematica, D[u',u] yields u''. However, > the correct answer is u''/u' > (Homework for Calculus 1: use the chain rule to prove this.) Not really. According to Mathematica's notion of derivative, D[u',u] ought to be 0, since u' does not involve u explicitly. In fact, D[u'', u'] 0 which, of course, is much the same thing. The only way I know to get the answer you have in mind with Mathematica is: Dt[Derivative[1][u][x], u[x]] Derivative[2][u][x]*Dt[x, u[x]] > The way Mathematica obtains its incorrect result is quite amusing, As > Trace shows, Mathematica evaluates D[u',u] by noting that the FullForm > of u' is Derivative[1][u], whose derivative with respect to u is (of > course ;) ) Derivative[1]'[u]. > Mathematica then decides that Derivative[1]' is Derivative[2], > yielding Derivative[2][u], i.e., u''. > Indeed, this is right, and has been mentioned on this forum several times in the past (at least twice by me). See, for example, http://forums.wolfram.com/mathgroup/archive/2008/Jul/msg00801.html Andrzej Kozlowski === Subject: Bug in D (or Derivative) ( Was: Re: DSolve bug) The problem is not just that D[u[x][y],x,y] and D[u[y][x],y,x] yield apparently different results but that the results Mathematica gives for both of them are wrong. For example, define usub=u -> (Function[{x}, Function[{y}, E^(a x + b y)]]); Substituting and then differentiating (in either order) gives correct results (as several posters pointed out): D[u[x][y]/.usub,x,y] yields a b E^(a x + b y) However D[u[x][y],x,y]/.usub yields the incorrect answer a^2 E^(a x+ b y) Taking the derivative in the opposite order and then substituting yields an expression that does not even reduce to a specific function of x and y. The source of this bug seems to be the following bug in in D (or Derivative): According to Mathematica, D[u',u] yields u''. However, the correct answer is u''/u' (Homework for Calculus 1: use the chain rule to prove this.) The way Mathematica obtains its incorrect result is quite amusing, As Trace shows, Mathematica evaluates D[u',u] by noting that the FullForm of u' is Derivative[1][u], whose derivative with respect to u is (of course ;) ) Derivative[1]'[u]. Mathematica then decides that Derivative[1]' is Derivative[2], yielding Derivative[2][u], i.e., u''. Steve > More to the point, using Bob's example: Clear[f] > f[a_][x_] := Sin[a*x] > D[f[x][y], x, y] - D[f[x][y], y, x] 0 As you can see, both derivatives ARE the same. Here's a better test, I = > think (since a and x were used symmetrically, above): Clear[f] > f[a_][x_] := Sin[a]^x > diff = D[f[x][y], x, y] - D[f[x][y], y, x] 0 But let's try it Sotirios' way, keeping f symbolic for a bit: Clear[f] > raw=D[f[x][y],x,y]-D[f[x][y],y,x]; > Block[{g},g[a_][x_]:=Sin[a]^x;raw/.f->g]//ExpandAll//Simplify -(Log[Sin[x]]^2 Sin[x]^#1& (g^[Prime])[x])[y]+(g^[Prime][Prime])[x][y] Now Mathematica can't equate the two derivatives. But that's a problem with D, not withDSolve. Note that Dt does better, too: Clear[f] > raw = Dt[f[x][y], x, y] - Dt[f[x][y], y, x] 0 DSolve'ssolution IS correct. It's D that may not be all it should be. Bobby Your example gives two different ways of referring to the same function= > (Sin[a*x]). But I want to be able to use the arbitrary function in the = > solution given byDSolve(and its derivatives) in other expressions. > This I cannot do because the derivatives D[f1[x][y], x, y], D[f1[x][y],= > y, x] are not equal: Clear[f1, f2] {D[f1[x][y], x, y], D[f1[x][y], y, x]} That's why I claim, if it is not abug, it is an unfortunate choice of = > representation! Sotirios Bonanos > It is just an alternate representation > Clear[f1, f2] > f1[a_][x_] := Sin[a*x] > f2[a_, x_] := Sin[a*x] > f1[c][t] == f2[c, t] > True > {Plot3D[f1[a][x], {x, 0, 2 Pi}, {a, 1, 3}], >> Plot3D[f2[a, x], {x, 0, 2 Pi}, {a, 1, 3}]} > Some people prefer the f[a][x] representation to explicitly separate o= ut >> parameter(s) from argument(s) > If you prefer >DSolve[D[F[x, y, z], x, y] == 0, F[x, y, z], {x, y, z}] > {{F(x,y,z)->Subscript[c, 1][z][x]+Subscript[c, 2][z][y]}} > % /. f_[arg1_][arg2_] :> f[arg2, arg1] > {{F(x,y,z)->Subscript[c, 1][x,z]+Subscript[c, 2][y,z]}} > Bob Hanlon >> I have encountered the followingbuginDSolve: >>DSolve[D[F[x, y, z], x, y] == 0, F[x, y, z], {x, y, z}] >> gives {{F[x, y, z] -> C[1][z][x] + C[2][z][y]}} >> instead of {{F[x, y, z] -> C[1][x, z] + C[2][y, z]}} >> I don't know if this has been fixed in Mathematica 7, but it is >> present in versions 5 and 6. >> S. Bonanoshttp://www.inp.demokritos.gr/~sbonano/ -- > DrMajor...@bigfoot.com === Subject: Re: SetDelayed::write ... [x_] is protected I already told you before that you should get rid of the SetDelayed (:=) and use Set (=) instead for the definition of myfun. > messages), but in fact it doesn't work. sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; > myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] > (no errors here) but: In: myfun[1] Out: 11000/x + 2 (100 + x) and not 11202 which would be result for argument 1. So it cannot recognize (or connect together with the pattern x_) the = > variable > x in the result from sol. What to do with it? > Jakub -----Original Message----- > Cc: mathgr...@smc.vnet.net === > Subject: RE: is protected sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] 2*(x + 100) + 11000/x Bob Hanlon > I have solution of equations which is dependend on one > parameter lets > say: > sol={{i1->220/x}, {i2 -> 100+x}} and I need to define > function based > on this solution with the x as argument lets say: > myfun[x_]:=50*220/x > + 2 (100+x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is > protected. Does anybody know what's the problem and how to define such > function? > Jakub === Subject: Re: SetDelayed::write ... [x_] is protected > messages), but in fact it doesn't work. No, it doesn't seem to work... since it doesn't work. But this does: Clear[x, myfun] sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] 11000/x + 2 (100 + x) myfun[1] 11202 or this: Clear[x, myfun] sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] := Evaluate[50*i1 + 2*i2 /. Flatten[sol]] myfun[1] 11202 Bobby > messages), but in fact it doesn't work. sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; > myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] > (no errors here) but: In: myfun[1] Out: 11000/x + 2 (100 + x) and not 11202 which would be result for argument 1. So it cannot recognize (or connect together with the pattern x_) the = > variable > x in the result from sol. What to do with it? > Jakub >> -----Original Message----- >> Cc: mathgroup@smc.vnet.net === >> Subject: RE: is protected >> sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; >> myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] >> 2*(x + 100) + 11000/x >> Bob Hanlon >> I have solution of equations which is dependend on one >> parameter lets >> say: >> sol={{i1->220/x}, {i2 -> 100+x}} and I need to define >> function based >> on this solution with the x as argument lets say: >> myfun[x_]:=50*220/x >> + 2 (100+x); >> I'm trying to do it like this: >> myfun[x_]:=50 * i1 + 2 * i2 /. sol >> But it prints the error message: SetDelayed::write ... [x_] is >> protected. >> Does anybody know what's the problem and how to define such >> function? >> Jakub > -- DrMajorBob@bigfoot.com === Subject: Re: is protected messages), but in fact it doesn't work. sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] (no errors here) but: In: myfun[1] Out: 11000/x + 2 (100 + x) and not 11202 which would be result for argument 1. So it cannot recognize (or connect together with the pattern x_) the = variable x in the result from sol. What to do with it? Jakub > -----Original Message----- > Cc: mathgroup@smc.vnet.net === > Subject: RE: is protected sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] 2*(x + 100) + 11000/x Bob Hanlon I have solution of equations which is dependend on one > parameter lets > say: > sol={{i1->220/x}, {i2 -> 100+x}} and I need to define > function based > on this solution with the x as argument lets say: > myfun[x_]:=50*220/x > + 2 (100+x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is > protected. Does anybody know what's the problem and how to define such > function? > Jakub > === Subject: Re: SetDelayed::write ... [x_] is protected Hi Jakub, the problem is the delayed assignment. Functions arguments are substituted before the function code is evaluated. x does nowhere appear in the function body and is therefore not substituted. On the other hand, in a direct assignment, what is stored is: 11000/x + 2 (100 + x) and the problem disappears. Daniel > messages), but in fact it doesn't work. sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; > myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] > (no errors here) but: In: myfun[1] Out: 11000/x + 2 (100 + x) and not 11202 which would be result for argument 1. So it cannot recognize (or connect together with the pattern x_) the = > variable > x in the result from sol. What to do with it? > Jakub >> -----Original Message----- >> Cc: mathgroup@smc.vnet.net === >> Subject: RE: is protected >> sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; >> myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] >> 2*(x + 100) + 11000/x >> Bob Hanlon > I have solution of equations which is dependend on one >> parameter lets > say: > sol={{i1->220/x}, {i2 -> 100+x}} and I need to define >> function based > on this solution with the x as argument lets say: >> myfun[x_]:=50*220/x > + 2 (100+x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is > protected. Does anybody know what's the problem and how to define such >> function? Jakub > === Subject: Asking PlotRange to take a Dynamic value I apologise in advance for what is probably a stupid question, but I would appreciate some help in persuading PlotRange to take a Dynamic value - or suggesting another way to go about things entirely! For teaching purposes I wanted to draw a series of graphs of Log[x] vs. x^a for small positive values of a at different scales (simply to illustrate how Log[x] is eventually < x^a, for any positive a). I thought I would use Manipulate to allow students to explore this interactively. E.g for x=0 to 10: Manipulate[ Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, PlotStyle -> {Red, Blue, Blue, Blue}, PlotRange -> {{0, 10}, {0, 3}}], Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small positive a 0.2, 0.25 & 0.3, 12, Bold], Style[x = 0 to 10, 12, Bold], {n, 0.01, 10, Appearance -> Labeled}] & for x=0 to 500,000: Manipulate[ Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, PlotStyle -> {Red, Blue, Blue, Blue}, PlotRange -> {{0, 500000}, {0, 55}}], Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small positive a 0.2, 0.25 & 0.3, 12, Bold], Style[x = 0 to 500,000, 12, Bold], {n, 0.01, 500000, Appearance -> Labeled}] But rather than a series of separate graphs I thought it would be more elegant to combine them in one plot with a Dynamic value to choose the scale, e.g.: Manipulate[ Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.01, n}, PlotStyle -> {Red, Blue, Blue, Blue}, PlotRange -> {{1, Dynamic[z]}, {0, 55}}], Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small positive a 0.2, 0.25 & 0.3, 12, Bold], Row[{Style[x, Bold], from 1 to , PopupMenu[Dynamic[z], {10, 500, 10000, 500000}]}], {n, 0.1, Dynamic[z], Appearance -> Labeled}] Unfortunately, although the graphs will plot, with continually updating axes, what I really want is to change the plot range for each value of x & fix it so one can see the curves evolving more easily. I hope the 2 individual examples above make it clear what I hoped for - essentially, to click from one to the next with the PopupMenu. The error message reads (e.g. for x=10): Plot::prng: Value of option PlotRange -> {{1,10},{0,55}} is not All, Full, Automatic, a positive machine number, or an appropriate list of range specifications. >> What's gone wrong? PlotRange -> {{1,10},{0,55}} looks like an appropriate list of range specifications to me! Any advice appreciated Andrew Graham === Subject: animation in version 7.0 looks bad Folks -- maybe its just my old mac ( a G4 967 MHz) but animations just don't look very good when using Animate or ListAnimate in Mathematica Version 7.0.1. This is particularly true if the plots in the animation are at all complicated. The animations run rather slowly and look jumpy. It works better if I use the old method of grouping a series of plots and then doing apple-Y . An example is given below -- two different modes of animation, one using ListAnmate and the other producing the same plots that must then be animated by hand using Animate Selected Graphics. On my machine the second method looks much smoother and also runs faster. How do I get Animate and/or ListAnimate to give better-looking output (besides going out and buying a new machine)? [Psi][x_, t_] = Exp[-(x - t)^2/(2 (1 + t))]/Sqrt[1 + t]; ListAnimate[ Table[Plot[[Psi][x, t], {x, -2, 10}, AxesLabel -> {x, }, Ticks -> False, PlotLabel -> t = <> ToString[t], PlotRange -> {0, 1}], {t, 0., 10, 1}], DisplayAllSteps -> True, AnimationRate -> 5]; Do[Print[ Plot[[Psi][x, t], {x, -2, 10}, AxesLabel -> {x, }, Ticks -> False, PlotLabel -> t = <> ToString[t], PlotRange -> {0, 1}]], {t, 0., 10, 1}] -- --------------- | Professor Dan Dubin | Dept of Physics , Mayer Hall Rm 3531, | UC San Diego La Jolla CA 92093-0319 | phone (858) - 534-4174 fax: (858)-534-0173 | ddubin@ucsd.edu === Subject: Re: SetDelayed::write ... [x_] is protected >messages), but in fact it doesn't work. >sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; >myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] >(no errors here) but: >In: myfun[1] >Out: 11000/x + 2 (100 + x) >and not 11202 which would be result for argument 1. >So it cannot recognize (or connect together with the pattern x_) the >= variable x in the result from sol. What you have done is use SetDelayed. That means by design evaluation of the 50*i1 + 2*i2 /. Flatten[sol] part on the right hand side isn't done until myfun is called. Consequently, nothing matches the pattern x_ and you get the result you posted. What you need for this application is to replace SetDelayed with Set which causes evaluation of the right hand side to occur immediately. That is: In[1]:= sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol]; In[3]:= myfun[1] Out[3]= 11202 Does what you want === Subject: What's going on here (Table-generated lists)? I'm seeing a difference in behavior with Plot in conjunction with Table, and I'm rather confused at the reason. If I use Plot to plot a list of functions, it works as expected, and I get a plot with each function in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I don't see anything obviously different about them. Here's what confuses me more: If I generate the table separately and then use that as a result in a later evaluation in the Plot, then I get the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special scan of its first argument before Evaluating it, and if it doesn't start out as a List, it concludes that it's all one thing and plots it with the same color, as opposed to an explicitly provided list of separate colors? -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis In this world, nothing is certain but death and taxes. -- Benjamin Franklin === Subject: Import ZIP, 5000+ Files per Archive I have a large directory of zip archives, each containing about 5000 files. When I use Import[] to extract just the FileNames component, it takes forever. The archives themselves can be extracted outside of Mathematica in just a few seconds. Any suggestions? Or must I resort to using the command line? === Subject: Re: SetDelayed::write ... [x_] is protected Use the expression that I sent, i.e., use Set ( = ) rather than SetDelayed ( := ). Bob Hanlon messages), but in fact it doesn't work. sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] (no errors here) but: In: myfun[1] Out: 11000/x + 2 (100 + x) and not 11202 which would be result for argument 1. So it cannot recognize (or connect together with the pattern x_) the = variable x in the result from sol. What to do with it? Jakub > -----Original Message----- > Cc: mathgroup@smc.vnet.net === > Subject: RE: is protected sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] 2*(x + 100) + 11000/x Bob Hanlon I have solution of equations which is dependend on one > parameter lets > say: > sol={{i1->220/x}, {i2 -> 100+x}} and I need to define > function based > on this solution with the x as argument lets say: > myfun[x_]:=50*220/x > + 2 (100+x); I'm trying to do it like this: myfun[x_]:=50 * i1 + 2 * i2 /. sol But it prints the error message: SetDelayed::write ... [x_] is > protected. Does anybody know what's the problem and how to define such > function? > Jakub > -- Bob Hanlon === Subject: Re: UNDO and Mathematica - how useless is it? So, Bob, are you saying there's a problem with Undo then ? Peter 2009/3/25 Bob F : > Hello Everyone, Does anyone else think the UNDO menu function is about as useful as > ice in Antarctica?? I had just copied/pasted a long expression from a > web site to a notebook I was working on, but the expression had some > exponents/superscripts that did not come through with the paste so > what ended up being in the notebook was something like this: ((((((((((((((((((((((((((((x2*x)2*x)2)2*x)2*x)2*x)2)2)2*x)2*x)2)2*x)2) > 2*x)2*x)2)2)2*x)2)2*x)2)2)2)2)2)2)2)2)2 so to Mathematica it looked like all the 2's were just multipliers > instead of exponents. No problem, says I, just highlight this string > and use the Edit/Find&Replace dialog box to change 2 to ^2, but only > one at a time was changed with each click of the replace. OK, says I, > use the Replace All and surely that will only apply to the > highlighted section. WRONG!!!!!! It changed the entire notebook to > have ^2 instead of every 2 in the entire notebook. OK, says I, just > click the Edit/Undo and get back to where I was. WRONG -- notebook is > totally hosed and I loose a few hours worth of work. Yeah, Yeah, Yeah > I should have done a Save before doing the Replace All -- now I know > for next time. So, hey Wolfram -- please fix the UNDO. Make it work like every other > program on the face of the planet, even the entire Solar System, even > the known and unknown universe!!!!!!!!!! Even one level of UNDO would > have saved me hours of working, let alone a multiple level UNDO like > you see in so many other programs. I would be much happier Mathematica user, if Wolfram would spend time > in solving problems like this, than coming out with new versions with > hundred of functions. Please make the next release fix some of the > major outstanding issues with the current version (and for many years > as far as I can tell)!!! If you want to add new functionality that's > great, but give users a modern user interface feature like > UNDO!!!!!!!!!!! And as long as you're about it, give the Find dialog box a way to do a > find/replace on a cell or multiple cells or any highlighted section of > a notebook. As it stands right now, you have to click the Replace > button for each and every occurrence of the string you wish to change. > Maybe a Replace in this cell or Replace in the highlighted section > button. How can something so simple (the UNDO) be so uselessly implemented. > What is it even good for in the state that it is in?? -Bob (grrrrrrrrrrrrrrrrrrrrrrr) ;-( -- Peter Lindsay === Subject: Re: UNDO and Mathematica - how useless is it? Totally agree! Another feature that i expected in 7 but it didn't show up was window tabs, it would be great to have multiple notepads opened without having to minimize/maximize windows all the time... Hope to see both in 8! Is there a way to discuss with developers about fatures/bugs? Filippo > Hello Everyone, Does anyone else think the UNDO menu function is about as useful as > ice in Antarctica?? I had just copied/pasted a long expression from a > web site to a notebook I was working on, but the expression had some > exponents/superscripts that did not come through with the paste so > what ended up being in the notebook was something like this: ((((((((((((((((((((((((((((x2 > *x)2*x)2)2*x)2*x)2*x)2)2)2*x)2*x)2)2*x)2) > 2*x)2*x)2)2)2*x)2)2*x)2)2)2)2)2)2)2)2)2 so to Mathematica it looked like all the 2's were just multipliers > instead of exponents. No problem, says I, just highlight this string > and use the Edit/Find&Replace dialog box to change 2 to ^2, but only > one at a time was changed with each click of the replace. OK, says I, > use the Replace All and surely that will only apply to the > highlighted section. WRONG!!!!!! It changed the entire notebook to > have ^2 instead of every 2 in the entire notebook. OK, says I, just > click the Edit/Undo and get back to where I was. WRONG -- notebook is > totally hosed and I loose a few hours worth of work. Yeah, Yeah, Yeah > I should have done a Save before doing the Replace All -- now I know > for next time. So, hey Wolfram -- please fix the UNDO. Make it work like every other > program on the face of the planet, even the entire Solar System, even > the known and unknown universe!!!!!!!!!! Even one level of UNDO would > have saved me hours of working, let alone a multiple level UNDO like > you see in so many other programs. I would be much happier Mathematica user, if Wolfram would spend time > in solving problems like this, than coming out with new versions with > hundred of functions. Please make the next release fix some of the > major outstanding issues with the current version (and for many years > as far as I can tell)!!! If you want to add new functionality that's > great, but give users a modern user interface feature like > UNDO!!!!!!!!!!! And as long as you're about it, give the Find dialog box a way to do a > find/replace on a cell or multiple cells or any highlighted section of > a notebook. As it stands right now, you have to click the Replace > button for each and every occurrence of the string you wish to change. > Maybe a Replace in this cell or Replace in the highlighted section > button. How can something so simple (the UNDO) be so uselessly implemented. > What is it even good for in the state that it is in?? -Bob (grrrrrrrrrrrrrrrrrrrrrrr) ;-( > === Subject: UNDO and Mathematica - how useless is it? Hello Everyone, Does anyone else think the UNDO menu function is about as useful as ice in Antarctica?? I had just copied/pasted a long expression from a web site to a notebook I was working on, but the expression had some exponents/superscripts that did not come through with the paste so what ended up being in the notebook was something like this: ((((((((((((((((((((((((((((x2*x)2*x)2)2*x)2*x)2*x)2)2)2*x)2*x)2)2*x)2) 2*x)2*x)2)2)2*x)2)2*x)2)2)2)2)2)2)2)2)2 so to Mathematica it looked like all the 2's were just multipliers instead of exponents. No problem, says I, just highlight this string and use the Edit/Find&Replace dialog box to change 2 to ^2, but only one at a time was changed with each click of the replace. OK, says I, use the Replace All and surely that will only apply to the highlighted section. WRONG!!!!!! It changed the entire notebook to have ^2 instead of every 2 in the entire notebook. OK, says I, just click the Edit/Undo and get back to where I was. WRONG -- notebook is totally hosed and I loose a few hours worth of work. Yeah, Yeah, Yeah I should have done a Save before doing the Replace All -- now I know for next time. So, hey Wolfram -- please fix the UNDO. Make it work like every other program on the face of the planet, even the entire Solar System, even the known and unknown universe!!!!!!!!!! Even one level of UNDO would have saved me hours of working, let alone a multiple level UNDO like you see in so many other programs. I would be much happier Mathematica user, if Wolfram would spend time in solving problems like this, than coming out with new versions with hundred of functions. Please make the next release fix some of the major outstanding issues with the current version (and for many years as far as I can tell)!!! If you want to add new functionality that's great, but give users a modern user interface feature like UNDO!!!!!!!!!!! And as long as you're about it, give the Find dialog box a way to do a find/replace on a cell or multiple cells or any highlighted section of a notebook. As it stands right now, you have to click the Replace button for each and every occurrence of the string you wish to change. Maybe a Replace in this cell or Replace in the highlighted section button. How can something so simple (the UNDO) be so uselessly implemented. What is it even good for in the state that it is in?? -Bob (grrrrrrrrrrrrrrrrrrrrrrr) ;-( === Subject: Re: UNDO and Mathematica - how useless is it? > Hello Everyone, Does anyone else think the UNDO menu function is about as useful as > ice in Antarctica?? I agree - WRI seem to have a blind spot about UNDO - nowadays, people just expect a multi-level UNDO as part of working on a computer. Notebooks are not quite like other documents, because they change programatically as well as by user editing, but I would not have thought it would be too hard to provide a multi-level UNDO that would at least operate between evaluations. Alternatively, UNDO could be restricted to cells of particular styles - ignoring output cells. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: UNDO and Mathematica - how useless is it? Been there, done that. I feel your pain. > Hello Everyone, Does anyone else think the UNDO menu function is about as useful as > ice in Antarctica?? I had just copied/pasted a long expression from a > web site to a notebook I was working on, but the expression had some > exponents/superscripts that did not come through with the paste so > what ended up being in the notebook was something like this: ((((((((((((((((((((((((((((x2*x)2*x)2)2*x)2*x)2*x)2)2)2*x)2*x)2)2*x)2) > 2*x)2*x)2)2)2*x)2)2*x)2)2)2)2)2)2)2)2)2 so to Mathematica it looked like all the 2's were just multipliers > instead of exponents. No problem, says I, just highlight this string > and use the Edit/Find&Replace dialog box to change 2 to ^2, but only > one at a time was changed with each click of the replace. OK, says I, > use the Replace All and surely that will only apply to the > highlighted section. WRONG!!!!!! It changed the entire notebook to > have ^2 instead of every 2 in the entire notebook. OK, says I, just > click the Edit/Undo and get back to where I was. WRONG -- notebook is > totally hosed and I loose a few hours worth of work. Yeah, Yeah, Yeah > I should have done a Save before doing the Replace All -- now I know > for next time. So, hey Wolfram -- please fix the UNDO. Make it work like every other > program on the face of the planet, even the entire Solar System, even > the known and unknown universe!!!!!!!!!! Even one level of UNDO would > have saved me hours of working, let alone a multiple level UNDO like > you see in so many other programs. I would be much happier Mathematica user, if Wolfram would spend time > in solving problems like this, than coming out with new versions with > hundred of functions. Please make the next release fix some of the > major outstanding issues with the current version (and for many years > as far as I can tell)!!! If you want to add new functionality that's > great, but give users a modern user interface feature like > UNDO!!!!!!!!!!! And as long as you're about it, give the Find dialog box a way to do a > find/replace on a cell or multiple cells or any highlighted section of > a notebook. As it stands right now, you have to click the Replace > button for each and every occurrence of the string you wish to change. > Maybe a Replace in this cell or Replace in the highlighted section > button. How can something so simple (the UNDO) be so uselessly implemented. > What is it even good for in the state that it is in?? -Bob (grrrrrrrrrrrrrrrrrrrrrrr) ;-( === Subject: Re: UNDO and Mathematica - how useless is it? So, hey Wolfram -- please fix the UNDO. Make it work like every other > program on the face of the planet, even the entire Solar System, even > the known and unknown universe!!!!!!!!!! Even one level of UNDO would > have saved me hours of working, let alone a multiple level UNDO like > you see in so many other programs. > I suspect this is a near impossible task logically -- and the inability to have a real UNDO is another (but only one) of the many reasons why Conrad Wolfram's concept of Mathematica: The All-In-One System The Wolfram Video Gallery ==> is IMHO a *fundamentally* bad idea. In many (most?) conventional software applications, you have a *program*, which operates (using operations implemented under user control) on a separate *document* of some sort. If you do a sequence of those operations, and then decide you want to reverse some or all them (because you made a mistake, or just changed your mind), in almost any conventional app you can back up at least one step using UNDO; and in many applications you can back up a near-unlimited number of steps, all the way to when you opened the document -- and then step back forward on the same chain if you want to. In Mathematica, however, the notebook is typically both the program *and* your document. Some steps you take, or operations you invoke, edit the program part of the notebook; some may edit data parts of the notebook (or even results parts); some may *execute* one or more program parts of the document -- which may well operate on, and modify, in multiple stages, any and all of the program, data, and results parts of the notebook. At this point, is there a single obvious choice as to what is meant by UNDO? You might want, but could you get, a complete massive UN-EXECUTE of the massive (but now unwanted) execution you just invoked? And suppose you suddenly realize this only after several you've invoked several more operations, edits, commands, whatever? I don't have anywhere near enough depth in logical analysis or computer programming to know whether or not a complete multistep or even single-step UN-EXECUTE is always possible in a system like Mathematica, other than with some kind of brute force saving of the complete state of the system. Even if this is possible, having enough memory to do this for multiple steps back seems impossible -- not to mention taking into account various *outside* events (like computer clock time) that might influencing the evaluation, un-evaluation, and re-evaluation. So, I continue to suspect that having any kind of user-comprehensible, multi-stage UNDO in Mathematica is a near impossible task, if not logically then realistically -- and this rather minor but non-trivial problem joins many other important more concerns (like unacceptable complexity of the user interface and syntax, and of the user documentation, not to mention suppression of software innovation) as reasons why the all-in-one model of Mathematica, while it may have a role in providing a massive all-in-one programming system for highly trained professional programmers, who are hired to write applications for others, is pretty likely to destroy Mathematica as a usable system for ordinary non-computer-expert users, who just want to use it to solve much smaller problems in their own field. === Subject: HoldAll for Integrate The following commands yield unexpected output: x=10; Integrate[x^2, {x,0,1}] That is because Integrate does not have attributes HoldAll, so that the second command will be interpreted as Integrate[100, {10,0,1}] which is not a command that Integrate can work with (so a warning message is returned). However, I can add the attribute HoldAll to Integrate myself: SetAttributes[Integrate, HoldAll]; I'm not very sure what to expect when now trying the same experiment (the correct answer 1/3 would be nice), but the actual output surprised me: x=10; Integrate[x^2, {x,0,1}] Yields as output: 0 (without any warnings). Could anyone explain why I should have expected this result? On a side note, I found a similar in the Tech Support column of the Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the integral without limits: x=10; SetAttributes[Integrate, HoldAll]; Integrate[x^2, x] In the journal, the output 1000/3 is mentioned, whereas in Mathematica 7.0.1 this outputs 1000. Again, does anyone understand this? === Subject: Numerical Optimization with Parameters CI needed I need to obtain the CI's for parameters of the model from comparing it with the data. The problem is in the discret character of the model - for each point of the data there exists a separate function of the model. Therefore I cannot use the NonlinearRegress routine for it. I've allready estimated the exact values of the parameters with NMinimizing the Squared Residuals, but I need a CI's for them also. Whether there exists an option (in NMinimize routine or in similar) to calculate the CI's? === Subject: coefficients but not from polynomial (variables does not work) Probably my question is very simple. Suppose that we have expression a= Sin[x]+Sin[y]. I would like receive variables from which this expression is dependent, so in this case {x,y}. The Variables does not work of course in this because it is not a polynomial and it gives me {Sin[x],Sin[y]}. Do anyone know how to solve my problem. I would be very grateful for quick response. Magdalena === Subject: Re: Question about how to graph the vector field for the differential the direction field is plotted by: dir[x_, y_] := Normalize[{1, 2 x - y}] VectorPlot[dir[x, y], {x, -3, 3}, {y, -3, 3}] The velocity field: vel[x_, y_] := {1, 2 x - y} VectorPlot[vel[x, y], {x, -3, 3}, {y, -3, 3}] The stream field: vel[x_, y_] := {1, 2 x - y} StreamPlot[vel[x, y], {x, -3, 3}, {y, -3, 3}] hope this helps, Daniel > i need to graph the vector field and the family of solutions for the > DE: dy/dx=2x-y > and i tried the graph the vector field, but while i tried to use the > VectorFieldPlot it show up some kind of wierd graph... > and i cannot even get start on the family of Solutions > graph...searched online but still cannot figure out. > hope some pros can help me out on this...thx alot~!! > Bluefly > === Subject: Re: Question about how to graph the vector field for the differential the direction field is plotted by: dir[x_, y_] := Normalize[{1, 2 x - y}] VectorPlot[dir[x, y], {x, -3, 3}, {y, -3, 3}] The velocity field: vel[x_, y_] := {1, 2 x - y} VectorPlot[vel[x, y], {x, -3, 3}, {y, -3, 3}] The stream field: vel[x_, y_] := {1, 2 x - y} StreamPlot[vel[x, y], {x, -3, 3}, {y, -3, 3}] hope this helps, Daniel > i need to graph the vector field and the family of solutions for the > DE: dy/dx=2x-y > and i tried the graph the vector field, but while i tried to use the > VectorFieldPlot it show up some kind of wierd graph... > and i cannot even get start on the family of Solutions > graph...searched online but still cannot figure out. > hope some pros can help me out on this...thx alot~!! > Bluefly > === Subject: Re: Question about how to graph the vector field for the differential I have the feeling you're looking for the wrong type of plot. Your differential equation yields a family of funtions of x and these can be plotted simply by using Plot. First, solve the differntial equation: In[20]:= DSolve[y'[x] == 2 x - y[x], y[x], x] Out[20]= {{y[x] -> 2 (-1 + x) + E^-x C[1]}} Then plot it for some values of the constant C[1]: Plot[Table[2 (-1 + x) + E^-x c, {c, -10, 10, 5}] // Evaluate, {x, -1, 5}, PlotRange -> All] > i need to graph the vector field and the family of solutions for the > DE: dy/dx=2x-y > and i tried the graph the vector field, but while i tried to use the > VectorFieldPlot it show up some kind of wierd graph... > and i cannot even get start on the family of Solutions > graph...searched online but still cannot figure out. > hope some pros can help me out on this...thx alot~!! > Bluefly === Subject: Re: Question about how to graph the vector field for the differential Ïî $B7n(B24$BF|(B, $B>e8a(B3$B;~(B30$BJ,(B, Sjoerd C. de Vries ÷òïôåº I have the feeling you're looking for the wrong type of plot. Your differential equation yields a family of funtions of x and these can be plotted simply by using Plot. > First, solve the differntial equation: > In[20]:= DSolve[y'[x] == 2 x - y[x], y[x], x] > Out[20]= {{y[x] -> 2 (-1 + x) + E^-x C[1]}} > Then plot it for some values of the constant C[1]: > Plot[Table[2 (-1 + x) + E^-x c, {c, -10, 10, 5}] // Evaluate, {x, -1, 5}, PlotRange -> All] > i need to graph the vector field and the family of solutions for the > DE: dy/dx=2x-y > and i tried the graph the vector field, but while i tried to use the > VectorFieldPlot it show up some kind of wierd graph... > and i cannot even get start on the family of Solutions > graph...searched online but still cannot figure out. > hope some pros can help me out on this...thx alot~!! > Bluefly ôèfor the answers... ôèáô òåáììù èåì[Eth]åä íå ïî ôèpart where i need the family of óïìõôéïî ó¢®®[RegisteredTrade mark]® âõi dont understand is that why isnt the vector field or direction æéåìwork on this? =( remember i saw someone used it and graph bunch of arrows along with ôèsolution's direction... ÷èáô mean is that on the graph there are many arrows (vectors) that ëéîäfilled up the graph....and the directions of the vectors are the óáíå áó ôèsolution graph. âô÷¬ èïto graph the orthogonal trajectories along the same function? ôèáîyou all for the help Âìõåæì === Subject: Re: Question about how to graph the vector field for the differential > i need to graph the vector field and the family of solutions for the > DE: dy/dx=2x-y > and i tried the graph the vector field, but while i tried to use the > VectorFieldPlot it show up some kind of wierd graph... > and i cannot even get start on the family of Solutions > graph...searched online but still cannot figure out. > hope some pros can help me out on this...thx alot~!! It's not clear what you're trying to accomplish. Your differential equation involves one function, y(x), and one independent variable, x. This isn't a vector at all. Written into Mathematica-speak: In[1]:= sol = DSolve[y'[x] == 2 x - y[x], y[x], x] Out[1]= {{y[x] -> 2 (-1 + x) + E^-x C[1]}} If you want to plot this, pull out the solution and play with it (%1 /. sol[[1]]). If you want to graph it, just use Plot, but you'll have to specify a value of the constant of integration C[1]. -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis The only completely consistent people are the dead. -- Aldous Huxley === Subject: Re: Selecting left hand sides from assignments Hi again, The following works as I wanted: it takes apart *lhs* and *rhs* of *Set* expressions while keeping the relation between the *lhs* to the *rhs* for further use. But, to get it to work one has to start working with a fresh kernel as to ensure the *lhs*(s) have not been assigned any value before the sequence of assignments *assign* is sent to the function *SplitSetSides*. However, since I am to use it as a meta-programming tool (not to be include in end user programs) this is not a big drawback, tough a bit artificial. The first sublist in *Out[4]* contains the *lhs*(s) while the second contains the *rhs*(s). In[1]:= Clear@frhs frhs[rhs_][symbols_] := Module[{step}, step = Fold[Flatten[#1, Infinity, #2] &, rhs, symbols]; step = Union@Flatten@FixedPoint[Apply[List, #, Infinity] &, step]; step = List @@ step; ] In[2]:= Clear@SplitSetSides SplitSetSides[holdassignments_] := Quiet@Module[{symbols = Symbol[#] & /@ Names[System`*]}, {SymbolName[#] & /@ (List @@ Map[First, Map[Unevaluated, holdassignments]]), frhs[#][symbols] & /@ Apply[List, Map[Hold, holdassignments, {1}]]}] In[3]:= assign = Hold[a1 = Log[b1*c1^12], a2 = Sqrt[b2*c2], a3 = Log[b1*c1^12]*Sqrt[a2*c2]^b3*c3 ]; In[4]:= SplitSetSides[assign] Out[4]= {{a1, a2, a3}, {{a1, b1, c1}, {a2, b2, c2}, {a3, c3, b1, c1, a2, c2, b3}}} For now, this solution seems to be good enough for my needs. For instance, it will help me in building the data dependency graph for a large notebook meant to make dense computations involving many dynamic interrelated objects. The simplification of the data dependency graph helps in to improving efficiency by eliminating superfluous or redundant computation paths which would slow down significantly the performance. Also would help in pointing out circularities. And, although it needs some additional testing it seems to be working ok under my conditions. One thing which is still left (among many others) is to take out the names in *symbols* which do not correspond to true symbols (operators) in the list generated by the expression *symbols = Symbol[#] & /@ Names[System`*]*} in the module of the function *SplitSetSides*. Any feed back will be appreciated. I hope it will be of any use to someone else. E. Martin-Serrano ------------------------------------------------------------ >I need help on the following. >assignmentslist = {LHS1 = RHS1, LHS2 = RHS2, LHS3 = RHS3, ..., LHSi = RHSi, ..., LHSn = RSHn} >I need to extract all the left hand sides (symbols) within a list like: >lhslist = {LHS, LHS2, LHS3, ..., LHSi, ..., LHSn} >Where the left hand sides are all symbols and the right hand sides are any expression. >E. Martin-Serrano ------------------------------------------- === Subject: Re: Installation question yes, i think so - just save the files in a different folder. 2009/3/25 daniele : > whether it's possible to keep the previous version (v6) that I have > already installed on my machine. I have an Intel Mac. Daniele -- Peter Lindsay === Subject: Re: Installation question >wondering whether it's possible to keep the previous version (v6) >that I have already installed on my machine. I have an Intel Mac. There is no problem having both versions installed. This is exactly how I have my MacBook Pro set up. === Subject: Adding text to RegionPlot I would like to add text at specific (x,y) locations for a 2D graphic generated by RegionPlot (meaning, I'd rather not use the graphic tool and add text by hand). Is there a way to do this? I get mathematica complaints that RegionPlot is not a type of graphics. For example, this code fails: RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}},Graphics[Text[mytext, {1.5, 1}]] Apparently I'm using Graphics[Text[]] incorrectly. How can I get such a simple function of putting text at a specific location to work in RegionPlot? Jim === Subject: MaxIterations for FindRoot called by NDSolve When running NDSolve, I get this error message: FindRoot::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations. I wish to change MaxIterations, and I am calling this line before NDSolve, SetOptions[FindRoot, MaxIterations -> [Infinity]]; But, the options is not applying to FindRoot when it is called by NDSolve, I get the same error message. How can I change MaxIterations for FindRoot when called my NDSolve? David === Subject: Re: how to build pattern for a square matrix of reals? You called l a lower diagonal vector and u an upper diagonal vector -- neither of which makes any sense. Only matrices, not vectors, can be upper or lower diagonal. I also noticed that you want 0 (an integer) to be treated as if it were Real. So here's a rendition of your TridiagonalSolve: tridiagonal[___] := False tridiagonal[lower : {0 | 0., __Real}, d : {__Real}, upper : {__Real, 1 | 1.}, b : {__Real}] /; Equal @@ Length /@ {lower, d, upper, b} := True Notice I'd never, EVER use l as a variable name, as it's indistinguishable from 1 for many of us. I used the lower and upper names because you're thinking of them that way, even though vectors can't physically BE lower or upper. And here's a replacement for the second line of code, where I would NOT redefine the built-in Solve: realQ[0] = True; realQ[x_] := MatchQ[x, _Real] realQ[_] = False; commensurable[a_ /; MatrixQ[a, realQ], b : {__Real}] /; Union@Dimensions@a == {Length@b} := True commensurable[__] = False; Bobby > fully get what I wanted. I guess it would be better if I explained initially what is all about: > I have some simple Fortran routines for solving tri-diagonal, and then > regular, system of linear equations, that I'm wrapping, through > Mathlink, for use from Mathematica. I want Mathematica to do arguments > checking for me, and this could be achieved through specifying > corresponding patterns for functions signature in the MathLink > template file. So, my functions are: > TridiagonalSolve[l, d, u, b] - for tridiagonal solver > Solve[A, b] - for regular solver > If the dimension of system is n in both cases, then here: > l - lower diagonal vector, of size n, with first element set to 0 > d - diagonal vector, of size n > u - upper diagonal vector, of size n, with last element set to 0 > b - right-side vector, of size n > A - matrix of the system, of size nxn So, I want to check that dimensions of all vectors match, for > tridiagonal solver function, and also that vector l has 0 as first, > and vector u has 0 as last element. Also, for regular solver > function, I want to check that dimensions of system matrix, and the > length of the right-side vector match. Of course, I also want to > check that A is matrix of reals, and that l, d,u and b are vectors of > reals. So here are final patterns I came up with (these seem to work > fine, but I'd appreciate any further suggestions on improvement): TridiagonalSolve[l_/;(VectorQ[l,MatchQ[#,_Real]&]&&l[[1]] > ==0),d_/;VectorQ[d,MatchQ[#,_Real]&],u_/;(VectorQ[u,MatchQ[#,_Real]&] > &&u[[-1]]==0),b_/;VectorQ[b,MatchQ[#,_Real]&]]/;Length[l]==Length[d] > ==Length[u]==Length[b]:=OK Solve[A_/;(MatrixQ[A,MatchQ[#,_Real]&]&&Equal@@Dimensions > [A]),b_/;VectorQ[b,MatchQ[#,_Real]&]]/;Dimensions[A][[2]]==Length > [b]:=OK -- DrMajorBob@bigfoot.com === Subject: Re: dynamic popupmenu help needed Its just weird hierarchical menus is not supported , yet. === Subject: Re: Help with ScriptSource in GUIKit On Apr 11, 12:52 am, Paul Ellsmore Update, BindEvent[action, > Script[{Print[Clicked]}]]}], IncludedScriptContexts -> {$Context}]; I want the button to execute a large block of code, and the GUIKit > documentation suggests I use the ScriptSource function: In[1827]:= Needs[GUIKit`]; ref = GUIRun[Widget[Button, {text -> Update, BindEvent[action, > Script[{}, ScriptSource -> targetNB.m]]}], IncludedScriptContexts -> {$Context}]; In this test case, targetNB.m just has the code Print[Clicked] in it. > Nothing happens when I click the button, no error message, no clicked g= ets > printed. I have put the GUI notebook and the targetNB.m file in the same > folder, and set Directory to that folder. The documentation for ScriptSou= rce > is appalling (no surprise there), but I assume that the contents of > targetNB.m will effectively be pasted into the Script function. Is this t= oo > naive? Note that if I specify a non-existent m file for ScriptSource, I get no > error message. Am I doing something clearly dumb? Is there a better way t= o > make some GUI action run a separate notebook or m file? BTW, I realise that GUIKit is (pretty much) obsolete, and I will be (am, = in > parallel) developing a V7 GUI from built-in code, but we have a lot of > legacy V5 notebooks, and GUIKit is actually a pretty easy way to interfac= e > with them (apart from little issues like this one!). > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 > Usually, the Script[{}, ScriptSource -> targetNB.m] is called once inside a GUI construct to load a large set of external definitions; it works kinda like Get[] but automatically loads into the script context which isn't known until after the GUI is run/loaded. Using this concept, the BindEvent action should just call to a function defined in this external file. GUIRun[Widget[Button, { Text -> Update, BindEvent[Action, Script[update[]]], Script[{}, ScriptSource -> targetNB.m] }]] Although, after writing numerous large GUIKit apps, I prefer the following: update[] := Print[Clicked]; GUIRun[Widget[Button, {Text -> Update, BindEvent[Action, Script [update[]]]}], IncludedScriptContexts->{Global`}] This way, as your program is running, you can make changes to your functions and the modifications are available immediately because they are not buried in some private context. Additionally, you could define your own package, or context, if you don't want full access to the Global` space. === Subject: Re: Help with Recursive Minimization The first function is better defined with Set, not SetDelayed: V1[y_] = First@Minimize[{x/2, x >= 2, x >= y}, {x}] [Piecewise] { {1, y <= 2}, {(y/2), !(* TagBox[True, PiecewiseDefault, AutoDelete->False, DeletionWarning->True])} } Your plot is deceptive, since it leaves out the regions that cause your third statement to fail. Try this instead: Plot[V1[y] + 3/y, {y, -5, 5}] No unconstrained minimum exists, as the plot plainly shows, so this must fail: Minimize[V1[y] + 3/y, y] Minimize::natt: The minimum is not attained at any point satisfying the given constraints. >> {-[Infinity], {y -> 0}} and so does this: NMinimize[V1[y] + 3/y, y] NMinimize::cvdiv: Failed to converge to a solution. The function may be unbounded. >> {-2.45422*10^15, {y -> -1.22238*10^-15}} WITH constraints, however: Minimize[{V1[y] + 3/y, y > 0}, y] {Sqrt[6], {y -> Sqrt[6]}} Bobby I tried to minimize a function which itself is a minimum value > function. I can plot the function, but cannot get a numerical solution: V1[y_] := Minimize[{0.5 x, x >= 2, x >= y}, {x}][[1]]; > Plot[ V1[y] + 3/y, {y, 1, 5}] > Minimize[ V1[y] + 3/y, {y, 1, 5}] Appreciate your help > Owen > -- DrMajorBob@bigfoot.com === Subject: Re: Help with Recursive Minimization I tried to minimize a function which itself is a minimum value function. = I can plot the function, but cannot get a numerical solution: V1[y_] := Minimize[{0.5 x, x >= 2, x >= y}, {x}][[1]]; > Plot[ V1[y] + 3/y, {y, 1, 5}] > Minimize[ V1[y] + 3/y, {y, 1, 5}] Appreciate your help > Owen Minimize[{0.5 x, x >= 2, x >= y}, {x}][[1]] is the same as: Max[2, y] / 2 => First@Minimize[{Max[2, y]/2 + 3/y, 1 <= y <= 5}, y] => Sqrt[6] === Subject: Re: what went wrong in this ordinary differential eq g[x_]:=x y'[x] s=NDSolve[{g'[x]+Sin[y[x]]*y[x]==0,y[0]==1,y'[0]==0},y[x],{x,0,30}] Power::infy: Infinite expression 1/0. encountered. >> NDSolve::ndnum: Encountered non-numerical value for a derivative at x == 0.`. >> NDSolve[{Sin[y[x]] y[x]+(y^[Prime])[x]+x (y^[Prime][Prime])[x]==0,y[0]==1,(y^[Prime])[0]==0},y[x],{x,0,30}] Mathematica needs to solve for y''[0] and can't, because its coefficient (x) is 0. THIS problem works fine, on the other hand: Clear[s] g[x_]:=(x+1) y'[x] s[x_]=y[x]/.NDSolve[{g'[x]+Sin[y[x]]*y[x]==0,y[0]==1,y'[0]==0},y[x],{x,0,30} ] {InterpolatingFunction[{{0.,30.}},<>][x]} Plot[s@x, {x, 0, 30}, PlotStyle -> Automatic] Bobby > s = NDSolve[{(x*y'[x])'[x] + Sin[y[x]]*y[x] == 0, y[0] == 1, > y'[0] == 0}, y[x], {x, 0, 30}]; > Plot[Evaluate[{y[x]} /. s], {x, 0, 30}, PlotStyle -> Automatic] > -- DrMajorBob@bigfoot.com === Subject: Re: Change in NSolve algorithm What surprised me about Wilkinson's polynomial example, which should return Range[20], is the following. Mathematica Help says that: NSolve[eqns,vars,n] gives results to n- digit precision. Consequently, omitting n should imply machine precision. Nevertheless: sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x] {1.,2.00000000000096,2.99999999986639,4.0000000049587,4.99999990255529,6.00= 000083841557+1.13297570609149*10^-9 I,7.00008136819274-0.0000108589979212047 I, 8.00087475000192+0.000151959812492809 I, 9.0002388679906+0.000147736991612302 I, 10.000992367067-0.000579336748622785 I, 11.0030045370741-0.00438286449628658 I, 12.0383486261734-0.102068022121597 I, 13.1275500318654+0.0361732078353353 I, 13.9803341855889+0.0168546889387958 I, 14.9015299203113-0.0418410427904214 I, 15.8215727528799+0.0440619301323384 I, 16.9944217046715-0.00669060159139528 I, 18.0000979553809-0.000170510501593321 I, 18.999972121053+0.00014011316501936 I, 19.9999979459428+1.38662076005353*10^-6 I} while sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, $MachinePrecision] {1.000000000000000,2.000000000000000,3.000000000000000,4.000000000000000,5.= 000000000000000,6.000000000000000,7.000000000000000,8.000000000000000,9.000= 000000000000,10.00000000000000,11.00000000000000,12.00000000000000,13.00000= 000000000,14.00000000000000,15.00000000000000,16.00000000000000,17.00000000= 000000,18.00000000000000,19.00000000000000,20.00000000000000} Even with 2 digits precision the result is correct! sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, 2] {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.,11.,12.,13.,14.,15.,16.,17.,18.,19= .,20.} So, I would say that your example indicates a misbehavior or a bug in NSolve. Any comments? Alberto > Has anyone noticed that the algorithm used by NSolve has > changed in V7? > ... > On the other hand, V7 fares slightly worse with Wilkinson's > polynomial: > sols = x/.NSolve[Expand[Product[x-i, {i,1,20}] == 0,x]]; > Norm[Table[sols[[i]] - i, {i, 1, 20}]] > ... > Mark McClure === Subject: Re: Change in NSolve algorithm > Has anyone noticed that the algorithm used by NSolve has > changed in V7? I think the change is mostly for the better, > but not exclusively. To see the change, enter the following > in both V7 (7.0.0 or 7.0.1) and any version < 7.0: > Abs[sols = z /. NSolve[z^200 == 1, z]] In V7, Mathematica correctly generates a list of 1.0s. In > versions prior to V7, numerical error creeps in so you get > numbers ranging from 0.004 to 2.55. V7 is noticeably faster, > too. To visualize the error in V6, you can enter > ListPlot[{Re[#], Im[#]} & /@ sols, > AspectRatio -> Automatic] Of course, you should get a circle. On the other hand, V7 fares slightly worse with Wilkinson's > polynomial: > sols = x/.NSolve[Expand[Product[x-i, {i,1,20}] == 0,x]]; > Norm[Table[sols[[i]] - i, {i, 1, 20}]] I get 0.087351 from V6 and 0.26578 in V7. Also, V6 returns > all real solutions, while V7 returns some complex. Of course, the change is platform independent. I haven't > played with it extensively, but I think this is probably a > net big improvement. > For the people reading this post and wondering about whether Mathematica can find more accurate solutions to those equations: using the WorkingPrecision option with a non-machine-precision setting will usually improve the results (but the computation will take longer). === Subject: Re: nostalgia for old behaviour: graphics re-sizing > In all versions of Mathematica, you can re-size graphical output with a >> click and a drag. However, prior to v6 (or maybe even v7), once you re- >> sized an output, that new size remained coupled to its input. So that if >> you were to re-evaluate the input, possibly even tweaking it in some >> way, the new output would have the new size. This doesn't seem to work >> anymore. Now, all new outputs are given the default size. Is there >> anyway to get Mathematica to revert to the old behaviour? >> j > On my Mac with Mathematica version 7.0.1 the sizes get reset every > time the cell is re-executed, so guess this is yet another difference > in behavior of Mathematica between Mac's and Windows. Personally, I > think the behavior on Window's is correct, as if I go to the trouble > of clicking/dragging to make an output cell's graphics bigger, I think > that effort should not be lost by re-executing the input cell again, > with or without changes to some of the cell's parameters. So, Wolfram > what is the correct behavior?? What kind of system are you doing this on Joshua? I will bet it's not > a Window's system. How does this work on Linux? On Solaris, and > others?? -Bob Joshua and I exchanged several emails off group. We found all of the cases where he was experiencing this problem fell into one of two categories... * Visualization commands which include explicit ImageSize options. Mathematica considers explicit ImageSize option settings from the evaluation to trump those set by the user after the fact. This behavior is by design, and I think it's quite defensible. * A bug which Joshua helped to uncover where a graphic with a PlotLegend inappropriately includes an explicit ImageSize setting even when the plotting command itself doesn't contain one. As long as there are no explicit ImageSize settings (or, until the bug is fixed, a PlotLegend), graphics should be remembering their sizes on all platforms. If you find any counter examples, please let me know and I'll investigate. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Wolfram support website documents deleted > There used to be a site that listed those functions that are > compilable so that one did not have to weed them out of the > Compile[] expression by trial and error. Those functions are still listed on the Compile page of Ted Ersek's Mathematica Tricks page. That page also includes the best discussion of Compile that I've seen anywhere. His main page is here: http://www.verbeia.com/mathematica/tips/Tricks.html You can scroll down and click on Compile. Mark McClure === Subject: problem with mathematica :( Hi Mathematica community, I have this system of equations: Reduce[{i >= iP, v + a*t/(1 - d) == vP + a*tP/(1 - d), t/d^(x/a) == tP/d^(xP/a), a*i + 1*x == a*iP + 1*xP, t/d^(i/-1) == tP/d^(iP/-1), z - c*x*(x - a)/(2*a) == zP - c*xP*(xP - a)/(2*a),iP==0}, {iP,tP,vP,xP,zP},Backsubstitution->True] But mathematica still in running until I abort.Could you tell me what is the problem? === Subject: Re: Mathematica behavior using highlighting and keyboard arrows - BUG??? It seems debatable as to which would be the better behavior. The best way to select material from an Input or Output cell for copying is to place the cursor at a position in the desired material and then use successive Ctrl-. to select successively larger sub-expressions. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have been puzzled by the way that Mathematica handles highlighting when using the keyboard arrow keys. For example if the cursor is in an Input cell in the middle of any expression and you press and hold the Shift key and then press the right-arrow key to highlight each character for each press of the right-arrow key, and then if you accidently go one or more characters too far (the repeat rate of the key faster than my reaction time), and then I try and back up to the intended correct position by letting go of the right-arrow key and press the left-arrow key while still pressing the Shift, the highlighting is extended to the left of the original starting position, not the current position of the cursor, so instead of correcting the overshoot you end up with even more unwanted highlighted portion of an expression or text. And the most bizarre thing about this is that the behavior is different depending on whether it's a Text or an Input style cell, in that Input style cells do it this way and Text style cells do it as I would expect. The net result is that you have to start all over to correctly highlight the portion of the cell expression you wanted to highlight for subsequent Copy/Paste operation somewhere else for these Input cells. Is this a bug or a feature? Does this work the same on Windows and Linux and all the other versions of Mathematica? I am on a Mac OS X system. When you use the mouse to drag the current position cursor this behavior does not occur either, in that there is an original start position and as you drag the mouse to the left or right of this start position, the intervening text is highlighted as you would expect. So why the difference? The Up/Down arrow keys DO NOT have this same behavior when trying to highlight multiple cells, so this also seems inconsistent if this is a feature rather than a bug. I even looked up in the old Stephen Wolfram Mathematica book and it talks about the using the arrow keys to highlight two-dimensional expressions (on the bottom of page 180 if you wish to look), and it says that the definitions for the arrow keys are move to the next character for the right-arrow and move to the previous character for the left-arrow. So on that basis it would appear this is indeed a bug. I agree that it's not talking specifically about high-lighting, but the fact that highlighting seems to break this definition of what right-arrow and left-arrow do, seems to be another reason this behavior a bug. Would some of the people who have been using Mathematica for many, many years please comment on whether this has always been the way this highlighting with arrow keys has worked? Has it been this way since version 1.0? If not, when did it change and why? What is the reason for this seemingly inconsistent behaviour? (inconsistent between the way highlighting works between left-right and up-down and mouse- dragging highlighting) Comments??? -Bob === Subject: How to find current ViewAngle, ViewPoint during Rotating graphics? Mathematica 7. Is there a way to display the current ViewAngle and/or View point of a 3D graphics as one is rotating it with the mouse? Sometimes I am not sure what is the best view angle to use initially, but after I rotate the 3D graphics and find a good angle I like, there does not seem to be a way to determine its value from the front end. I was expecting may be that a mouse right-click on the graphics or something similar would bring up some information about the current state of the graphics. Any one knows a trick way to find this information? --Nasser === Subject: Re: Efficient construction of a correlation matrix dan Hello all, to have a response: is there a fast way to generate a matrix of > correlation coefficients given a list of vectors? I have about > fifty vectors that are each around 1300 elements long and I'd like > to correlate them with each other to get a 50x50 matrix. I know > that I can do this with loops or tables but I thought that perhaps > there exists a fast and computationally inexpensive way to do this. > Any thoughts? Dan If you're using 6 or 7, Correlation[data] > will give you the 50 x 50 correlation matrix. If you're pre-6, < will load a standard add-on package, and CorrelationMatrix[data] > will give you the correlation matrix. In both cases, the dimensions of the data matrix must be > {#_of_cases, #_of_variables}, so transpose as necessary. === Subject: Re: Scaling JPEGs or TIFFs inside PDF slides (using Illustrator)? Is there a particular reason you are using JPEG/TIFF and not vector > images? On the occasions that I have imported mathematica graphics into > illustrator (and freehand) they were EPS or PDF images. One worked > well and one was jnot so well but I can't remember which. Resizing was > easy -- just group all the points in the image and resize. > Many of these just _are_ JPEGs or TIFFs from the start: photographs of apparatus, of notable people or events, of experimental results, that has been gathered from archives, other publications, or the web (Google Images). Some are scans, e.g. titles-and-abstracts from important papers or illustrations), material from archives, things that I've scanned or that are available online only in scanned form. Anything I can create in vector format (from Mathematica, Illustrator, TeX) or type in myself as text, I do. === Subject: Re: Replace Table[Sum...]...] with Functional code > mm[data_, period_] := > Table[ > Sum[(Log[data[[t]]] - Log[data[[t - i]]])/Sqrt[i], > {i, 1, period}]/period, > {t, period + 1, Length[data]}] mm2[data_, period_] := Module[ > {logData = Log[data], d = Sqrt[Range[period, 1, -1]]}, > Mean[#/d] & /@ > (Drop[logData, period] - > Most[Partition[logData, period, 1]])] data = Array[x, {500}]; period = Random[Integer, {20, 100}] 41 Timing[r1 = mm[data, period];] {0.459393,Null} Timing[r2 = mm2[data, period];] {0.228474,Null} %/%% {0.497339,1} r1 == r2 True Bob Hanlon > I use the following two functions to analyze time series: mm[data_, period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t - i]]]) /= Sqrt[i], {i, 1, period}] / period, {t, period + 1, Length[data]}] mr[data_, period_] := Table[Sum[Log[data[[t - i]] / data[[-i + t - 1]]]= * (Sqrt[i] - Sqrt[i - 1]), {i, 1, period}],{t, period + 2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a bunch of = stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but as th= e increments in the Table function come into play in the Sum, I haven't bee= n able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, but I could us= e some pointers. Any help much appreciated. By using Table and Sum you are repeating a lot of calculations. Once period has been set all the possible values of (Sqrt[i] - Sqrt[i - 1]) and Log[data[[t - i]] / data[[-i + t - 1]]] are set. Therefore: kernel=Table[(Sqrt[i]-Sqrt[i-1]),{i,period}]; ls=ListCorrelate[{1,1},data,{1,-1},1,Times,Log[#2/#1]&]; so now combine them: ListConvolve[kernel,ls,{-1,1},0] functionalMR[data_,period_]:=Module[{kernel,ls}, kernel=Table[(Sqrt[i]-Sqrt[i-1]),{i,period}]; ls=ListCorrelate[{1,1},data,{1,-1},1,Times,Log[#2/#1]&]; ListConvolve[kernel,ls,{-1,1},0] ] This is a little bit slower than Ray Koopman's code but I just like using ListCorrelate and ListConvolve as replacements for Table[Sum [ ...]...] :) Mike === Subject: Re: Replace Table[Sum...]...] with Functional code > I use the following two functions to analyze time series: mm[data_,period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t-i]]])/ > Sqrt[i], {i,1,period}] / period, {t, period+1, Length[data]}] mr[data_,period_] := Table[Sum[Log[data[[t-i]]/data[[-i + t-1]]] * > (Sqrt[i] - Sqrt[i-1]), {i,1,period}],{t, period+2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a > bunch of stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but > as the increments in the Table function come into play in the Sum, > I haven't been able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, > but I could use some pointers. Any help much appreciated. Here is a fourth version of mm. Why I transposed things in the third version is beyond me! This one is both faster and more elegant. mm[data_, period_] := Partition[Log@data,period+1,1]. (Append[-#,Tr@#]&[1/(Sqrt@Range[period,1,-1]*period)]) === Subject: Re: Replace Table[Sum...]...] with Functional code > I use the following two functions to analyze time series: mm[data_,period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t-i]]])/ > Sqrt[i], {i,1,period}] / period, {t, period+1, Length[data]}] mr[data_,period_] := Table[Sum[Log[data[[t-i]]/data[[-i + t-1]]] * > (Sqrt[i] - Sqrt[i-1]), {i,1,period}],{t, period+2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a > bunch of stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but > as the increments in the Table function come into play in the Sum, > I haven't been able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, > but I could use some pointers. Any help much appreciated. Here is a third pair of suggestions. This mm is about as fast as the second version but is perhaps a little more elegant. mm[data_, period_] := (Append[-#,Tr@#]&[1/(Sqrt@Range[period,1,-1]*period)]). Transpose@Partition[Log@data,period+1,1] This mr is faster than the second version. mr[data_, period_] := Partition[Rest@#-Most@#&@Log@data,period,1]. (Reverse[Rest@#-Most@#]&@Sqrt@Range[0,period]) === Subject: Re: UNDO and Mathematica - how useless is it? Yes, this is very similar to the approach within A WorkLife FrameWork.... there is a means there to also add associated comments associated with each backup. But it's clear that one can write a tool that does this without the full machinery of my package... ...David > I think for just having backups for your notebooks the possibility to > use a full featured version control system from within the workbench is > overkill. The automatic history which eclipse offers for textfiles is > AFAIK not something that automatically works for mathematica notebooks > (does it? can it work for an external editor at all? I use SVN with > workbench which turns automatic local backups off). The following will add a simple menubar to your notebook which will let > you save a backup with the current date/time encoded into the filename. > Just press the backup button whenever you think is appropriate to create > a version. This could of course be further improved and adopted to > your needs, maybe a directory hierarchy would be handy to make it easy > to delete backups of certain periods that you don't need anymore. Also > some additional buttons to manage the versions directly would also be > nice and some error checking would certainly also be a good idea. There > are no guarantees that this way you will never loose work, but it should > basically do what it is supposed to... SetOptions[EvaluationNotebook[], > DockedCells -> Append[ > DeleteCases[ > DockedCells /. Options[EvaluationNotebook[], DockedCells], > HoldPattern[Cell[___, CellTags -> {BackupMenuBar}, ___]] > ], > Cell[BoxData[ToBoxes@Row[{Button[backup, > Module[{backupname, backupnb}, > backupname = StringReplace[ ToFileName[ > FileName /. NotebookInformation[ButtonNotebo= ok[]]], fname___ ~~ .nb : fname <> _ <> _, > Hour, -, Minute, -, Second}] <>= .nb > ]; > SelectionMove[ButtonNotebook[], All, Notebook]; backupnb = > NotebookPut[ > Notebook[NotebookRead[ButtonNotebook[]], > Visible -> False]]; > NotebookSave[backupnb, backupname]; > MessageDialog[backup saved to: <> backupname]; > NotebookClose[backupnb]; > ], > Method -> Queued > ] > }] > ], DockedCell, CellTags -> {BackupMenuBar}] > ] > ] hth, albert === I found what appears to be a new tile associated with Barnsley's triangular affine. The fourth transform algorithm is my own. Riddle rotation of Barnsley affine: fractal animation http://www.mathematica-users.org/mathematica/images/d/db/affine_riddle.avi Clear[f, dlst, pt, cr, ptlst, M, p, a, b, c, n] rotate[theta_] := {{Cos[theta], -Sin[theta]}, {Sin[theta], Cos[theta]}}; n0 = 4; dlst = Table[ Random[Integer, {1, n0}], {n, 10000}]; a = b = c = 0.5; M = {{{-1 + b, -1/2 + b/2 + a/2}, {0, a}}, {{b + c/2 - 1/2, b/2 - c/4 + 1/4}, {1 - c, c/2 - 1/2}}, {{c/2, -1/2 + a/2 - c/4}, {-c, -1 + a + c/2}}, rotate[-Pi/((7/4 - a/2 - b/2 - c/2)) + n*Pi/20].{{1/2 - a/2 - b/2 - c/2, 3/4 - a/4 - b/4 - c/4}, {1 - a/3 - b/3 - c/3, 1/2 - a/6 - b/6 - c/6}}} a0 = Table[Det[M[[i]]], {i, 1, 4}] FullSimplify[Apply[Plus, a0]] rotate[-Pi/((7/4 - a/2 - b/2 - c/2))] in = {{1 - b, 0}, {1 - b, 0}, {1/2, 1}, {1 - b, 0}}; Length[in] f[j_, {x_, y_}] := M[[j]]. {x, y} + in[[j]] pt = {0.5, 0.5}; cr[n_] := Flatten[Table[If[i == j == k == 1, {}, RGBColor[i, j, k]], {i, 0, 1}, {j, 0, 1}, {k, 0, 1}]][[1 + Mod[n + 1, 7]]]; ptlst[n_] := Table[{cr[dlst[[j]]], Point[pt = f[dlst[[j]], Sequence[pt]]]}, {j, Length[dlst]}]; Table[Show[Graphics[Join[{PointSize[.001]}, ptlst[n]]], AspectRatio -> Automatic, PlotRange -> All], {n, 0, 20}] > > > === Subject: Re: Mathematica behavior using highlighting and keyboard arrows - I too have been bothered by how highlighting is handled with Mathematica. I am in process of figuring out how to drive selection via buttons that simulate keystrokes etc... My efforts would be spoiled by bugs for highlighting and effective editing for me. Sometimes I am getting the sense deep testing of some key UI issues have been put aside for the more sexy math/features. This will only tarnish Mathematica eventually. Maybe Mathematica is a sports car, great to look at, great to drive, but is often in the shop for annoying repairs. (Oh, I am legally blind so I can't drive, but know folks who owned sports cars.) === Subject: Re: Mathematica behavior using highlighting and keyboard arrows - BUG??? > I have been puzzled by the way that Mathematica handles highlighting > when using the keyboard arrow keys. For example if the cursor is in an > Input cell in the middle of any expression and you press and hold the > Shift key and then press the right-arrow key to highlight each > character for each press of the right-arrow key, and then if you > accidently go one or more characters too far (the repeat rate of the > key faster than my reaction time), and then I try and back up to the > intended correct position by letting go of the right-arrow key and > press the left-arrow key while still pressing the Shift, the > highlighting is extended to the left of the original starting > position, not the current position of the cursor, so instead of > correcting the overshoot you end up with even more unwanted > highlighted portion of an expression or text. And the most bizarre > thing about this is that the behavior is different depending on > whether it's a Text or an Input style cell, in that Input style cells > do it this way and Text style cells do it as I would expect. Without trying to argue which of the two alternative behaviors you describe here is right or correct, I'd suggest that both can be useful or desirable in different situations and for different purposes; and it seems to me I've encountered both of them in different applications I've used. One more example of the eternal conflict in attempting to induce or assist software developers and interface designers in achieving consistency or adhering to accepted standards, whether it's in behavior like this, or in the meanings attached to Cmd-key combinations, or other examples. (I have apps in which ^D means Duplicate, others in which it means Delete -- obviously one wants to pause and think before using this keystroke shortcut!) Just for historical interest, I'm looking right now at an attractive 144-page softbound copy of Apple Computer's thoughtful 1987 manual on Human Interface Guidelines: The Apple Desktop Interface (published and sold through Addison-Wesley) that I just took down from my bookshelf. It includes about a dozen pages (and 30 index entries) on the topic of Selection, that include much of what you discuss above. Nice to know that software companies once thought carefully about these issues -- not to mention publishing them and living by them. === Subject: Two Notebooks Open at the Same Time Hello everyone, Is it possible to have more than one notebook active at a time, that is, so that the variables of one do not conflict with variables in another whose names are the same. I notice that when I open a Mathematica 7 notebook, under the Evaluation menu, the Default Kernel is local, the Notebook's Kernel is local, and the Notebook's Default Context is global. Do I need to change anything? Gregory === Subject: Internet connectivity -- CountryData using Mathematica 6.0, I would like to use CountryData[Austria, Shape] to access country information. But I get the error message: CountryData::dlfail: Internet download of data for CountryData failed. Use Help > Internet Connectivity... to test or reconfigure internet connectivity When I test the internet connectivity, the program says Connectivity test succeeded using pacletserver.wolfram.com. What can I do now? I am sitting behind a firewall and access the internet via a proxy. Our IT service asks for an address which the program wants to use. Any help appreciated, Karsten. === Subject: Re: Internet connectivity -- CountryData C:Userskuska>nslookup pacletserver.wolfram.com Server: ws1.izbi.uni-leipzig.de Address: 139.18.75.11 Nicht-autorisierende Antwort: Name: pacletserver2.wolfram.com Address: 140.177.205.45 Aliases: pacletserver.wolfram.com and so I would guss 140.177.205.45 may help your IT service. Jens using Mathematica 6.0, I would like to use CountryData[Austria, > Shape] to access country information. But I get the error message: > CountryData::dlfail: Internet download of data for CountryData > failed. Use Help > Internet Connectivity... to test or reconfigure > internet connectivity When I test the internet connectivity, the program says Connectivity > test succeeded using pacletserver.wolfram.com. What can I do now? I am sitting behind a firewall and access the > internet via a proxy. Our IT service asks for an address which the > program wants to use. Any help appreciated, Karsten. > === Subject: Re: Mathematica Graphics - speed bottleneck You don't tell us quite enough about your dynamic presentation. There might, or might not, be a solution within Mathematica. A Graphics3D object that is extremely dense with objects is going to be slow to update. For example, it may be sluggish just in using the mouse to rotate the image. (In examples I tried I was surprised to see that the use of VectorStyle -> Arrow3D produced images that seemed easier to rotate than with the simpler default arrows.) If you MUST show many hundreds of objects and they ALL change with some dynamic variable, then there may be no practical solution within Mathematica or on a PC. But if only a few things change, then you could write a custom dynamic presentation where only the few things are updated and that should be much faster. (I hardly ever write Manipulate statements anymore, finding custom dynamics much easier.) We must also recognize that a graphical image with a thousand objects, say, is something that may be difficult for a viewer to grasp or to prevent from being cluttered. It might be possible to use multiple images. One image might be detailed, but non-dynamic. Other images might be dynamic but using a simplified representation that somehow captured the essential changes. It might be possible to dynamically show pairs of images, one that illustrated the configuration of dynamic variables and a second that illustrated the effect at some limited region with a smaller set of objects. Thinking about how to make such presentations might actually lead to a better understanding of the phenomenon. But if everything is dynamic, interconnected, and equally important, then you will probably have a problem with practical real-time presentations in Mathematica. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Mathematica 7. has lured me back into using Mathematica at work and I am wondering if it really has reached a point where it can be used to deploy applications / solutions. I had some success with one small application but found the graphics became a bottleneck which slowed to a grinding halt when applied to a real problem. Key culprits were the vector field plotting functions, and Graphics3D's ability to manipulate objects comprising hundreds of tubes. It was fine for tens but not hundreds. This led me to wonder if there are alternative approaches. I recall LiveGraphics3D but it seems to have stopped at v5. Basically I want to manipulate 3D graphics through use of DynamicModule, Sliders, etc. and see the changes in realtime (as opposed to geological time!) Any thoughts? === Subject: Re: Mathematica Graphics - speed bottleneck Robert, if you have lots of Point, Line, Tube or Polygon primitives, you can really speed up the rendering by combining them together into multi-argument primitives, like (*slow rendering*) {Line[{{1, 1, -1}, {2, 2, 1}}], Line[{{3, 3, -1}, {4, 4, 1}}]} (*faster rendering*) Line[{{{1, 1, -1}, {2, 2, 1}}, {{3, 3, -1}, {4, 4, 1}}}] (*replace consecutive Line primitives by a multi-argument line*) ToMultiPrimitives[g_] := g /. {a___, b : Longest[_Line ..], c___} :> {a, Line[{b}[[All, 1]]], c} ToMultiPrimitives[{Line[{{1, 1, -1}, {2, 2, 1}}], Line[{{3, 3, -1}, {4, 4, 1}}]}] {Line[{{{1, 1, -1}, {2, 2, 1}}, {{3, 3, -1}, {4, 4, 1}}}]} If you have lots of individual coloring, then you should use VertexColors, because these can be incorporated into the muli-argument primitives. The example above can be modified to do such stuff. If you know the structure of your arguments, then you can do it much more efficiently than using ReplaceAll and Longest etc.. Yves > Mathematica 7. has lured me back into using Mathematica at work and I am wondering if it really has reached a point where it can be used to deploy applications / solutions. I had some success with one small application but found the graphics became a bottleneck which slowed to a grinding halt when applied to a real problem. Key culprits were the vector field plotting functions, and Graphics3D's ability to manipulate objects comprising hundreds of tubes. It was fine for tens but not hundreds. This led me to wonder if there are alternative approaches. I recall LiveGraphics3D but it seems to have stopped at v5. Basically I want to manipulate 3D graphics through use of DynamicModule, Sliders, etc. and see the changes in realtime (as opposed to geological time!) Any thoughts? > > === Subject: Bug in LaplaceTransform? how can it happen that Mathematica throws out -i for the Laplace transform of one, LaplaceTransform[1, t, I] = -i? After all the Laplace transformation (with s = I) is defined as Integrate[Exp[-I t], {t, 0, Infinity}] and should be undefined. Am I wrong or is this a bug? Wieland === Subject: Re: NMF problem > Hi friends, > I am making a project where I have to make use of NMF (non-negative > matrix factorization). But there's a problem I'm facing. Its been > quite some time since I studied any maths. I am getting to understand > NMF slowly but it does not seem to be working. I have a few questions: 1. Kindly tell me some good resources to study NMF and LNMF from. I > would prefer resources that start from scratch. 2. Whats the real intuitive/graphical meaning of the multiplicative > update functions? O! I forget to mention. I only have to study NMF for > minimizing Euclidean distance and KL Divergence. I understand well through graphs. I need conceptual information on how > this stuff works. Vaibhav This does not address your questions, but does indicate how one might approach the decomposition problem in Mathematica (and with relatively simple code). A brute-force approach is to set it up as a quadratic optimization problem. Given a matrix mat, you want to find factors A,X such that A.X is a close approximation to mat, and all elements of A,X are nonnegative. Below is an example that uses NMinimize. In[3]:= mat = RandomReal[{0, 1}, {4, 4}] Out[3]= {{0.936465, 0.861454, 0.610776, 0.797641}, {0.633923, 0.960643, 0.203871, 0.92107}, {0.254202, 0.248351, 0.438789, 0.263852}, {0.539495, 0.283209, 0.364426, 0.11926}} amat = Array[a, {4, 4}]; xmat = Array[x, {4, 4}]; vars = Flatten[Join[amat, xmat]]; In[23]:= {min, vals} = NMinimize[{Total[(amat.xmat - mat)^2, 2], Thread[0<=vars]}, vars] Out[23]= {2.49829*10^-26, {a[1, 1] -> 0.340709, a[1, 2] -> 1.31141, a[1, 3] -> 0.476329, a[1, 4] -> 0.63511, a[2, 1] -> 2.11758*10^-22, a[2, 2] -> 1.2244, a[2, 3] -> 0.145836, a[2, 4] -> 0.893492, a[3, 1] -> 0.490447, a[3, 2] -> 0.325596, a[3, 3] -> 1.00647*10^-8, a[3, 4] -> 0.191064, a[4, 1] -> 0.210105, a[4, 2] -> 0.733511, a[4, 3] -> 0.286423, a[4, 4] -> 6.40909*10^-9, x[1, 1] -> 0.219704, x[1, 2] -> 0.0387703, x[1, 3] -> 0.812809, x[1, 4] -> 0.143658, x[2, 1] -> 0.449788, x[2, 2] -> 0.374994, x[2, 3] -> 0.122797, x[2, 4] -> 0.0426963, x[3, 1] -> 0.570518, x[3, 2] -> 6.24158*10^-7, x[3, 3] -> 0.361628, x[3, 4] -> 0.201654, x[4, 1] -> 1.19304*10^-7, x[4, 2] -> 0.56128, x[4, 3] -> 0.000873426, x[4, 4] -> 0.939443}} We double-check the closeness of approximation by looking at the largest discrepancy between product and original matrix. In[26]:= Max[Abs[amat.xmat - mat /. vals]] Out[26]= 1.37002*10^-13 This is not a viable approach once the dimension gets to even modest size. Decomposing an 11x11 gave a reasonable result but took about 42 seconds. There are ways to coax a decent result from FindMinimum but that, too, seems to get quite slow as dimension rises. Daniel Lichtblau Wolfram Research === Subject: Multivariate normal distribution is there anyone who is able to show me how solve in Mathematica the following problem? I have two random variable S_i and S_j whose mean and variances are m_i, m_j and sigma_i and sigma_j and whose correlation is rho_ij how can I compute ExpectedValue(S_j , S_j) and its derivative PT === Subject: Re: Multivariate normal distribution The mean vector is *defined* as the expected value of the random vector. It does not depend on the variances or the correlation. On Mar 19, 12:09 am, tarpane...@libero.it is there anyone who is able to show me how solve in Mathematica the > following problem? I have two random variable S_i and S_j whose mean and variances are > m_i, m_j and sigma_i and sigma_j and whose correlation is rho_ij > how can I compute ExpectedValue(S_j , S_j) and its derivative > PT === Subject: Re: FullGraphics of Graphics3D Istvan, I don't think I completely understand what you are trying to do. If you are trying to make a side-by-side Row display of two Graphics3D objects and you wanted the same Axes and Ticks in the two plots, then I would use the CustomTicks command from the Presentations package and specify them, along with PlotRange for each of the plots. That way they would be the same. The CustomTicks command is very easy to use and it automatically provides the minor unlabeled ticks as well as the major labeled ticks and you can get just what you want. If you want to plot two different curves or surfaces in a single graphic, then that is also easy to do with Presentations. You just draw one item after another in a single plotting statement. In custom graphics one simply has to specify each of the elements of the graphic, and it is easier to do that directly than by trying to extract elements from some other plot, or one of the plot elements. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ On Mar 14, 11:39 am, Jens-Peer Kuska You must write your own ... Jens No idea, anyone? Istvan I would, if I had the slightest idea how to extract axis data and other details from the Graphics3D data. Which I (and others, it seems so) don't know. Still I could do it the hard way, to manually input primitives to work as axes, ticks, labels, etc., but frankly, this does not worth the effort. I was simply interested in how others deal with the problem, namely: how to combine two 3D graphics such that they are reproduced in 3D space e.g. side by side, but with their own Boxes, Axes, and other details as well, not the way Show would do it. If noone has any idea beside writing it myself, I leave this topic die. Istvan === Subject: Compress timing with different data types I noticed that the speed of Compress is very much dependent on the type of data that is compressed: (*start*)data = RandomReal[{-1, 1}, {100, 10, 3}]; cdt = AbsoluteTiming[cd = Compress[data]][[1]]; udt = AbsoluteTiming[Uncompress[cd]][[1]]; lines = Line /@ data; scale = ByteCount[lines]/ByteCount[data]; clt = AbsoluteTiming[cl = Compress[lines];][[1]]/scale; cut = AbsoluteTiming[ul = Uncompress[cl];][[1]]/scale; TableForm[{{, Coordinates, Lines, Factor}, {Compress, cdt, clt, clt/cdt}, {Uncompress, udt, cut}}] (*end*) Result: Coordinates Lines Factor Compress 0.0468738 2.6967411 57.5319 Uncompress 0. 0. So compressing an expression only containing lists and numbers is about 60 times faster than compressing an expression containing Line statements. And the difference gets worse the larger the expression becomes... On the other hand, Uncompress is not much affected... Does anyone have experience and/or a workaround with that behaviour (6.03 & 7.01 on WinXP)? Yves === Subject: Re: Superscripts in post-processed plot labels Yeah, I normally use Epilog to do such annotations, but this was a one-off plot, so I tried the interactive way. I'll see what I can do (on Windows and Linux) later today, and report whether it's reproduceable. I absolutely prefer the programmatic way of labeling things; still, Wolfram should fix this! Best wishes, Curtis O. > I don't notice that effect on Windows 32-bit Vista. What happens if you use Epilog and position the label with a Text statement? > This might be better anyway because it leaves you with a complete written > description of the graphics, that would be easier to modify later if > necessary. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ > Howdy, all, I'm not sure if this has been reported before, but adding text to a plot > via the editor palette (ctrl-d on my installation, then double-click on the > plot, and add text containing superscripts) pushes the thing the superscript > is attached to downward, so that the superscript stays level with the > surrounding text. This effect persists upon exporting the graphic to a .pdf. For example, if I were to put an equation such as x^2 ( where the > exponent is properly superscripted) on a plot, the x is pushed below the > level it should be and the 2 aligns with the surrounding text. This is on 7.0 for Linux x86 (32-bit) (November 11, 2008), > incidentally. C.O. -- 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: All Possible Combinations from N Sublists myList = {{1, 2, 3}, {e, f}, {g, h}}; Tuples@myList {{1, e, g}, {1, e, h}, {1, f, g}, {1, f, h}, {2, e, g}, {2, e, h}, {2, f, g}, {2, f, h}, {3, e, g}, {3, e, h}, {3, f, g}, {3, f, h}} Bobby > myList = {{1, 2, 3}, {e, f}, {g, h}}; Flatten[Outer[List, Sequence @@ myList], 2] > {{1, e, g}, {1, e, h}, {1, f, g}, {1, f, h}, {2, e, g}, {2, e, h}, {2, > f, g}, {2, f, h}, {3, e, g}, {3, e, h}, {3, f, g}, {3, f, h}} > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ Given a list of N sublists, how can I produce all possible combinations > where the first > element comes from the first sublst, the second element from the second > sublist etc. For instance, myList = {{1, 2, 3}, {e, f}, {g, h}} the result should be, > {{1, e, g}, {1, e, h}, {1, f, g}, {1, f, h}, {2, e, g}, {2, e, h}, {2, f, > g}, {2, f, h}, {3, e, g}, {3, e, h}, {3, f, g}, {3, f, h}} -- DrMajorBob@bigfoot.com === Subject: SparseArray[]: no warning for repeated indices By default, SparseArray[] gives no warning when an index is specified twice. Example: SparseArray[{1->a, 2->b, 1->c}] This is incorrect because both a and c are associated with index 1, but SparseArray gives no warning. Is there a message that can be turned on to get SparseArray to warn about such situations? === Subject: Re: Compatibility issue in Mathematica 7 > Hello everybody, I've been using Mathematica 6 for a while and now I'm about to > purchase version 7: I was wondering whether it's possible, in the > latest version, to save a notebook which can be subsequently opened > (and edited) with version 6. To the best of my knowledge, this was not > possible in version 6 (saving for, say, version 5) and it's something > that has always buggered me quite a lot, because I often have the > necessity to exchange notebooks with people who haven't the same > version as me. Daniele Version 7 notebooks are compatible with version 6, except where new features are used. The principal new features I can think of which you might run across are graphics which use splines, tubes, or 3D arrows. Graphics containing any of these new features will render partially or not at all with a pink box noting the problem. Also, any Manipulate output which relies on new Manipulate features (sorry, don't have the list, but I could probably obtain it if it's important) might display a compatibility message instead of the Manipulate itself. When opening a version 7 notebook in version 6, you'll get a warning dialog box indicating the notebook was created with a newer version. But, aside from that, if you stick to the version 6 feature set in your code, you'll probably be okay. And if you re-save the notebook in v6, even that warning will go away. As a general remark about compatibility, I know that a lot of things changed in version 6, which was a considerable challenge for some. But version 6 is very atypical of our releases in that regard. Version 7, like the vast majority of our upgrades, is highly compatible with its predecessor, modulo new features. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: gridMathematica 7: Multiplying the Power of Mathematica over the Grid Less than six months ago, Wolfram Research integrated automatic parallel technology into Mathematica 7. Today, that power can be multiplied by more powerful hardware and clusters with the release of gridMathematica 7, including new technology, Wolfram Lightweight Grid Manager, for launching Mathematica on remote computers. gridMathematica extends the built-in parallelization features of Mathematica by adding extra computation kernels and automated network distribution tools--allowing users to run more tasks in parallel, over more CPUs, for faster execution without changing a line of code. gridMathematica's new extension technology makes parallel tasks, even personal supercomputing, easy. Whether computations are distributed over local or remote CPUs, process coordination and management is completely automated. * gridMathematica Local adds four additional computation kernels to the four already included in a single-machine Mathematica license, making it ideal for individual user who needs a boost of power on a multicore machine. * gridMathematica Server provides a network-managed pool of computation kernels that can be shared by a group of Mathematica users locally or run on remote hardware to combine the power of multiple computers. * Wolfram Lightweight Grid Manager makes it easy for users to acquire and run Mathematica computation kernels on remote hardware and can control high-performance clusters or create ad hoc grids from idle computers. Using gridMathematica 7, you can automatically scale up your tasks to grids of any size--allowing you to deliver accurate solutions even faster. More details about gridMathematica are available on its web pages: http://www.wolfram.com/gridmathematica gridMathematica requires a Mathematica license and is available for Windows, Mac OS X, and Linux. NOTE: gridMathematica users with Premier Service will receive an email in the next few days notifying them of their free upgrade and when they will receive their media shipment. === Subject: Re: Problem with mathlink:PLEASE HELP ME Hi mathematica community, >Under windows xp,I have a c++ program in which I established a >comunication with mathematica via mathlink. >But when my program is executed, a Choose a MathLink Program to >Launch dialog box appears and ask me to choose between some >executables. This is my code and the problem should be in the path of >the connection. >In this path I have chosen to launch mathkernel.exe so why the dialog box >appears and How can I GET RID OF THIS DIALOG BOX? ml = MLOpenString(env,-linkname C:Program FilesWolfram >ResearchMathematica6.0 MathKernel.exe -mathlink,&error); I suspect that you are encountering escaping issues with your > linkname string containing the Windows path backslashes. Also, the > -mathlink parameter to the kernel should be part of the > linkname. Here are a few different ways to address those issues: 1) Use forward slashes (which Windows XP accepts): > ml = MLOpenString(-linkname C:/Program Files/Wolfram > Research/Mathematica/6.0/MathKernel.exe -mathlink, &error); 2) Add more escaping of the backslashes, one level for the C compiler > and the other for MathLink: > ml = MLOpenString(-linkname C:Program FilesWolfram > ResearchMathematica6.0MathKernel.exe -mathlink); 3) You may find it more convenient to use MLOpenArgcArgv instead of > MLOpenString, which avoids the escaping issue: > char* v[10]; > int c = 0; > v[c++] = -linkname; > v[c++] = C:Program FilesWolfram > ResearchMathematica6.0MathKernel.exe -mathlink; ml = MLOpenArgcArgv(env, c, v, &erro= r); Finally, if you are interested in suppressing the dialog box even if > the link name was in fact incorrect you can use the MLDontBrowse option: ml = MLOpenString(env, -linkname badlinkname -linkoptions > MLDontBrowse,&error); Chris Hill > Wolfram Research thank you very much Mr Chris it works :) === Subject: Re: Fitting using a custom function On which version of Mathematica are you working. If you're on 6 or 7 did you read at least this documentation: http://reference.wolfram.com/mathematica/tutorial/CurveFitting.html. Which part of it you didn't understand? > My problem is pretty simple: I have a data file with experimental data that I would like two fit (x and y values). > In order to calculate the theoretical function I only can use a Finite difference method and iterate the calculus as a function of time. At the end of the calculation I get a list with theoretical x and y values. Now, since the calculation is made by using some parameters, I would like Mathematica to find the best set of fitting parameter that fit the experimental data. > Anybody knows how to do this kind of thing!? > The loop that I use for the calculation is itself a Module but I don't know if I can use this together with the Fit function... Any idea??? > === Subject: Re: Fitting using a custom function if I understand correctly, you have some 2 dim. array of experimental values (not y[x]), call it exp. Further you have a function fun that takes input values (your parameters) and returns an array similar to exp. You now want to optimize the function argument. This can be done by defining an (here least square) error function: err[p1_,p2_,..]:= Plus@@ Flatten@ (fun[p1,p2,..]-exp)^2 Now we need to find the minimum of err using e.g. NMinimize or FindMinimum. Here is an example: exp = Table[2 Sin[1.1 x] + 3 Sin[0.5 y], {x, 0, 10}, {y, 0, 10}]; fun[p1_, p2_, p3_, p4_] := Table[p2 Sin[p1 x] + p3 Sin[p4 y], {x, 0, 10}, {y, 0, 10}]; err[p1_, p2_, p3_, p4_] := Plus @@ Flatten[(fun[p1, p2, p3, p4] - exp)^2]; res = NMinimize[err[p1, p2, p3, p4], {p1, p2, p3, p4}] ListPlot3D[{fun[p1, p2, p3, p4] /. res[[2]], exp}] hope this helps, Daniel > My problem is pretty simple: I have a data file with experimental data that I would like two fit (x and y values). > In order to calculate the theoretical function I only can use a Finite difference method and iterate the calculus as a function of time. At the end of the calculation I get a list with theoretical x and y values. Now, since the calculation is made by using some parameters, I would like Mathematica to find the best set of fitting parameter that fit the experimental data. > Anybody knows how to do this kind of thing!? > The loop that I use for the calculation is itself a Module but I don't know if I can use this together with the Fit function... Any idea??? === Subject: Re: multiple points in WorldPlot What about using the function Map? > I would like to plot multiple points on a Mercator projection using > WorldPlot. The easiest way for me would be to plot a single expression > which is a set of pairs of coordinates of the form > {{lat1,long1},{lat2,long2}...{latn,longn}}, but it seems that the > primative Point in WorldGraphics will accept only one pair of > coordinates. The alternative of using multiple Point functions (e.g., > Point[{lat1,long1}], Point[{lat2,long2}] is simply too cumbersome for a > list of 20 or more points. Is there a way around this problem? Leathem Mehaffey === Subject: Re: multiple points in WorldPlot As Help plainly says: Point[{Subscript[coords, 1],Subscript[coords, 2],[Ellipsis]}] represents a collection of points. Bobby > I would like to plot multiple points on a Mercator projection using > WorldPlot. The easiest way for me would be to plot a single expression > which is a set of pairs of coordinates of the form > {{lat1,long1},{lat2,long2}...{latn,longn}}, but it seems that the > primative Point in WorldGraphics will accept only one pair of > coordinates. The alternative of using multiple Point functions (e.g., > Point[{lat1,long1}], Point[{lat2,long2}] is simply too cumbersome for a > list of 20 or more points. Is there a way around this problem? Leathem Mehaffey -- DrMajorBob@bigfoot.com === Subject: Re: Mathematica Graphics - speed bottleneck > Mathematica 7. has lured me back into using Mathematica at work and I am > wondering if it really has reached a point where it can be used to deploy > applications / solutions. I had some success with one small application > but found the graphics became a bottleneck which slowed to a grinding > halt when applied to a real problem. Key culprits were the vector field > plotting functions, and Graphics3D's ability to manipulate objects > comprising hundreds of tubes. It was fine for tens but not hundreds. This > led me to wonder if there are alternative approaches. I recall > LiveGraphics3D but it seems to have stopped at v5. Basically I want to > manipulate 3D graphics through use of DynamicModule, Sliders, etc. and > see the changes in realtime (as opposed to geological time!) Any thoughts? Not having seen your problem, I can't make any authoritative comment on what's causing your performance problems. If your examples are purely about manipulation of graphics primitives and spend lots of time in the graphics rendering pipelines, then there's probably not much that can be done without improvements to the front end or off-loading the rendering to another app. But you mention plotting vector fields as an example of something that's slow. This isn't just about the rendering pipelines. There's a large amount of computation that's going on here, too. Finding another rendering platform wouldn't help if, in your case, the time sink is in computing the primitives to be displayed rather than actually displaying them. So I wouldn't jump to any conclusions like manipulating 3D graphics is slow without first quantifying where the actual time is being spent. I will make a few quick remarks about graphics performance, though. In general, when dealing with large numbers of objects, things will be much more efficient if you use multi-primitives rather than many individual primitives. Primitives like Tube[], Point[], Line[], etc., all support forms where you can specify a collection of primitives by passing in a list of coordinate lists. E.g., randompoint := {RandomReal[], RandomReal[], RandomReal[]}; Graphics3D[Tube[Table[{randompoint, randompoint}, {50}]]] Secondly, 3D graphics with any transparency at all are always going to render far more slowly than 3D graphics without transparency. The overhead for sorting polygons is much higher when you take into account that you can actually see through some of them. Finally, Graphics3D supports the Method options SpherePoints, ConePoints, CylinderPoints, and TubePoints which can specify the number of points used to render each kind of primitive in the entire scene. Providing a very small number can make a big performance difference with virtually no visual difference if the primitives are tiny or thin in your graphic. E.g., randompoint := {RandomReal[], RandomReal[], RandomReal[]}; Graphics3D[Tube[Table[{randompoint, randompoint}, {500}]], Method -> {TubePoints -> 6}] which rotates quite noticeably faster than if you omit the Method option. In the help viewer type =09tutorial/ThreeDimensionalGraphicsPrimitives to see documentation which discusses multi-primitives and the Method options. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: How does Mathematica interpolate in higher dimensions ? I have tri-variate histograms, which count the number of points from a large group of (x,y,z)'s that fall within a 3D grid. I then use func = Interpolation[histogram, InterpolationOrder->1] to create a linear Interpolation over the histogram's grid for the various heights of the grid. My question, though, is what is mathematica doing to make this interpolation? My best guess is that it is solving f = a1 +a2 x + a3 y + a4 z + a5 x y + a6 x z + a7 y z + a8 x y z using the 8 corner points of each cube. It is not clear to me how this generalizes to higher orders, but I am only interested in the linear case anyway. Is the method documented anywhere ? or does anyone know ? Ben === Subject: Re: How does Mathematica interpolate in higher dimensions ? http://www.nrbook.com/a/bookcpdf/c3-6.pdf ? Jens I have tri-variate histograms, which count the number of points from a > large group of (x,y,z)'s that fall within a 3D grid. I then use func = Interpolation[histogram, InterpolationOrder->1] to create a linear Interpolation over the histogram's grid for the > various heights of the grid. My question, though, is what is mathematica doing to make this > interpolation? My best guess is that it is solving > f = a1 +a2 x + a3 y + a4 z + a5 x y + a6 x z + a7 y z + a8 x y z using the 8 corner points of each cube. It is not clear to me how this generalizes to higher orders, but I am > only interested in the linear case anyway. Is the method documented anywhere ? or does anyone know ? Ben > === Subject: Re: Using Mathematica notebooks in couldn't agree more. Form without content is a blight on the world of Education. Its fine for the world of Advertising, but for stuff that matters.... Peter 2009/3/17 Murray Eisenberg slide show tools. If what is meant is the absence of fades, dissolves, fancy borders and > backgrounds, etc. -- GOOD, I'm glad they're not available. In almost > every case I've ever seen, such features are just distracting junk. > The current slideshow tools in Mathematica are still too basic to > compete > > with the commercial presentation packages > -- > 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 === Subject: Re: PlotMarkers bug? > try In[1]:= > ListPlot[{1}, PlotMarkers -> {[FilledSquare]}] > click on the output and Save As...EPS. > When I do that, the FilledSquare isn't actually in the .eps file. > Does anyone know a workaround? > j > PS > In[2]:= > {$Version, $ReleaseNumber} > Out[2]= > {7.0 for Mac OS X x86 (64-bit) (February 19, 2009), 1} Hmm. I wasn't able to reproduce your problem on a Mac or Windows machine running 7.0.1 (didn't try earlier versions, but I know of no reason they should differ in this regard). How did you confirm that the [FilledSquare] character wasn't there? I tried opening the resulting image in GhostScript, which showed it without a problem. However, for example, I know that there have been problems with Adobe Illustrator not being able to properly interpret some EPS generated by Mathematica. Apparently Illustrator only understands some subset of EPS, but it's not clear to us what that subset is. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: How to map a list on function Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. > How to use Map or similar ? Use Listability. Try: Plus @@ Times @@ Power[{x, y, z, u}, Transpose@{{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}}] Some timing for other list lengths---1 000 000 gives ~ 18 seconds, 10 000 gives ~ 0.1 seconds, and 1000 gives ~ 0 seconds. Vince Virgilio === Subject: Notebook State Saver: A new tool for saving the state of your open I have started a blog on which I will be posting tools that I create for Mathematica. It is at: http://www.scientificarts.com/mathematicatools/ The first item that I am posting there is a simple Palette, NotebookStateSaver.nb, that lets you save 5 different states of open Mathematica notebooks so that you can reopen them all, retaining their locations, sizes and order. I think that it's quite useful and I use it to reopen the sets of notebooks that I need for particular projects that I am working on (including the associated palettes that I need open for those projects). The free tools that I will be posting are supported through the (small bits of ) advertising revenue that I get when users click on the Google ads on my site. So please click on them so that I can take the time to refine the many things that I have in the wings so that they are of sufficient quality to share with people. Enjoy! And I hope that these things are useful to all of you.... Also, please feel free to pass on suggestions for other useful things that I might create for the Mathematica community. --David === Subject: Can Plot, can't FindRoot - what gives? Here's my code for a model problem. I do not need a solution to this simple problem, of course - I just need to understand why Mathematica is giving me an error. f[c_] := ( s = NDSolve[{ y'[x] == c - 1, y[0] == 0}, y, {x, 0, 2*Pi}]; (Evaluate[y[x] /. s] /. x -> 2*Pi)[[1]] ) Plot[f[c], {c, 0, 10}] f[1] FindRoot[f[c] == 0, {c, 1}] I get a series of errors, the first of which is NDSolve::ndnum: Encountered non-numerical value for a derivative at x == 0.` I'm on Win32 version 6. Aaron === Subject: Re: Can Plot, can't FindRoot - what gives? f[c_?NumericQ] := (s = NDSolve[{y'[x] == c - 1, y[0] == 0}, y, {x, 0, 2*Pi}]; (Evaluate[y[x] /. s] /. x -> 2*Pi)[[1]]) Plot[f[c], {c, 0, 10}] f[1] FindRoot[f[c] == 0, {c, 1}] gives not a single error .. Jens Here's my code for a model problem. I do not need a solution to this > simple problem, of course - I just need to understand why Mathematica > is giving me an error. f[c_] := ( > s = NDSolve[{ y'[x] == c - 1, y[0] == 0}, y, {x, 0, 2*Pi}]; > (Evaluate[y[x] /. s] /. x -> 2*Pi)[[1]] > ) > Plot[f[c], {c, 0, 10}] > f[1] > FindRoot[f[c] == 0, {c, 1}] I get a series of errors, the first of which is > NDSolve::ndnum: Encountered non-numerical value for a derivative at x > == 0.` I'm on Win32 version 6. > Aaron > === Subject: Re: Different results with FourierTransform[] > I somewhat stumbled over the following behaviour of mathematica: I tried > to calculate the fouriertransform of Tanh[x]. I did this in two ways: 1. Directly: > InverseFourierTransform[Tanh[x], x, p] 2. Indirectly: > InverseFourierTransform[Tanh[B x], x, p] where I set B -> 1 in the end. However, the result between the two approaches differs: Whereas in the > first approach I get a complex number (with both real and imaginary part > being non-zero for almost all values of p), the result in the second > approach yields NO real part; the imaginary part however is the same as > in the first approach. Is there any explanation for this behaviour? Wieland The second one is correct, but in general you have to be careful with integral transforms with parameters, as there may be implicit assumptions present. Notice that InverseFourierTransform[Tanh[B x], x, p] == -I Sqrt[Pi/2] Csch[p Pi/(2*B)]/B cannot be right for both positive and negative B, because the transform has to be an odd function of B. Here are other ways to get the correct answer for InverseFourierTransform[Tanh[x], x, p]: In[1]:= {-I/p InverseFourierTransform[Tanh'[x], x, p], InverseFourierTransform[Tanh[x] E^(-a Abs[x]), x, p] /. a -> 0, 1/Sqrt[2 Pi] Integrate[(Tanh[x] - Sign[x]) E^(-I p x), {x, - Infinity, Infinity}, Assumptions -> Element[p, Reals]] + InverseFourierTransform[Sign[x], x, p]} // FullSimplify Out[1]= {-I Sqrt[Pi/2] Csch[p Pi/2], -I Sqrt[Pi/2] Csch[p Pi/2], -I Sqrt[Pi/2] Csch[p Pi/2]} Maxim Rytin m.r@inbox.ru === Subject: demonstrations and presentations Perhaps i'm wrong, but I read on the demonstrations section of the wolfram website that to create a demonstration that can be used with the viewer you need to submit it, and that it's not possible to create one by yourself. did i get it correctly? My problem is that i am preparing a presentation and i would like to show a notebook with a dynamic content in the demonstrations fashon, and i'm really not convinced that there is mathematica 7 installed in the computer where i'll have to open the presentation file (but if the demonstration file could be seen by the viewer I could carry it in a usb stick..!) did you ever had this problem? what do you suggest? Filippo === Subject: Re: Filling Between Surfaces and RegionPlot3D[ z > Sin[Pi*x*y] && z < Cos[Pi*x*y], {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] does not help ?? Jens > Is it possible to fill between two surfaces? I can't see where the Help > specifically says one can't, but neither does it give any examples of doing > so and I believe, in fact, that one can't. It is, however, possible to fill > a surface to a specific numerical value or to Top or Bottom. Examples: data1 = Table[Sin[i + j^2] + 2, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]; data2 = Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]; ListPointPlot3D[{data1, data2}, Filling -> Bottom, FillingStyle -> Directive[Opacity[.3], Gray]] ListPointPlot3D[{data1, data2}, Filling -> {2 -> {1}}, FillingStyle -> Directive[Opacity[.3], Gray]] or ListPlot3D[{data1, data2}, DataRange -> {{0, 3}, {0, 3}}, RegionFunction -> Function[{x, y, z}, Norm[{x, y}] < 2.5], Filling -> {1 -> Bottom}, FillingStyle -> Directive[Opacity[.3], Gray]] ListPlot3D[{data1, data2}, DataRange -> {{0, 3}, {0, 3}}, RegionFunction -> Function[{x, y, z}, Norm[{x, y}] < 2.5], Filling -> {1 -> {2}}, FillingStyle -> Directive[Opacity[.3], Gray]] It is a disappointment not to have that capability because it would be a way > represent a solid volume that was filled with a kind of translucent > material. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > === Subject: Re: Filling Between Surfaces Hi David, the following will do it: ListPointPlot3D[{data1, data2}, Filling -> 2, FillingStyle -> Directive[Opacity[.3], Gray]] Daniel > Is it possible to fill between two surfaces? I can't see where the Help > specifically says one can't, but neither does it give any examples of doing > so and I believe, in fact, that one can't. It is, however, possible to fill > a surface to a specific numerical value or to Top or Bottom. Examples: data1 = Table[Sin[i + j^2] + 2, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]; data2 = Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]; ListPointPlot3D[{data1, data2}, Filling -> Bottom, FillingStyle -> Directive[Opacity[.3], Gray]] ListPointPlot3D[{data1, data2}, Filling -> {2 -> {1}}, FillingStyle -> Directive[Opacity[.3], Gray]] or ListPlot3D[{data1, data2}, DataRange -> {{0, 3}, {0, 3}}, RegionFunction -> Function[{x, y, z}, Norm[{x, y}] < 2.5], Filling -> {1 -> Bottom}, FillingStyle -> Directive[Opacity[.3], Gray]] ListPlot3D[{data1, data2}, DataRange -> {{0, 3}, {0, 3}}, RegionFunction -> Function[{x, y, z}, Norm[{x, y}] < 2.5], Filling -> {1 -> {2}}, FillingStyle -> Directive[Opacity[.3], Gray]] It is a disappointment not to have that capability because it would be a way > represent a solid volume that was filled with a kind of translucent > material. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > === Subject: Re: Filling Between Surfaces Hi David, you may benefit from this thread: Basically you have to combine RegionPlot3D with ListPlot3D (or equivalent). Istvan === Subject: Re: Return a value from function a pure function is not the optimal way for recursive calls because the function has no name and so it is difficult to call a nameless function. Only pure functions without argument list can do that because Slot[0] is the function itself so that compute the factorial. And your pure function make the code unnecessary complicated and more over, if you plan to use the function recursive you should create local values with Module[] or Block[]. Jens > I'm using Mathematica 6. Trying to count the Maximum Independent Vertex Set in a graph g. I'm using recursive calls to a function. I think that when I call a return on a function that is called from its recursive predecesor, the two functions finish. Is that possible, or is it only me thinking wrong. If its possible, how can i solve this. Here is the code: Needs[Combinatorica`] > g = CompleteGraph[5]; > g = DeleteEdge[g, {1, 2}]; > g = DeleteEdge[g, {3, 2}]; > g = DeleteEdge[g, {1, 3}]; > g = DeleteEdge[g, {1, 5}]; > g = DeleteEdge[g, {3, 5}]; > g = DeleteEdge[g, {2, 5}]; ShowLabeledGraph[g] > n1 = 0; > n2 = 0; > func = Function[g1, > deg = 0; > degrees = Degrees[g1]; > temp = 0; > For[i = 1, i <= V[g1], i++, > If[degrees[[i]] > 0, deg = deg + degrees[[i]];]]; > deg = Divide[deg, 2]; > Print[Degree: , deg]; > v = V[g1]; > If[deg == 0, Print[true, V[G] = , v]; Return[v]; > Print[Ret ne rabote];, > Print[false, V[G] = , v]; > v = V[g1]; > Print[Izbrana tocka , v]; > n1 = func[DeleteVertex[g1, v]]; > Print[N1 = , n1]; > n2 = func[DeleteVertices[g1, Neighborhood[g1, v, 1]]]; > Print[N2 = , n2]; > Print[Max = , Max[n1, n2]] > Return[Max[n1, n2]]];]; > Print[func[g]] > === Subject: Re: Compatibility issue in Mathematica 7 To the best of my knowledge, you can save your version 6 or 7 notebook and open it in versions down to at least 5. Given that it is plain ASCII earlier versions should be able to open it. The Notebook[ ] function appeared in version 3, so I guess that presentable results will be possible as old as that. Whether or not you can use it is another thing. Obviously, as the version number increases so does the functionality and you can't use the added functionalities in older versions. Other compatibility issues involve existing functions that have changed in options (like the PlotJoined to Joined change in ListPlot) or behavior (like the output of graphics shown as a direct result of command execution instead of being a side effect and consting of Mathematica primitives instead of postscript). There were a few of this type going from 5 to 6, but I haven't seen many going from 6 to 7. Some functionality from packages has been moved to the kernel. > Hello everybody, > I've been using Mathematica 6 for a while and now I'm about to > purchase version 7: I was wondering whether it's possible, in the > latest version, to save a notebook which can be subsequently opened > (and edited) with version 6. To the best of my knowledge, this was not > possible in version 6 (saving for, say, version 5) and it's something > that has always buggered me quite a lot, because I often have the > necessity to exchange notebooks with people who haven't the same > version as me. Daniele === Subject: Re: Compatibility issue in Mathematica 7 that depends, if you have just some algebraic computations it will work fine, if you have a lot of image processing in it it will not. The best way is to look what's new in version 7 and to decide how much you will/would use of it. Jens > Hello everybody, > I've been using Mathematica 6 for a while and now I'm about to > purchase version 7: I was wondering whether it's possible, in the > latest version, to save a notebook which can be subsequently opened > (and edited) with version 6. To the best of my knowledge, this was not > possible in version 6 (saving for, say, version 5) and it's something > that has always buggered me quite a lot, because I often have the > necessity to exchange notebooks with people who haven't the same > version as me. Daniele > === Subject: Re: Compatibility issue in Mathematica 7 >Hello everybody, I've been using Mathematica 6 for a while and now >I'm about to purchase version 7: I was wondering whether it's >possible, in the latest version, to save a notebook which can be >subsequently opened (and edited) with version 6. To the best of my >knowledge, this was not possible in version 6 (saving for, say, >version 5) and it's something that has always buggered me quite a >lot, because I often have the necessity to exchange notebooks with >people who haven't the same version as me. I have had no difficulty with my MacBook Pro (Intel processor) other than getting a warning message which I simply ignore. And I have done more than just open the notebook since my goal was to edit it for usage by colleagues that have access to version 6 but not version 7. But having said this, I have encountered some difficulty after opening a notebook created in version 7 on my MacBook with version 6 on a Windows based machine. Opening seemed to work OK (getting the expected warning message). But attempts to edit the message on the Windows machine caused Mathematica version 6 to crash. I haven't yet taken time to determine what is causing the crash. === Subject: Re: Compatibility issue in Mathematica 7 Daniele === Subject: Re: Wolfram WorkBench and iDisk I must agree about the pitiful iDisk (MobileMe, it's now called). Bobby > I'm a mac fan but would not recommend iDisk for anything other than a > good > laugh.An excellent alternative [ that works ] is Dropbox. I think its > free > for the first 2GB. You can also back-track to recover previously deleted > stuff I think. Peter 2009/3/18 robert prince-wright > I have a MacBook and an i-Mac and have been struggling with version >> control. I've also been wondering how to keep my Mathematica work >> totally >> safe. >> My first attempt to control versions and keep files safe was to start >> using >> Apple's i-Disk. This ensured my mac-Book and i-Mac were always >> synchronized. >> All was going well, until i deleted a file from a local copy on the >> MacBook, >> only to find it was deleted on the i-Disk and i-Mac. That led me to read >> horror stories online by people who have lost all their i-Disk and local >> files! This lead me to think I should not Auto Sync the computers - have >> others had similar problems and do you have a better approach? >> I spoke to someone at Apple Store and they suggested I use the iDisk to >> provide offsite storage and accessibility, and that I write an Automated >> Script to copy the i-Disk to my i-Mac. That way its backed up on my Time >> Capsule. Has anyone written this script already? If so I would >> appreciate a >> copy. >> Now the main question is whether anyone has tried using Workbench with a >> 'WolframWorkbenchBase' folder located on an i-Disk? I am wondering >> whether >> this is sensible or not if so I can use the approach described above. >> What do you all think? > > -- DrMajorBob@bigfoot.com === Subject: Re: Wolfram WorkBench and iDisk I'm a mac fan but would not recommend iDisk for anything other than a good laugh.An excellent alternative [ that works ] is Dropbox. I think its free for the first 2GB. You can also back-track to recover previously deleted stuff I think. Peter 2009/3/18 robert prince-wright I have a MacBook and an i-Mac and have been struggling with version > control. I've also been wondering how to keep my Mathematica work totally > safe. My first attempt to control versions and keep files safe was to start using > Apple's i-Disk. This ensured my mac-Book and i-Mac were always synchronized. > All was going well, until i deleted a file from a local copy on the MacBook, > only to find it was deleted on the i-Disk and i-Mac. That led me to read > horror stories online by people who have lost all their i-Disk and local > files! This lead me to think I should not Auto Sync the computers - have > others had similar problems and do you have a better approach? > I spoke to someone at Apple Store and they suggested I use the iDisk to > provide offsite storage and accessibility, and that I write an Automated > Script to copy the i-Disk to my i-Mac. That way its backed up on my Time > Capsule. Has anyone written this script already? If so I would appreciate a > copy. Now the main question is whether anyone has tried using Workbench with a > 'WolframWorkbenchBase' folder located on an i-Disk? I am wondering whether > this is sensible or not if so I can use the approach described above. What do you all think? > -- Peter Lindsay === Subject: Re: Wolfram WorkBench and iDisk Have you looked into using a standard revision control system, such as SVN? It also provides integrity across multiple files in a project. I am using myself, for example, Subversion (SVN). For a hosted (versus local) repository I have an account on cvsdude for non-public items. But it's just one of many possible setups. Best, Hans-Martin === Subject: Re: PlotMarkers bug? >> try >> In[1]:= >> ListPlot[{1}, PlotMarkers -> {[FilledSquare]}] >> click on the output and Save As...EPS. >> When I do that, the FilledSquare isn't actually in the .eps file. >> Does anyone know a workaround? >> j >> PS >> In[2]:= >> {$Version, $ReleaseNumber} >> Out[2]= >> {7.0 for Mac OS X x86 (64-bit) (February 19, 2009), 1} Hmm. I wasn't able to reproduce your problem on a Mac or Windows machine > running 7.0.1 (didn't try earlier versions, but I know of no reason they > should > differ in this regard). Weird. Look at Out[2], above. It says 7.0, but I'm pretty sure that the onl= y version of Mathematica on my machine is 7.0.1. > How did you confirm that the [FilledSquare] character wasn't there? Double-clicking the EPS file brings up Preview. It's not there in Preview. It also is not there in Illustrator. As for a workaround, Export[tmp.eps, ListPlot[{1}, PlotMarkers -> {[FilledSquare]}]] works j > I tried > opening the resulting image in GhostScript, which showed it without a pro= blem. > However, for example, I know that there have been problems with Adobe > Illustrator not being able to properly interpret some EPS generated by > Mathematica. Apparently Illustrator only understands some subset of EPS,= but > it's not clear to us what that subset is. > John Fultz > jfultz@wolfram.com > User Interface Group > Wolfram Research, Inc. -- Joshua A. Solomon http://www.staff.city.ac.uk/~solomon === Subject: Incompatible units? Hi Today I struggled with the units package - again... Let me show you what I did: Dynamic[Subscript[[Tau], p]] Subscript[l, case] [Lambda] = Convert[Subscript[l, case]/Dynamic[Subscript[[Tau], p]], 1] This input results in: 27.4889 Meter Milli 281 Meter Milli Convert::incomp : Incompatible units in (281 Meter Milli)/(27.4889 Meter Milli) and 1. (281 Meter Milli)/(27.4889 Meter Milli) If I don't use dynamic but constant tau_p everything is fine... So Mathematica isn't able to to reduce this fraction? What's the reason for this behaviour and what can I do about it? Mathias === Subject: FindRoot and evaluations Let's say: F[x_]:=Module[ {x0=x}, Print[x0]; SomethingLongAndHeavy[x0] ]; now I do: FindRoot[F[x],{x,0}] and it prints: x because it first attempts to evaluate F[x] in a symbolic form. I don't want this. Because SomethingLongAndHeavy is a recursion set of relations which generates a polynomial of order... too much. What I would like to see is: 0.0001 0.0002 ... So that F[x] is treated as a blackbox, and some Newton or Bisection method is applied on this blackbox. How to do that? Davide PS: Based on previous discussions I already tried to play with attributes HoldAll and option Evaluated, with no success. === Subject: contourlabels in contour plot I was wondering that in Mathematica 6 how can we define a specific size and special font for the labels of a certain contour plot. As we change the size of contourplot, the labels stay same size! For example ContourPlot[a+b,{a, 0, 4}, {b, 0, 1.3}, ColorFunction -> GrayLevel, Axes -> True, AxesLabel -> {a, b}, LabelStyle -> Directive[Black, Large, Bold], ContourLabels -> Automatic, Frame -> False, PlotRange -> {16, 24}, Contours -> 10] we always get one size for the contourlabels. Pasha === Subject: Re: Show problem: combining ListPlot and Plot Works for me (under v. 7); replace PlotJoined with Joined. Also, to remove the squishedness of the plot, use, in the outer Show, the AspectRatio -> 1/GoldenRatio option. C.O. > The following extract exemplifies a plot technique I used to > combine ListPlot and a Plot under v 2.2. It worked fine > under 3.0, 4.1,4.2 and 5.1. But students using this under 6.0 and > 7.0 for a HW report the plot frame squished, and that line colors > disagree with the title. Question: can this be fixed in DisplayChannel=$DisplayFunction; > If [$VersionNumber>=6.0, DisplayChannel=Print]; > (* fix for Mathematica 6 & later *) > Off[General::spell1]; Off[General::spell]; ClearAll[r]; > vFEM={{4., 0.054}, {7., 0.0395}, {10., 0.037}}; > vexact=0.1905*(1/r + r/100); rbeg=4.; rend=10.; > pFEM=ListPlot[vFEM,PlotJoined->True,PlotStyle->{RGBColor[1,0,0]}, > DisplayFunction->Identity]; > pexact=Plot[vexact,{r,rbeg,rend},PlotStyle->{RGBColor[0,0,0]}, > DisplayFunction->Identity]; > Show[Graphics[AbsoluteThickness[2]],pexact, > pFEM,TextStyle->{FontFamily->Times,FontSize->12}, > GridLines->Automatic,Axes->True,PlotRange->All, > PlotLabel->Radial displacement (black=exact,red=FEM), > Frame->True, DisplayFunction->DisplayChannel]; -- 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: Show problem: combining ListPlot and Plot This is how I would do it using Presentations: Needs[Presentations`Master`] vFEM = {{4., 0.054}, {7., 0.0395}, {10., 0.037}}; vexact = 0.1905*(1/r + r/100); rbeg = 4.; rend = 10.; Draw2D[ {AbsoluteThickness[2], Red, ListDraw[vFEM, Joined -> True], Black, Draw[vexact, {r, rbeg, rend}]}, AspectRatio -> 1/2, PlotRange -> All, Frame -> True, GridLines -> Automatic, GridLinesStyle -> GrayLevel[.8], PlotLabel -> Radial displacement (black=exact,red=FEM), BaseStyle -> {FontFamily -> Times, FontSize -> 12}, ImageSize -> 400] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ The following extract exemplifies a plot technique I used to combine ListPlot and a Plot under v 2.2. It worked fine under 3.0, 4.1,4.2 and 5.1. But students using this under 6.0 and 7.0 for a HW report the plot frame squished, and that line colors disagree with the title. Question: can this be fixed in DisplayChannel=$DisplayFunction; If [$VersionNumber>=6.0, DisplayChannel=Print]; (* fix for Mathematica 6 & later *) Off[General::spell1]; Off[General::spell]; ClearAll[r]; vFEM={{4., 0.054}, {7., 0.0395}, {10., 0.037}}; vexact=0.1905*(1/r + r/100); rbeg=4.; rend=10.; pFEM=ListPlot[vFEM,PlotJoined->True,PlotStyle->{RGBColor[1,0,0]}, DisplayFunction->Identity]; pexact=Plot[vexact,{r,rbeg,rend},PlotStyle->{RGBColor[0,0,0]}, DisplayFunction->Identity]; Show[Graphics[AbsoluteThickness[2]],pexact, pFEM,TextStyle->{FontFamily->Times,FontSize->12}, GridLines->Automatic,Axes->True,PlotRange->All, PlotLabel->Radial displacement (black=exact,red=FEM), Frame->True, DisplayFunction->DisplayChannel]; === Subject: Re: Show problem: combining ListPlot and Plot set the aspect ratio by hand, i.e., DisplayChannel = $DisplayFunction; If[$VersionNumber >= 6.0, DisplayChannel = Print]; (*fix for Mathematica 6& later*) Off[General::spell1]; Off[General::spell]; ClearAll[r]; vFEM = {{4., 0.054}, {7., 0.0395}, {10., 0.037}}; vexact = 0.1905*(1/r + r/100); rbeg = 4.; rend = 10.; pFEM = ListPlot[vFEM, PlotJoined -> True, PlotStyle -> {RGBColor[1, 0, 0]}, DisplayFunction -> Identity]; pexact = Plot[vexact, {r, rbeg, rend}, PlotStyle -> {RGBColor[0, 0, 0]}, DisplayFunction -> Identity]; Show[Graphics[AbsoluteThickness[2]], pexact, pFEM, TextStyle -> {FontFamily -> Times, FontSize -> 12}, GridLines -> Automatic, Axes -> True, PlotRange -> All, PlotLabel -> Radial displacement (black=exact,red=FEM), Frame -> True, DisplayFunction -> DisplayChannel, AspectRatio -> 1] Jens > The following extract exemplifies a plot technique I used to > combine ListPlot and a Plot under v 2.2. It worked fine > under 3.0, 4.1,4.2 and 5.1. But students using this under 6.0 and > 7.0 for a HW report the plot frame squished, and that line colors > disagree with the title. Question: can this be fixed in DisplayChannel=$DisplayFunction; > If [$VersionNumber>=6.0, DisplayChannel=Print]; > (* fix for Mathematica 6 & later *) > Off[General::spell1]; Off[General::spell]; ClearAll[r]; > vFEM={{4., 0.054}, {7., 0.0395}, {10., 0.037}}; > vexact=0.1905*(1/r + r/100); rbeg=4.; rend=10.; > pFEM=ListPlot[vFEM,PlotJoined->True,PlotStyle->{RGBColor[1,0,0]}, > DisplayFunction->Identity]; > pexact=Plot[vexact,{r,rbeg,rend},PlotStyle->{RGBColor[0,0,0]}, > DisplayFunction->Identity]; > Show[Graphics[AbsoluteThickness[2]],pexact, > pFEM,TextStyle->{FontFamily->Times,FontSize->12}, > GridLines->Automatic,Axes->True,PlotRange->All, > PlotLabel->Radial displacement (black=exact,red=FEM), > Frame->True, DisplayFunction->DisplayChannel]; > === Subject: Re: Exporting data into a file, OpenWrite sure, but the guy obviously had difficulty typing and the word notepad with lowercase n is generic. I take your point of course that Notepad is a windoze program but its always worth pointing out to people that Microsoft is not the only way. Peter 2009/2/26 Sjoerd C. de Vries : > I know, but the guy mentioned Notepad which is a PC program. > no double-slashes for me thank you very much - I've got a Mac. >> 2009/2/24 Sjoerd C. de Vries : > When you use Export, the file will be created in the current > working directory. >> I might add ...unless you include the full path to the file in the >> filename (using double slashes to separate directories and files, as a >> slash is used as an escape character in strings) > === Subject: Do What I Mean - a suggestion for improving Mathematica experience A few days ago I posted that Mathematica should have a DWIM feature - Do What I Mean. In InterLisp, in the 80's, the DWIM facility was hooked into error messages, and when invoked on a user error would poke around on the stack and in the environment using some rules to describe common error situations and it would uncover user errors and offer to correct them. Many of the errors were simple spelling errors and it would correct a misspelled variable name if it found an unbound variable but a similarly spelled variable was bound in the environment. Mathematica could benefit from this, and in fact, we at mathgroup could supply the rules (and framework) as a useful group project. If some guru would write the framework - trapping error messages somehow, perhaps when they were written to the $Messages channel (by replacing the default $Messages channel with something that would hook into the DWIM function), or perhaps with some other hook like redefining Message[] - then the rest of us could supply rules for the common errors. Especially the common errors we see puzzling Mathematica newbies on this list. I would suggest that the rules provide messages, hopefully with hyperlinks to the documentation. A true DWIM might also offer to rewrite the current expression and try it again, but I don't know if that can be done given the hooks into Mathematica that are currently available. Some situations that could be addressed are: under evaluation and find (unevaluated) symbols like xy of the form where both and were either symbols used in the expression or symbols bound in the environment. Rule would explain the problem and offer to rewrite expression and try again. 2. Some expression using a user-defined function causes an error when evaluating, or doesn't evaluate. Looking at the function, a rule finds function calls where the function arguments' patterns include _Integer or similar but the arguments given to it are not integers. Rule points to documentation describing argument types required by the called function. 3. Similar to 2 above, but it finds function calls that do numeric evaluation only or are optimized for numeric evaluation but the arguments given to it are symbolic. 4. Result returned is machine precision very close to zero (that is, with large negative exponent), but an error message complained of singularity, or other ill-conditioning. Rule points to documentation explaining about machine precision, and/or singularity, and offers to retry the expression with more digits of precision, rewriting the expression to achieve this. Actually, now that I think of it, the DWIM facility needs also to be invoked by the user because some of these situations don't cause error messages, but only cause (wholly or partially) unevaluated expressions. So maybe the user could be trained to type a word, like Explain[] after he didn't get the result he wanted and the DWIM facility would look at the In[] and Out[] arrays to find out what he's been doing recently. I would be glad to contribute rules to the framework ... but I'm not yet up to writing the framework. Hopefully one of the gurus here will find this interesting (and possible) and provide a framework. Then the rest of us could contribute rules that would improve the Mathematica experience for all newcomers. (AES, I'm looking at you! :-) ) -- David === Subject: Re: newbie: programmatic sequence of plots? >> Loops themselves only have a null return value. Doh! I was assuming ListPlot would have a side effect. > >> return a list of these plots additionaly or instead of just >> printing them, so that you can use ListAnimation or TabView or >> whatever you like for displaying them. And the way to do that is > >> Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; >> a = 3.5; >> nRecurr = 50; >> yinit = 0.1; >> yinc = 0.01; >> yfinal = 0.2; >> out = {}; (* modification here *) >> For[y0 = yinit, y0 <= yfinal, y0 += yinc, >> AppendTo[out, (* modification here *) >> ListPlot[ >> RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, >> y, {n, 1, nRecurr}]]]; >> ]; >> out (* modification here *) So I modified that to do For[y0 = yinit, y0 <= yfinal, y0 += yinc, > AppendTo[out, > ListPlot[ > RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, > y, {n, 1, nRecurr}], Joined -> True > ] > ]; > ]; > ListAnimate[out] which is even better than printing a list of static plots. just another suggestion for improvement: In Mathematica loops are often only the second best solution, and using AppendTo within a loop is rather inefficient (probably not a problem in this example). I think this is close to what you would use after using Mathematica for a while: plotlst = Table[ ListPlot[ RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1, nRecurr}], Joined -> True ], {y0, yinit, yfinal, yinc} ]; ListAnimate[plotlst] (I haven't tested the code, but think it should work) hth, albert === Subject: Re: Bug in Export to HTML in v7? On Feb 27, 12:13 pm, Sjoerd C. de Vries this makes the file name a directory name? The following very handy code to save a notebook as HTML and to follow > closed links used to work in v6 no longer works in v7. Was wondering > if there is a workaround: Export[~/tmp/, EvaluationNotebook[], HTML, > ConvertClosed -> LinkedPage]; (I put this code is in the notebook I am saving itself so it appears > in the HTML output, which is OK). is not a bug, but something strange I must have done. I had a large notebook that generated an error when I executed a similar Export command in v7, I would load it in v6 and it would execute fine. But now the notebook executes without error in v7. Art. === Subject: Re: question about simplify function >This seems like a basic question, but I can't see the answer: Why >doesn't either the Simplify or FullSimplify function transform the >expression x/(xy) into 1/y? When I substitute a specific value in >for x, the simplification occurs as expected, e.g., 4/(4y) >transforms to 1/ y. Puzzling. Jack If you literally entered x/(xy) then Mathematica sees this as dividing x by the variable xy, not the product of two variables. Check you code. You need a space between the x and y for Mathematica to see this as a product not a new variable. === Subject: Re: Error message when using NonlinearRegress >I have been encountering an error message when using >NonlinearRegress that I have not seen before: >FindFit::fmmp: Machine precision is insufficient to achieve the >requested accuracy or precision. >My question is, can I still trust the fit it gives me? The best answer any one can give based on the information provided is maybe. >Or, how would I go about finding a fit that doesn't give this error messag= e? Try increasing the working precision and the precision of your input. =46or more definitive and useful answers, you need to provide details of what you are doing preferably with the code you are using. === Subject: simplifying quotient of piecewise functions I'm solving some conditional probability density functions. One solution involves a division such that the numerator is (1) [Piecewise]1/5 (2 [Chi]+[Psi]) {0<=[Chi]<=2,0<=[Psi]<=1} and the denominator is (2) [Piecewise]((2 (2+[Psi]))/5) 0<=[Psi]<=1 For the quotient, Mathematica 7 is just giving me (1) over (2), rather than (3) [Piecewise]((2 [Chi]+[Psi])/(2 (2+[Psi]))) {0<=[Chi]<=2,0<=[Psi]<=1} even when I append // Simplify and re-evaluate. Am I using the wrong syntax to get the simplified quotient? or am I wrong to expect (3)? === Subject: wrong solution for double integral of piecewise function? wrong solution for double integral of piecewise function I've got a function f[[Chi]_, [Psi]_] = {Piecewise[{{k, {a <= [Chi] <= b, a <= [Psi] <= b}}}, 0]} I'm attempting to solve for k such that f becomes a probability density function by applying the normalization constraint, i.e. solving for k such that the double (indefinite) integral of f equals 1. I can do this by hand pretty easily, integrating first/inside WRT psi and second/outside WRT chi, and I get (1) k = 1/((b-a)^2) I don't have the world's greatest calculus chops, but that looks correct to me. (Am I missing something?) However, when I use Mathematica to Solve[ First[ Integrate[ Integrate[ f[[Chi], [Psi]], {[Psi], -[Infinity], [Infinity]} ], {[Chi], -[Infinity], [Infinity]} ] ] == 1, k ] I get (2) {{k -> -(1/((a - b)^2 (-1 + UnitStep[a - b])))}} which seems wrong to me, though I'll admit I don't know what UnitStep means. So I'm wondering * does (1) = (2)? or * have I made a syntax error? or * is this just really hard to solve symbolically? If so, is there a better way to setup this function and its solution? === Subject: Re: Dificulty on Integrate function! Sorry, I meant d in the denominator (not t), and integrating d (not t) on an interval starting with 0. Bobby > You want to integrate an equation (but equations CAN'T be integrated) > and anyway, you haven't given us an equation. (Just an expression.) Indefinite integration of that expression w.r.t. b, c, and d would still > give a function of FIVE variables -- not just t and a. And definite integration w.r.t. b, c, and d probably isn't possible, > either -- I'm pretty sure there's no closed form expression for it, when > t and a are undefined (variable). So you'll have to rein in your wants, here. What CAN be done (maybe) is > something like f[t_, a_][b_, c_, > d_] = (5.985857026794833*^-14*(14 + c)^2.37* > E^(-0.0003630681026445808*(-50.29 + b)^2 - c/41 - > 0.0003125*(-43.7 + d)^2 - b/d + t/d - > 1.1985780806058064*^-6*(-3535.42 + > c + ((a - c)*E^((-b + t)/d))/(t/b)^(b/d))^2))/(t/b)^(b/ > d); > g[t_?NumericQ, a_?NumericQ] := > NIntegrate[f[t, a][b, c, d], {b, 0, 170.}, {c, 0, 400.}, {d, 0, 170.}] g[0.5, 0.3] But, if you execute that, you'll see that NIntegrate has convergence > problems. Experiment with various options to NIntegrate and maybe, for some values > of t and a, you can get convergence. Your expression has t in a couple of denominators, but you want to > integrate with t from 0 to (doesn't matter what). That in itself may > make convergence impossible. So changing the lower limit might help a > lot. Bobby >> I got a problem in integrating the expression (given below in input >> form) on Mathematica. Please give me some hints or a way around to get >> the solutions. . I want to integrate the equation with respect to b, >> c, and d. So that I get an equation only in terms of t and a. I tried >> to use Integrate function in Mathematica both in the form of definite >> and indefinite integral but it could not turn out the result. If the >> indefinite integral is not working the ranges of integration for >> definite integral shall be the following {b, 0, 170}, {c, 0, 400} and >> {d, 0,170}. >> (5.985857026794833*^-14*(14 + c)^2.37*E^(-0.0003630681026445808* >> (-50.29 + b)^2 - c/41 - 0.0003125*(-43.7 + d)^2 - b/d + t/d - >> 1.1985780806058064*^-6*(-3535.42 + c + ((a - c)*E^((-b + t)/d))/(t/b)^ >> (b/d))^2))/(t/b)^(b/d) >> Please please help me. If I could not get this solution I have to >> discard so many things I spent considerable time on! >> Negede > -- DrMajorBob@bigfoot.com === Subject: Re: Dificulty on Integrate function! You want to integrate an equation (but equations CAN'T be integrated) and anyway, you haven't given us an equation. (Just an expression.) Indefinite integration of that expression w.r.t. b, c, and d would still give a function of FIVE variables -- not just t and a. And definite integration w.r.t. b, c, and d probably isn't possible, either -- I'm pretty sure there's no closed form expression for it, when t and a are undefined (variable). So you'll have to rein in your wants, here. What CAN be done (maybe) is something like f[t_, a_][b_, c_, d_] = (5.985857026794833*^-14*(14 + c)^2.37* E^(-0.0003630681026445808*(-50.29 + b)^2 - c/41 - 0.0003125*(-43.7 + d)^2 - b/d + t/d - 1.1985780806058064*^-6*(-3535.42 + c + ((a - c)*E^((-b + t)/d))/(t/b)^(b/d))^2))/(t/b)^(b/ d); g[t_?NumericQ, a_?NumericQ] := NIntegrate[f[t, a][b, c, d], {b, 0, 170.}, {c, 0, 400.}, {d, 0, 170.}] g[0.5, 0.3] But, if you execute that, you'll see that NIntegrate has convergence problems. Experiment with various options to NIntegrate and maybe, for some values of t and a, you can get convergence. Your expression has t in a couple of denominators, but you want to integrate with t from 0 to (doesn't matter what). That in itself may make convergence impossible. So changing the lower limit might help a lot. Bobby I got a problem in integrating the expression (given below in input > form) on Mathematica. Please give me some hints or a way around to get > the solutions. . I want to integrate the equation with respect to b, > c, and d. So that I get an equation only in terms of t and a. I tried > to use Integrate function in Mathematica both in the form of definite > and indefinite integral but it could not turn out the result. If the > indefinite integral is not working the ranges of integration for > definite integral shall be the following {b, 0, 170}, {c, 0, 400} and > {d, 0,170}. (5.985857026794833*^-14*(14 + c)^2.37*E^(-0.0003630681026445808* > (-50.29 + b)^2 - c/41 - 0.0003125*(-43.7 + d)^2 - b/d + t/d - > 1.1985780806058064*^-6*(-3535.42 + c + ((a - c)*E^((-b + t)/d))/(t/b)^ > (b/d))^2))/(t/b)^(b/d) Please please help me. If I could not get this solution I have to > discard so many things I spent considerable time on! > Negede > -- DrMajorBob@bigfoot.com === Subject: Re: Dificulty on Integrate function! and if there exist no closed form of the integral ?? You should think about asymptotic techniques to approximate the integral. Jens I got a problem in integrating the expression (given below in input > form) on Mathematica. Please give me some hints or a way around to get > the solutions. . I want to integrate the equation with respect to b, > c, and d. So that I get an equation only in terms of t and a. I tried > to use Integrate function in Mathematica both in the form of definite > and indefinite integral but it could not turn out the result. If the > indefinite integral is not working the ranges of integration for > definite integral shall be the following {b, 0, 170}, {c, 0, 400} and > {d, 0,170}. (5.985857026794833*^-14*(14 + c)^2.37*E^(-0.0003630681026445808* > (-50.29 + b)^2 - c/41 - 0.0003125*(-43.7 + d)^2 - b/d + t/d - > 1.1985780806058064*^-6*(-3535.42 + c + ((a - c)*E^((-b + t)/d))/(t/b)^ > (b/d))^2))/(t/b)^(b/d) Please please help me. If I could not get this solution I have to > discard so many things I spent considerable time on! > Negede > === Subject: Re: Transparent background with PNG I wondered how could it be, that I overlooked this simple solution: Export[..., Background -> None], when I realized, I didn't. Actually, when saving any graphics object with this method indeed produces transparent background, *however* importing the result into Corel Photopaint X3 the figure does show up with a solid black background. That was the cause that made me write the post. It was pure chance that once I opened Photopaint X4 instead of X3 by mistake, I discovered that the background is indeed transparent. So it seems that it is a Corel X3 issue: it does not support alpha channels for PNG files. Istv=E1n === Subject: Re: question about simplify function you need a space or a * between x and y. Jens > This seems like a basic question, but I can't see the answer: Why > doesn't either the Simplify or FullSimplify function transform the > expression x/(xy) into 1/y? When I substitute a specific value in for > x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ > y. Puzzling. > Jack > === Subject: Re: question about simplify function x/(x y) // Simplify 1/y Don't you see the difference between x y and xy? Bobby > This seems like a basic question, but I can't see the answer: Why > doesn't either the Simplify or FullSimplify function transform the > expression x/(xy) into 1/y? When I substitute a specific value in for > x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ > y. Puzzling. > Jack > -- DrMajorBob@bigfoot.com === Subject: Re: question about simplify function > This seems like a basic question, but I can't see the answer: Why > doesn't either the Simplify or FullSimplify function transform the > expression x/(xy) into 1/y? When I substitute a specific value in for > x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ > y. Puzzling. > Jack Forget it; I figured it out. Mathematica doesn't recognize xy as multiplication. You either need to leave a space (x y) or use the asterisk (x*y) === Subject: Re: question about simplify function > This seems like a basic question, but I can't see the answer: Why > doesn't either the Simplify or FullSimplify function transform the > expression x/(xy) into 1/y? When I substitute a specific value in for > x, the simplification occurs as expected, e.g., 4/(4y) transforms > to 1/ > y. Puzzling. Both Simplify and FullSimplify work for me. Did you remember the space between the x and the y, or did you enter xy with no space? --Lou Talman Department of Mathematical and Computer Sciences Metropolitan State College of Denver === Subject: Re: question about simplify function > This seems like a basic question, but I can't see the answer: Why > doesn't either the Simplify or FullSimplify function transform the > expression x/(xy) into 1/y? When I substitute a specific value in for > x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ > y. Puzzling. > Jack > Mathematica 7 In[1]:= Simplify[x/(x*y)] Out[1]= 1/y --Nasser === Subject: Re: question about simplify function Insert a space between x and y (xy isn't x times y) Adriano Pascoletti 2009/2/27 doesn't either the Simplify or FullSimplify function transform the > expression x/(xy) into 1/y? When I substitute a specific value in for > x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ > y. Puzzling. > Jack === Subject: Re: question about simplify function > This seems like a basic question, but I can't see the answer: Why > doesn't either the Simplify or FullSimplify function transform the > expression x/(xy) into 1/y? When I substitute a specific value in for > x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ > y. Puzzling. Because if you type xy without a space between the two letters, Mathematica interprets it as single variable named xy, which it obviously can't simply. x/(x y) or x/(x*y) will do what you want. Personally, I don't think the convenience of using a space for multiplication has turned out to be worth the trouble, but clearly WRI disagrees with me. Pillsy === Subject: Need some help on Integration I got difficulty in integrating the following equation with respect to the variables b, c, and d. If possible indefinite integration otherwise definite according to the following ranges {b, 1, 170}, {c,0,400} and {d, 1, 170} (5.985857026794833*^-14*(14 + c)^2.37*E^(-0.0003630681026445808*(-50.29 + b)^2 - c/41 - 0.0003125*(-43.7 + d)^2 - b/d + t/d - 1.1985780806058064*^-6*(-3535.42 + c + ((a - c)*E^((-b + t)/d))/(t/b)^(b/d))^2))/(t/b)^(b/d) Please, give me suggestions, round about ways or a solution. Negede === Subject: Re: Can't quite figure out tensors I'm trying to write code that will produce Christoffel symbols for > various coordinate systems. I would like to use the definition that > yields Gamma_ij^k as the partial of the covariant basis e_i with > respect to variables x^j dotted with the contravariant vector e^k. So > far I have z[r_, theta_] := {r Cos[theta], r Sin[theta]} > ei[r_, theta_] := {Derivative[1, 0][z][r, theta], > Derivative[0, 1][z][r, theta]} > gij[r_, theta_] := ei[r, theta].Transpose[ei[r, theta]] > gIJ[r_, theta_] := Inverse[gij[r, theta]] > deidxj[r_, theta_] := {Derivative[1, 0][zi][r, theta], > Derivative[0, 1][zi][r, theta]} and now i need to form the tensor product > deidxj * gIJ * ei and it has proven to be a bit to intense for me to pull off. Could > someone show me how to do that? > Aaron > Hi Aaron, I made a small package, which is able to calculate the Christoffel symbols, the curvature tensor and so on from a given set of variables and a metric tensor. you can download it from Documentation and examples are here: usages and examples are in German though -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Can't quite figure out tensors I'm trying to write code that will produce Christoffel symbols for > various coordinate systems. I would like to use the definition that > yields Gamma_ij^k as the partial of the covariant basis e_i with > respect to variables x^j dotted with the contravariant vector e^k. So > far I have z[r_, theta_] := {r Cos[theta], r Sin[theta]} > ei[r_, theta_] := {Derivative[1, 0][z][r, theta], > Derivative[0, 1][z][r, theta]} > gij[r_, theta_] := ei[r, theta].Transpose[ei[r, theta]] > gIJ[r_, theta_] := Inverse[gij[r, theta]] > deidxj[r_, theta_] := {Derivative[1, 0][zi][r, theta], > Derivative[0, 1][zi][r, theta]} and now i need to form the tensor product > deidxj * gIJ * ei and it has proven to be a bit to intense for me to pull off. Could > someone show me how to do that? > Look for the Christoffel and related functions from General Relativity in the example notebooks of Zimmerman/Olness Mathematica for Physicists You can download the notebooks from http://library.wolfram.com/infocenter/Books/4539/ -- Roland Franzius === Subject: Re: How to Export the Manipulate Wayne I'd never thought about doing this before, but it turns out to be easy. Export[filename.avi,Manipulate[...your code here...]] Do the manipulations and click on the code line and you'll find your file. ekt > Hi ,all i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF > figure, but dont know how to Export the Manipulate produced > animations,can someone here drop me a hint ? > Wayne. > === Subject: Re: How to Export the Manipulate the non-interactive version make a flash video, the interactive variant need a MathPlayer and the translation of you code into MathPlayer. Jens > Hi ,all i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF > figure, but dont know how to Export the Manipulate produced > animations,can someone here drop me a hint ? > Wayne. > === Subject: Re: Experimental Mathematica debugger > Hi David, another great addition from you, thank's a lot. There is a samll bug with the conditional break point window. It is not possible to input any text because it does not take the focus. I have Mathematica version 7 on Vista. thank's again, Daniel that problem - the result of some last minute changes.... The conditionals window now looks a little ugly, but I will fix that in due course. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: procedures > Simple question: Unfortunately no simple answer. > how can I in mathematica write a complex function? What do you mean by complex. > What I need to do is (pseudocode) FunctionToCode[x,n] { D[x_,n]:= something symbolic Do[ D[x,s]=D[x,s], {s,0,n} ]; return D[x,s] > Clear[D] > } Your meaning is not clear, D[x_,n] defines a function for a fixed variable n, I think you meant D[x_,n_]. Secondly is D supposed to have side effects? What is the purpose of assigning its value to itself? Third, s only has value within the Do loop, do you mean to return D[x,n]? Fourth, why clear D? In short the pseudocode raises more questions than one could answer. Sseziwa Mukasa === Subject: Re: procedures No clue what you're trying to do. D is a built-in symbol for differentiation, so you can't write D[x,s]=(anything) Even if you could, what could D[x,s]=D[x,s] possibly accomplish, since both arguments to Set are the same? Beyond that, there's no construct like function[anything] {anything else} And the list goes on. Bobby > Simple question: > how can I in mathematica write a complex function? > What I need to do is (pseudocode) FunctionToCode[x,n] { D[x_,n]:= something symbolic Do[ D[x,s]=D[x,s], {s,0,n} ]; return D[x,s] > Clear[D] > } Davide > -- DrMajorBob@bigfoot.com === Subject: Re: procedures you wish to assign n+1 times D[x,s]=D[x,s] ?? Or do you mean D[x_,n_]:=something symbolic Table[D[x,s],{s,0,n}] ?? Jens > Simple question: > how can I in mathematica write a complex function? > What I need to do is (pseudocode) FunctionToCode[x,n] { D[x_,n]:= something symbolic Do[ D[x,s]=D[x,s], {s,0,n} ]; return D[x,s] > Clear[D] > } Davide > === Subject: Re: procedures > What is the purpose of assigning its value to >> itself? I am evaluating a recursive function. > I want to store every computed value in such a way that next time the > code calls it, it remembers if it has already evaluated it. > So while I need := for definition of the recursive functions, I use > the > Do loop to assign actual values to the array. Do you have a better idea? You can implement functions with memory as F[x_]:=f[x]=(*body goes here*) This would obviate the need for Do loop, just evaluating D[x,n] would be sufficient. Search for FunctionsThatRememberValuesTheyHaveFound in the Mathematica help documentation (for v7). > I now have another problem, anyway! When I do FindRoot[f[x],{x,0}] it looks for all instances of x in the > definition of the function, and THEN evaluate the function for the > symbol X. I think this occurs because FindRoot defaults to Newton's method and it needs to take the derivative of the expression. > What I want is to override this symbolic method and call f[x] with the > numerical value of x, since in the definition of f[x] I have recursive > functions that would imply to evaluate a huge polynomial of x, and > keeping track of all the terms is really lengthy. > While if I substitute x=x0 at each recursive step, the computation is > less costy. So is there a way to tell mathematica in FindRoot to call the function > with numerical values, like it was a black box? This comes up from time to time on this mailing list. The usual suggestion is to make the function definition valid only for numeric arguments see browse_thread/thread/a076ff6d9b72b462 for example. Hope that helped, Sseziwa Mukasa === Subject: Re: procedures > What is the purpose of assigning its value to > itself? I am evaluating a recursive function. I want to store every computed value in such a way that next time the code calls it, it remembers if it has already evaluated it. So while I need := for definition of the recursive functions, I use the Do loop to assign actual values to the array. Do you have a better idea? > Third, s only has value within the Do loop, do you mean to > return D[x,n]? Yes. > Fourth, why clear D? In short the pseudocode raises > more questions than one could answer. Anyway I solved the problem using the Module[] function. I now have another problem, anyway! When I do FindRoot[f[x],{x,0}] it looks for all instances of x in the definition of the function, and THEN evaluate the function for the symbol X. What I want is to override this symbolic method and call f[x] with the numerical value of x, since in the definition of f[x] I have recursive functions that would imply to evaluate a huge polynomial of x, and keeping track of all the terms is really lengthy. While if I substitute x=x0 at each recursive step, the computation is less costy. So is there a way to tell mathematica in FindRoot to call the function with numerical values, like it was a black box? Davide Sseziwa Mukasa === Subject: Epilog doesn't work with loglinearplot I've have a problem with loglinearplot Plot[x, {x, 1, 10}, Epilog -> Line[{{4, 0}, {4, 10}}]] Ok, I see the line LogLinearPlot[x, {x, 1, 10}, Epilog -> Line[{{4, 0}, {4, 10}}]] why I don't see the line? Can someone suggest an alternative method to superimpose a line over a loglinearplot? === Subject: Problem of evaluate Numerically Eigensystem in Nminimize I have to compute NUMERICALLY (not analytically) the Eigensystem a 3x3 Matrix, put the result into a function and use Nminimize to optimize. I pos= e: M[t6_, t7_, t8_, t9_, t10_] :=Eigensystem[N[{{t6, 0, 0}, {t7, t8, t9},{0, 0, t10= }}]]; M221[t6_?NumericQ, t7_?NumericQ, t8_?NumericQ, t9_?NumericQ, t10_?NumericQ]:= M[t6, t7, t8, = t9, t10][[2, 3, 1]]; M222[t6_?NumericQ, t7_?NumericQ, t8_?NumericQ, t9_?NumericQ, t10_?NumericQ] := M[t6, t7, t8,= t9, t10][[2, 3, 2]]; M232[t6_?NumericQ, t7_?NumericQ, t8_?NumericQ, t9_?NumericQ, t10_?NumericQ] := M[t6, t7, t8,= t9, t10][[2, 1, 2]]; M233[t6_?NumericQ, t7_?NumericQ, t8_?NumericQ, t9_?NumericQ, t10_?NumericQ] := M[t6, t7, t8,= t9, t10][[2, 1, 3]]; M2 = Transpose[{{0, 1, 0}, {M221[t6, t7, t8, t9, t10],M222[t6, t7, t8, t9, t10], 0}, {0, M232[t= 6, t7, t8, t9, t10],M233[t6, t7, t8, t9, t10]}}]; I have to Inverse M2 in my function (type Maximum Likelihood), and then use Nminimize to opti= mize. But Mathematica give an error message: Power::infy: Infinite expression 1/0 encountered. That comes from the fact, I have (1/M221) and (1/M233) in the objective function and I searched and don=E2=80=99t know how to solve this problem. I think that in = the others software, they don=E2=80=99t have this problem because the Eigensystem is computed di= rectly numerically. Any ideas will be much appreciated? LAI. === Subject: Re: find the maxima in a function f[x_] := 1/(8*(Pi*t)^(3/2))*Exp[(-(x^2 + y^2 + z^2)/4*t)] Reduce[f'[x] == 0, x] t!=0[And]x[LongEqual]0 Off[Solve::ifun] Solve[f'[x] == 0, x] {{x->0}} Bob Hanlon Hallo, how can one find the maxima by using mathematica for the following function: f[x_] := 1/(8*(Pi*t)^(3/2)) * Exp[(-(x^2 + y^2 + z^2)/4*t)] i mean, the first derivation equal Zero. Oli. === Subject: Re: Huge memory consumption of GIF.exe what is GIF.exe? Anyway, it seems to be an external program that has nothing to do with mathematica. Daniel > Hello! I have difficulties with high memory consumption of GIF.exe. I need to > statistically evaluate a few million SQL-recordsets (grouped by a few > thousand batches). After calculating the data, I also create some > little GIF-images as a visual aid. So far, I have generated approx. > 2000 images using Export[..., ...GIF] (average image size approx. > code is a loop (using some Block constructs); all intermediate > variables are cleared (using Clear[...]) at the end of the loop. It seems, that GIF.exe does not deallocate the used memory. Is there > any way to deallocate the memory used by GIF.exe? The Mathematica > front end has crashed after 4 hours and I still need to evaluate a few > hundred batches. === Subject: Re: Do What I Mean - a suggestion for improving > While I understand this is small comfort to a new user, there >> really isn't much else to be said. Mathematica forms a rich >> complex toolset for doing mathematica analysis. Any such system >> will require significant time and effort on the part of an user >> to become proficient in making use of its capabilities. I'm afraid that this, if true, is small comfort to me -- but it's > because I thought that the point to Mathematica was making a toolset > with which many different levels of users -- smart high school juniors > and seniors, college students at all levels, working engineers at BS > or > MS levels, professionals in many other fields without extensive math > or > computer science bckgrounds -- could do both analytical and numerical > analyses, make plots, graphs, animations, demonstrations, in their own > areas, **without having to invest significant time and effort (which > they may simply not have) in learning the increasingly arcane, > massive, > and complex complications involved in working with Mathematica. Well, clearly you have been labouring under an false belief. Mathematica is a program of huge power but how much of this power you can utilize depends on the amount of time and effort that you invest in becoming proficient in it. Now, because this power is huge, even a small amount of time and effort invested ( > 0) will produce a fair return, but obviously much less than will be obtained by someone who invests more. Is that really surprising or wrong? Andrzej Kozlowski The second sentences above says, Mathematica forms a rich complex > toolset for doing mathematica [NOTE: 'mathematica'] analysis. Freudian slip? I think a more fitting reference here would be not to Freud but to Euclid. I mean his supposed remark to Ptolemy I : there is not royal road to geometry. There isn't one to Mathematica either. Andrzej Kozlowski === Subject: Re: Do What I Mean - a suggestion for improving well, if you make mathematica *too* easy - everyone's going to be using it. Then where will we all be ? Peter 2009/3/4 AES DrMajorBob, I think you're missing the point here - and actually, this is exactly the > point that AES keeps banging on. It's up to a user to write what he > means > is small comfort to a user, especially one new to Mathematica, who > doesn't > know how to express what he means. and can't **easily and quickly** track down that information, in > documentation that's **matched to his or her needs**. > DWIM is a tongue-in-cheek name, not to be taken literally. It is just > a > name for an meta-analysis feature that inspects the user's input and > proposes similar input forms that may be closer to what the user has in > mind, based on a database of common errors. Right. Given the sophistication of everything else that Wolfram does, I assume > that it has always done a massive amount of sophisticated user testing, > in which it presents its (soft)wares to a wide variety of different > kinds of users, and observes and studies what errors they commonly make > -- right? (At least it's my understanding that many other companies do this kind > of thing, with whatever kind of wares they vend -- right?) So, the above-mentioned database of common errors already exists -- > right? -- Peter Lindsay === Subject: Re: Problems in writing into a sequential filename Hi Xavier, Sr > Nomfich is an abreviation and does not do any parameter substitution, Nomfich is taken literally. Therefore, you want to use the full command: PutAppend. Concerning the non-apearing Plot, in version 6+7 graphics is treated equal to text. You must wrap Print around the Plot. hope this helps, Daniel > Hi everybody I am enjoying the beautiful rules of programming in mathematica, and I > step onto a rock: > How can I write datas into a sequential filename? > Let's explain myself, with an exemple below: First I work on mathematica 6.0.2 on linux I want to make a Do loop in witch I choose values for a variable: Sr > (here, 0.5 and 1) > Then I concatenate a pattern and the value (here RappSr and the > value) and put the name into a variable (Nomfich) > then I open the file (It works) > But then, the problem is it does not write into the file, but it close > it normally. So How can I do this not-so-tricky-thing in Mathematica? And by the way, I can't plot graphes into any Loop neither. Xavier The code: ClearAll[Global`*]; > Do[ > Nomfich = ToString[RappSr <> ToString[Sr]]; Print[Nomfich]; > poiuy4 = OpenWrite[Nomfich]; Sr > Nomfich; > 1 > Nomfich; > Close[Nomfich]; , {Sr, {0.5, 1}}]; > === Subject: Re: Problems in writing into a sequential filename Hi Xavier, The problem is you're mixing up various ways of writing to a file in Mathematica. With >> and > you can write directly to a file without opening it. OpenWrite give you something like a file handle that is to be used by functions like Write and WriteString. All these things are pretty clearly explained in the manual. I'd say: select '>' and press the help button (not sure what it is on a Linux platform) and you're set. Relevant tutorials are: tutorial/ReadingAndWritingMathematicaFiles tutorial/StreamsAndLowLevelInputAndOutput (names to be pasted in the help Search bar) By the way: I don't think it's a good idea to use reals in file names. For instance, the decimal point may provide your file with an unwanted extension. Showing Plots in a loop can be done by adding the Print function. Indeed, plots can be printed as well As of version 6 this must be done when plots are used in a loop and there visibility is desired. > Hi everybody I am enjoying the beautiful rules of programming in mathematica, and I > step onto a rock: > How can I write datas into a sequential filename? > Let's explain myself, with an exemple below: First I work on mathematica 6.0.2 on linux I want to make a Do loop in witch I choose values for a variable: Sr > (here, 0.5 and 1) > Then I concatenate a pattern and the value (here RappSr and the > value) and put the name into a variable (Nomfich) > then I open the file (It works) > But then, the problem is it does not write into the file, but it close > it normally. So How can I do this not-so-tricky-thing in Mathematica? And by the way, I can't plot graphes into any Loop neither. Xavier The code: ClearAll[Global`*]; > Do[ > Nomfich = ToString[RappSr <> ToString[Sr]]; Print[Nomfich]; > poiuy4 = OpenWrite[Nomfich]; Sr > Nomfich; > 1 > Nomfich; > Close[Nomfich]; , {Sr, {0.5, 1}}]; === Subject: Re: Problems in writing into a sequential filename Do[ Nomfich = c:/temp/RappSr <> ToString[Sr] <> .dat; Print[Nomfich]; poiuy4 = OpenWrite[Nomfich]; Write[poiuy4, Sr]; Write[poiuy4, 1]; Close[poiuy4];, {Sr, {0.5, 1}}]; ?? Jens > Hi everybody I am enjoying the beautiful rules of programming in mathematica, and I > step onto a rock: > How can I write datas into a sequential filename? > Let's explain myself, with an exemple below: First I work on mathematica 6.0.2 on linux I want to make a Do loop in witch I choose values for a variable: Sr > (here, 0.5 and 1) > Then I concatenate a pattern and the value (here RappSr and the > value) and put the name into a variable (Nomfich) > then I open the file (It works) > But then, the problem is it does not write into the file, but it close > it normally. So How can I do this not-so-tricky-thing in Mathematica? And by the way, I can't plot graphes into any Loop neither. Xavier The code: ClearAll[Global`*]; > Do[ > Nomfich = ToString[RappSr <> ToString[Sr]]; Print[Nomfich]; > poiuy4 = OpenWrite[Nomfich]; Sr > Nomfich; > 1 > Nomfich; > Close[Nomfich]; , {Sr, {0.5, 1}}]; > === Subject: Re: GraphPlot questions Hi Robert, The rendering function gets two parameters thrown at it, the name of the vertex and its position. You can use the name as an index in an array with pictures, (call it pics) and then: GraphPlot[{1 -> 4, 1 -> 5, 2 -> 3, 2 -> 4, 2 -> 5, 3 -> 4, 3 -> 5}, VertexRenderingFunction -> (Inset[pics[[#2]], #1] &)] On Mar 4, 2:09 pm, robert prince-wright ({EdgeForm[Black], Yellow, Disk[#1, 0.05], > Black, Text[#2, #1]} &) It seems like VertexRenderingFunction is a one shot deal. Robert === Subject: Re: find the maxima in a function Reduce[D[f[x], x] == 0, x] ?? Jens > Hallo, > how can one find the maxima by using mathematica for the following function: f[x_] := 1/(8*(Pi*t)^(3/2)) * Exp[(-(x^2 + y^2 + z^2)/4*t)] i mean, the first derivation equal Zero. > Oli. > === Subject: Re: find the maxima in a function f[x_] := 1/(8*(Pi*t)^(3/2))*Exp[(-(x^2 + y^2 + z^2)/4*t)] D[f[x], x] -((E^(1/4 t (-x^2 - y^2 - z^2)) x)/(16 [Pi]^(3/2) Sqrt[t])) As you can see, the denominator is zero if and only if x == 0, and at that point, the second derivative is D[f[x], {x, 2}] /. x -> 0 -(E^(1/4 t (-y^2 - z^2))/(16 [Pi]^(3/2) Sqrt[t])) (negative). Unless Sqrt[t] is taken negative somehow. Bobby > Hallo, > how can one find the maxima by using mathematica for the following > function: f[x_] := 1/(8*(Pi*t)^(3/2)) * Exp[(-(x^2 + y^2 + z^2)/4*t)] i mean, the first derivation equal Zero. > Oli. > -- DrMajorBob@bigfoot.com === Subject: Re: find the maxima in a function Your function definition has x as an argument, but apart from x it also depends on y, z and t. With respect to which variable do you want the function to be maximized? If it is t, then you could try something like Solve[D[1/(8*(Pi*t)^(3/2))*Exp[(-(x^2 + y^2 + z^2)/4*t)], t] == 0, t], and you should make a plot or so to check whether this is a local/ global minimum or maximum. You might check FindMaximum and Maximize in the manual. > Hallo, > how can one find the maxima by using mathematica for the following functi= on: f[x_] := 1/(8*(Pi*t)^(3/2)) * Exp[(-(x^2 + y^2 + z^2)/4*t)] i mean, the first derivation equal Zero. > Oli. === Subject: Re: find the maxima in a function Easy: Solve[f'[x] == 0, x] > Hallo, > how can one find the maxima by using mathematica for the following function: f[x_] := 1/(8*(Pi*t)^(3/2)) * Exp[(-(x^2 + y^2 + z^2)/4*t)] i mean, the first derivation equal Zero. > Oli. > === Subject: Announcing Mathematica 7.0.1 Since Mathematica 7 was released, there has been tremendous appreciation for it amongst our user base. For me, the release of Mathematica 7 was exciting for additional reasons. I was most enthusiastic to see the ease of transition between Mathematica 6 and 7. In most cases, the conversion from Mathematica 6 is as simple as opening a notebook in Mathematica 7. For you, this means you can build on your existing work in the new version with little or no modification. I want to let you know that Mathematica 7.0.1 is now available--a maintenance update that incorporates over 600 user-requested features and usability enhancements. For more information about Mathematica 7.0.1, visit: http://www.wolfram.com/mathematica/latestversion Please continue to provide your valuable feedback. Wolfram Research Technical Support is committed to providing the best, timely support to you. If you have any questions, please do not hesitate to contact me. Onkar Singh Manager, Technology Services Group Wolfram Research, Inc. http://support.wolfram.com NOTE: Mathematica users with Premier Service will receive an email in the next few days with instructions on how to download their free upgrades. === Subject: Re: Legends in GraphicsGrid Padding is often a struggle for me as well. In this case Grid seems to be working better than GraphicsGrid. > Hello Group, I am again struggling with inserting legends into plots.I need to > automate the plotting of many GraphicsGrids with some automated legend > control. Usually I use a customized approach via Epilog/Inset but I > need to use LogLogPlots and positioning and scaling within them is not > very straight forward to me. Using the built in PlotLegends Package I somewhat loose control over > my plots. The legend package introduces some invisible plot margins I > cannot get rid of: Compare: (*with legends*) > GraphicsGrid[ > Partition[ > Table[Plot[i, {x, 0, 100}, ImageSize -> 200, PlotLegend -> {1}, > LegendShadow -> False, LegendPosition -> {0, 0}, > LegendSize -> 0.5, ImageMargins -> None, ImagePadding -> 0], {i, > 1, 4}], 2], Spacings -> 0., Frame -> All] > (* without legends *) > GraphicsGrid[ > Partition[ > Table[Plot[i, {x, 0, 100}, ImageSize -> 200, ImageMargins -> None, > ImagePadding -> 0], {i, 1, 4}], 2], Spacings -> 0., Frame -> All] Is there a way to keep the legend fully wihtin the plot without adding > some invisible wasted space? I appreciate any hints, Markus === Subject: Re: Legends in GraphicsGrid you need to get David Park's Presentations package: http://home.comcast.net/~djmpark/DrawGraphicsPage.html see some examples at: http://blackbook.mcs.st-and.ac.uk/~Peter/djmpark/html/ Peter > Hello Group, I am again struggling with inserting legends into plots.I need to > automate the plotting of many GraphicsGrids with some automated legend > control. Usually I use a customized approach via Epilog/Inset but I > need to use LogLogPlots and positioning and scaling within them is not > very straight forward to me. Using the built in PlotLegends Package I somewhat loose control over > my plots. The legend package introduces some invisible plot margins I > cannot get rid of: Compare: (*with legends*) > GraphicsGrid[ > Partition[ > Table[Plot[i, {x, 0, 100}, ImageSize -> 200, PlotLegend -> {1}, > LegendShadow -> False, LegendPosition -> {0, 0}, > LegendSize -> 0.5, ImageMargins -> None, ImagePadding -> 0], {i, > 1, 4}], 2], Spacings -> 0., Frame -> All] > (* without legends *) > GraphicsGrid[ > Partition[ > Table[Plot[i, {x, 0, 100}, ImageSize -> 200, ImageMargins -> None, > ImagePadding -> 0], {i, 1, 4}], 2], Spacings -> 0., Frame -> All] Is there a way to keep the legend fully wihtin the plot without adding > some invisible wasted space? I appreciate any hints, Markus -- Peter Lindsay === Subject: How to express the results in normal cdf instead of erf() Hi All, I am working on some integrals involving the Normal Distribution, and would like the end results to be expressed in normal density as opposed to the Erf[] function. For example, the default result of the following: Integrate[PDF[NormalDistribution[0, 1], x] Exp[x], x] will result in an expression in Erf[]. I'd like it to be in terms of CDF[NormalDistribution[]] instead. Of course the two functions are related: CDF[NormalDistribution[0,1],x] ==1/2*(1+Erf[[x/Sqrt[2]]) Is there any way to do that? Irving. === Subject: MakeBoxes on v7.0 Hi all, after executing this on v7.0 h /: MakeBoxes[h[i_], StandardForm] := SubscriptBox[h, MakeBoxes[i, StandardForm]] evaluating h[4] results not in an h with a subscript, but in Global`h with the expected subscript. Is that intentional? This code is very close to an example in the documentation for MakeBoxes... -- m === Subject: Re: question about mathlink.h >Hi mathematica community, i want to connect a external C++ Programm >to Mathematica. The Help Browser tells me that I have to include the >standard MathLink header file ''mathlink.h'' in my C++ >program(#include ''mathlink.h''). But where is this header file or This is included in the standard installation of Mathematica. Use the documentation center to search for mathlink developer guide Click on the one appropriate to your operating system and a tutorial will come up with details of how to install the needed components and where they are located. === Subject: Re: Problems in writing into a sequential filename >I am enjoying the beautiful rules of programming in mathematica, and >I step onto a rock: How can I write datas into a sequential >filename? Let's explain myself, with an exemple below: >First I work on mathematica 6.0.2 on linux >I want to make a Do loop in witch I choose values for a variable: Sr >(here, 0.5 and 1) Then I concatenate a pattern and the value (here >RappSr and the value) and put the name into a variable (Nomfich) >then I open the file (It works) But then, the problem is it does not >write into the file, but it close it normally. >So How can I do this not-so-tricky-thing in Mathematica? >And by the way, I can't plot graphes into any Loop neither. >The code: >ClearAll[Global`*]; >Do[ Nomfich = ToString[RappSr <> ToString[Sr]]; >Print[Nomfich]; poiuy4 = OpenWrite[Nomfich]; >Sr > Nomfich; 1 > Nomfich; Close[Nomfich]; >, {Sr, {0.5, 1}}]; There are a variety of ways of creating sequential files in Mathematica. And while this could be done using an explicit Do loop, this would be my last choice. Suppose I wanted a list of things sent to various files with a given base name with a sequential number appended to that base name. I would do that using MapIndexed[Put[#1, basename<>ToString[#2[[1]]]<>ext&, listOfStuff] Or if I needed something more readable than what Put creates, MapIndexed[Export[basename<>ToString[#2[[1]]]<>ext, #1, Table]&, listOfStuff] Or if I wanted to use explicit values rather than sequential integers: MapThread[Put[#1, basename<>ToString[#2]<>ext]&, {listOfStuff, listOfValues= }] These simple examples can easily be embellished in numerous ways. For example, NumberPadding could be used to format numbers to a fixed width which could be very nice. === Subject: Re: Do What I Mean - a suggestion for improving >>While I understand this is small comfort to a new user, there >>really isn't much else to be said. Mathematica forms a rich complex >>toolset for doing mathematica analysis. Any such system will >>require significant time and effort on the part of an user to >>become proficient in making use of its capabilities. >I'm afraid that this, if true, is small comfort to me -- but it's >because I thought that the point to Mathematica was making a toolset >with which many different levels of users -- smart high school >juniors and seniors, college students at all levels, working >engineers at BS or MS levels, professionals in many other fields >without extensive math or computer science bckgrounds -- could do >both analytical and numerical analyses, make plots, graphs, >animations, demonstrations, in their own areas, **without having to >invest significant time and effort (which they may simply not >have) in learning the increasingly arcane, massive, and complex >complications involved in working with Mathematica. Since I don't work for Wolfram, I cannot truly know what there goals are for Mathematica. While I do think Wolfram does try to make Mathematica as easy to use as possible, I don't believe this is their primary goal. I do not think it is even a good idea to attempt to make Mathematica accessible to users with minimal computer/mathematics experience/knowledge assuming this is even possible. There are a great many things in mathematics that work in specialized cases. For example, a user with little experience in mathematics likely would expect Sqrt[x^2] to simplify to x. But that transformation is only valid when x is real and positive. If Mathematica were to automatically do this simplification (or many others of a similar nature) it would not be an adequate tool for me or many other users since it would be creating erroneous output. Worse, even for those users where this happened to be the correct output, the issue gets hidden and they would learn to trust Mathematica only to lose trust when things were more complex. The point is mathematics is complex. A tool designed to implement mathematics can hardly be less complex. Attempts to reduce the complexity invariably mean some aspects (typically special cases) of the mathematics are being ignored or hidden. Ignoring or hiding such special cases limits the usefulness of Mathematica. >The second sentences above says, Mathematica forms a rich complex >toolset for doing mathematica [NOTE: 'mathematica'] analysis. >Freudian slip? Simple typo. It should have been mathematical analysis. === Subject: Re: question about mathlink.h execute: FileNames[mathlink.h, $TopDirectory, 10] and take the one that you like. Jens BTW: '' is not > Hi mathematica community, > i want to connect a external C++ Programm to Mathematica. The Help > Browser tells me > that I have to include the standard MathLink header file > ''mathlink.h'' > in my C++ program(#include ''mathlink.h''). But where is this header > file or where can I get it ? > === Subject: Re: question about mathlink.h Have you considered using the search/find facility of your computer? If I search for mathlink.h starting at the mathematica 7 folder I get a number of hits among which: C:Program FilesWolfram ResearchMathematica7.0SystemFilesLinks MathLinkDeveloperKitWindowsCompilerAdditionsmldev32include This information can also be found in the manual: tutorial/ MathLinkDeveloperGuide-Windows #31065 I don't want to insult you, but if you're going to take up MathLink programming would you mind looking around for an answer yourself for more than a few micro seconds before posting questions? > Hi mathematica community, > i want to connect a external C++ Programm to Mathematica. The Help > Browser tells me > that I have to include the standard MathLink header file > ''mathlink.h'' > in my C++ program(#include ''mathlink.h''). But where is this header > file or where can I get it ? === Subject: Re: question about mathlink.h you may find different versions for different compilers at: c:/Program Files/Wolfram Research/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit/Windows/Com pilerAdditions/cygwin/include/mathlink.h c:/Program Files/Wolfram Research/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit/Windows/Com pilerAdditions/mldev32/include/mathlink.h c:/Program Files/Wolfram Research/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit/Windows-x86 -64/CompilerAdditions/mldev64/include/mathlink.h , Daniel > Hi mathematica community, > i want to connect a external C++ Programm to Mathematica. The Help > Browser tells me > that I have to include the standard MathLink header file > ''mathlink.h'' > in my C++ program(#include ''mathlink.h''). But where is this header > file or where can I get it ? > === Subject: Exporting a Manipulate[] I'm wondering if it's possible to export a Manipulate in a format that I can embed in a webpage so that users (without access to Mathematica) can play with it. -tom === Subject: could I get webmathematica trial? I think Webmathematica is charming! could I get webmathematica trial? how to get the trial version. In addition, NumberOfGraphs[n] gives the number of nonisomorphic undirected graphs with n vertices. Then, How to get the number of nonisomorphic undirected graphs with n vertices which have CompleteGraph[v] subgraph. === Subject: Re: FullGraphics of Graphics3D Hmm... seems that my earlier post didn't make it, so I briefly recapitulate my problem: Your method returns a 2D vector-version of a 3D plot, however what I want is the same 3D graphics object than the original, with options (like Axes->True) replaced by explicit 3D primitives (lines and text). Basically I want the same functionality in 3D that FullGraphics provides in 2D. Istvan Zachar === Subject: Re: custom coordinate systems in mathematica Help! there is a package VectorAnalysis, you can load it with Needs[VectorAnalysis`] and that does this for the most coordinate systems. You need only look in the source code of the package to extend it to your coordinate system if it is not already defined in VectorAnalysis`. Jens > Hi!, > HELP! I've asked this question a couple of times but never received an > answer. > I have a new coordinate system to deal with. > x=f(u, v,w) > y=g(u,v,w) > z=h(u,v,w) > (x,y,z) are Cartesian > and it's inverse is known. > How can I program this in Mathematica and compute the gradient, curl, > divergence, laplacian > and other operators in this coordinate system ???? > === Subject: Re: custom coordinate systems in mathematica Help! Magician, As far as I can see in recent history no one going by your nickname has posted a question on this topic. Anyways, there is a vector analysis package in Mathematica (found in a 5 sec search) that knows about 14 different coordinate systems and can do the tricks you ask for. If your coordinate system is included you're lucky. If your system is not, you might consider extending the package. That doesn't seem to be too difficult as it is plain Mathematica code and you've 14 examples in it that show you how to set up a new coordinate system. > Hi!, > HELP! I've asked this question a couple of times but never received an > answer. I have a new coordinate system to deal with. > x=f(u, v,w) > y=g(u,v,w) > z=h(u,v,w) > (x,y,z) are Cartesian > and it's inverse is known. > How can I program this in Mathematica and compute the gradient, curl, > divergence, laplacian > and other operators in this coordinate system ???? === Subject: Re: custom coordinate systems in mathematica Help! first check out the standard package: VectorAnalysis. If you can find your coordinate system there, you are done. If not there exists a package GeneralVectorAnalysis.m. You will have to search the group archive or at Wolfram for it. If this does not help neither, you must do the work yourself. E.g. Assume we have: u[x,y,z],v[x,y,z],w[x,y,z], then we get the Gradient operator in {u,v,w} coordinates by: gr = Function[xx, Tr /@ (Outer[ D[#3, #1] D[xx, #2] &, {x, y, z}, {u, v, w}, {U, V, W}])] This is a handsome piece of code, but it works by first creating all possible combination of derivatives. Then Tr picks the one we want and sums them. E.g. if we want the gradient of the scalar function p[u,v,w]: gr[u[u,v,w]] this gives: { (p^(1,0,0))[u,v,w] (u^(1,0,0))[x,y,z]+(p^(0,1,0))[u,v,w] (v^(1,0,0))[x,y,z]+(p^(0,0,1))[u,v,w] (w^(1,0,0))[x,y,z] , (p^(0,1,0))[u,v,w] (v^(0,1,0))[x,y,z]+(p^(0,0,1))[u,v,w] (w^(0,1,0))[x,y,z]+(u^(0,1,0))[x,y,z] (p^(1,0,0))[u,v,w] , (p^(0,0,1))[u,v,w] (w^(0,0,1))[x,y,z]+(v^(0,0,1))[x,y,z] (p^(0,1,0))[u,v,w]+(u^(0,0,1))[x,y,z] (p^(1,0,0))[u,v,w] } have fun, Daniel > Hi!, > HELP! I've asked this question a couple of times but never received an > answer. > I have a new coordinate system to deal with. > x=f(u, v,w) > y=g(u,v,w) > z=h(u,v,w) > (x,y,z) are Cartesian > and it's inverse is known. > How can I program this in Mathematica and compute the gradient, curl, > divergence, laplacian > and other operators in this coordinate system ???? > === Subject: Re: GraphComplement doesn't work in 7.0 what output do you expect as complement of 1->2 ?? Jens > I find some functions do not work in mathematica 7.0. Why? > are some function not implemented yet? > << Combinatorica` > In[4]:= GraphComplement[{1 -> 2}] Out[4]= GraphComplement[{1 -> 2}] > === Subject: Re: GraphComplement doesn't work in 7.0 They return unevaluated because you don't provide them with the input formats for which they are defined. As can be clearly (!) seen in the Combinatorica manual, GraphComplement needs a graph as input. What you gave him is not a graph. Look up this manual page: Combinatorica/guide/GraphConstructionAndRepresentations and find some graph representation functions. Hint: they start with > I find some functions do not work in mathematica 7.0. Why? > are some function not implemented yet? > << Combinatorica` > In[4]:= GraphComplement[{1 -> 2}] Out[4]= GraphComplement[{1 -> 2}] === Subject: Re: GraphComplement doesn't work in 7.0 Hi tangarine, I think your syntax is wrong. GraphComplement does work, e.g.: ShowGraph@Star[4] ShowGraph@GraphComplement@Star[4] Daniel > I find some functions do not work in mathematica 7.0. Why? > are some function not implemented yet? > << Combinatorica` > In[4]:= GraphComplement[{1 -> 2}] Out[4]= GraphComplement[{1 -> 2}] > === Subject: Re: GraphComplement doesn't work in 7.0 The function GraphComplement IS implemented in the Combinatorica package -- but only for the kinds of graph structures handled by Combinatorica. For example: <2}, is a newer type of graph structure that can be displayed by the new kernel function GraphPlot. But it is not the native Combinatorica type of graph, and you would need to convert your graph to the Combinatorica type structure first. This is all an unfortunate result of a very incomplete integration so far between the older Combinatorica package (where you use ShowGraph to display a graph) and the newer kernel functionality where you use GraphPlot. > I find some functions do not work in mathematica 7.0. Why? > are some function not implemented yet? > << Combinatorica` > In[4]:= GraphComplement[{1 -> 2}] Out[4]= GraphComplement[{1 -> 2}] > -- 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: Convolution of a Gaussian Distribution and a discontinuous function Hi Jens, take a step back and look at your conv. It is a sum over Gaussians, the number of summands depends on ll. You have an expansions in Gaussians, what is not the worst thing to work with. Derivatives are a piece of cake. Integration will give error functions that are a bit more cumbersome. But they are built into Mathematica. If you still want another approximation, here is a rational approximation of your example: fun = conv /. vars /. xx -> x; x0 = 0.5; ap = MiniMaxApproximation[fun, {x, {-x0, x0}, 12, 12}][[2]] Plot[{fun, ap}, {x, -x0, x0}, PlotRange -> All] Plot[{fun - ap}, {x, -x0, x0}, PlotRange -> All] Plot[{ap}, {x, -1, 1}, PlotRange -> All] hope this helps, Daniel > This is a repost of a reply on an earlier thread but I think it got > buried so I'm putting it up as a new topic with a more relevant > subject line. > ------- > I don't know if this is a forum where math questions are posted (as > opposed to strictly Mathematica questions), but I'll ask anyway. The PDF of the circular uniform distribution in one dimension has two > discontinuities at x = radius. This makes the required integration to > do a convolution fail, and it fails in Fourier space as well. If I do > a numeric convolution with ListConvolve, of course, I can easily get a > result. Alternatively I can use a summation and get a symbolic result > consisting of hundreds of summands. These work, but neither solution > can be readily integrated or differentiated when the other independent > variables are complicated as they are in my case. I'd really like to > get a closed form symbolic formula for the convolution. Am I dreaming > to think that Mathematica, with all it's rich complexity, can do > something like this? Or it is simply a fact of math that a > discontinuous function cannot be convolved with a Gaussian > Distribution and no trick (DiracDelta, HeavisideTheta) or > computational genius will make it work? Given a failed convolution, I can use the summation solution and then > fit the resulting curve. I've used the Taylor and polynomial > expansions along with FFTs, but I'm not able to get a close enough > approximation. The convolution is a beautiful, continuous curve based > on a sum of Gaussians and so intuitively it seems as though it would > be easy to fit, but I can't seem to get it. It seems that an > approximation of either the Gaussian Distribution or the circular > uniform distribution would make the integration possible, too. But I > struggle with getting suitable non-exponential approximations to > either of those. So, for the illustration, look at this: vars = { ll -> .27, mm -> 0, ss -> .06 }; > pdf1[ xx_ ] := PDF[ NormalDistribution[ mm, ss ], xx ]; > pdf2[ xx_ ] := > Piecewise[ > { { 1/(Pi * Sqrt[ ll^2 - xx^2 ]), Abs[ xx ] < ll } } > ]; > Plot[ { pdf1[ xx ], pdf2[ xx ] } /. vars, { xx, -.3, .3 } ] > conv = Sum[ > (pdf1[ xx - zz ] pdf2[ zz ]), { zz, -.6, .6, 0.02 } ] / 60; > Plot[ Evaluate[ conv /. vars ], { xx, -.5, .5 } ] I'm seeking a symbolic representation of the second curve. (All variables are real, and both ll and ss are always positive.) Please be kind Jens -- I'm admittedly an amateur! > === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p Hi Bob, You don't seem to have noticed that in the conjecture negative primes were allowed as well. Therefore, the conjecture reads as 2n+1 = 2^i+p OR 2n+1 = 2^i - p, with p now defined as positive prime. This is much harder to prove or disprove numerically because the search space is infinite contrary to the case you examined. > The conjecture is false. It fails when the number tested is prime (but no= t > the second of a twin prime pair). And it fails in other cases, too. Proof: Clear[test] > test[k_?OddQ] /; k >= 3 := > Module[{n = 0}, > Catch[While[2^n < k, PrimeQ[k - 2^n] && Throw@{2^n, k - 2^n, True}= ; > n++]; {k, False}]] These are the failures up to 1000: failures = > Cases[test /@ Range[3, 1000, 2], {k_, False} :> {k, PrimeQ@k}] {{127, True}, {149, True}, {251, True}, {331, True}, {337, > True}, {373, True}, {509, True}, {599, True}, {701, True}, {757, > True}, {809, True}, {877, True}, {905, False}, {907, True}, {959, > False}, {977, True}, {997, True}} Primes are marked with True, and non-primes with False, so the most > interesting of these is the first non-prime failure, 905. Here's an independent test for that one: 905 - 2^Range[0, Log[2, 905]] > PrimeQ /@ % {904, 903, 901, 897, 889, 873, 841, 777, 649, 393} {False, False, False, False, False, False, False, False, False, False} Also, there are 2^k + 1 that fail: test /@ (1 + 2^Range[18]) {{1, 2, True}, {2, 3, True}, {2, 7, True}, {4, 13, True}, {2, 31, > True}, {4, 61, True}, {2, 127, True}, {16, 241, True}, {4, 509, > True}, {4, 1021, True}, {32, 2017, True}, {4, 4093, True}, {2, 819= 1, > True}, {4, 16381, True}, {512, 32257, True}, {16, 65521, True}, {= 2, > 131071, True}, {0, 262145, False}} The smallest of these is 2^18+1 == 262145. Bobby > I have a conjecture: > Any odd positive number is the sum of 2 to an i-th power and a > (negative) prime. > 2n+1 = 2^i+p for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... > as to 2293=2^i +p =1B$B!$=1B(BI don't know i , p . it is sure = that i>30 000 = > if > the conjecture is correct. More, > n = 3^i+p, (if n=6k-2 or n=6k+2) > for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 I can't proof this. Do you have any idea? -- = DrMajor...@bigfoot.com === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p Because the moderator kindly told me that this group doesn't discuss general math questions, I posted it on ea# To my surprise, this question had been mentioned long years ago. In 1950 , a mathematician proved the conjecture is false! On 3=D4=C24=C8=D5, =CF=C2=CE=E78=CA=B111=B7=D6, Sjoerd C. de Vries don't belong in this forum as long as they are not connected with > Mathematica. I tried the brute force method for your particular > example of 2293 and the formal approach for the general conjecture. By brute force using Monitor[ > While[! PrimeQ[2^i - 2293], i++], > i > ] for 2 n +1 ==2293 I find after a long wait that i must be larger tha= n > 43 032 if the conjecture is correct. A formal way of stating the problem in Mathematica would be ForAll[n, n [Element] Integers, > Exists[{i, p}, i [Element] Integers [And] p [Element] Primes, > 2 n + 1 == 2^i + p [Or] 2 n + 1 == 2^i - p]] Resolve or FullSimplify could then be used to find out whether or not > there is any truth in this statement. Alas, they both return unsolved. I have a conjecture: > Any odd positive number is the sum of 2 to an i-th power and a > (negative) prime. > 2n+1 = 2^i+p for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... > as to 2293=2^i +p =A3=ACI don't know i , p . it is sure that i>30 00= 0 if > the conjecture is correct. More, > n = 3^i+p, (if n=6k-2 or n=6k+2) > for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 I can't proof this. Do you have any idea? === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p I have a conjecture: Any odd positive number is the sum of 2 to an i-th power and a (negative) prime. 2n+1 = 2^i+p > for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... as to 2293=2^i +p $B!$(BI don't know i , p . it is sure that i>30 000 if the conjecture is correct. > More, n = 3^i+p, (if n=6k-2 or n=6k+2) for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 > I can't proof this. Do you have any idea? Ôèconjecture ist false. A (o.k. brute force) approach is: [Eth]òéíåó Table[Prime[i], {i, 1, 100}]; ôåí[Eth] DeleteCases[ Äéóôòéâ[OTild e]ôåÛû[Eth]ï÷å[O Grave]óprimes}, List, List, List, Plus], _?EvenQ] // Õîéï// Sort; Ãïí[Eth]ìåí[ARin g]îôÛÄåìå[ OHat]åÃáóåó[CapitalUHat ]ÒáîçåÛ[PlusMinus ]1500], _?EvenQ], temp] // Short [Times]èéãgets: û±¬.b3¬±.b2·¬[PlusM inus]´.b9¬.b2[Micro]±¬.bc.bc.b2[Micro].b9.be .be¬±´¸.b9¬±´.b9.b3¬[PlusM inus]´.b9[Micro]¬±´.b9·¬± ´.b9.b9[YAcute] ÓïMathematica could in an easy way help to show that it, the conjecture, ist îïtrue. Çòååôéî[CCedilla ] í®ç® === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p Well, actually there is a funny story behind this. In 1849, Alphonse de Polignac conjectured that every odd number is the sum of a prime and power of 2. He claimed to have verified this up to 3,000,000. However, much earlier Euler had already noted that 127 and 959 are not. In fact, Erd=F6s proved that there is an infinite arithmetic progression of odd integers that cannot be represented as sum of a prime and 2^n. Numbers that refute Polignac's conjecture are known as obstinate numbers. It seems that people are still interested in wasting computing power on finding more obstinate numbers. http://sprott.physics.wisc.edu/pickover/obstinate.html Why? Beats me. On the other hand, the OP question was a bit different as he included the possibility of negative prime, in other words his question was: is it true that for every obstinate number x one can find an integer n such that 2^n-x is prime. Actually, one could ask an even stronger question: is it true that for every odd number a there exists an integer n such that 2^n - a is prime? It seems very likely that the answer is yes, and probably the proof is easy but I can't spend any more time on this... Andrzej Kozlowski > The conjecture is false. It fails when the number tested is prime > (but not > the second of a twin prime pair). And it fails in other cases, too. Proof: Clear[test] > test[k_?OddQ] /; k >= 3 := > Module[{n = 0}, > Catch[While[2^n < k, PrimeQ[k - 2^n] && Throw@{2^n, k - 2^n, True}; > n++]; {k, False}]] These are the failures up to 1000: failures = > Cases[test /@ Range[3, 1000, 2], {k_, False} :> {k, PrimeQ@k}] {{127, True}, {149, True}, {251, True}, {331, True}, {337, > True}, {373, True}, {509, True}, {599, True}, {701, True}, {757, > True}, {809, True}, {877, True}, {905, False}, {907, True}, {959, > False}, {977, True}, {997, True}} Primes are marked with True, and non-primes with False, so the most > interesting of these is the first non-prime failure, 905. Here's an independent test for that one: 905 - 2^Range[0, Log[2, 905]] > PrimeQ /@ % {904, 903, 901, 897, 889, 873, 841, 777, 649, 393} {False, False, False, False, False, False, False, False, False, False} Also, there are 2^k + 1 that fail: test /@ (1 + 2^Range[18]) {{1, 2, True}, {2, 3, True}, {2, 7, True}, {4, 13, True}, {2, 31, > True}, {4, 61, True}, {2, 127, True}, {16, 241, True}, {4, 509, > True}, {4, 1021, True}, {32, 2017, True}, {4, 4093, True}, {2, 8191, > True}, {4, 16381, True}, {512, 32257, True}, {16, 65521, True}, {2, > 131071, True}, {0, 262145, False}} The smallest of these is 2^18+1 == 262145. Bobby >> I have a conjecture: >> Any odd positive number is the sum of 2 to an i-th power and a >> (negative) prime. >> 2n+1 = 2^i+p >> for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... >> as to 2293=2^i +p =1B$B!$=1B(BI don't know i , p . it is sure = that >> i>30 000 = > if >> the conjecture is correct. >> More, >> n = 3^i+p, (if n=6k-2 or n=6k+2) >> for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 >> I can't proof this. Do you have any idea? > > -- = DrMajorBob@bigfoot.com > === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p Yeah, I get that now. Hence, it's not a Mathematica issue. Bobby > Hi Bob, You don't seem to have noticed that in the conjecture negative primes > were allowed as well. Therefore, the conjecture reads as > 2n+1 = 2^i+p OR 2n+1 = 2^i - p, with p now defined as positive prime. > This is much harder to prove or disprove numerically because the > search space is infinite contrary to the case you examined. >> The conjecture is false. It fails when the number tested is prime (but >> not >> the second of a twin prime pair). And it fails in other cases, too. >> Proof: >> Clear[test] >> test[k_?OddQ] /; k >= 3 := >> Module[{n = 0}, >> Catch[While[2^n < k, PrimeQ[k - 2^n] && Throw@{2^n, k - 2^n, True}; >> n++]; {k, False}]] >> These are the failures up to 1000: >> failures = >> Cases[test /@ Range[3, 1000, 2], {k_, False} :> {k, PrimeQ@k}] >> {{127, True}, {149, True}, {251, True}, {331, True}, {337, >> True}, {373, True}, {509, True}, {599, True}, {701, True}, {757, >> True}, {809, True}, {877, True}, {905, False}, {907, True}, {959, >> False}, {977, True}, {997, True}} >> Primes are marked with True, and non-primes with False, so the most >> interesting of these is the first non-prime failure, 905. >> Here's an independent test for that one: >> 905 - 2^Range[0, Log[2, 905]] >> PrimeQ /@ % >> {904, 903, 901, 897, 889, 873, 841, 777, 649, 393} >> {False, False, False, False, False, False, False, False, False, False} >> Also, there are 2^k + 1 that fail: >> test /@ (1 + 2^Range[18]) >> {{1, 2, True}, {2, 3, True}, {2, 7, True}, {4, 13, True}, {2, 31, >> True}, {4, 61, True}, {2, 127, True}, {16, 241, True}, {4, 509, >> True}, {4, 1021, True}, {32, 2017, True}, {4, 4093, True}, {2, 8191, >> True}, {4, 16381, True}, {512, 32257, True}, {16, 65521, True}, {2, >> 131071, True}, {0, 262145, False}} >> The smallest of these is 2^18+1 == 262145. >> Bobby >> I have a conjecture: >> Any odd positive number is the sum of 2 to an i-th power and a >> (negative) prime. >> 2n+1 = 2^i+p >> for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... >> as to 2293=2^i +p =1B$B!$=1B(BI don't know i , p . it is sure that >> i>30 000 = >> if >> the conjecture is correct. >> More, >> n = 3^i+p, (if n=6k-2 or n=6k+2) >> for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 >> I can't proof this. Do you have any idea? >> -- = >> DrMajor...@bigfoot.com > -- DrMajorBob@bigfoot.com === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p I have a conjecture: Any odd positive number is the sum of 2 to an i-th power and a (negative) prime. 2n+1 = 2^i+p for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... as to 2293=2^i +p $B!$(BI don't know i , p . it is sure that i>30 000 if the conjecture is correct. More, n = 3^i+p, (if n=6k-2 or n=6k+2) for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 I can't proof this. Do you have any idea? Ùïworded this in a way that is a bit confusing, and the typography ¨óôòáîçå óùíâïìó¬ éî íù åíáéclient) does not help. [Times]èáô ùïconjecture: Given any positive odd integer n, there is an é.beÌïçÛ.b2[Not ]î[CapitalYAcute] áîa (positive) prime p such that n=2^i-p. Éæ [Eth]òéíåó áòrandom (whatever that might mean), then this is true ÷éôè [Eth]òïâáâéì[EAcute ]ô1. Moreover we can formulate the expected number of öáìõåó that work, for given n, from the distribution of primes as [Eth]òïöéäå[ADo ubleDot] âù ôèPrime Number Theorem. It is ÓõíÛ±¯é[N ot]ûé¬Ãåéìé îçÛÌïç[Cap italUHat].b2¬î[CapitalYAcute][CapitalYAcute]¬[CapitalEAcu te]îæéîéôù[YAcute][CapitalYAc ute]¬ áîthat is clearly infinity ¨éô§a tail of the harmonic series). Óï ÷èáô éó èá[Eth][Eth]åîéîwith 2293? To put this into a sensible context, is ôèåòreason to believe it might sometimes be difficult to find a pair ûé¬[Eth]for given odd n? We'll see what one might expect to happen when we áììïall i from Ceiling[Log[2,2293]]=12 to 100000. ÉîÛ·[CapitalYAcute]ºSum[1/i , {i,12,100000}] // N ÏõôÛ·[CapitalYAcut e]9.07027 Óï æïn between 2^11 and 2^12, we'd expect on average around 9 values ïæ between Log[2,n] and 100000 to work (that is, provide a difference ïããáóéï[IHa t]áììù óïíå ÷éìì òåáììù òåñõéògoing above 100000. We can test ôèéó áó æïììï÷ó[Register edTrademark] Áó åöåò áóóõíéîç ¨[Eth]åòèá[Eth]ó éîãïòòåã[OH at]ìù© ¢éîäå[Eth]åî[ADoubleDot ]åîô òáîäïílocations for the primes, the probability of no i in the range ÷ïòëéîis given as ÉîÛ±±[CapitalYAcute ]º.bd Éî[Eth]õôÆï[OGrav e]íÛ [CapitalEth]òïäõãô[Ca pitalUHat]¨é 1)/i, {i, 12, 100000}]] ÏõôÛ±±[ CapitalYAcute]¯¯Éî[Eth]õô[CapitalA E]ïòí11/100000 Ôèáô§ó bit more than 1 in ten thousand. So it is not implausible that, åöåî éæ ôèconjecture is true, some odd n in the ballpark of a few ôèïõóáîä ÷éìì òåñõéòi to be alrger than 10^5. do not know offhand whether 2293 will find a pair {i,p} with i<10^5. ÁìI can say is it has not done so as yet, and has been running overnight. Äáîéåì ÌéãèôâìáWo lfram Research === Subject: Re: Looking to time how long a command takes in mathematica 6 tia try Timing[] > Grettings All I'm running this command > Play[Piecewise[{{4.000000000*x^2 - 4.000000000*x, > 0 = x <= 1}, {-2*x^2 + 8*x - 6, 1 = x <= 3}, {x^2 - 10*x + 21, > 3 = x <= 7}, {-1/2*x^2 + 11*x - 105/2, > 7 = x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, > 15 = x <= 22}, {-.8000000000*x^2 + 39.20000000*x - 475.2000000, > 22 = x <= 27}}], {x, 0, 27}] and it's taking extremely long and would like to find out how long it > takes to run this line. Also if anyone has a more efficient way of > using this command please let me know. I'm just trying to output the > wave file to an audio file. Aloha > sal2 > === Subject: Wolfram Workbench source editor and corrupted file I have an important Mathematica Notebook (.nb) file which became corrupted. The end of it is missing (incomplete), and I cannot seem to salvage the contents yet. I read that I could use the Source Editor in Wolfram-Workbench to examine the corrupted file, and make usable the complete parts which are still there. However, it is not apparent how to see (view/edit) the NoteBook file in Workbench. I have imported it, but I cannot see it...I just see a 4-line long bit. But using a text editor I see that there are really thousands of lines. My question is: how can I view and edit the nb file, so as to fix it to make parts of it usable again? Maybe vim or Notepad+ or the like are preferable to the WW SourceEditor? /Mark ------------------- Mark C Kelly, PhD Scientist, Ris=F8/DTU === Subject: Legends in GraphicsGrid Hello Group, I am again struggling with inserting legends into plots.I need to automate the plotting of many GraphicsGrids with some automated legend control. Usually I use a customized approach via Epilog/Inset but I need to use LogLogPlots and positioning and scaling within them is not very straight forward to me. Using the built in PlotLegends Package I somewhat loose control over my plots. The legend package introduces some invisible plot margins I cannot get rid of: Compare: (*with legends*) GraphicsGrid[ Partition[ Table[Plot[i, {x, 0, 100}, ImageSize -> 200, PlotLegend -> {1}, LegendShadow -> False, LegendPosition -> {0, 0}, LegendSize -> 0.5, ImageMargins -> None, ImagePadding -> 0], {i, 1, 4}], 2], Spacings -> 0., Frame -> All] (* without legends *) GraphicsGrid[ Partition[ Table[Plot[i, {x, 0, 100}, ImageSize -> 200, ImageMargins -> None, ImagePadding -> 0], {i, 1, 4}], 2], Spacings -> 0., Frame -> All] Is there a way to keep the legend fully wihtin the plot without adding some invisible wasted space? I appreciate any hints, Markus === Subject: Re: Do What I Mean - a suggestion for improving > While I understand this is small comfort to a new user, there > really isn't much else to be said. Mathematica forms a rich > complex toolset for doing mathematica analysis. Any such system > will require significant time and effort on the part of an user > to become proficient in making use of its capabilities. I'm afraid that this, if true, is small comfort to me -- but it's because I thought that the point to Mathematica was making a toolset with which many different levels of users -- smart high school juniors and seniors, college students at all levels, working engineers at BS or MS levels, professionals in many other fields without extensive math or computer science bckgrounds -- could do both analytical and numerical analyses, make plots, graphs, animations, demonstrations, in their own areas, **without having to invest significant time and effort (which they may simply not have) in learning the increasingly arcane, massive, and complex complications involved in working with Mathematica. The second sentences above says, Mathematica forms a rich complex toolset for doing mathematica [NOTE: 'mathematica'] analysis. Freudian slip? === Subject: Re: Do What I Mean - a suggestion for improving > DrMajorBob, I think you're missing the point here - and actually, this is exactly the > point that AES keeps banging on. It's up to a user to write what he means > is small comfort to a user, especially one new to Mathematica, who doesn't > know how to express what he means. and can't **easily and quickly** track down that information, in documentation that's **matched to his or her needs**. > DWIM is a tongue-in-cheek name, not to be taken literally. It is just a > name for an meta-analysis feature that inspects the user's input and > proposes similar input forms that may be closer to what the user has in > mind, based on a database of common errors. Right. Given the sophistication of everything else that Wolfram does, I assume that it has always done a massive amount of sophisticated user testing, in which it presents its (soft)wares to a wide variety of different kinds of users, and observes and studies what errors they commonly make -- right? (At least it's my understanding that many other companies do this kind of thing, with whatever kind of wares they vend -- right?) So, the above-mentioned database of common errors already exists -- right? === Subject: Problems in writing into a sequential filename Hi everybody I am enjoying the beautiful rules of programming in mathematica, and I step onto a rock: How can I write datas into a sequential filename? Let's explain myself, with an exemple below: First I work on mathematica 6.0.2 on linux I want to make a Do loop in witch I choose values for a variable: Sr (here, 0.5 and 1) Then I concatenate a pattern and the value (here RappSr and the value) and put the name into a variable (Nomfich) then I open the file (It works) But then, the problem is it does not write into the file, but it close it normally. So How can I do this not-so-tricky-thing in Mathematica? And by the way, I can't plot graphes into any Loop neither. Xavier The code: ClearAll[Global`*]; Do[ Nomfich = ToString[RappSr <> ToString[Sr]]; Print[Nomfich]; poiuy4 = OpenWrite[Nomfich]; Sr > Nomfich; 1 > Nomfich; Close[Nomfich]; , {Sr, {0.5, 1}}]; === Subject: find the maxima in a function Hallo, how can one find the maxima by using mathematica for the following function: f[x_] := 1/(8*(Pi*t)^(3/2)) * Exp[(-(x^2 + y^2 + z^2)/4*t)] i mean, the first derivation equal Zero. Oli. === Subject: Huge memory consumption of GIF.exe Hello! I have difficulties with high memory consumption of GIF.exe. I need to statistically evaluate a few million SQL-recordsets (grouped by a few thousand batches). After calculating the data, I also create some little GIF-images as a visual aid. So far, I have generated approx. 2000 images using Export[..., ...GIF] (average image size approx. code is a loop (using some Block constructs); all intermediate variables are cleared (using Clear[...]) at the end of the loop. It seems, that GIF.exe does not deallocate the used memory. Is there any way to deallocate the memory used by GIF.exe? The Mathematica front end has crashed after 4 hours and I still need to evaluate a few hundred batches. === Subject: Speed differences between Union, Tally and DeleteDuplicates I just noticed some differences in speed between Union, Tally and DeleteDuplicates. Consider 3D-points that appear multiple times in a coordinate list. I'd like to remove duplicates without changing the order (pre-6: the good ole UnsortedUnion). Now DeleteDuplicates and Tally can do this, and for lists only containing numbers DeleteDuplicates is very fast - but for coordinate tuples it is much slower than Tally (and Union, although the sorted result differs of course) (*Example*) n = 500; don = 10; pts = RandomReal[{-1, 1}, {n, 3}]; rpts = RandomSample[Join[pts, pts], 2 n]; union = Do[Union[rpts], {don}] // Timing; tally = Do[Tally[pts][[All, 1]], {don}] // Timing; deleteduplicates = Do[DeleteDuplicates[pts], {don}] // Timing; Tally[pts][[All, 1]] == DeleteDuplicates[pts] {union, tally, deleteduplicates} (*EOF*) True {{0., Null}, {0.016, Null}, {0.484, Null}} For me this is important information because the online documentation shows an example that is much faster than Union/Tally, but that does not seem to be the case for more complex lists... So I guess I=C2=B4ll go back to Tally - anyway suggestions to optimized use of DeleteDuplicates or others are welcome. Yves === Subject: MatrixRank[m, Modulus -> 5] is broken I have a strange problem. I ask for MatrixRank of matrix over the reals without Modulus and I get some number, assume 5; next I add a raw into this matrix and ask for the rank and I get 5; next I do both calculations using Modulus -> 7 and get 4 and 5. There is a problem!!! if a the additional raw was linear depended over the reals, it m-u-s-t be linear depended over Modulus because a linear combination for this extra row using other rows is valid when we apply Modulus -> 7. Therefor I suppose to get 4 and 4. what is the conclusion? === Subject: GraphPlot questions Does anyone know whether it is possible to have different Graphics objects as vertices for a GraphPlot? I would like to use Rectangle and Disk in the same plot but can't figure out how to modify statements like the one below so that it allows me to do this: VertexRenderingFunction -> ({EdgeForm[Black], Yellow, Disk[#1, 0.05], Black, Text[#2, #1]} &) It seems like VertexRenderingFunction is a one shot deal. Robert === Subject: GraphComplement doesn't work in 7.0 I find some functions do not work in mathematica 7.0. Why? are some function not implemented yet? << Combinatorica` In[4]:= GraphComplement[{1 -> 2}] Out[4]= GraphComplement[{1 -> 2}] === Subject: Re: Design choice for Printout Screen Environment I suspect not. The only thing that I can come up with is that this changes the default size for graphics (Plots for example) so that they will not run off of the side of the page. However, as a design choice, this throws out the baby with the bath water. The graphics do indeed need to be rescaled to look good on a printed page; but to change all fonts & c as well alters the expectations that 12 point type should print as 12 point type. Perhaps it was the only choice that managed the variety of issues, but it's not the correct one in my opinion so that expected document design is what the user gets. Of course one might work in the Printing Environment, but that is not the way most people use Mathematica... --David I would hazard a guess about it having to do with the aspect ratio of > a normal 8.5x11 page which is .7727272727272727... and 0.8 is close > enough. But this is a pure guess on my part. -Bob === Subject: How to vectorize code The code below computes Christoffel symbols for 2D coordinate systems. I know there are packages that do that, but that's not what I am after. Computing Christoffels is just a model problem for me. The actual class of problems that I am after is much different and wouldn't be in any package, but will have some of the same elements. I know that the attached code as atrocious and I am looking for hints on how to vectorize it so, for example, in can work in any dimension, with no loops, etc. So this is really an open ended advance, Aaron Clear[Global`*]; Christoffel2D[mapping_] := ( e1 = Derivative[1, 0][mapping]; e2 = Derivative[0, 1][mapping]; gij = ({{ e1[##].e1[##], e1[##].e2[##]}, {e2[##].e1[##], e2[##].e2[##]}} // FullSimplify) &; gIJ = Inverse[gij[##]] &; E1 = gIJ[##][[1, 1]]*e1[##] + gIJ[##][[1, 2]]*e2[##] &; E2 = gIJ[##][[2, 1]]*e1[##] + gIJ[##][[2, 2]]*e2[##] &; e11 = Derivative[1, 0][e1]; e12 = Derivative[0, 1][e1]; e21 = Derivative[1, 0][e2]; e22 = Derivative[0, 1][e2]; For [i = 1, i <= 2, i = i + 1, For [j = 1, j <= 2, j = j + 1, For [k = 1, k <= 2, k = k + 1, ToExpression[ G <> ToString[i] <> ToString[j] <> ToString[k] <> =Dot[e <> ToString[i] <> ToString[j] <> [##],E <> ToString[k] <> [##]]&;]; ]]]; ({ {{G111[##], G112[##]}, {G121[##], G122[##]}}, {{G211[##], G212[##]}, {G221[##], G222[##]}} } // FullSimplify) & ) polar[r_, theta_] := {r Sin[theta], -r Cos[theta]} Christoffel2D[polar][r, theta] // MatrixForm === Subject: Re: semi-implicit Runge-Kutta SIRUKE method with the method plugin inteface of Mathematica s NDSolve[] you can add your own method. Jens > Hello to all of you, > I am reading about the semi-implicit Runge-Kutta SIRUKE method for > solving differential equations by approximation. I'd like to know if > there are methods and examples of the method solved with Mathematica Dino. > === Subject: Re: semi-implicit Runge-Kutta SIRUKE method if you go to Menu/Help and enter Runge-Kutta, you receive a lot of links you seem to be looking for. Have success, Alexei Hello to all of you, I am reading about the semi-implicit Runge-Kutta SIRUKE method for solving differential equations by approximation. I'd like to know if there are methods and examples of the method solved with Mathematica Dino. -- Alexei Boulbitch, Dr., Habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p [Times]èéìI think questions like these may be great fun, I feel that they äïî§belong in this forum as long as they are not connected with Íáôèåíáô[ EAcute]ãá® tried the brute force method for your particular åøáí[Eth]ìof 2293 and the formal approach for the general conjecture. Âù âòõôforce using Íïîéôïò[ CapitalUHat] [Times]èéìåÛPrimeQ[2^i - 2293], i++], ] æï2 n +1 ==2293 I find after a long wait that i must be larger than ´.b3 °.b3if the conjecture is correct. formal way of stating the problem in Mathematica would be ÆïòÁìì[Capita lUHat]în [Element] Integers, ÅøéóôóÛ[UHa t]é¬ [Eth][YAcute]i [Element] Integers [And] p [Element] Primes, n + 1 == 2^i + p [Or] 2 n + 1 == 2^i - p]] Òåóïìöor FullSimplify could then be used to find out whether or not ôèåòis any truth in this statement. Alas, they both return unsolved. Ãèååòó [Hyphen][Hyphen] Óïåòä I have a conjecture: Any odd positive number is the sum of 2 to an i-th power and a (negative) prime. 2n+1 = 2^i+p > for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... as to 2293=2^i +p $B!$(BI don't know i , p . it is sure that i>30 000 if the conjecture is correct. > More, n = 3^i+p, (if n=6k-2 or n=6k+2) for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 > I can't proof this. Do you have any idea? === Subject: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p The conjecture is false. It fails when the number tested is prime (but not the second of a twin prime pair). And it fails in other cases, too. Proof: Clear[test] test[k_?OddQ] /; k >= 3 := Module[{n = 0}, Catch[While[2^n < k, PrimeQ[k - 2^n] && Throw@{2^n, k - 2^n, True}; n++]; {k, False}]] These are the failures up to 1000: failures = Cases[test /@ Range[3, 1000, 2], {k_, False} :> {k, PrimeQ@k}] {{127, True}, {149, True}, {251, True}, {331, True}, {337, True}, {373, True}, {509, True}, {599, True}, {701, True}, {757, True}, {809, True}, {877, True}, {905, False}, {907, True}, {959, False}, {977, True}, {997, True}} Primes are marked with True, and non-primes with False, so the most interesting of these is the first non-prime failure, 905. Here's an independent test for that one: 905 - 2^Range[0, Log[2, 905]] PrimeQ /@ % {904, 903, 901, 897, 889, 873, 841, 777, 649, 393} {False, False, False, False, False, False, False, False, False, False} Also, there are 2^k + 1 that fail: test /@ (1 + 2^Range[18]) {{1, 2, True}, {2, 3, True}, {2, 7, True}, {4, 13, True}, {2, 31, True}, {4, 61, True}, {2, 127, True}, {16, 241, True}, {4, 509, True}, {4, 1021, True}, {32, 2017, True}, {4, 4093, True}, {2, 8191, True}, {4, 16381, True}, {512, 32257, True}, {16, 65521, True}, {2, 131071, True}, {0, 262145, False}} The smallest of these is 2^18+1 == 262145. Bobby > I have a conjecture: > Any odd positive number is the sum of 2 to an i-th power and a > (negative) prime. > 2n+1 = 2^i+p for example: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... > as to 2293=2^i +p =1B$B!$=1B(BI don't know i , p . it is sure that i>30 000 = > if > the conjecture is correct. More, > n = 3^i+p, (if n=6k-2 or n=6k+2) > for example:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 I can't proof this. Do you have any idea? > -- = DrMajorBob@bigfoot.com === Subject: Re: Looking to time how long a command takes in mathematica 6 tia I think, you should write <= , rather than = in the definition of your piecewise function. Have a look at this: In[16]:= f[x_] := Piecewise[{{4.*x^2 - 4.*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6, 1 <= x <= 3}, {x^2 - 10*x + 21, 3 <= x <= 7}, {-1/2*x^2 + 11*x - 105/2, 7 <= x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, 15 <= x <= 22}, {-.8*x^2 + 39.2*x - 475.2, 22 <= x <= 27}}] In[20]:= Timing[Play[f[x], {x, 0, 27}]] Out[20]= {0.031, (Sound[ SampledSoundFunction[ CompiledFunction[{Blank[Integer]}, {{2, 0, 0}, {3, 0, 1}}, {0, 1, 3, 0, 0}, {{1, 5}, {8, 0., 0}, {8, 0.000125, 1}, {15, 1, 0, 2}, {21, 1, 2, 1}, {18, 0, 1, 0}, { 54, Function[{ Play`Time5}, $CellContext`f[$CellContext`x]], {$CellContext`x, 3, 0, 0, Block}, 2, 0, 0, 3, 0, 1}, { 8, -0.5000937551520472, 2}, {18, 1, 2, 1}, { 8, 0.13333620140328437`, 2}, {21, 1, 2, 1}, {2}}, Function[{Play`Time5}, Block[{$CellContext`x = 0. + 0.000125 Play`Time5}, ($CellContext`f[$CellContext`x] - 0.5000937551520472) 0.13333620140328437`]], Evaluate], 216000, 8000]])} Have a success, Alexei Grettings All I'm running this command Play[Piecewise[{{4.000000000*x^2 - 4.000000000*x, 0 = x <= 1}, {-2*x^2 + 8*x - 6, 1 = x <= 3}, {x^2 - 10*x + 21, 3 = x <= 7}, {-1/2*x^2 + 11*x - 105/2, 7 = x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, 15 = x <= 22}, {-.8000000000*x^2 + 39.20000000*x - 475.2000000, 22 = x <= 27}}], {x, 0, 27}] and it's taking extremely long and would like to find out how long it takes to run this line. Also if anyone has a more efficient way of using this command please let me know. I'm just trying to output the wave file to an audio file. Aloha sal2 -- Alexei Boulbitch, Dr., Habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Hasse Diagram That's an example from the Conbinatorica manual, which is included in the electronic help texts of Mathematica. No need to search the internet for that. MakeGraph and Subsets can be found there as well. Apparently you haven't thought of reading the manual before asking questions... Could you provide an example of the matrix or graph you tried? > that did not display all vertices for me I found this command searching the web > It works, but I don't understand what the syntax means ShowGraph[ > HasseDiagram[ > MakeGraph[ > Subsets[4], ((Intersection[#2, #1] == #1) && (#1 != #2)) &]]= ] === Subject: Re: Experimental Mathematica debugger > Hi David, I do not intent to be picky, but there are still problems. You can now type into the edit box, but you can not paste. Further, I tried a conditional breakpoint(with Cup replaced by Underscore!: > but this seems to have no effect. Daniel Daniel and I have had a useful private discussion about the issues here. He persuaded me that since many users will be beginners, I should avoid using [Breve] in my function names (which he was reading as a [Cup] character - which looks very similar!), and I have made this change in the latest version (0.97) - now available on my website. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Looking to time how long a command takes in mathematica 6 tia The calculation is finished in 16 ms. The waveform you are generating doesn't seem to be meaningful. Try to make one with audible frequency content (as others, whom you stubbornly ignored, already pointed out to you). > Grettings All I'm running this command > Play[Piecewise[{{4.000000000*x^2 - 4.000000000*x, > 0 = x <= 1}, {-2*x^2 + 8*x - 6, 1 = x <= 3}, {x^2 - 10*x = + 21, > 3 = x <= 7}, {-1/2*x^2 + 11*x - 105/2, > 7 = x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, > 15 = x <= 22}, {-.8000000000*x^2 + 39.20000000*x - 475.200000= 0, > 22 = x <= 27}}], {x, 0, 27}] and it's taking extremely long and would like to find out how long it > takes to run this line. Also if anyone has a more efficient way of > using this command please let me know. I'm just trying to output the > wave file to an audio file. Aloha > sal2 === Subject: Re: Looking to time how long a command takes in mathematica 6 tia Set[] is not Equal[] and so you must write == instead of = and if you end a sub-itnerval with {-2*x^2 + 8*x - 6, 1 = x <= 3} than the next must start with {x^2 - 10*x + 21, 3 < x <= 7} because x==3 is already defined from the previous interval. Play[Piecewise[{{4.000000000*x^2 - 4.000000000*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6, 1 < x <= 3}, {x^2 - 10*x + 21, 3 < x <= 7}, {-1/2*x^2 + 11*x - 105/2, 7 < x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, 15 < x <= 22}, {-.8000000000*x^2 + 39.20000000*x - 475.2000000, 22 < x <= 27}}], {x, 0, 27}] works fine. Jens > Grettings All I'm running this command > Play[Piecewise[{{4.000000000*x^2 - 4.000000000*x, > 0 = x <= 1}, {-2*x^2 + 8*x - 6, 1 = x <= 3}, {x^2 - 10*x + 21, > 3 = x <= 7}, {-1/2*x^2 + 11*x - 105/2, > 7 = x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, > 15 = x <= 22}, {-.8000000000*x^2 + 39.20000000*x - 475.2000000, > 22 = x <= 27}}], {x, 0, 27}] and it's taking extremely long and would like to find out how long it > takes to run this line. Also if anyone has a more efficient way of > using this command please let me know. I'm just trying to output the > wave file to an audio file. Aloha > sal2 > === Subject: Re: Looking to time how long a command takes in mathematica 6 tia it runs so long because you have a syntax error.Equal is written == not =. Daniel > Grettings All I'm running this command > Play[Piecewise[{{4.000000000*x^2 - 4.000000000*x, > 0 = x <= 1}, {-2*x^2 + 8*x - 6, 1 = x <= 3}, {x^2 - 10*x + 21, > 3 = x <= 7}, {-1/2*x^2 + 11*x - 105/2, > 7 = x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, > 15 = x <= 22}, {-.8000000000*x^2 + 39.20000000*x - 475.2000000, > 22 = x <= 27}}], {x, 0, 27}] and it's taking extremely long and would like to find out how long it > takes to run this line. Also if anyone has a more efficient way of > using this command please let me know. I'm just trying to output the > wave file to an audio file. Aloha > sal2 > === Subject: Re: Head logic Hi Carlos, The reason is that Equal tests for equality by value, not syntactic equality. And symbols generally have no value, otherwise they would evaluate to that value. On two symbols, for which there is no rule built in the system (or added by the user) telling Mathematica that they should be considered equal, Equal (==) will return unevaluated, which is correct because they are neither necessarily equal nor necessarily you will get what you want. Alternatively, use TrueQ[lhs==rhs] - this will force Mathematica to give False whenever the result does not evaluate to True. However, for the case at hand the first method (SameQ) seems more appropriate. Leonid > Entering ClearAll[r]; > Head[r] > Head[r]!=Symbol > Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? > Head[r] is certainly not Integer. Likewise r=4; > Head[r]==Integer > Head[r]!=Symbol > Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. > Why not True and False? === Subject: Re: Head logic It's the same for every comparison of heads, e.g. Times == Plus return unevaluated as well. Not sure why this is so, but I guess it would be difficult to provein general that two functions are exactly functional equivalent or not. whether the comparants are literally the same. For testing of heads you could use expressions described in tutorial/PuttingConstraintsOnPatterns and tutorial/SpecifyingTypesOfExpressionInPatterns > Entering ClearAll[r]; > Head[r] > Head[r]!=Symbol > Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? > Head[r] is certainly not Integer. Likewise r=4; > Head[r]==Integer > Head[r]!=Symbol > Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. > Why not True and False? === Subject: Re: Head logic Hi Carlos, this behavior/logic has nothing to do with Head, but with Mathematica's treatment of Integer and Symbol symbols. Unfortunately those symbols which do not have values and will never have values are interpreted by Mathematica in the same way as variables like In[10]:= a == b Out[10]= a == b and not like constants: In[11]:= Pi == MachinePrecision Out[11]= False The behavior for variables is ok since the output depends on their current values (e.g. b = a would evaluate to True; but {a = 3, b = 4} would evaluate to False). In the case of symbols like Pi or E the value is fixed (attribute Constant) and cannot be changed (attribute Protected) so predicates can always give True or False. If Mathematica would use the attribute Protected in its evaluation of predicates (like Equal[]) we would also get the expected definite behavior for Symbol and Integer symbols. This would generally mean that, for example In[12]:= Protect[{a, b}] Out[12]= {a, b} In[13]:= a == b would evaluate to False because the symbols have no values and are protected (so cannot have values). Those symbols are then just pure symbols and not variables. Integer and Symbol have both the Protected attributes and my suggestion is that Mathmatica should use it in evaluations. Other opinions about this matter? Drago > Entering ClearAll[r]; > Head[r] > Head[r]!=Symbol > Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? > Head[r] is certainly not Integer. Likewise r=4; > Head[r]==Integer > Head[r]!=Symbol > Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. > Why not True and False? > === Subject: Re: Head logic Bobby > Entering ClearAll[r]; > Head[r] > Head[r]!=Symbol > Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? > Head[r] is certainly not Integer. Likewise r=4; > Head[r]==Integer > Head[r]!=Symbol > Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. > Why not True and False? > -- DrMajorBob@bigfoot.com === Subject: Re: Head logic may be there is a reason why there exist SameQ[] The reason is that a==b is may be true if a and b have values but general this is an equation. If want to test something that must yield True or False use SameQ[] anf UnsameQ[] Jens > Entering ClearAll[r]; > Head[r] > Head[r]!=Symbol > Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? > Head[r] is certainly not Integer. Likewise r=4; > Head[r]==Integer > Head[r]!=Symbol > Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. > Why not True and False? > === Subject: Re: Head logic In situations like this one ought really use SameQ and UnsameQ. True, in this case one can't assign values to Symbol or Integer, but Mathematica is clearly not using that fact and therefore does not know whether they are Equal or not. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Entering ClearAll[r]; Head[r] Head[r]!=Symbol Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? Head[r] is certainly not Integer. Likewise r=4; Head[r]==Integer Head[r]!=Symbol Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. Why not True and False? === Subject: Re: Head logic > Entering ClearAll[r]; > Head[r] > Head[r]!=Symbol > Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? > Head[r] is certainly not Integer. Likewise r=4; > Head[r]==Integer > Head[r]!=Symbol > Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. > Why not True and False? > == only evaluates to False for comparisons between certain types of raw data according to the help documentation, == apparently doesn't and =!= if this is a problem. Sseziwa === Subject: Re: FindRoot and evaluations Davide, You should define SomethingLongAndHeavy so that it only accepts numeric input. Instead of defining it as SomethingLongAndHeavy[x_] := ... define it as SomethingLongAndHeavy[x_?NumericQ] := ... Don't forget to clear the previous definition before using ClearAll [SomethingLongAndHeavy] or Quit the kernel. > Let's say: F[x_]:=Module[ > {x0=x}, > Print[x0]; > SomethingLongAndHeavy[x0] > ]; now I do: FindRoot[F[x],{x,0}] and it prints: x because it first attempts to evaluate F[x] in a symbolic form. > I don't want this. Because SomethingLongAndHeavy is a recursion set of > relations which generates a polynomial of order... too much. What I > would like to see is: 0.0001 > 0.0002 > ... So that F[x] is treated as a blackbox, and some Newton or Bisection > method is applied on this blackbox. > How to do that? Davide PS: Based on previous discussions I already tried to play with > attributes HoldAll and option Evaluated, with no success. === Subject: different output!! Hi Mathematica community, Why output2 (with integers as domain) is different from output1 (with reals as domain) ?!! I think it should be the same thing. input1:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Reals, Backsubstitution -> True] output1: 0 <= Mod[x, 5] < 5 && xP == Mod[x, 5] input2:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Integers, Backsubstitution -> True] output2: (Mod[x, 5] == 0 && xP == 0) || (Mod[x, 5] == 1 && xP == 1) || (Mod[x, 5] == 2 && xP == 2) || (Mod[x, 5] == 3 && xP == 3) || (Mod[x, 5] == 4 && xP == 4) === Subject: Re: Example for NetworkFlow function Not sure whether this helps, but as an example the network in the translates to (if I'm interpreting everything right): Infinity}, {0, Infinity, 2, 3, Infinity, Infinity}, {0, 2, Infinity, Infinity, 4, Infinity}, {Infinity, 0, Infinity, Infinity, 1, 2}, {Infinity, Infinity, 0, 0, Infinity, 5}, {Infinity, Infinity, Infinity, 0, 0, Infinity}}, EdgeWeight], 1, 6] You're talking about sinks and sources. Judging from the documentation I'd say only one sink and one source are possible. can you point me to a minimal commented example of the NetworkFlow > function? I have a graph with sources, sinks and transshipment nodes and I do > not know how to specify these nodes as function parameters. Any hint appreciated, Karsten. === Subject: Re: Do What I Mean - a suggestion for improving Mathematica experience > A few days ago I posted that Mathematica should have a DWIM feature - Do > What I Mean. In InterLisp, in the 80's, the DWIM facility was hooked into error messages, > and when invoked on a user error would poke around on the stack and in the > environment using some rules to describe common error situations and it > would uncover user errors and offer to correct them. Many of the errors > were simple spelling errors and it would correct a misspelled variable name > if it found an unbound variable but a similarly spelled variable was bound > in the environment. Mathematica could benefit from this, and in fact, we at mathgroup could > supply the rules (and framework) as a useful group project. If some guru would write the framework - trapping error messages somehow, > perhaps when they were written to the $Messages channel (by replacing the > default $Messages channel with something that would hook into the DWIM > function), or perhaps with some other hook like redefining Message[] - then > the rest of us could supply rules for the common errors. Especially the > common errors we see puzzling Mathematica newbies on this list. I would suggest that the rules provide messages, hopefully with hyperlinks > to the documentation. A true DWIM might also offer to rewrite the current expression and try it > again, but I don't know if that can be done given the hooks into Mathematica > that are currently available. Some situations that could be addressed are: under evaluation and find (unevaluated) symbols like xy of the form > where both and were either symbols > used in the expression or symbols bound in the environment. Rule would > explain the problem and offer to rewrite expression and try again. 2. Some expression using a user-defined function causes an error when > evaluating, or doesn't evaluate. Looking at the function, a rule finds > function calls where the function arguments' patterns include _Integer or > similar but the arguments given to it are not integers. Rule points to > documentation describing argument types required by the called function. 3. Similar to 2 above, but it finds function calls that do numeric > evaluation only or are optimized for numeric evaluation but the arguments > given to it are symbolic. 4. Result returned is machine precision very close to zero (that is, > with large negative exponent), but an error message complained of > singularity, or other ill-conditioning. Rule points to documentation > explaining about machine precision, and/or singularity, and offers to retry > the expression with more digits of precision, rewriting the expression to > achieve this. Actually, now that I think of it, the DWIM facility needs also to be invoked > by the user because some of these situations don't cause error messages, but > only cause (wholly or partially) unevaluated expressions. So maybe the user > could be trained to type a word, like Explain[] after he didn't get the > result he wanted and the DWIM facility would look at the In[] and Out[] > arrays to find out what he's been doing recently. I would be glad to contribute rules to the framework ... but I'm not yet up > to writing the framework. Hopefully one of the gurus here will find this > interesting (and possible) and provide a framework. Then the rest of us > could contribute rules that would improve the Mathematica experience for all > newcomers. (AES, I'm looking at you! :-) ) -- David > Wow - that sounds a very challenging project! I wonder if it would be better to start with a slightly more modest idea, and write a CommentOn function that would have attribute HoldFirst, and take any expression as an argument, and apply as many heuristics as possible, looking for possible mistakes - such as your xy example. Another such function might be WhyNoMatch that would take a function call and attempt to explain why it did not match the definition. The problem is, I suspect beginners write arguments as x_ rather than x_Integer - but having said that, they sometimes write them as x - which can waste a lot of time. As it happens, I have just released an experimental debugger (see my post of the other day). I guess that could look for certain things going wrong - such as the problem you cite of a numeric routine ending up doing a symbolic calculation. I think the real challenge might be to raise the success rate high enough that people felt it was worth running the code. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Need some help with monitoring evaluation This has caused me some consternation in the past. By this I mean that > I make some coding error that causes Mathematica to loop. I would check out: ref/TimeConstrained > ref/Reap > ref/StepMonitor HTH. Roger Williams For the curious, TracePrint provided the most useful following information using _Integrate as the pattern. After about 24 hours the InverseFourierTransform could not be done and Mathematica returned the original expression. I was wistfully optimistic, expecting the multiplication in the Fourier domain to give a result when the corresponding integral in the normal domain won't. I don't know if this is a forum where math questions are posted (as opposed to strictly Mathematica questions), but I'll ask anyway. The PDF of the circular distribution has two discontinuities. If I do a numeric convolution with ListConvolve I can easily get a result. Alternatively I can use a summation and get a symbolic result consisting of hundreds or thousands of summands. Neither solution can be readily integrated nor differentiated (the variables shown as constants below are more complicated that that, though they are independent). I'd really like to get a closed form symbolic formula for the convolution. Am I dreaming to think that Mathematica can do something like this? Or it is simply a fact of math that a discontinuous function cannot be convolved with a Gaussian Distribution and no trick or computational genius will make it work? Finally, I've tried to curve fit to the summation solution without much luck. I've used the Taylor and polynomial expansions along with FFTs. The convolution is a beautiful curve based on a sum of Gaussians and so intuitively seems easy to fit, but I can't seem to get it. All variables are real, and both ll and ss are always positive. So, for the illustration, try this: vars = { ll -> .27, mm -> 0, ss -> .06 }; pdf1[ xx_ ] := PDF[ NormalDistribution[ mm, ss ], xx ]; pdf2[ xx_ ] := Piecewise[ { { 1/(Pi * Sqrt[ ll^2 - xx^2 ]), Abs[ xx ] < ll } }, 0 ]; Plot[ { pdf1[ xx ], pdf2[ xx ] } /. vars, { xx, -.3, .3 } ] conv = Sum[ (pdf1[ xx - zz ] pdf2[ zz ]), { zz, -.6, .6, 0.02 } ] / 200; Plot[ Evaluate[ conv /. vars ], { xx, -.5, .5 } ] I'm seeking a symbolic representation of the second curve. Please be kind Jens -- I'm admittedly an amateur! === Subject: Re: wrong solution for double integral of piecewise When you integrated by hand you assumed that b > a, Mathematica gives a more complicated result since it does not make that assumption unless you tell it to do so. Clear[f] f[x_, p_] = Piecewise[{{k, {a <= x <= b, a <= p <= b}}}]; int = Integrate[f[x, p], {x, -Infinity, Infinity}, {p, -Infinity, Infinity}] Piecewise[{{k*(a - b)^2, a - b < 0}}, 0] Simplify[Reduce[int == 1], b > a] // ToRules {k -> 1/(a - b)^2} The UnitStep expression is equivalent to the Piecewise expression expr = {k -> -(1/((a - b)^2 (-1 + UnitStep[a - b])))}; Simplify[expr, b > a] {k -> 1/(a - b)^2} You can include the assumption with the integral Assuming[{b > a}, Integrate[f[x, p], {x, -Infinity, Infinity}, {p, -Infinity, Infinity}]] k (a-b)^2 Integrate[f[x, p], {x, -Infinity, Infinity}, {p, -Infinity, Infinity}, Assumptions -> {b > a}] k (a-b)^2 Bob Hanlon wrong solution for double integral of piecewise function I've got a function f[[Chi]_, [Psi]_] = {Piecewise[{{k, {a <= [Chi] <= b, a <= [Psi] <= b}}}, 0]} I'm attempting to solve for k such that f becomes a probability density function by applying the normalization constraint, i.e. solving for k such that the double (indefinite) integral of f equals 1. I can do this by hand pretty easily, integrating first/inside WRT psi and second/outside WRT chi, and I get (1) k = 1/((b-a)^2) I don't have the world's greatest calculus chops, but that looks correct to me. (Am I missing something?) However, when I use Mathematica to Solve[ First[ Integrate[ Integrate[ f[[Chi], [Psi]], {[Psi], -[Infinity], [Infinity]} ], {[Chi], -[Infinity], [Infinity]} ] ] == 1, k ] I get (2) {{k -> -(1/((a - b)^2 (-1 + UnitStep[a - b])))}} which seems wrong to me, though I'll admit I don't know what UnitStep means. So I'm wondering * does (1) = (2)? or * have I made a syntax error? or * is this just really hard to solve symbolically? If so, is there a better way to setup this function and its solution? === Subject: Re: How to Export the Manipulate On 2=D4=C228=C8=D5, =CF=C2=CE=E77=CA=B145=B7=D6, ekt Wayne I'd never thought about doing this before, but it turns out to be easy. Export[filename.avi,Manipulate[...your code here...]] Do the manipulations and click on the code line and you'll find your file= . ekt Hi ,all i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF > figure, but dont know how to Export the Manipulate produced > animations,can someone here drop me a hint ? > Wayne.- =D2=FE=B2=D8=B1=BB=D2=FD=D3=C3=CE=C4=D7=D6 - - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 - as a better explanation , please see this GIF,i just want it to be produced by Mathematica codes: http://hiphotos.baidu.com/%B0%D7%C0%CB/pic/item/e5fdb90e02ed1ff036d122bf.jp= eg === Subject: Re: How to Export the Manipulate If you just want a movie, you can use a screen capture program. I sue Snapz Pro X on OS X, but there must be similar programs for Linux or Windows. Once the program is capturing video, you can manipulate the controls. The resulting video can be processed for QuickTime, Flash, or some other format. george the non-interactive version make a flash video, the > interactive variant need a MathPlayer and the translation of you > code into MathPlayer. Jens > Hi ,all >> i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF >> figure, but dont know how to Export the Manipulate produced >> animations,can someone here drop me a hint ? >> Wayne. > === Subject: Re: simplifying quotient of piecewise functions Tom, As far as I can see you have not built your Piecewise construction correctly. Look in the basic example sextion of the Piecewise doc page for information how to do this as either a 2D displayed function (with esc pw esc and ctrl-, and ctrl-enter) or a 1D InputForm function, using the formal Piecewise syntax. One thing that is missing is a default value in case the conditions are false. You can do without (and then you get the default of 0), but is often safer to state your assumptions explicitely. The main problem is the combination of the two conditions for chi and psi. You used a comma, whereas you should have used the logical AND (&& or esc-&&- esc). After correcting these errors Simplify or PiecewiseExpand work just fine. I get: Piecewise[{{Indeterminate, [Psi] > 1 || [Psi] < 0}, {(2*[Chi] + [Psi])/(4 + 2*[Psi]), 0 <= [Psi] <= 1 && 0 <= [Chi] <= 2}}, 0] > I'm solving some conditional probability density functions. One > solution involves a division such that the numerator is (1) [Piecewise]1/5 (2 [Chi]+[Psi]) {0<=[Chi]<=2,0<=[Psi]<= =1} and the denominator is (2) [Piecewise]((2 (2+[Psi]))/5) 0<=[Psi]<=1 For the quotient, Mathematica 7 is just giving me (1) over (2), rather > than (3) [Piecewise]((2 [Chi]+[Psi])/(2 (2+[Psi]))) > {0<=[Chi]<=2,0<=[Psi]<=1} even when I append // Simplify and re-evaluate. Am I using the wrong syntax to get the simplified > quotient? or am I wrong to expect (3)? === Subject: Question about MathLink and .NET/Link with Mono on Mac OS X and Linux hi there, I would like to be able to interact between the Mono runtime and Mathematica but I am running into problems regarding the MathLink libMLi3 library. I have the following setup: OS X --> 10.5.6 Mathematica version string --> 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) Mono version string --> Mono JIT compiler version 2.2 (tarball Fri On searching the MathGroup archive I found a message indicating that there exists experimental support for Mono on Linux in .NET/Link since ver 5.2 of Mathematica as long as the mono command is in your $PATH (yes in my case). ( Oct 2005 [msg61190] ) and as NETLink was placed in $InstallationDirectory/SystemFiles/ Links/, next to JLink, by the Mathematica for OS X installer, I expected things to work out of the box, like JLink does. Following the procedure set out in the NETLink tutorial I typed into a notebook with an active kernel: Needs[NETLink`] $Packages and received the following output: {NETLink`, ResourceLocator`, DocumentationSearch`, JLink`, PacletManager`, WebServices`, System`, Global`} However, when trying to launch the runtime via InstallNET[] it fails with: LinkOpen::linke : Could not find MathLink executable. >> InstallNET::fail : A link to the .NET runtime could not be established. >> $Failed This happens even when I SetDirectory to $InstallationDirectory/ SystemFiles/Links/MathLink When trying to launch the mathlink executable manually from the shell it fails with: -bash: ./mathlink: cannot execute binary file I am still very much of a Mathematica noob but I went and opened the InstallNET.m source file and found another indicator that this should be possible, line 176,7 If[!osIsWindows[], netlinkPath = mono ... The source in this file seems to indicate that the key to getting this working lies in the netLinkExe file, InstallableNET.exe, which is next to NETLink.m. I tried to launch this file on the Mono CLR and received the following error message: rools@roolsMBP:~/Applications/Mathematica.app/SystemFiles/Links/ NETLink $mono InstallableNET.exe Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Wolfram.NETLink.Internal.NativeLink ---> System.DllNotFoundException: libML32i3.so at (wrapper managed-to-native) Wolfram.NETLink.Internal.UnixMathLinkAPIProvider:MLBegin (intptr) at Wolfram.NETLink.Internal.UnixMathLinkAPIProvider.extMLBegin (IntPtr zero) [0x00000] at Wolfram.NETLink.Internal.NativeLink..cctor () [0x00000] --- End of inner exception stack trace --- at Wolfram.NETLink.MathLinkFactory.createMathLink0 (System.String cmdLine, System.String[] argv) [0x00000] at Wolfram.NETLink.MathLinkFactory.CreateMathLink (System.String[] argv) [0x00000] at Wolfram.NETLink.MathLinkFactory.createKernelLink0 (System.String cmdLine, System.String[] argv) [0x00000] at Wolfram.NETLink.MathLinkFactory.CreateKernelLink (System.String[] argv) [0x00000] at Wolfram.NETLink.InstallableNET.Main (System.String[] args) [0x00000] The problem is that the UnixMathLinkAPIProvider is called and not the MacMathLinkAPIProvider. Because of this it is trying to find the libML32i3.so shared library. Mathematica for OS X does not have an OS X dynamic library, i.e. libML32i3.dylib - the equivalent of the Linux shared library. Only a static library, libMLi3.a which resides in $InstallationDirectory/SystemFiles/Links/MathLink/DeveloperKit/ CompilerAdditions for which I created a link in /usr/local/lib I'm wondering if there is a way to change things to load the MacMathLinkAPIProvider instead. Obviously the .cs source files are available but this is baked into InstallableNET.exe And if I could, would I be able to do the DllImport on libMLi3.a? Currently the MacMathLinkAPIProvider.cs file declares the library [DllImport(mathlink)] compared to the Unix provider's [DllImport(libML32i3.so)] Any advice, thoughts and ideas will be greatly appreciated. Cornelis === Subject: Re: FindRoot and evaluations F[x_?NumericQ] := Module[ {x0 = x}, Print[x0]; SomethingLongAndHeavy[x0]]; Bob Hanlon Let's say: F[x_]:=Module[ {x0=x}, Print[x0]; SomethingLongAndHeavy[x0] ]; now I do: FindRoot[F[x],{x,0}] and it prints: x because it first attempts to evaluate F[x] in a symbolic form. I don't want this. Because SomethingLongAndHeavy is a recursion set of relations which generates a polynomial of order... too much. What I would like to see is: 0.0001 0.0002 ... So that F[x] is treated as a blackbox, and some Newton or Bisection method is applied on this blackbox. How to do that? Davide PS: Based on previous discussions I already tried to play with attributes HoldAll and option Evaluated, with no success. === Subject: Re: contourlabels in contour plot Hi Pasha, Your example didn't show any contours, but that's because you used an incorrect PlotRange. You can change the fontsize of the contour lables by adding the option BaseStyle -> {FontSize -> 20}. You can change the size of the axis labelling by replacing the directive Large with FontSize -> x, with x the desired font size. I was wondering that in Mathematica 6 how can we define a specific size > and special font for the labels of a certain contour plot. > As we change the size of contourplot, the labels stay same size! For example > ContourPlot[a+b,{a, 0, 4}, {b, 0, 1.3}, ColorFunction -> GrayLevel, Axes > -> True, > AxesLabel -> {a, b}, LabelStyle - Directive[Black, Large, > Bold], ContourLabels -> Automatic, Frame -> False, PlotRange -> {16, > 24}, Contours -> 10] > we always get one size for the contourlabels. Pasha === Subject: Delayed function does not behave as original input Hello All: I am trying to make a simple function to Riffle two lists together for trying to do. Clearly, I am missing something basic here, but cannot seem to see what. close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2] Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, 52.05}} (* The above is what I want *) dateDataMerge[datedata_, ordinatedata_] := Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; closedatesbad = dateDataMerge[dates, close] During evaluation of In[180]:= Riffle::list: List expected at position 1 in Riffle[52.25,2009,{1,-1,2}]. >> During evaluation of In[180]:= Riffle::list: List expected at position 1 in Riffle[52.25,2009]. >> During evaluation of In[180]:= Riffle::argtu: Riffle called with 1 argument; 2 or 3 arguments are expected. >> During evaluation of In[180]:= Riffle::list: List expected at position 1 in Riffle[52.25,2,{1,-1,2}]. >> During evaluation of In[180]:= General::stop: Further output of Riffle::list will be suppressed during this calculation. >> Any help is appreciated. t. === Subject: Re: Exporting data into a file, OpenWrite I usually use the Insert/File Path ... menu to paste the file path. > I use either ToFileName or a variant of the following, when I want to > capture/create file or directory names: {FileNameSetter[Dynamic@ts, Directory], Dynamic@ts} I never, ever type in the file name by hand, so I never, ever get Windows= > and Mac conventions confused. Bobby > > no double-slashes for me thank you very much - I've got a Mac. > 2009/2/24 Sjoerd C. de Vries : > When you use Export, the file will be created in the current >> working directory. > I might add ...unless you include the full path to the file in the > filename (using double slashes to separate directories and files, as = a > slash is used as an escape character in strings) > I think correctly you would call the character that you need to use on > Windows a backslash () and that's the one you need to escape, because > it is the escape character in Mathematica. On other systems you will > need other characters for separating directories in pathes, which one i= s > held in the variable $PathnameSeparator. AFAIK on Windows in many > places within Mathematica a single slash (/) will also work as a > pathname separator in filenames. Probably you shouldn't rely on that bu= t > it's more convenient than the double backslash sometimes. An even better approach is to construct the filename with the function > ToFileName, starting with one of the predefined directory variables you > can find with Information[$*Directory*] hth, albert -- > DrMajor...@bigfoot.com === Subject: Do Hershey Vector Fonts exist in Mathematica? Hello everyone: Just wondering if the Hershey Vector Fonts (in particular the SIMPLEX Roman ones) are available for use with Mathematica. I know, they are ugly, primitive looking etc., however, I'm not ashamed to admit I love the look of them for text on plots. Can't explain it really. Perhaps it's because I was used to using them with old school plotting calls from Fortran using DISLIN and have grown rather fond of them. If you do not know what they look like, they are posted here: http://idlastro.gsfc.nasa.gov/idl_html_help/Hershey_Vector_Font_Samples.html Currently I've defaulted my fonts in graphics to Courier as a compromise, but still, I wonder if I could ever use those fonts again.... Nothing serious, just missing my old fonts and hoping they might be able to be installed and used. For what it's worth I am using a Linux Kubuntu 8.04 box. t. === Subject: Re: Can't quite figure out tensors The tensor product of two matrices m1 and m2 is given by Outer [Times,m1,m2] if that's your question. Depending on your needs, you may throw in an ArrayFlatten I'm trying to write code that will produce Christoffel symbols for > various coordinate systems. I would like to use the definition that > yields Gamma_ij^k as the partial of the covariant basis e_i with > respect to variables x^j dotted with the contravariant vector e^k. So > far I have z[r_, theta_] := {r Cos[theta], r Sin[theta]} > ei[r_, theta_] := {Derivative[1, 0][z][r, theta], > Derivative[0, 1][z][r, theta]} > gij[r_, theta_] := ei[r, theta].Transpose[ei[r, theta]] > gIJ[r_, theta_] := Inverse[gij[r, theta]] > deidxj[r_, theta_] := {Derivative[1, 0][zi][r, theta], > Derivative[0, 1][zi][r, theta]} and now i need to form the tensor product > deidxj * gIJ * ei and it has proven to be a bit to intense for me to pull off. Could > someone show me how to do that? > Aaron === Subject: Re: newbie: diff equation Not only for differential equations, but for all equations. == is the equals Function, = is the Set function. > You have to use two equals signs instead of one when inputting a > differential equation. -----Original Message----- === > Subject: newbie: diff equation My problem is very simple, I'm sure someone can help me out quickly. I am > trying to solve some systems of differential equations a bit like a parti= cle > in a box (QM) so I started with this basic problem which I know how to so= lve > just to make sure I am entering everything ok, but I can't even get it to > work. I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer but= if > I do DSolve on the above with the boundary conditions I just get f=0. H= ow > can I get mathematica to solve this and give me the conditions on m? I ne= ed > to solve much more general problems of this type. I hope someone can help= . === Subject: Using Play command and polynomial tia sal2 I know the play command uses sin, cos, etc. But I would like to use the Play command to listen to a polynomial. Example below of polynomial Plot[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6 , 1 = x < 3}}], {x, 0, 3}] I replace the Plot command with Play Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6 , 1 = x < 3}}], {x, 0, 3}] but mathematica 6 just comes back with errors and just says running.. I think it's syntax but I haven't found an example of using the Play command and Piecewise. Should I be doing this another way? tia sal2 === Subject: Hasse Diagram Hi I'm trying to display and manipulate a Hasse Diagram with 16 vertices. Can someone help with the syntax === Subject: Re: Do What I Mean - a suggestion for improving DrMajorBob, I think you're missing the point here - and actually, this is exactly the point that AES keeps banging on. It's up to a user to write what he means is small comfort to a user, especially one new to Mathematica, who doesn't know how to express what he means. Not only do we see a lot of comments on this list of the form Why doesn't this work? we see a lot of the form I've looked and looked and I can't figure out why this doesn't work. And meanwhile, xy instead of x y is sitting there obvious as hell to all of us who, in fact, do know what the user means. Perhaps you're hung up on the idea that I propose that DWIM be invoked automatically. I didn't mean for everyone! Not you! And maybe not for anyone: Just consider my idea that it is invoked by the user typing Explain[] after an evaluation of something that didn't go as he expected. Then you have the proper conditions: The user typed something, he didn't get the answer he wanted, he suspects it may be to his input being not what he meant, so he takes a positive action to find out why. The Explain[] rule inspects In[] and Out[] and the environment and offers suggestions. When you say DWIM is impossible even in theory perhaps you didn't get that DWIM is a tongue-in-cheek name, not to be taken literally. It is just a name for an meta-analysis feature that inspects the user's input and proposes similar input forms that may be closer to what the user has in mind, based on a database of common errors. Please reconsider my suggestion with this clarification in mind. -- David > Sorry, but most (maybe none) of that can be done. Point by point: 1) x/xy is NOT a syntax error, and it may be exactly what I mean. It's up > to a user to write what he means. 2) There are no functions in Mathematica; only rules. If you defined > f[x_Integer]:=x^2 and then tried to evaluate f[2.3] the first rule isn't > invoked because 2.3 doesn't fit the pattern, so Mathematica has no > opportunity to match it (since it DOESN'T match) and then TELL you it > doesn't match. This may be EXACTLY what I want and expect to happen, so it > would be a waste of time for Mathematica to flag this as an error every time > it occurs. 3) NIntegrate, for instance, can only work if all variables and parameters > are numeric, and you already get an error message if they're not. Integrate, > on the other hand, can work with symbolic variables and numeric parameters. > There are a lot of case-by-case situations. I don't see how Mathematica > could guess whether you've tried what you meant to try. It only knows > (sometimes) how successful it was. 4) When FindMinimum or NIntegrate or NDSolve has precision problems, > there's no way for Mathematica to know how to proceed. Sometimes you need a > new Method, other times a new WorkingPrecision, and often, you're simply NOT > going to integrate the thing you're trying to integrate, no matter WHAT you > do. DWIM is impossible, even in theory. Bobby A few days ago I posted that Mathematica should have a DWIM feature - Do >> What I Mean. >> In InterLisp, in the 80's, the DWIM facility was hooked into error >> messages, >> and when invoked on a user error would poke around on the stack and in the >> environment using some rules to describe common error situations and it >> would uncover user errors and offer to correct them. Many of the errors >> were simple spelling errors and it would correct a misspelled variable >> name >> if it found an unbound variable but a similarly spelled variable was bound >> in the environment. >> Mathematica could benefit from this, and in fact, we at mathgroup could >> supply the rules (and framework) as a useful group project. >> If some guru would write the framework - trapping error messages somehow, >> perhaps when they were written to the $Messages channel (by replacing the >> default $Messages channel with something that would hook into the DWIM >> function), or perhaps with some other hook like redefining Message[] - >> then >> the rest of us could supply rules for the common errors. Especially the >> common errors we see puzzling Mathematica newbies on this list. >> I would suggest that the rules provide messages, hopefully with hyperlinks >> to the documentation. >> A true DWIM might also offer to rewrite the current expression and try it >> again, but I don't know if that can be done given the hooks into >> Mathematica >> that are currently available. >> Some situations that could be addressed are: >> under evaluation and find (unevaluated) symbols like xy of the form >> where both and were either >> symbols >> used in the expression or symbols bound in the environment. Rule would >> explain the problem and offer to rewrite expression and try again. >> 2. Some expression using a user-defined function causes an error when >> evaluating, or doesn't evaluate. Looking at the function, a rule finds >> function calls where the function arguments' patterns include _Integer >> or >> similar but the arguments given to it are not integers. Rule points to >> documentation describing argument types required by the called function. >> 3. Similar to 2 above, but it finds function calls that do numeric >> evaluation only or are optimized for numeric evaluation but the arguments >> given to it are symbolic. >> 4. Result returned is machine precision very close to zero (that is, >> with large negative exponent), but an error message complained of >> singularity, or other ill-conditioning. Rule points to documentation >> explaining about machine precision, and/or singularity, and offers to >> retry >> the expression with more digits of precision, rewriting the expression to >> achieve this. >> Actually, now that I think of it, the DWIM facility needs also to be >> invoked >> by the user because some of these situations don't cause error messages, >> but >> only cause (wholly or partially) unevaluated expressions. So maybe the >> user >> could be trained to type a word, like Explain[] after he didn't get the >> result he wanted and the DWIM facility would look at the In[] and Out[] >> arrays to find out what he's been doing recently. >> I would be glad to contribute rules to the framework ... but I'm not yet >> up >> to writing the framework. Hopefully one of the gurus here will find this >> interesting (and possible) and provide a framework. Then the rest of us >> could contribute rules that would improve the Mathematica experience for >> all >> newcomers. (AES, I'm looking at you! :-) ) >> -- David > -- > DrMajorBob@bigfoot.com > === Subject: Re: Do What I Mean - a suggestion for improving > Please reconsider my suggestion with this clarification in mind. very far off. Bobby > DrMajorBob, I think you're missing the point here - and actually, this is exactly the > point that AES keeps banging on. It's up to a user to write what he > means > is small comfort to a user, especially one new to Mathematica, who > doesn't > know how to express what he means. Not only do we see a lot of comments > on > this list of the form Why doesn't this work? we see a lot of the form > I've looked and looked and I can't figure out why this doesn't work. > And > meanwhile, xy instead of x y is sitting there obvious as hell to all > of > us who, in fact, do know what the user means. Perhaps you're hung up on the idea that I propose that DWIM be invoked > automatically. I didn't mean for everyone! Not you! And maybe not for > anyone: Just consider my idea that it is invoked by the user typing > Explain[] after an evaluation of something that didn't go as he > expected. > Then you have the proper conditions: The user typed something, he didn't > get the answer he wanted, he suspects it may be to his input being not > what > he meant, so he takes a positive action to find out why. The Explain[] > rule inspects In[] and Out[] and the environment and offers suggestions. When you say DWIM is impossible even in theory perhaps you didn't get > that > DWIM is a tongue-in-cheek name, not to be taken literally. It is just > a > name for an meta-analysis feature that inspects the user's input and > proposes similar input forms that may be closer to what the user has in > mind, based on a database of common errors. Please reconsider my suggestion with this clarification in mind. -- David >> Sorry, but most (maybe none) of that can be done. Point by point: >> 1) x/xy is NOT a syntax error, and it may be exactly what I mean. It's >> up >> to a user to write what he means. >> 2) There are no functions in Mathematica; only rules. If you defined >> f[x_Integer]:=x^2 and then tried to evaluate f[2.3] the first rule isn't >> invoked because 2.3 doesn't fit the pattern, so Mathematica has no >> opportunity to match it (since it DOESN'T match) and then TELL you it >> doesn't match. This may be EXACTLY what I want and expect to happen, so >> it >> would be a waste of time for Mathematica to flag this as an error every >> time >> it occurs. >> 3) NIntegrate, for instance, can only work if all variables and >> parameters >> are numeric, and you already get an error message if they're not. >> Integrate, >> on the other hand, can work with symbolic variables and numeric >> parameters. >> There are a lot of case-by-case situations. I don't see how Mathematica >> could guess whether you've tried what you meant to try. It only knows >> (sometimes) how successful it was. >> 4) When FindMinimum or NIntegrate or NDSolve has precision problems, >> there's no way for Mathematica to know how to proceed. Sometimes you >> need a >> new Method, other times a new WorkingPrecision, and often, you're >> simply NOT >> going to integrate the thing you're trying to integrate, no matter WHAT >> you >> do. >> DWIM is impossible, even in theory. >> Bobby >> A few days ago I posted that Mathematica should have a DWIM feature - >> Do > What I Mean. In InterLisp, in the 80's, the DWIM facility was hooked into error > messages, > and when invoked on a user error would poke around on the stack and in > the > environment using some rules to describe common error situations and it > would uncover user errors and offer to correct them. Many of the > errors > were simple spelling errors and it would correct a misspelled variable > name > if it found an unbound variable but a similarly spelled variable was > bound > in the environment. Mathematica could benefit from this, and in fact, we at mathgroup could > supply the rules (and framework) as a useful group project. If some guru would write the framework - trapping error messages > somehow, > perhaps when they were written to the $Messages channel (by replacing > the > default $Messages channel with something that would hook into the DWIM > function), or perhaps with some other hook like redefining Message[] - > then > the rest of us could supply rules for the common errors. Especially > the > common errors we see puzzling Mathematica newbies on this list. I would suggest that the rules provide messages, hopefully with > hyperlinks > to the documentation. A true DWIM might also offer to rewrite the current expression and try > it > again, but I don't know if that can be done given the hooks into > Mathematica > that are currently available. Some situations that could be addressed are: expression > under evaluation and find (unevaluated) symbols like xy of the form > where both and were either > symbols > used in the expression or symbols bound in the environment. Rule would > explain the problem and offer to rewrite expression and try again. 2. Some expression using a user-defined function causes an error when > evaluating, or doesn't evaluate. Looking at the function, a rule finds > function calls where the function arguments' patterns include > _Integer > or > similar but the arguments given to it are not integers. Rule points to > documentation describing argument types required by the called > function. 3. Similar to 2 above, but it finds function calls that do numeric > evaluation only or are optimized for numeric evaluation but the > arguments > given to it are symbolic. 4. Result returned is machine precision very close to zero (that is, > with large negative exponent), but an error message complained of > singularity, or other ill-conditioning. Rule points to documentation > explaining about machine precision, and/or singularity, and offers to > retry > the expression with more digits of precision, rewriting the expression > to > achieve this. Actually, now that I think of it, the DWIM facility needs also to be > invoked > by the user because some of these situations don't cause error > messages, > but > only cause (wholly or partially) unevaluated expressions. So maybe the > user > could be trained to type a word, like Explain[] after he didn't get > the > result he wanted and the DWIM facility would look at the In[] and Out[] > arrays to find out what he's been doing recently. I would be glad to contribute rules to the framework ... but I'm not > yet > up > to writing the framework. Hopefully one of the gurus here will find > this > interesting (and possible) and provide a framework. Then the rest of > us > could contribute rules that would improve the Mathematica experience > for > all > newcomers. (AES, I'm looking at you! :-) ) -- David >> -- >> DrMajorBob@bigfoot.com >> -- DrMajorBob@bigfoot.com === Subject: Re: Do What I Mean - a suggestion for improving this is, at first sight, very plausible and encouraging. My concern is that if you don't say what you mean, then you don't know what you mean. The biggest difficulty in problem solving is, IMHO, stating the problem clearly. I think you often find that if you put great effort into stating the problem precisely; the answer tumbles out with much less effort. I think this stating the problem thing extends even to the rules of language of the coding regime. Just my tuppence-worth; good luck with your idea. Peter 2009/2/28 David Bakin : > A few days ago I posted that Mathematica should have a DWIM feature - = Do > What I Mean. In InterLisp, in the 80's, the DWIM facility was hooked into error messag= es, > and when invoked on a user error would poke around on the stack and in th= e > environment using some rules to describe common error situations and it > would uncover user errors and offer to correct them. Many of the error= s > were simple spelling errors and it would correct a misspelled variable na= me > if it found an unbound variable but a similarly spelled variable was boun= d > in the environment. Mathematica could benefit from this, and in fact, we at mathgroup could > supply the rules (and framework) as a useful group project. If some guru would write the framework - trapping error messages somehow, > perhaps when they were written to the $Messages channel (by replacing the > default $Messages channel with something that would hook into the DWIM > function), or perhaps with some other hook like redefining Message[] - th= en > the rest of us could supply rules for the common errors. Especially th= e > common errors we see puzzling Mathematica newbies on this list. I would suggest that the rules provide messages, hopefully with hyperlink= s > to the documentation. A true DWIM might also offer to rewrite the current expression and try it > again, but I don't know if that can be done given the hooks into Mathemat= ica > that are currently available. Some situations that could be addressed are: > sion > under evaluation and find (unevaluated) symbols like xy of the form > where both and were either symbo= ls > used in the expression or symbols bound in the environment. Rule would > explain the problem and offer to rewrite expression and try again. 2. Some expression using a user-defined function causes an error when > evaluating, or doesn't evaluate. Looking at the function, a rule finds > function calls where the function arguments' patterns include _Integer = or > similar but the arguments given to it are not integers. Rule points to > documentation describing argument types required by the called function. 3. Similar to 2 above, but it finds function calls that do numeric > evaluation only or are optimized for numeric evaluation but the arguments > given to it are symbolic. 4. Result returned is machine precision very close to zero (that is, > with large negative exponent), but an error message complained of > singularity, or other ill-conditioning. Rule points to documentation > explaining about machine precision, and/or singularity, and offers to ret= ry > the expression with more digits of precision, rewriting the expression to > achieve this. Actually, now that I think of it, the DWIM facility needs also to be invo= ked > by the user because some of these situations don't cause error messages, = but > only cause (wholly or partially) unevaluated expressions. So maybe the= user > could be trained to type a word, like Explain[] after he didn't get the > result he wanted and the DWIM facility would look at the In[] and Out[] > arrays to find out what he's been doing recently. I would be glad to contribute rules to the framework ... but I'm not yet = up > to writing the framework. Hopefully one of the gurus here will find th= is > interesting (and possible) and provide a framework. Then the rest of u= s > could contribute rules that would improve the Mathematica experience for = all > newcomers. (AES, I'm looking at you! :-) ) -- David === Subject: Re: wrong solution for double integral of piecewise function? Tom, Why didn't you look up UnitStep? One press on F1 (PC) and you're done. It shows you that the answers are the same if a wrong solution for double integral of piecewise function I've got a function f[[Chi]_, [Psi]_] = > {Piecewise[{{k, {a <= [Chi] <= b, a <= [Psi] <= b}}}, 0]} I'm attempting to solve for k such that f becomes a probability > density function by applying the normalization constraint, i.e. > solving for k such that the double (indefinite) integral of f equals > 1. I can do this by hand pretty easily, integrating first/inside WRT > psi and second/outside WRT chi, and I get (1) k = 1/((b-a)^2) I don't have the world's greatest calculus chops, but that looks > correct to me. (Am I missing something?) However, when I use > Mathematica to Solve[ > First[ > Integrate[ > Integrate[ > f[[Chi], [Psi]], {[Psi], -[Infinity], [Infinity]} > ], > {[Chi], -[Infinity], [Infinity]} > ] > ] == 1, k > ] I get (2) {{k -> -(1/((a - b)^2 (-1 + UnitStep[a - b])))}} which seems wrong to me, though I'll admit I don't know what > UnitStep means. So I'm wondering * does (1) = (2)? or * have I made a syntax error? or * is this just really hard to solve symbolically? If so, is there a > better way to setup this function and its solution? === Subject: Re: wrong solution for double integral of piecewise function? Tom Roche Feb 28, 6:43 am >> Solve[ >> First[ >> Integrate[ >> Integrate[ >> f[[Chi], [Psi]], {[Psi], -[Infinity], [Infinity]} >> ], >> {[Chi], -[Infinity], [Infinity]} >> ] >> ] == 1, k >> ] >> [gets] >> (2) {{k -> -(1/((a - b)^2 (-1 + UnitStep[a - b])))}} Bob Hanlon > When you integrated by hand you assumed that b > a, Mathematica > gives a more complicated result since it does not make that > assumption unless you tell it to do so. and he points out that the proper way to do this is by wrapping an Assuming around the procedure above: Assuming[{b > a}, Solve[ First[ Integrate[ Integrate[ f[[Chi], [Psi]], {[Psi], -[Infinity], [Infinity]} ], {[Chi], -[Infinity], [Infinity]} ] ] == 1, k ] ] produces {{k -> 1/(a - b)^2}} === Subject: Re: Do What I Mean - a suggestion for improving Mathematica experience >A few days ago I posted that Mathematica should have a DWIM >feature - Do What I Mean. Until there is a mind to Mathematica interface, there is really no way for this to be successful. Short of reading a users mind, there is no way to be certain as to what was meant by a given input. expression under evaluation and find (unevaluated) symbols like xy >of the form where both and environment. Rule would explain the problem and offer to rewrite >expression and try again. A common notation in statistics is Subscript[s,xy] typically meaning the covariance of x and y. Since Mathematica by default doesn't handle subscripted variables well, I might choose to use xy to represent the covariance of x and y. How, could you determine I meant a new variable xy instead of the product x y? Think of other issues surrounding naming of variables or other common errors. New users often use single capital letters as variable names. Additionally, new users often use ( instead of [. Given this how do you determine intent when N is used? The software I most dislike is software that attempts to be helpful by correcting my errors. Well written descriptive error messages are good and appropriate when the software cannot parse my input. But re-writing my input into some other form because there is an assumption of error is very very undesired. === Subject: Design choice for Printout Screen Environment When Printing the default Screen Environment is Printout. I have always been puzzled about the design choice for one setting for this environment. This is that the Magnification is set to 0.8. Hence, printing of, for example, a Text cell in 10 point type, is rendered on the printed page as effective 8 point type. I cannot think of any sensible reason for this design choice (and I am very often having to fix this for people who want to see as Printed what they set up in their working notebook, which is usually worked with on the screen in the Working environment. It is, of course, easy to change this by editing the stylesheet... but it seems a very non intuitive design choice.... Thoughts? --David === Subject: Re: Design choice for Printout Screen Environment > When Printing the default Screen Environment is Printout. I have > always been puzzled about the design choice for one setting for this > environment. This is that the Magnification is set to 0.8. Hence, > printing of, for example, a Text cell in 10 point type, is rendered on > the printed page as effective 8 point type. I cannot think of any sensible reason for this design choice (and I am > very often having to fix this for people who want to see as Printed > what they set up in their working notebook, which is usually worked > with on the screen in the Working environment. It is, of course, easy to change this by editing the stylesheet... > but it seems a very non intuitive design choice.... Thoughts? --David I would hazard a guess about it having to do with the aspect ratio of a normal 8.5x11 page which is .7727272727272727... and 0.8 is close enough. But this is a pure guess on my part. -Bob === Subject: Re: How to Export the Manipulate On 2=D4=C228=C8=D5, =CF=C2=CE=E77=CA=B143=B7=D6, Jens-Peer Kuska the non-interactive version make a flash video, the > interactive variant need a MathPlayer and the translation of you > code into MathPlayer. Jens Hi ,all i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF > figure, but dont know how to Export the Manipulate produced > animations,can someone here drop me a hint ? > Wayne.- =D2=FE=B2=D8=B1=BB=D2=FD=D3=C3=CE=C4=D7=D6 - - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 - Hi~,Jens but sorry to say i only favor the GIF things,because the MathPlayer seems too huge for me who only want animated figures === Subject: Re: How to Export the Manipulate On 3=D4=C21=C8=D5, =CF=C2=CE=E75=CA=B158=B7=D6, George Woodrow III If you just want a movie, you can use a screen capture program. I sue > Snapz Pro X on OS X, but there must be similar programs for Linux or > Windows. Once the program is capturing video, you can manipulate the > controls. The resulting video can be processed for QuickTime, Flash, > or some other format. george the non-interactive version make a flash video, the > interactive variant need a MathPlayer and the translation of you > code into MathPlayer. Jens > Hi ,all > i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF >> figure, but dont know how to Export the Manipulate produced >> animations,can someone here drop me a hint ? >> Wayne.- =D2=FE=B2=D8=B1=BB=D2=FD=D3=C3=CE=C4=D7=D6 - - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 - i am just curious whether Mathematica can by itself translate the Manipulate product to a non-interactive *.GIF (not a movie). i just had that idea and wonder whether it is possible. :) Wayne === Subject: Convolution of a Gaussian Distribution and a discontinuous function This is a repost of a reply on an earlier thread but I think it got buried so I'm putting it up as a new topic with a more relevant subject line. ------- I don't know if this is a forum where math questions are posted (as opposed to strictly Mathematica questions), but I'll ask anyway. The PDF of the circular uniform distribution in one dimension has two discontinuities at x = radius. This makes the required integration to do a convolution fail, and it fails in Fourier space as well. If I do a numeric convolution with ListConvolve, of course, I can easily get a result. Alternatively I can use a summation and get a symbolic result consisting of hundreds of summands. These work, but neither solution can be readily integrated or differentiated when the other independent variables are complicated as they are in my case. I'd really like to get a closed form symbolic formula for the convolution. Am I dreaming to think that Mathematica, with all it's rich complexity, can do something like this? Or it is simply a fact of math that a discontinuous function cannot be convolved with a Gaussian Distribution and no trick (DiracDelta, HeavisideTheta) or computational genius will make it work? Given a failed convolution, I can use the summation solution and then fit the resulting curve. I've used the Taylor and polynomial expansions along with FFTs, but I'm not able to get a close enough approximation. The convolution is a beautiful, continuous curve based on a sum of Gaussians and so intuitively it seems as though it would be easy to fit, but I can't seem to get it. It seems that an approximation of either the Gaussian Distribution or the circular uniform distribution would make the integration possible, too. But I struggle with getting suitable non-exponential approximations to either of those. So, for the illustration, look at this: vars = { ll -> .27, mm -> 0, ss -> .06 }; pdf1[ xx_ ] := PDF[ NormalDistribution[ mm, ss ], xx ]; pdf2[ xx_ ] := Piecewise[ { { 1/(Pi * Sqrt[ ll^2 - xx^2 ]), Abs[ xx ] < ll } } ]; Plot[ { pdf1[ xx ], pdf2[ xx ] } /. vars, { xx, -.3, .3 } ] conv = Sum[ (pdf1[ xx - zz ] pdf2[ zz ]), { zz, -.6, .6, 0.02 } ] / 60; Plot[ Evaluate[ conv /. vars ], { xx, -.5, .5 } ] I'm seeking a symbolic representation of the second curve. (All variables are real, and both ll and ss are always positive.) Please be kind Jens -- I'm admittedly an amateur! === Subject: Re: Hasse Diagram Tony, Don't know much about this stuff and the Combinatorica documentation is far from complete, but I pieced together something that works. Remember that the input for a HasseDiagram must be an acyclic graph, otherwise it returns unevaluated. ShowGraph[ HasseDiagram[ { {0, 1, 1, 1}, {0, 0, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0} }, Type -> Directed ] ], VertexLabel -> True ] > Hi > I'm trying to display and manipulate a Hasse Diagram with 16 vertices. = Can someone help with the syntax === Subject: mesh in RegionPlot When plotting the RegionPlot below, some of the mesh lines appear thicker than the others. The mesh functions are defined in terms of the function f that describes the region to be plotted and the thicker mesh lines are the pre-image of the positive real axis under f. I would like this lines to have the same thickness as the other mesh lines. Any suggestions are very much appreciated. Cristina f[z_] = z^3*(z + 2)/((z - I)^4*(z + 3 - I)^3) sol := Solve[f'[z] == 0, z] c3 := z /. Extract[sol, {3}] c4 := z /. Extract[sol, {4}] w3 := f[c3] w4 := f[c4] r3 := Abs[w3] r4 := Abs[w4] plotw4[tmin_, tmax_, c_] := RegionPlot[ Abs[f[x + I*y]] > tmin && Abs[f[x + I*y]] < tmax, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 150, ColorFunction -> Function[{x, y, z}, With[{bb = f[x + I y]}, Hue[c, Mod[(Arg[bb] - t4)/(2 Pi), 1], Mod[(Abs[bb] - tmin)/(tmax - tmin), 1] + .4]]], ColorFunctionScaling -> False, MeshFunctions -> {Abs[f[#1 + I*#2]] &, Arg[f[#1 + I*#2]] &}, Mesh -> {5, 10}] With[{tmin = r3, tmax = r4, c = .5}, Show[plotw4[tmin, tmax, c]]] === Subject: Re: Show problem: combining ListPlot and Plot > Works for me (under v. 7); replace PlotJoined with Joined. Also, to r= emove the squishedness of the plot, use, in the outer Show, the AspectRa= tio -> 1/GoldenRatio option. C.O. > The following extract exemplifies a plot technique I used to > combine ListPlot and a Plot under v 2.2. It worked fine > under 3.0, 4.1,4.2 and 5.1. But students using this under 6.0 and > 7.0 for a HW report the plot frame squished, and that line colors > disagree with the title. Question: can this be fixed in DisplayChannel=$DisplayFunction; > If [$VersionNumber>=6.0, DisplayChannel=Print]; > (* fix for Mathematica 6 & later *) > Off[General::spell1]; Off[General::spell]; ClearAll[r]; > vFEM={{4., 0.054}, {7., 0.0395}, {10., 0.037}}; > vexact=0.1905*(1/r + r/100); rbeg=4.; rend=10.; > pFEM=ListPlot[vFEM,PlotJoined->True,PlotStyle->{RGBColor[1,0,0= ]}, > DisplayFunction->Identity]; > pexact=Plot[vexact,{r,rbeg,rend},PlotStyle->{RGBColor[0,0,0]}, > DisplayFunction->Identity]; > Show[Graphics[AbsoluteThickness[2]],pexact, > pFEM,TextStyle->{FontFamily->Times,FontSize->12}, > GridLines->Automatic,Axes->True,PlotRange->All, > PlotLabel->Radial displacement (black=exact,red=FE= M), > Frame->True, DisplayFunction->DisplayChannel]; -- > 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 So under $VersionNumber>=6.0 the default AspectRatio has changed and Joined has replaced PlotJoined? === Subject: Re: Do What I Mean - a suggestion for improving Mathematica experience A common notation in statistics is Subscript[s,xy] typically > meaning the covariance of x and y. Since Mathematica by default > doesn't handle subscripted variables well, I might choose to use > xy to represent the covariance of x and y. How, could you > determine I meant a new variable xy instead of the product x y? > A 'CommentOn' function could warn about the variable xy if variables x and y already existed, and then leave it to the user to think about what they intended. Yes - DWIM is probably impractical, but a generator of intelligent suggestions, could possibly be useful, I think. A lot of error messages are extremely opaque to a beginner, e.g. Set::setraw: Cannot assign to raw object 1. >> If the user finds the help attached to the >> he may figure out what is wrong, but an explanation that related to his actual code would probably help. In my experience, a lot of beginners simply ignore error messages that they don't understand! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: altering axeslabel positions I'm creating a grid of four plots which I'm exporting as an eps. I've had to reduce the fontsize to 4 so that the fonts are correctly sized in the output file. In the final eps the position of the axeslabels are further from the axes than I would like. What is the simplest way of altering the position of the axeslabels? Do I have to do this by adding my own Text [] object rather than using the built in axeslabels? Jonathan === Subject: Re: Delayed function does not behave as original input Both sets of code do the same thing, here. close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; good = Partition[Riffle[close, dates, {1, -1, 2}], 2] {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, 52.05}} dateDataMerge[datedata_, ordinatedata_] := Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; bad = dateDataMerge[dates, close] {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, 52.05}} bad == good True I suspect you had an earlier (buggy) definition of dateDataMerge and failed to Clear it before using the new (debugged) definition. That wouldn't matter if both signatures were the same or the new signature were more specific... but if the earlier definition had a MORE specific signature, like dateDataMerge[datedata_List, ordinatedata_List], it would take precedence over the newer, less specific signature. Bobby > Hello All: I am trying to make a simple function to Riffle two lists together for > trying to do. Clearly, I am missing something basic here, but cannot > seem to see what. > close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, > 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, > 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, > 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, > 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2] Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, > 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, > 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, > 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, > 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, > 52.05}} (* The above is what I want *) dateDataMerge[datedata_, ordinatedata_] := > Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; closedatesbad = dateDataMerge[dates, close] During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009,{1,-1,2}]. > > During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009]. > > During evaluation of In[180]:= Riffle::argtu: Riffle called with 1 > argument; 2 or 3 arguments are expected. > > During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2,{1,-1,2}]. > > During evaluation of In[180]:= General::stop: Further output of > Riffle::list will be suppressed during this calculation. > > Any help is appreciated. > t. > -- DrMajorBob@bigfoot.com === Subject: Re: Delayed function does not behave as original input Apologies if I am missing some subtlety here, but it looks as though you are trying to reconstruct the Transpose command. Transpose[{dates, close}] gives the answer you seek. Michael Stern > Hello All: I am trying to make a simple function to Riffle two lists together for > trying to do. Clearly, I am missing something basic here, but cannot > seem to see what. > close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, > 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, > 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, > 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, > 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2] Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, > 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, > 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, > 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, > 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, > 52.05}} (* The above is what I want *) dateDataMerge[datedata_, ordinatedata_] := > Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; closedatesbad = dateDataMerge[dates, close] During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009,{1,-1,2}]. > > During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009]. > > During evaluation of In[180]:= Riffle::argtu: Riffle called with 1 > argument; 2 or 3 arguments are expected. > > During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2,{1,-1,2}]. > > During evaluation of In[180]:= General::stop: Further output of > Riffle::list will be suppressed during this calculation. > > Any help is appreciated. > t. > === Subject: Re: Delayed function does not behave as original input Either start with a clean kernel or Clear dateDataMerge prior to its definition. close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2]; Clear[dateDataMerge]; dateDataMerge[datedata_, ordinatedata_] := Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; dateDataMerge[dates, close] == closedates True Bob Hanlon Hello All: I am trying to make a simple function to Riffle two lists together for trying to do. Clearly, I am missing something basic here, but cannot seem to see what. close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2] Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, 52.05}} (* The above is what I want *) dateDataMerge[datedata_, ordinatedata_] := Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; closedatesbad = dateDataMerge[dates, close] During evaluation of In[180]:= Riffle::list: List expected at position 1 in Riffle[52.25,2009,{1,-1,2}]. >> During evaluation of In[180]:= Riffle::list: List expected at position 1 in Riffle[52.25,2009]. >> During evaluation of In[180]:= Riffle::argtu: Riffle called with 1 argument; 2 or 3 arguments are expected. >> During evaluation of In[180]:= Riffle::list: List expected at position 1 in Riffle[52.25,2,{1,-1,2}]. >> During evaluation of In[180]:= General::stop: Further output of Riffle::list will be suppressed during this calculation. >> Any help is appreciated. t. === Subject: Re: Do Hershey Vector Fonts exist in Mathematica? >Just wondering if the Hershey Vector Fonts (in particular the >SIMPLEX Roman ones) are available for use with Mathematica. I know, >they are ugly, primitive looking etc., however, I'm not ashamed to >admit I love the look of them for text on plots. Can't explain it >really. Perhaps it's because I was used to using them with old >school plotting calls from Fortran using DISLIN and have grown >rather fond of them. If you do not know what they look like, they >are posted here: >http://idlastro.gsfc.nasa.gov/idl_html_help/ >Hershey_Vector_Font_Samples.html There is a package available that implements Hershey Fonts. See I modified this package for my own use with versions 3.x and 4.x of Mathematica. But, I've not used it since version 5 was released that corrected a problem with font rendering on Macs. Consequently, I don't know how well it will play with versions 6 and 7. I suspect (given the changes in the way graphics are done in version 6) you will need to update some of the code to achieve what you want. === Subject: Re: Do Hershey Vector Fonts exist in Mathematica? Some more information about the Hershey fonts: they were used from the beginning as the font solution for AutoCAD, and were there supplied as .SHX files. In later distributions of AutoCAD, they are also included as TTF files (true-type fonts), and can be used in Mathematica as any other TTF font. To obtain these fonts, you might ask someone using AutoCAD. If you are student or faculty you might alternatively go to www.autodesk.com/edcommunity, register and download software, and probably get the fonts that way. You might also search for the TTF fonts on Internet, but some of the sites looks a bit pesky. These TTF files are copyrighted by Autodesk, Inc., and I do not know how restrictive they are about redistribution of their font files. Ingolf Dahl -----Original Message----- === Subject: Re: Do Hershey Vector Fonts exist in Mathematica? >Just wondering if the Hershey Vector Fonts (in particular the >SIMPLEX Roman ones) are available for use with Mathematica. I know, >they are ugly, primitive looking etc., however, I'm not ashamed to >admit I love the look of them for text on plots. Can't explain it >really. Perhaps it's because I was used to using them with old >school plotting calls from Fortran using DISLIN and have grown >rather fond of them. If you do not know what they look like, they >are posted here: >http://idlastro.gsfc.nasa.gov/idl_html_help/ >Hershey_Vector_Font_Samples.html There is a package available that implements Hershey Fonts. See I modified this package for my own use with versions 3.x and 4.x of Mathematica. But, I've not used it since version 5 was released that corrected a problem with font rendering on Macs. Consequently, I don't know how well it will play with versions 6 and 7. I suspect (given the changes in the way graphics are done in version 6) you will need to update some of the code to achieve what you want. === Subject: Re: Do Hershey Vector Fonts exist in Mathematica? get it to work. t. === Subject: Please answer to my question thank you. Hi Mahtematica community, Is it possible to call from a C++ program, mathematica functions, which I previously defined in a mathematica file (.nb), to retrieve the results, and use them in my C++ program? If so, in which way should I proceed (how to do)? For example: I have this input stored in a file intitled sample1.nb: Reduce[{Element[{a, x}, Integers], n >= nP, x/a^(n/-1) == xP/a^ (nP/-1), y*(1 - a) + x == yP*(1 - a) + xP, nP == 0}, {nP, xP, yP}, Backsubstitution -> True] I want my C++ program to call this file then something in my program should execute it and finally store the output which is: (x [Element] Integers && a == 1 && n >= 0 && nP == 0 && xP == x) || ((a | x) [Element] Integers && a <= -1 && n >= 0 && nP == 0 && xP == a^n x && yP == (-x + a^n x - y + a y)/(-1 + a)) || ((a | x) [Element] Integers && a >= 2 && n >= 0 && nP == 0 && xP == a^n x && yP == (-x + a^n x - y + a y)/(-1 + a)) in a new file intitled ressample1.nb or ressample1.txt THANK YOU! === Subject: Re: Please answer to my question thank you. Manual: guide/MathLinkAPI > Hi Mahtematica community, > Is it possible to call from a C++ program, mathematica functions, which > I previously defined in a mathematica file (.nb), to retrieve the > results, and use them in my C++ program? > If so, in which way should I proceed (how to do)? > For example: > I have this input stored in a file intitled sample1.nb: > Reduce[{Element[{a, x}, Integers], n >= nP, x/a^(n/-1) == xP/a^ > (nP/-1), y*(1 - a) + x == yP*(1 - a) + xP, > nP == 0}, {nP, xP, yP}, Backsubstitution -> True] > I want my C++ program to call this file then something in my program > should execute it and finally store the output which is: (x [Element] > Integers && a == 1 && n >= 0 && nP == 0 && xP == x) || ((a = | x) > [Element] Integers && a <= -1 && n >= 0 && nP == 0 && xP == a= ^n x && > yP == (-x + a^n x - y + a y)/(-1 + a)) || ((a | x) [Element] Integer= s > && a >= 2 && n >= 0 && nP == 0 && xP == a^n x && yP == (-= x + a^n x - y > + a y)/(-1 + a)) > in a new file intitled ressample1.nb or ressample1.txt THANK YOU! === Subject: Re: Experimental Mathematica debugger Hi David, I do not intent to be picky, but there are still problems. You can now type into the edit box, but you can not paste. Further, I tried a conditional breakpoint(with Cup replaced by Underscore!: but this seems to have no effect. Daniel >> Hi David, >> another great addition from you, thank's a lot. >> There is a samll bug with the conditional break point window. It is not >> possible to input any text because it does not take the focus. I have >> Mathematica version 7 on Vista. >> thank's again, Daniel that problem - the result of some last minute changes.... The > conditionals window now looks a little ugly, but I will fix that in due > course. David Bailey > http://www.dbaileyconsultancy.co.uk > === Subject: DC-Area Mathematica SIG Meeting The Washington D.C. area Mathematica Special Interest Group will meet Friday, 6 March 2009, 7:30 to 9:30 a.m. at the SAIC Enterprise Center building in Tysons Corner (see directions below). Early risers meet before 7:00 in the morning for admission at the front desk, then we have a Dutch treat breakfast downstairs. By about 7:30 we have moved to one of the classrooms. Meetings consist of prepared talks, informal discussion about Mathematica programming and applications, general questions, and new business. 1. Prepared Talks: A. Program Evaluation and Review Technique, by Bruce Colletti Abstract. PERT is widely used to plan, track, and manage projects, helping to keep these on-time and on-budget (unless the project controls its masters). After briefly reviewing PERT and the Critical Path Method, we'll discuss familiar ways to estimate project duration. We'll then examine a new method that overcomes the weaknesses of the old ones. B. A Rotating Plane Exercise, by Dan Martinez. This presents techniques for basic 3D programming, something we can never know enough about. C. Dynamic Horizontal Bar Graph. Also by Dan, this talk presents a unique view of the terms of office of all US Presidents (President Obama, you have an open invitation to attend our meetings). A general technique for dynamic plotting of time-series data will be illustrated. To inquire about attending, e-mail Dan Martinez (dmartinez@sprintmail.com) or Bruce Colletti (bcolletti@compuserve.com). In your e-mail subject line, please include 'Mathematica SIG.' The SIG-site is http://web.mac.com/hrbishop.pmsi/DCSIG.m/DCSIG.html A SIG representative will meet you in the lobby. Please arrive no later than ten minutes to seven if you wish to join us for breakfast, and no later than twenty after seven to attend the meeting only. The desk officer will ask for a driver's license before issuing a visitor's badge. === Subject: Re: different output!! this is simple. While e.g. 0.5 is be a solution of the former, it is no solution to the later. Daniel > Hi Mathematica community, > Why output2 (with integers as domain) is different from output1 (with > reals as domain) ?!! I think it should be the same thing. input1:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Reals, > Backsubstitution -> True] output1: 0 <= Mod[x, 5] < 5 && xP == Mod[x, 5] input2:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Integers, > Backsubstitution -> True] output2: (Mod[x, 5] == 0 && xP == 0) || (Mod[x, 5] == 1 && > xP == 1) || (Mod[x, 5] == 2 && xP == 2) || (Mod[x, 5] == 3 && > xP == 3) || (Mod[x, 5] == 4 && xP == > 4) > === Subject: Re: different output!! It seems correct to me. Please note that Mod[x,5] is not necessarily integer and therefore not countable if x is a real whereas it is countable when x is an integer. Reduce does a fine job here. > Hi Mathematica community, > Why output2 (with integers as domain) is different from output1 (with > reals as domain) ?!! I think it should be the same thing. input1:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Reals, > Backsubstitution -> True] output1: 0 <= Mod[x, 5] < 5 && xP == Mod[x, 5] input2:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Integer= s, > Backsubstitution -> True] output2: (Mod[x, 5] == 0 && xP == 0) || (Mod[x, 5] == 1 && > xP == 1) || (Mod[x, 5] == 2 && xP == 2) || (Mod[x, 5] = == 3 && > xP == 3) || (Mod[x, 5] == 4 && xP == > 4) === Subject: Re: different output!! On 2 mar, 11:23, Sjoerd C. de Vries integer and therefore not countable if x is a real whereas it is > countable when x is an integer. Reduce does a fine job here. Hi Mathematica community, > Why output2 (with integers as domain) is different from output1 (with > reals as domain) ?!! I think it should be the same thing. input1:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Reals= , > Backsubstitution -> True] output1: 0 <= Mod[x, 5] < 5 && xP == Mod[x, 5] input2:Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Integ= er= > s, > Backsubstitution -> True] output2: (Mod[x, 5] == 0 && xP == 0) || (Mod[x, 5] == 1 && > xP == 1) || (Mod[x, 5] == 2 && xP == 2) || (Mod[x, 5= ] = > == 3 && > xP == 3) || (Mod[x, 5] == 4 && xP == > 4)- Masquer le texte des messages pr=E9c=E9dents - - Afficher le texte des messages pr=E9c=E9dents - What I mean is that I want to represent output2 by: Mod[x,5] belongs to Integers and 0<=Mod[x,5]<5 and xP==Mod[x,5], is it possible?should I add something in reduce to have this output. === Subject: Head logic Entering ClearAll[r]; Head[r] Head[r]!=Symbol Head[r]==Symbol give Symbol, False and True as expected. But Head[r]==Integer evaluates to Symbol==Integer. Why not False? Head[r] is certainly not Integer. Likewise r=4; Head[r]==Integer Head[r]!=Symbol Head[r]==Symbol give True (correct) but Integer!=Symbol and Integer==Symbol. Why not True and False? === Subject: Re: Using Play command and polynomial tia sal2 your speaker cannot reproduce sound below some frequency. Your ear has a threshold too. Therefore, you must define (for the PC speaker) something that has at least say 100 wiggles a second. hope this helps, Daniel I know the play command uses sin, cos, etc. But I would like to use > the Play command to listen to a polynomial. Example below of > polynomial Plot[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6 > , 1 = x < 3}}], {x, 0, 3}] I replace the Plot command with Play > Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6 > , 1 = x < 3}}], {x, 0, 3}] but mathematica 6 just comes back with errors and > just says running.. I think it's syntax but I haven't found an example of using the Play > command and Piecewise. Should I be doing this another way? tia sal2 > === Subject: Re: Using Play command and polynomial tia sal2 I know the play command uses sin, cos, etc. But I would like to use > the Play command to listen to a polynomial. Example below of > polynomial Plot[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6 > , 1 = x < 3}}], {x, 0, 3}] I replace the Plot command with Play > Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6 > , 1 = x < 3}}], {x, 0, 3}] but mathematica 6 just comes back with errors and > just says running.. I think it's syntax but I haven't found an example of using the Play > command and Piecewise. Should I be doing this another way? tia sal2 > You had used = instead of == in one of the tests inside Piecewise. Curiously, this did not cause an error using Plot. Here is a corrected version: Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6, 1 == x < 3}}], {x, 0, 3}] Note that = means assignment, and therefore 1=x doesn't make sense - which is what the message was trying to tell you - whereas == is a comparison. However, I am not sure I would pay to attend a concert in which the result was playing :) I think the result would sound more interesting if instead of playing f[x], you played Sin[2 Pi f[x] x] with f scaled into the range of (say) 200-1000. The pitch of the resultant sound would represent the value of f. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: semi-implicit Runge-Kutta SIRUKE method Hello to all of you, I am reading about the semi-implicit Runge-Kutta SIRUKE method for solving differential equations by approximation. I'd like to know if there are methods and examples of the method solved with Mathematica Dino. === Subject: equation numbering _________________________________________________________________ === Subject: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p have a conjecture: Áîodd positive number is the sum of 2 to an i-th power and a ¨îåçáôéöå © [Eth]òéíå® .b2 2^i+p æïexample: 5 = 2+3 9=4+5 15=2^3+7 905=2^12-3191 .... áó ôï .b2.b2.b9.b3.bd.b2[CapitalThorn]é «[Eth] ¤Â¡¤¨Âdon 't know i , p . it is sure that i>30 000 if ôèconjecture is correct. Íïòån = 3^i+p, (if n=6k-2 or n=6k+2) æïexample:8 = 3+5 16=3^2+7 100=3+97, 562 = 3^6 -167 can't proof this. Do you have any idea? === Subject: Re: Do What I Mean - a suggestion for improving > DrMajorBob, I think you're missing the point here - and actually, this is exactly the > point that AES keeps banging on. It's up to a user to write what he m= eans > is small comfort to a user, especially one new to Mathematica, who doesn'= t > know how to express what he means. Not only do we see a lot of comment= s on > this list of the form Why doesn't this work? we see a lot of the form > I've looked and looked and I can't figure out why this doesn't work. = And > meanwhile, xy instead of x y is sitting there obvious as hell to all = of > us who, in fact, do know what the user means. Perhaps you're hung up on the idea that I propose that DWIM be invoked > automatically. I didn't mean for everyone! Not you! And maybe not for > anyone: Just consider my idea that it is invoked by the user typing > Explain[] after an evaluation of something that didn't go as he expecte= d. > Then you have the proper conditions: The user typed something, he didn= 't > get the answer he wanted, he suspects it may be to his input being not w= hat > he meant, so he takes a positive action to find out why. The Explain[= ] > rule inspects In[] and Out[] and the environment and offers suggestions. When you say DWIM is impossible even in theory perhaps you didn't get t= hat > DWIM is a tongue-in-cheek name, not to be taken literally. It is jus= t a > name for an meta-analysis feature that inspects the user's input and > proposes similar input forms that may be closer to what the user has in > mind, based on a database of common errors. Please reconsider my suggestion with this clarification in mind. -- David > e: > Sorry, but most (maybe none) of that can be done. Point by point: 1) x/xy is NOT a syntax error, and it may be exactly what I mean. It's = up > to a user to write what he means. 2) There are no functions in Mathematica; only rules. If you defined > f[x_Integer]:=x^2 and then tried to evaluate f[2.3] the first rule is= n't > invoked because 2.3 doesn't fit the pattern, so Mathematica has no > opportunity to match it (since it DOESN'T match) and then TELL you it > doesn't match. This may be EXACTLY what I want and expect to happen, so= it > would be a waste of time for Mathematica to flag this as an error every= time > it occurs. 3) NIntegrate, for instance, can only work if all variables and paramet= ers > are numeric, and you already get an error message if they're not. Integ= rate, > on the other hand, can work with symbolic variables and numeric paramet= ers. > There are a lot of case-by-case situations. I don't see how Mathematica > could guess whether you've tried what you meant to try. It only knows > (sometimes) how successful it was. 4) When FindMinimum or NIntegrate or NDSolve has precision problems, > there's no way for Mathematica to know how to proceed. Sometimes you ne= ed a > new Method, other times a new WorkingPrecision, and often, you're simpl= y NOT > going to integrate the thing you're trying to integrate, no matter WHAT= you > do. DWIM is impossible, even in theory. Bobby > A few days ago I posted that Mathematica should have a DWIM feature -= Do >> What I Mean. > In InterLisp, in the 80's, the DWIM facility was hooked into error >> messages, >> and when invoked on a user error would poke around on the stack and in= the >> environment using some rules to describe common error situations and i= t >> would uncover user errors and offer to correct them. Many of the er= rors >> were simple spelling errors and it would correct a misspelled variable >> name >> if it found an unbound variable but a similarly spelled variable was b= ound >> in the environment. > Mathematica could benefit from this, and in fact, we at mathgroup coul= d >> supply the rules (and framework) as a useful group project. > If some guru would write the framework - trapping error messages someh= ow, >> perhaps when they were written to the $Messages channel (by replacing = the >> default $Messages channel with something that would hook into the DWIM >> function), or perhaps with some other hook like redefining Message[] - >> then >> the rest of us could supply rules for the common errors. Especially= the >> common errors we see puzzling Mathematica newbies on this list. > I would suggest that the rules provide messages, hopefully with hyperl= inks >> to the documentation. > A true DWIM might also offer to rewrite the current expression and try= it >> again, but I don't know if that can be done given the hooks into >> Mathematica >> that are currently available. > Some situations that could be addressed are: > ression >> under evaluation and find (unevaluated) symbols like xy of the form >> where both and were either >> symbols >> used in the expression or symbols bound in the environment. Rule wo= uld >> explain the problem and offer to rewrite expression and try again. > 2. Some expression using a user-defined function causes an error wh= en >> evaluating, or doesn't evaluate. Looking at the function, a rule fi= nds >> function calls where the function arguments' patterns include _Intege= r >> or >> similar but the arguments given to it are not integers. Rule points= to >> documentation describing argument types required by the called functio= n. > 3. Similar to 2 above, but it finds function calls that do numeric >> evaluation only or are optimized for numeric evaluation but the argume= nts >> given to it are symbolic. > 4. Result returned is machine precision very close to zero (that is= , >> with large negative exponent), but an error message complained of >> singularity, or other ill-conditioning. Rule points to documentatio= n >> explaining about machine precision, and/or singularity, and offers to >> retry >> the expression with more digits of precision, rewriting the expression= to >> achieve this. > Actually, now that I think of it, the DWIM facility needs also to be >> invoked >> by the user because some of these situations don't cause error message= s, >> but >> only cause (wholly or partially) unevaluated expressions. So maybe = the >> user >> could be trained to type a word, like Explain[] after he didn't get = the >> result he wanted and the DWIM facility would look at the In[] and Out[= ] >> arrays to find out what he's been doing recently. > I would be glad to contribute rules to the framework ... but I'm not y= et >> up >> to writing the framework. Hopefully one of the gurus here will find= this >> interesting (and possible) and provide a framework. Then the rest o= f us >> could contribute rules that would improve the Mathematica experience f= or >> all >> newcomers. (AES, I'm looking at you! :-) ) > -- David -- > DrMajor...@bigfoot.com I think the framework for this already exists. It is the Mathematica's suggestion system when opening a notebook from an older version. It inspects every cell and it replaces the deprecated and obsolete functions and forms with the new ones. So I think your suggestions could be implemented similarly. I think it would be a good idea to create a DWIM panel or so where a user selects the offending cell and presses a button that scans the cell for standard errors. I think it's a good idea, especially for new users who may repeat the same errors. If this gets done, I would also suggest to add a feature that explains the errors made to the user (by say having a button Tell me more or something like that). === Subject: Re: Do What I Mean - a suggestion for improving >I think you're missing the point here - and actually, this is >exactly the point that AES keeps banging on. It's up to a user to >write what he means is small comfort to a user, especially one new >to Mathematica, who doesn't know how to express what he means. While I understand this is small comfort to a new user, there really isn't much else to be said. Mathematica forms a rich complex toolset for doing mathematica analysis. Any such system will require significant time and effort on the part of an user to become proficient in making use of its capabilities. >Not only do we see a lot of comments on this list of the form Why >doesn't this work? we see a lot of the form I've looked and looked >and I can't figure out why this doesn't work. And meanwhile, xy >instead of x y is sitting there obvious as hell to all of us who, in >fact, do know what the user means. Think a minute about how it is other more experience users are able to make a good *guess* as to what the intent was when xy was inputed. There is a lot more information in the post than is available to Mathematica starting with the fact the user is indicating he didn't get what he expected. And even with this additional information, more experienced users still are often unable to correctly discern what was intended. =46urther, this is the type of error a user should be able to work out on his own with a little thought using the built-in help system. One of the basic things that should be learned in any CAS, are allowed names for variables. In most systems, this is virtually any alphanumeric string so as to not limit the user. Simply giving this information bit of thought should cause a user to realize the only way to distinguish an arbitrary alphanumeric string from a product is for the product to have some character not allowed for variable names. Hence, xy cannot be way to input the produce of x and y. >Perhaps you're hung up on the idea that I propose that DWIM be >invoked automatically. I didn't mean for everyone! Not you! And >maybe not for anyone: Just consider my idea that it is invoked by >the user typing Explain[] after an evaluation of something that >didn't go as he expected. If it isn't automatic, all you've done is provide another thing for a new user to learn. And if it is automatic, you've created problems for more experienced users and even new users. They will now have to figure out why your system tried to see say xy as a product rather than a new variable. And suppose you are able to create something reasonably useful. How will you deploy it? If it is not distributed with Mathematica, then the new user has to learn about getting and installing packages to extend Mathematica. It seems to me, the level of learning needed to accomplish this is actually more than the level of learning needed to realize a product cannot be expressed as xy. Alternatively, if it is distributed with Mathematica, that implies Wolfram will need to support this functionality. And those resources won't be available to other things. Is this really where you want Wolfram to spend resource? === Subject: Re: Delayed function does not behave as original input there is nothing wrong with your example. You must have fooled yourself, as you can see from the error message. Instead of feeding lists, you must have fed scalars: 52.25 and 2009 to rifle. By the way, the {1, -1, 2} in Rifle is superfluous. hope thias helps, Daniel > Hello All: I am trying to make a simple function to Riffle two lists together for > trying to do. Clearly, I am missing something basic here, but cannot > seem to see what. > close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, > 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, > 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, > 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, > 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2] Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, > 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, > 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, > 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, > 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, > 52.05}} (* The above is what I want *) dateDataMerge[datedata_, ordinatedata_] := > Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; closedatesbad = dateDataMerge[dates, close] During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009,{1,-1,2}]. During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009]. During evaluation of In[180]:= Riffle::argtu: Riffle called with 1 > argument; 2 or 3 arguments are expected. During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2,{1,-1,2}]. During evaluation of In[180]:= General::stop: Further output of > Riffle::list will be suppressed during this calculation. Any help is appreciated. > t. > === Subject: Re: Delayed function does not behave as original input It works fine for me. I think that your close list may have become undefined during your activities. I get similar responses when I undefine it. By the way: your use of Riffle is overly complex. Instead of Riffle[close, dates, {1, -1, 2}] (which works, but uses an undocumented feature of Riffle) you could have used Riffle[dates, close]. Note the change in order of the two lists. > Hello All: I am trying to make a simple function to Riffle two lists together for > trying to do. Clearly, I am missing something basic here, but cannot > seem to see what. > close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, 51.89`, > 52.06`, 52.05`}; dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, > 26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, > 0}, {2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, > 26, 9, 37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2] Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, 0}, > 52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, > 52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, > 52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, > 51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, > 52.05}} (* The above is what I want *) dateDataMerge[datedata_, ordinatedata_] := > Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; closedatesbad = dateDataMerge[dates, close] During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009,{1,-1,2}]. > > During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2009]. > > During evaluation of In[180]:= Riffle::argtu: Riffle called with 1 > argument; 2 or 3 arguments are expected. > > During evaluation of In[180]:= Riffle::list: List expected at position > 1 in Riffle[52.25,2,{1,-1,2}]. > > During evaluation of In[180]:= General::stop: Further output of > Riffle::list will be suppressed during this calculation. > Any help is appreciated. > t. === Subject: Re: Delayed function does not behave as original input desk for 5 hours I never thought to clear all the junk that was still defined. Also, all of your suggestions to simplify the expression are now being employed. t. === Subject: Re: Delayed function does not behave as original input Transpose @ {dates, close} === Subject: Re: Delayed function does not behave as original input >I am trying to make a simple function to Riffle two lists together >what I am trying to do. Clearly, I am missing something basic here, >but cannot seem to see what. >close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`, >51.89`, >52.06`, 52.05`}; >dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2, >26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, 0}, >{2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, 26, 9, >37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}}; >closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2] >Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31, >0}, >52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0}, >52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0}, >52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0}, >51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0}, >52.05}} >(* The above is what I want *) >dateDataMerge[datedata_, ordinatedata_] := >Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2]; >closedatesbad = dateDataMerge[dates, close] On my system, your code works, In[8]:= closedates == dateDataMerge[dates, close] Out[8]= True But, your code is overly complex. Using Transpose gets the same result more efficiently. For example, In[9]:= Partition[Riffle[close, dates, {1, -1, 2}], 2] == Transpose@{dates, close} Out[9]= True === Subject: Re: Hasse Diagram that did not display all vertices for me I found this command searching the web It works, but I don't understand what the syntax means ShowGraph[ HasseDiagram[ MakeGraph[ Subsets[4], ((Intersection[#2, #1] == #1) && (#1 != #2)) &]] ] === Subject: Re: contourlabels in contour plot try this: ContourPlot[(a + b)^2, {a, 0, 4}, {b, 0, 1.3}, ColorFunction -> GrayLevel, Axes -> True, AxesLabel -> {a, b}, LabelStyle -> Directive[Black, Large, Bold], ContourLabels -> (Text[Style[#3, 10], {#1, #2}] &), Frame -> False, PlotRange -> {16, 24}, Contours -> 10] Play with the figure 10 in ...Text[Style[#3, 10],... , it is your parameter. Have success, Alexei I was wondering that in Mathematica 6 how can we define a specific size and special font for the labels of a certain contour plot. As we change the size of contourplot, the labels stay same size! For example ContourPlot[a+b,{a, 0, 4}, {b, 0, 1.3}, ColorFunction -> GrayLevel, Axes -> True, AxesLabel -> {a, b}, LabelStyle -> Directive[Black, Large, Bold], ContourLabels -> Automatic, Frame -> False, PlotRange -> {16, 24}, Contours -> 10] we always get one size for the contourlabels. Pasha -- Alexei Boulbitch, Dr., Habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Looking to time how long a command takes in mathematica 6 tia sal2 Grettings All I'm running this command Play[Piecewise[{{4.000000000*x^2 - 4.000000000*x, 0 = x <= 1}, {-2*x^2 + 8*x - 6, 1 = x <= 3}, {x^2 - 10*x + 21, 3 = x <= 7}, {-1/2*x^2 + 11*x - 105/2, 7 = x <= 15}, {.5714285714*x^2 - 21.14285714*x + 188.5714286, 15 = x <= 22}, {-.8000000000*x^2 + 39.20000000*x - 475.2000000, 22 = x <= 27}}], {x, 0, 27}] and it's taking extremely long and would like to find out how long it takes to run this line. Also if anyone has a more efficient way of using this command please let me know. I'm just trying to output the wave file to an audio file. Aloha sal2