mm-999 === Subject: Re: Import pdf problem > Importing PDFs does indeed sometimes fail in my experience. I suggest > that you forward such examples to Wolfram so that they have cases that > they can degub from... --David > A WorkLife FrameWork > E x t e n d i n g MATHEMATICAs Reach...http://scientificarts.com/worklife/ > Hi all, Im importing data from pdf documents on a web site. This works well > most of the time. But for a few of the pdfs, Mathematica barfs and > does not return either the Pages or the Plinatext. (I am only > really interest in the Plaintext.) Instead it produces error > messages such as Expected PDF object and Expected array operator > argument, etc. Here are actual examples. First, one that works fine: Import[http://www.cmegroup.com/daily_bulletin/Section09_Interest_ > Rate_And_Energy_Futures_2008017.pdf, Rules] Next, one that does not work fine: Import[http://www.cmegroup.com/daily_bulletin/Section09_Interest_ > Rate_And_Energy_Futures_2008016.pdf, Rules] Finally, one that really bums out Mathematica (it produces a Runtime > error from Visual C++): Import[http://www.cmegroup.com/daily_bulletin/Section09_Interest_ > Rate_And_Energy_Futures_2008022.pdf, Rules] Note that Adobe has no problem opening and reading the ones that give > Mathematica problems. Presumably, this behavior is a bug. Have others encountered such > problems with other pdf files? (FYI, Im using version 6 for Windows.) --Mark Done. --Mark === Subject: AuthorTools obsolete Is there/will there be a replacement for AuthorTools. Kevin -- === Subject: Re: mathematica 64-bit for ms windows But be aware that if you are buying a new computer, from Dell at least, and you specify a 64 bit microprocessor, you will not necessarily get a 64 bit operating system, and may not even be able to install a 64-bit operating system. So if you are looking to use 64-bit Mathematica check out very carefully before purchase that you will indeed have a 64-bit operating system. As I understand it, the main advantage of a 64-bit operating system is that you can address more memory, beyond 2GB, but that it is not significantly faster - and may even be slower. (Others may correct me or expand on this.) -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > hi > while browsing about the mathematica products i have noticed that there > is no something stated lucidly like: > mathematica 64-bit for windows > while there is such a statement (64-bit) regarding mathematica for Linux > does that mean that there is a one package for windows in which the > installer will detect whether the windows OS is 32 bit or 64 bit and will > install accordingly ?? > peter === Subject: Re: Test for Irreducibility of certain polynomials with Hi Guillermo, how can you determine if a polynomial is irreducible if the coefficients are unknown? It seems to me that you have to specify d before you can say if it is irreducible. hope this helps, Daniel > Hi there, I want to test the irreducibility of the following polynomials of > degree r with Mathematica. H[x_,d_] := Sum[(-d + 1)^(j)*Binomial[r - j, j]*x^(r - 2*j), {j, 0, (r - > 1)/2}] I use the Mathematica function > IrreducibleQ[p_?PolynomialQ,Modulus->m_]:=Module[{f=FactorList[p,Modulus->m]} , > Total[Last/@DeleteCases[f,{_Integer,_Integer}]]==1 > ] But I want Mathematica to consider H[x,d] as a function in x (not in x > and d). Is it possible??? Guillermo > === Subject: Re: more looping trouble > Sorry for these lame questions but Im still trying to get my head around > loops. I though I had it but I hit a snag today. I have a table of numbers {{1,2,3},{2,3,4}} I want to use a loop to remove > the third integer in each set and reassemble them as a new table. > However, something is going wrong I think its because im not grasping some > fundamental idea about how to perform these type of operations on tables. for many many cases you wont even need a Map or other constructs when learning that many functions in Mathematica work to various levels in nested lists, here I think the following will not only be very simple and easy to read but also quite efficient: lst = {{1, 2, 3}, {a, b, c}, {x, y, z}}; Take[lst, All, 2] hth, albert === Subject: 2d distribution in 3d Space Im trying to plot 2d distributions (like a bell curve) in 3d space. I tried combining a contour plot with a regional plot with this code ---------------------------------------------------------------------------- plot1 = RegionPlot3D[x y z < 1, {x, -5, 5}, {y, -5, 5}, {z, -5, 5}, PlotStyle -> Directive[Yellow, Opacity[0.5]], Mesh -> None]; slice1 = ContourPlot3D[ y == 2*x - 4, {x, -5, 5}, {y, -5, 5}, {z, -5, 5}, Mesh -> False, BoxRatios -> {1, 1, 1}, AspectRatio -> 1]; Show[plot1, slice1] ---------------------------------------------------------------------------- however, I cant constrain the z-values to get the shape of the distribution, I just get a continuous plane that extends from the top to the bottom of the graph. Any hints? === Subject: NDSolve Singularity The following input for NDSolve is giving me a singularity error (see error message below). As a result, my system of equations is being solved until the singularity at t=0.179 and not until t=30 as va = 4.71*y[t] - 246; q = 6; kl = 5; kt = 40; b = 760; mrco2 = 250; caco2 = 48 + 6*(paco2 - 40)/7; paco2 = (b - 47)*r[t]; fico2 = 0.07; grodinstime0to30 = NDSolve[{r[ t] == (1/ kl)*((fico2*va + 8.63*q*(y[t] - caco2)/(b - 47) - r[t]*va)), y[t] == (mrco2 + 10*q*(caco2 - y[t]))/(10*kt), r[0] == 0.058, y[0] == 0.533}, {r, y}, {t, 0, 30}] ERROR MESSAGE: NDSolve::ndsz: At t == 0.17926445744166167`, step size is effectively zero; singularity or stiff system suspected. >> === Subject: Re: NDSolve Singularity if you look at your equations you see that the equation for r[t] include a term r[t]== .. + 40.3234 * r[t] + .. and this must explode because it gives r[t] proportional to Exp[40.3234 *t] So there is only one solution .. solve other equations I would suggest {r[t]==0,y[t]==0} or fix you equations / parameters. Jens The following input for NDSolve is giving me a singularity error > (see error message below). As a result, my system of equations is > being solved until the singularity at t=0.179 and not until t=30 as va = 4.71*y[t] - 246; > q = 6; > kl = 5; > kt = 40; > b = 760; > mrco2 = 250; > caco2 = 48 + 6*(paco2 - 40)/7; > paco2 = (b - 47)*r[t]; > fico2 = 0.07; > grodinstime0to30 = > NDSolve[{r[ > t] == (1/ > kl)*((fico2*va + 8.63*q*(y[t] - caco2)/(b - 47) - r[t]*va)), > y[t] == (mrco2 + 10*q*(caco2 - y[t]))/(10*kt), r[0] == 0.058, > y[0] == 0.533}, {r, y}, {t, 0, 30}] > ERROR MESSAGE: > NDSolve::ndsz: At t == 0.17926445744166167`, step size is effectively > zero; singularity or stiff system suspected. === Subject: Re: Part or Partition or Split or Extract or ...... ???? First I tried the way Bill Rowe has suggested A =Import[new3.txt,Lines]; In[2]:= GetridOFF = A[[1]] Out[2]= (300a,011c) DS [2555] # 6, 2 LeafJawPositions In[3]:= StringReplace[GetridOFF,{RegularExpression@^.+ [->,RegularExpression@= [.+$->}] be followed by !(= (([.+$ -> ))).!() !(*ButtonBox[More..., ButtonStyle->RefGuideLinkText, ButtonFrame->None, ButtonData:>General::sntxf]) It shows some error .. which i did not understand !! Can you please tell me what it could be.. In[4]:= StringCases[GetridOFF,RegularExpression[(? import elem1 of file imported as format. Import[file, {format, elem1, subelem1, ...}] ---> When elem1 is itself a list of elements, you can import its subelements. This one means import the subelem1 of elem1 (when elem1 is a list of rules) of the file imported as format. Import[file, {format, {elem1, elem2, elem3...}}] ---> This is the syntax for importing multiple elements. To make things a little more confusing ;), theres a shorthand notation when the second argument is *only one string*: You can omit the {}s: Import[file.pdf, Author] Import[file.pdf, Title] Import uses FileFormat[] for format detection if you dont explicitly specify the format, but the {}s must remain as shown above if your second argument contains more than one string. Igor -- Igor C. Antonio Wolfram Research, Inc. http://www.wolfram.com To email me personally, remove the dash. > Hi all, I find Import wonderful but frustrating. For example, I can get > individual items such as Author and Title in separate calls: Import[file.pdf, Author] > Import[file.pdf, Title] but I cant get a list as in Import[file.pdf, {Author, Title}] Instead I get an error message that say Title is not present (which > seems misleading at best, since I already accessed it above). Is that > syntax supposed to work or not? (Frankly, Im having a hard time > figuring out what the proper generic syntax is for Import, especially > since there are so few examples in the documentation.) BTW, I found out I can use {Author, Title} /. Import[file.pdf, Rules] Is that what I should be doing? (It seems like overkill since Import > has to import a bunch more stuff that I dont want, at least in this > example.) --Mark === Subject: Re: Import syntax question > Hi Mark, You should do: Import[file.pdf, {{Author, Title}}] or Import[file.pdf, {PDF, {Author, Title}]. The general syntaxes for extracting elements are: Import[file, {format, elem1}] > ---> import elem1 of file imported as format. Import[file, {format, elem1, subelem1, ...}] > ---> When elem1 is itself a list of elements, you can import its subelements. > This one means import the subelem1 of elem1 (when elem1 is a list of rules) of > the file imported as format. Import[file, {format, {elem1, elem2, elem3...}}] > ---> This is the syntax for importing multiple elements. To make things a little more confusing ;), theres a shorthand notation when the > second argument is *only one string*: You can omit the {}s: Import[file.pdf, Author] > Import[file.pdf, Title] Import uses FileFormat[] for format detection if you dont explicitly specify > the format, but the {}s must remain as shown above if your second argument > contains more than one string. Igor -- > Igor C. Antonio > Wolfram Research, Inc.http://www.wolfram.com To email me personally, remove the dash. Hi all, I find Import wonderful but frustrating. For example, I can get > individual items such as Author and Title in separate calls: Import[file.pdf, Author] > Import[file.pdf, Title] but I cant get a list as in Import[file.pdf, {Author, Title}] Instead I get an error message that say Title is not present (which > seems misleading at best, since I already accessed it above). Is that > syntax supposed to work or not? (Frankly, Im having a hard time > figuring out what the proper generic syntax is for Import, especially > since there are so few examples in the documentation.) BTW, I found out I can use {Author, Title} /. Import[file.pdf, Rules] Is that what I should be doing? (It seems like overkill since Import > has to import a bunch more stuff that I dont want, at least in this > example.) --Mark --Mark === Subject: Re: Import syntax question > Of course you could do something like Import[file.pdf, #]&/@ {Author, Title} though it does call Import twice.... --David > A WorkLife FrameWork > E x t e n d i n g MATHEMATICAs Reach...http://scientificarts.com/worklife/ > Hi all, I find Import wonderful but frustrating. For example, I can get > individual items such as Author and Title in separate calls: Import[file.pdf, Author] > Import[file.pdf, Title] but I cant get a list as in Import[file.pdf, {Author, Title}] Instead I get an error message that say Title is not present (which > seems misleading at best, since I already accessed it above). Is that > syntax supposed to work or not? (Frankly, Im having a hard time > figuring out what the proper generic syntax is for Import, especially > since there are so few examples in the documentation.) BTW, I found out I can use {Author, Title} /. Import[file.pdf, Rules] Is that what I should be doing? (It seems like overkill since Import > has to import a bunch more stuff that I dont want, at least in this > example.) --Mark I sent an email to support and got a response that told me how to do it: Import[file.pdf, {{Author, Title}}] It was pointed out to me that there is an example on the PDF documentation page that illustrates this. It was also pointed out that the Import documentation page states that Import[..., {expr1, expr2, ...}] is for importing subexpressions of (sub)expressions. What was not pointed out, however, is that (as far as I can tell) the correct syntax is *not* noted on the Import page nor is it stated outside of scattered examples (to my knowledge). --Mark === Subject: Re: Re: How should I start with mathematica? If Im correct in what youre remembering, the original author was Thomas Meunch; I got that message on 2007-08-04. Then David Reiss made some minor changes; that message was received on the next day. Both of those messages are quoted at the bottom of this message. If it helps, great! If not, I apologize to the list for the static. Best wishes, C.O. Murray, Mathematica book generator and posted it here - if you can, I will add > a link to it on my site, because that is all that we seem to have for > the foreseeable future! I think WRIs approach to documentation is a real mistake. Newbies must > find it almost impossible to get into the software. Also, some of the > new features of 6.0 - such as all the new capabilities of Import and > Export are almost buried and unusable because of poor, vague, > Microsoft-style documentation. David Bailey > http://www.dbaileyconsultancy.co.uk Many users on this discussion group have complained about the absence of The Mathematica Book in the new Documentation Center; mainly because of a missing linear introductory text of Mathematica which was present in the old Help system. I completely agree. However, I noticed that the various tutorial files in the Documentation center contain the text of The Book. What is really missing is the outline. So I decided to build my own do-it- to the ingenious naming rules of the tutorial files (all main chapter TOC files end with ...Overview.nb.) The following code opens a new notebook, and prints a collection of hyperlinks to Documentation Center tutorials, laid out in the order of the good old Mathematica book. Simply execute the code and save the notebook for your own use. There are 11 chapters that I could not find in The Mathematica Book of the v5.2 Help system, I integrated them in an order that seemed most appropriate to me. The are marked by New: . Note that this link collection does not contain links to all tutorials. For example, no links to the Manipulate tutorials exist. Neither are the packages represented. Also be warned that the code opens help files to extract hyperlinks for incorporation in The Book, and closes them again. Lots of windows appearing and disappearing on the screen. There will also be warnings and a beeps popping up because of a mismatch in cell styles, which you can ignore. Everything works fine despite the mismatch. At the end, just close the Why the beep dialog box. Here is the code that you need to execute to build your own book in v6.0.x: fn = FileNames[ =C2=A0 =C2=A0*Overview.nb, $InstallationDirectory <> =C2=A0 =C2=A0 DocumentationEnglishSystemTutorials]; (*Find Overview.nb files in the tutorials-directory*) nameList = {StringTake[#, {StringPosition[#, ][[-1, 1]] + =C2=A0 =C2=A0 =C2=A0 =C2=A0 1, -12}], =C2=A0 =C2=A0 =C2=A0paclet:tutorial/ <> =C2=A0 =C2=A0 =C2=A0 StringTake[#, {StringPosition[#, ][[-1, 1]] + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A01, -4}], #} & /@ fn; (*create a list of strings needed for future code*) Do[nameList[[i, 1]] = =C2=A0 =C2=A0New: <> nameList[[i, 1]], {i, {3, 6, 7, 8, 18, 28, 29, 40, = 41, =C2=A0 =C2=A0 46, 48}}]; (* mark the chapter not present in v5.2 with New: *) orderOfChapters = {{36, 3, 8, 31, 4, 47, 1, 39, 32, 14, 20, 16, 18, =C2=A0 =C2=A0 17, 11, 43}, {10, 13, 35, 48, 22, 45, 9, 27, 38, 42, 44, 23, = 12, =C2=A0 =C2=A0 26, 15, 40, 41}, {30, 25, 2, 21, 5, 7, 37, 19, 33, 34, 28, 29= , 6, =C2=A0 =C2=A0 46, 24}}; (*The file list is alphabetical-this is the order in which the chapters should appear*) structure = Table[nameList[[i]], {k, 3}, {i, orderOfChapters[[k]]}]; (*needed for the code further down-represents the structure of the Matehmatica book*) mainChapters = {A practical introduction to Mathematica, =C2=A0 =C2=A0Principles of Mathematica, =C2=A0 =C2=A0Advanced Mathematics in Mathematica}; (*The three main headings*) d[x_] := Cell[ =C2=A0 =C2=A0BoxData[TagBox[ =C2=A0 =C2=A0 =C2=A0ButtonBox[ =C2=A0 =C2=A0 =C2=A0 PaneSelectorBox[{False -> x[[1]], =C2=A0 =C2=A0 =C2=A0 =C2=A0 True -> StyleBox[x[[1]], HyperlinkActive]}, =C2=A0 =C2=A0 =C2=A0 =C2=A0Dynamic[CurrentValue[MouseOver]], =C2=A0 =C2=A0 =C2=A0 =C2=A0BaselinePosition -> Baseline, FrameMargins -> 0, =C2=A0 =C2=A0 =C2=A0 =C2=A0ImageSize -> Automatic], BaseStyle -> Link, =C2=A0 =C2=A0 =C2=A0 ButtonData -> x[[2]], ButtonNote -> x[[2]]], =C2=A0 =C2=A0 =C2=A0Annotation[#, x[[2]], Hyperlink] &]], Subsection]; (*Cell representing a hyperlink to the ...Overview.nb files*) nb = NotebookPut[]; SetOptions[nb, StyleDefinitions -> BookTextbook.nb]; NotebookWrite[ =C2=A0 nb, {Cell[The Virtual Mathematica Book (v6), Title], =C2=A0 =C2=A0Cell[A collection of links to the tutorials present in the Mathematica 6.0 Documentation Center, arranged in the order of chapters in The Mathematica Book., Author]}]; Do[NotebookWrite[nb, Cell[mainChapters[[k]], Section]]; =C2=A0 Do[NotebookWrite[nb, d[i]]; =C2=A0 =C2=A0With[{nb1 = NotebookOpen[i[[3]]]}, =C2=A0 =C2=A0 NotebookFind[nb1, TOCChapter, All, CellStyle]; =C2=A0 =C2=A0 NotebookWrite[nb, NotebookRead[nb1]]; NotebookClose[nb1]], {i, =C2=A0 =C2=A0 structure[[k]]}], {k, 3}]; SelectionMove[nb, All, Notebook]; FrontEndExecute[ =C2=A0FrontEndToken[SelectionCloseAllGroups]]; FrontEndExecute[ =C2=A0FrontEndToken[OpenCloseGroup]]; (*Creates the Mathematica Book.The With[...] block in the middle opens an Overview.nb file,extracts the embedded hyperlinks,and prints those into the Mathematica Book as well.*) I hope that you might find this as helpful as I do! Happy clicking, Thomas This is good! I made a few small changes to your code so that it does not only work on Windows. The following version makes it OS independent =2D-David fn = FileNames[*Overview.nb, ToFileName[{$InstallationDirectory, Documentation, English, System, Tutorials}]]; (*Find Overview.nb files in the tutorials-directory*) nameList = With[{case = StringReplace[#, DirectoryName[#] -> ]}, {StringReplace[case, Overview.nb -> ], paclet:tutorial/ <> StringReplace[case, .nb -> ], #}] & /@ fn; (*create a list of strings needed for future code*) Scan[(nameList[[#, 1]] = New: <> nameList[[#, 1]]) &, {3, 6, 7, 8, 18, 28, 29, 40, 41, 46, 48}]; (*mark the chapter not present in v5.2 with New: *) orderOfChapters = {{36, 3, 8, 31, 4, 47, 1, 39, 32, 14, 20, 16, 18, 17, 11, 43}, {10, 13, 35, 48, 22, 45, 9, 27, 38, 42, 44, 23, 12, 26, 15, 40, 41}, {30, 25, 2, 21, 5, 7, 37, 19, 33, 34, 28, 29, 6, 46, 24}}; (*The file list is alphabetical-this is the order in which the chapters should appear*) structure = Table[nameList[[i]], {k, 3}, {i, orderOfChapters[[k]]}]; (*needed for the code further down-represents the structure of the Matehmatica book*) mainChapters = {A practical introduction to Mathematica, Principles of Mathematica, Advanced Mathematics in Mathematica}; (*The three main headings*) d[x_] := Cell[ BoxData[TagBox[ ButtonBox[ PaneSelectorBox[{False -> x[[1]], True -> StyleBox[x[[1]], HyperlinkActive]}, Dynamic[CurrentValue[MouseOver]], BaselinePosition -> Baseline, FrameMargins -> 0, ImageSize -> Automatic], BaseStyle -> Link, ButtonData -> x[[2]], ButtonNote -> x[[2]]], Annotation[#, x[[2]], Hyperlink] &]], Subsection]; (*Cell representing a hyperlink to the ...Overview.nb files*) nb = NotebookPut[]; SetOptions[nb, StyleDefinitions -> ToFileName[Book, Textbook.nb]]; NotebookWrite[ nb, {Cell[The Virtual Mathematica Book (v6), Title], Cell[A collection of links to the tutorials present in the Mathematica 6.0 Documentation Center, arranged in the order of chapters in The Mathematica Book., Author]}]; Do[NotebookWrite[nb, Cell[mainChapters[[k]], Section]]; Do[NotebookWrite[nb, d[i]]; With[{nb1 = NotebookOpen[i[[3]]]}, NotebookFind[nb1, TOCChapter, All, CellStyle]; NotebookWrite[nb, NotebookRead[nb1]]; NotebookClose[nb1]], {i, structure[[k]]}], {k, 3}]; SelectionMove[nb, All, Notebook]; FrontEndExecute[ FrontEndToken[SelectionCloseAllGroups]]; FrontEndExecute[ FrontEndToken[OpenCloseGroup]]; (*Creates the Mathematica Book.The With[...] block in the middle opens an Overview.nb file,extracts the embedded hyperlinks,and prints those into the Mathematica Book as well.*) =2D- 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: How should I start with mathematica? My advice is get some good Mathematica books favorites of mine are Mathematica Navigator http://www.amazon.com/Mathematica-Navigator-Mathematics-Statistics-Graphics/ dp/012603642X/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1202763339&sr=8-1 an Introduction to Mathematica http://www.amazon.com/Introduction-Programming-Mathematica-Third/dp/05218467 81/ref=pd_bxgy_b_text_b and Mastering Mathematica http://www.amazon.com/Mastering-Mathematica-Second-Programming-Applications/ dp/0122961056/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1202763621&sr=1-1 If you can master those 3 books then update your knowledge about new functionality on version 6.0 with http://reference.wolfram.com/mathematica/guide/Mathematica.html if you have questions then come here and if you know all the answers them come here to help answering questions! :-) While reading the books put yourself little problems and try to solve them using mathematica and check on the above books on how to solve your own problems. another source of inspiration could be going to the wolfram demo project and try recreating some of the demo there or just reading the code to see how they are done. === Subject: Re: How should I start with mathematica? On Feb 11, 1:15 pm, David Bailey a link to it on my site, because that is all that we seem to have for > the foreseeable future! > David Baileyhttp://www.dbaileyconsultancy.co.uk David - it was me who posted the code. Here is a link to the post: The code that generates The Mathematica Book is in the first post of the linked thread. The code should be pasted into a new notebook and executed. It will generate another notebook, the Virtual Mathematica Book. This notebook can be saved and is a valuable resource - I believe - to learn about Mathematica. thomas === Subject: Re: How should I start with mathematica? >> At one of the conferences, there was much criticism over the statement >> that WRI would no longer offer a printed The Mathematica Book as of >> version 6. The WRI defense was that 3rd parties would fill the gap. >> Well, 3rd parties havent. Maybe a bunch of books are about to appear. >> But so far it looks like WRI really dropped the ball on this. Perhaps >> WRI folks are so enamored with their electronic/on-line only mentality >> that they just dont care about books any more. A big mistake, IMHO. > In other words, approaching a year after its introduction there is > _still_ no really good, really usable, really readable, really > straightforward introduction to all the amazing, but immensely complex > and confusing, old and especially new features of the new 6.0 version of > Mathematica available for either newbies or experienced users of the > program, either online or (especially) in any printed _or printable_ > document(s). >> Given all the immense respect I have for the marvels of Mathematica > (and, as an aside, its stiff retail price), I still cannot comprehend > how Wolfram can have let this happen. > Murray, Mathematica book generator and posted it here - if you can, I will add > a link to it on my site, because that is all that we seem to have for > the foreseeable future! I think WRIs approach to documentation is a real mistake. Newbies must > find it almost impossible to get into the software. Also, some of the > new features of 6.0 - such as all the new capabilities of Import and > Export are almost buried and unusable because of poor, vague, > Microsoft-style documentation. David Bailey > http://www.dbaileyconsultancy.co.uk > I think the message you are looking for is this one from Thomas Muench: http://forums.wolfram.com/mathgroup/archive/2007/Aug/msg00334.html Stephen Luttrell West Malvern, UK === Subject: RE: Re: How should I start with mathematica? > Mathematica book generator and posted it here - if you can, > I will add a link to it on my site, because that is all that > we seem to have for the foreseeable future! I think WRIs approach to documentation is a real mistake. > Newbies must find it almost impossible to get into the > software. Also, some of the new features of 6.0 - such as all > the new capabilities of Import and Export are almost buried > and unusable because of poor, vague, Microsoft-style documentation. David Bailey > http://www.dbaileyconsultancy.co.uk > As a newbie I must say, that it is not so difficult to get into Mathematica 6. The free web seminars are great, I hope, that WRI is preparing the new ones, as I have already attended most of the now offered. But what Im missing for my work is some structured list of functions. For example when Im looking for lets say string manipulation functions, I start with writing word String and pressing F1 in notebook. Than I use See also, More about or Tutorials sections of the help and after while of clicking I usualy find what I need. But if I had such structured list of functions (may be printed on some bigger format poster), I think this searching could be much faster. Jakub === Subject: Re: How should I start with mathematica? >> Mathematica book generator and posted it here - if you can, >> I will add a link to it on my site, because that is all that >> we seem to have for the foreseeable future! >> I think WRIs approach to documentation is a real mistake. >> Newbies must find it almost impossible to get into the >> software. Also, some of the new features of 6.0 - such as all >> the new capabilities of Import and Export are almost buried >> and unusable because of poor, vague, Microsoft-style documentation. >> David Bailey >> http://www.dbaileyconsultancy.co.uk > As a newbie I must say, that it is not so difficult to get into Mathematica > 6. The free web seminars are great, I hope, that WRI is preparing the new > ones, as I have already attended most of the now offered. But what Im missing for my work is some structured list of functions. For > example when Im looking for lets say string manipulation functions, I start > with writing word String and pressing F1 in notebook. Than I use See also, > More about or Tutorials sections of the help and after while of clicking > I usualy find what I need. > But if I had such structured list of functions (may be printed on some bigger > format poster), I think this searching could be much faster. Jakub I am glad you are finding the seminars useful. I guess everyone has a different learning style, and I prefer to read a book at my own pace! To find all the string functions, type ?*String* This will give you a list of symbols containing String, and you can look them up to get the details. The asterisks stand for any text, and the ? command looks up symbols that match the pattern. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: White on white font Im having a weird problem with Mathematica 6. Suddenly, the text in notebooks is unreadable, it appears as white on white. See http://www.physik.fu-berlin.de/~goerz/download/mathematica.png. The same effect is also in the preferences (Appearance) The text there is white as well: http://www.physik.fu-berlin.de/~goerz/download/mathematica.png. Any way to solve this problem? Im not aware of any specific change having caused this problem, as I dont start mathematica that regularly, but in case it has to do something with the the video settings, heres my xorg.conf: http://www.physik.fu-berlin.de/~goerz/download/xorg.conf Michale === Subject: LogLogPlot with WorkingPrecision bug I can reliably crash the kernel on my laptop with the following command: LogLogPlot[x, {x, .001, 1}, WorkingPrecision -> 20] Of course, I discovered this problem with a very different function, but this is the simplest example that will demonstrate the kernel crash. I have already sent a message to support@wolfram.com, but I thought I would post here to see if anyone else can shed light on this apparent bug. -- Dan === Subject: Re: How should I start with mathematica? >Mathematica book generator and posted it here - if you can, I will >add a link to it on my site, because that is all that we seem to >have for the foreseeable future! Although you addressed this question to Murray, I am taking the liberty to answer since I still happen to have the relevant emails in my archives. There were two notebooks that did created this documentation. One was written by Thomas Muench, last updated in his message of Aug 2007. The other notebook was created by Fred Simons. Fred posted is code in the same thread. Fred indicated is code was not as complete but used a somewhat different approach to the problem. -- To reply via email subtract one hundred and four === Subject: Re: open URL programmatically? Hi all, I know how to create a hyperlink and click on it to go to an URL in my > browser. But I dont know how to write a program that does that > without making the user click. In other words, Id like a function > such as openURL[url] that goes to the URL in the browser. Any ideas? On Windows one can use Run[] and start: there a way to do this in a OS-free way? --Mark === Subject: Re: open URL programmatically? FrontEndExecute[{FrontEnd`NotebookLocate[{URL[theURL], None}]}] or NotebookLocate[{URL[theURL], None}] I hope that this helps... --David A WorkLife FrameWork E x t e n d i n g MATHEMATICAs Reach... http://scientificarts.com/worklife/ > Hi all, I know how to create a hyperlink and click on it to go to an URL in my > browser. But I dont know how to write a program that does that > without making the user click. In other words, Id like a function > such as openURL[url] that goes to the URL in the browser. Any ideas? --Mark === Subject: Re: open URL programmatically? > FrontEndExecute[{FrontEnd`NotebookLocate[{URL[theURL], None}]}] or NotebookLocate[{URL[theURL], None}] I hope that this helps... > --David > A WorkLife FrameWork > E x t e n d i n g MATHEMATICAs Reach...http://scientificarts.com/worklife/ > Hi all, I know how to create a hyperlink and click on it to go to an URL in my > browser. But I dont know how to write a program that does that > without making the user click. In other words, Id like a function > such as openURL[url] that goes to the URL in the browser. Any ideas? --Mark --Mark === Subject: Re: Re: open URL programmatically? By evaluating ?URL* I discovered that theres a System` context object URL. Anybody know what it does? >> Hi all, >> I know how to create a hyperlink and click on it to go to an URL in my >> browser. But I dont know how to write a program that does that >> without making the user click. In other words, Id like a function >> such as >> openURL[url] >> that goes to the URL in the browser. Any ideas? On Windows one can use Run[] and start: > -- 3 545-1801 Amherst, MA 01003-9305 === Subject: Re: Graph with different edge thicknesses here is a simple solution using a counter: count = 1; g = LayeredGraphPlot[{1 -> 2, 1 -> 3}, EdgeRenderingFunction -> ({Thickness[0.001 count++], Arrow[#1]} &)] However, there is a hitchup. The EdgeRenderingFunction is called twice on every edge (I do not know why). To prevent drawing each edge twice with different thickness, we may use a function that remembers its values: count=1; Clear[getThickness]; getThickness[d_]:=getThickness[d]=0.004 count++; g=LayeredGraphPlot[{1->2,1->3},EdgeRenderingFunction->({Thickness[getThickne ss[#1]],Arrow[#1]}&)] hope this helps, Daniel > Hello all, I created a graph with edges {1->2,1->3,2->4,2->5}. But I > want that these edge lines have thickness values {0.01, > 0.02,0.03,0.04} respectively. How can I do that with > === Subject: Re: Graph with different edge thicknesses > Hello all, I created a graph with edges {1->2,1->3,2->4,2->5}. But I > want that these edge lines have thickness values {0.01, > 0.02,0.03,0.04} respectively. How can I do that with Quick and dirty solution: In[1]:= edges = {1 -> 2, 1 -> 3, 2 -> 4, 2 -> 5} Out[1]= {1 -> 2, 1 -> 3, 2 -> 4, 2 -> 5} In[2]:= thickness = {0.01, 0.02, 0.03, 0.04} Out[2]= {0.01, 0.02, 0.03, 0.04} In[3]:= thickness /= 3. (* tone it down a bit *) Out[3]= {0.00333333, 0.00666667, 0.01, 0.0133333} In[4]:= GraphPlot[edges, EdgeRenderingFunction -> ({Thickness[thickness[[First@First@Position[edges, Rule @@ #2]]]], Arrow[#1, .05]} &)] === Subject: Re: Graph with different edge thicknesses what are these edge lines ?? or these edge. But GraphPlot[{1 -> 2, 1 -> 3, 2 -> 4, 2 -> 5}, EdgeRenderingFunction -> ({Thickness[RandomReal[{0.01, 0.04}]], Arrow[#1]} &)] look funny. Jens > Hello all, I created a graph with edges {1->2,1->3,2->4,2->5}. But I > want that these edge lines have thickness values {0.01, > 0.02,0.03,0.04} respectively. How can I do that with > === Subject: Table / TableForm Question Hi All, Simple question from the Homework section HW06.nb - Number 7. Use nested Table[] commands to create the following list display: TableForm[{{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, 10}, {3, 6, 9, 12}, {4, 8, 12}, {5, 10}, {6}}] { {1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, 10, }, {3, 6, 9, 12, , }, {4, 8, 12, , , }, {5, 10, , , , }, {6, , , , , } } Here is what it should look like Displayed:- 1 2 3 4 5 6 2 4 6 8 10 3 6 9 12 4 8 12 5 10 6 Here is my attempt. Table[i*j, {i, 6}, {j, 6}] {{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, 10, 12}, {3, 6, 9, 12, 15, 18}, {4, 8, 12, 16, 20, 24}, {5, 10, 15, 20, 25, 30}, {6, 12, 18, 24, 30, 36}} ... Im not quite there as you can see. Any help & advice gratefully received. === Subject: Re: Table / TableForm Question Hi Lea, the upper bound of the second iterator must depend on the first iterator: Table[i*j, {i, 6}, {j, 7 - i}] // TableForm hoipe this helps, Daniel > Hi All, Simple question from the Homework section HW06.nb - Number 7. Use nested Table[] commands to create the following list display: TableForm[{{1, 2, 3, 4, 5, 6}, > {2, 4, 6, 8, 10}, {3, 6, 9, 12}, > {4, 8, 12}, {5, 10}, {6}}] > { > {1, 2, 3, 4, 5, 6}, > {2, 4, 6, 8, 10, }, > {3, 6, 9, 12, , }, > {4, 8, 12, , , }, > {5, 10, , , , }, > {6, , , , , } > } Here is what it should look like Displayed:- > 1 2 3 4 5 6 > 2 4 6 8 10 > 3 6 9 12 > 4 8 12 > 5 10 > 6 > Here is my attempt. Table[i*j, {i, 6}, {j, 6}] > {{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, > 10, 12}, {3, 6, 9, 12, 15, 18}, > {4, 8, 12, 16, 20, 24}, > {5, 10, 15, 20, 25, 30}, > {6, 12, 18, 24, 30, 36}} ... Im not quite there as you can see. > Any help & advice gratefully received. === Subject: Re: Table / TableForm Question Table[Table[i*j, {i, 1, 7 - j}], {j, 1, 6}] ?? Jens > Hi All, Simple question from the Homework section HW06.nb - Number 7. Use nested Table[] commands to create the following list display: TableForm[{{1, 2, 3, 4, 5, 6}, > {2, 4, 6, 8, 10}, {3, 6, 9, 12}, > {4, 8, 12}, {5, 10}, {6}}] > { > {1, 2, 3, 4, 5, 6}, > {2, 4, 6, 8, 10, }, > {3, 6, 9, 12, , }, > {4, 8, 12, , , }, > {5, 10, , , , }, > {6, , , , , } > } Here is what it should look like Displayed:- > 1 2 3 4 5 6 > 2 4 6 8 10 > 3 6 9 12 > 4 8 12 > 5 10 > 6 > Here is my attempt. Table[i*j, {i, 6}, {j, 6}] > {{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, > 10, 12}, {3, 6, 9, 12, 15, 18}, > {4, 8, 12, 16, 20, 24}, > {5, 10, 15, 20, 25, 30}, > {6, 12, 18, 24, 30, 36}} ... Im not quite there as you can see. > Any help & advice gratefully received. === Subject: Re: Whats the new Code Style? Hi... Search the archives of this group (under my login if you wish). This has been covered a few times. For example: thread/5db307336214aed1/e856569e98cbdbe9 Best, David > In the transition from earlier versions to 6.0, the Cmd-8 style in the > Default Format was changed from something like Small Text (if Im > remembering correctly) to a style called Code, which appears to > function like Input but is formatted differently. What is this style? -- whats its purpose or objective? -- how does it > differ from Input? [And for those of you whove been following my ongoing rants against > Mathematica 6 documentation -- or lack of same -- a challenge: =A0Dont > answer the above questions, but instead show me how a novice or ordinary > user could find the answer to them, using what knowledge they might be > expected to have, and the Mathematica Help menu item. =A0 Youll find that looking for Input in the Find Selected Function menu > command brings up an immediate and informative answer. =A0Looking for > Code, however, brings up 356 entries -- spread over 36 pages that you > have to click through in sequence -- and this list is not alphabetized.] === Subject: Re: Whats the new Code Style? > In the transition from earlier versions to 6.0, the Cmd-8 style in the > Default Format was changed from something like Small Text (if Im > remembering correctly) to a style called Code, which appears to > function like Input but is formatted differently. What is this style? -- whats its purpose or objective? -- how does it > differ from Input? Code style cells are initialization cells. The main formatting difference is that they dont wrap like Input cells. -- Helen Read University of Vermont === Subject: Local variable in ToExpression? How can I create a local variable from text in ToExpression? test[] := Module[{result = 0}, ToExpression[result=1]; result] test[] will return 0 How can I make it return 1? (here ToExpression is creating a global variable; result=1, even though it is placed inside the Module) Karl Daggfeldt === Subject: Re: Local variable in ToExpression? > How can I create a local variable from text in ToExpression? test[] := Module[{result = 0}, > ToExpression[result=1]; result] test[] will return 0 > How can I make it return 1? > (here ToExpression is creating a global variable; result=1, even though it is placed inside the Module) This is because localization of variables is done by renaming: In[10]:= Module[{a}, a] Out[10]= a$343 But I am curious: what do you need this for? === Subject: Re: Local variable in ToExpression? Hi Karl, note that the local and global result are 2 different variables. Try e.g.: Module[{result = 3}, result = ToExpression[result=1]; result] note that this will set the global result as well. hope this helps, Daniel > How can I create a local variable from text in ToExpression? test[] := Module[{result = 0}, > ToExpression[result=1]; result] test[] will return 0 > How can I make it return 1? > (here ToExpression is creating a global variable; result=1, even though it is placed inside the Module) Karl Daggfeldt > === Subject: Re: Local variable in ToExpression? test[] := Block[{result = 0}, ToExpression[result=1]; result] ?? Jens > How can I create a local variable from text in ToExpression? test[] := Module[{result = 0}, > ToExpression[result=1]; result] test[] will return 0 > How can I make it return 1? > (here ToExpression is creating a global variable; result=1, even though it is placed inside the Module) Karl Daggfeldt > === Subject: Re: Re: How should I start with mathematica? > Hi Szabolcs, I am working my way through the link > You recommended - http://library.wolfram.com/infocenter/MathSource/1847/ Its Great! However many of the Homework questions do not have answers... Just wondering if there is a collection of ready made answers anywhere that > I can view after I have tried the problem myself... it would be very helpful > to double check my answers... Hi Lea, It was a long time ago when I played with this tutorial, but if I remember correctly, there were no answers to the problems ... However, if you are stuck, feel free to post to MathGroup! With friendly greetings, Szabolcs === Subject: RE: Re: How should I start with mathematica? Hi Szabolcs, I am working my way through the link You recommended - http://library.wolfram.com/infocenter/MathSource/1847/ Its Great! However many of the Homework questions do not have answers... Just wondering if there is a collection of ready made answers anywhere that I can view after I have tried the problem myself... it would be very helpful to double check my answers... -----Original Message----- === Subject: Re: How should I start with mathematica? > Im new in mathematica, Is there any approach recommended to start with mathematica? It depends on what you plan to use Mathematica for. If you would like to understand the system well, and you are not in a hurry, take a look at these notes: http://library.wolfram.com/infocenter/MathSource/1847/ They are terribly outdated, but still useful to learn the core language, especially if you dont have much programming experience. Some exercises are included, too. And, as others said, read the included documentation! It is full of good tutorials (suitable for beginners), though unfortunately it is a bit more difficult to navigate in version 6 than in previous versions. === Subject: FindMaximum query Consider the following function: fun[x_] := Module[ {y, sol}, sol = FindRoot[Sqrt[y] == Abs[x], {y, 0, 0.001}]; (* AppendTo[list, sol]; *) -y /. sol[[1]] ] Then Plot[fun[x], {x, -2, 2}] works fine, but FindMaximum[fun[x], {x, 1, 1.001}] fails. If I uncomment the debug line in fun and execute list = {}; FindMaximum[fun[x], {x, 1, 1.001}] Then list contains {FindRoot[Sqrt[y$21471] == Abs[x], {y$21471, 0, 0.001}]} So, FindRoot fails because x is passed through unevaluated, I think. I would appreciate any advice on how to get FindMaximum (or NMaximize) to work in this case. Mathematic 6.0.1.0 x86 32 bit Mac OS X 10.4.11 E. Neely Atkinson Department of Biostatistics M. D. Anderson Cancer Center neely@pdq.net === Subject: Re: FindMaximum query Hi Neely, deine fun like: fun[x_?NumericQ] hope this helps, Daniel > Consider the following function: fun[x_] := > Module[ > {y, sol}, > sol = FindRoot[Sqrt[y] == Abs[x], {y, 0, 0.001}]; > (* AppendTo[list, sol]; *) > -y /. sol[[1]] > ] Then Plot[fun[x], {x, -2, 2}] works fine, but FindMaximum[fun[x], {x, 1, 1.001}] fails. If I uncomment the debug line in fun and execute list = {}; > FindMaximum[fun[x], {x, 1, 1.001}] Then list contains {FindRoot[Sqrt[y$21471] == Abs[x], {y$21471, 0, 0.001}]} > So, FindRoot fails because x is passed through unevaluated, I think. > I would appreciate any advice on how to get FindMaximum (or NMaximize) > to work in this case. Mathematic 6.0.1.0 x86 32 bit > Mac OS X 10.4.11 > E. Neely Atkinson > Department of Biostatistics > M. D. Anderson Cancer Center neely@pdq.net > === Subject: Re: NDSolve Percision > So Im running a program that is trying to use NDSolve and parametrically plot the results. The result is periodic, so it should cycle back on itself with a period of 2Pi. It does that, but if I run from {t,0,20Pi} is starts to miss the initial point by more and more. Basically, its spiraling outward at a slow but unwanted rate. This will be a problem for when I increase the difficulty of the function. How do I increase the precision of NDSolve to make it keep more decimals and make the answer more accurate? The function is solution = NDSolve[{x[t] == 2p[t], x[0] == 2, > p[t] == -2x[t],p[0] == N[Sqrt[-3], 50]}, {x, p}, {t,0,20Pi}] > Might want to consider a DAE or other conserved-quantity approach. One might be simplectic Ringe-Kutta. Documentation in the Help Browser is located under tutorial/NDSolveSPRK. Under subsection Symplectic method I see an example quite similar to yours. I suspect a projection approach might also be applicable. See tutorial/ NDSolveProjection. There, too, I see a harmonic oscillator example. Daniel Lichtblau Wolfram Research === Subject: Re: NDSolve Percision Hi Alex, look up the option AccuracyGoal of NDSolve. hope this helps, Daniel > So Im running a program that is trying to use NDSolve and parametrically plot the results. The result is periodic, so it should cycle back on itself with a period of 2Pi. It does that, but if I run from {t,0,20Pi} is starts to miss the initial point by more and more. Basically, its spiraling outward at a slow but unwanted rate. This will be a problem for when I increase the difficulty of the function. How do I increase the precision of NDSolve to make it keep more decimals and make the answer more accurate? The function is > > solution = NDSolve[{x[t] == 2p[t], x[0] == 2, > p[t] == -2x[t],p[0] == N[Sqrt[-3], 50]}, {x, p}, {t,0,20Pi}] === Subject: Re: NDSolve Percision The solution is represented by complex numbers, right? === Subject: Re: NDSolve Percision have you used Method -> {SymplecticPartitionedRungeKutta} ?? to avoid that ? An non-symplectic method *must* loss the energy of the system, this has nothing to do with the Precision, this has to do with the fact that a normal numerical method for initial value problems is designed to reduce the local error and not to preserve a global quantity like the energy. Jens > So Im running a program that is trying to use NDSolve and parametrically plot the results. The result is periodic, so it should cycle back on itself with a period of 2Pi. It does that, but if I run from {t,0,20Pi} is starts to miss the initial point by more and more. Basically, its spiraling outward at a slow but unwanted rate. This will be a problem for when I increase the difficulty of the function. How do I increase the precision of NDSolve to make it keep more decimals and make the answer more accurate? The function is > > solution = NDSolve[{x[t] == 2p[t], x[0] == 2, > p[t] == -2x[t],p[0] == N[Sqrt[-3], 50]}, {x, p}, {t,0,20Pi}] === Subject: NearestFunction Algorithm Im looking to iteratively assign a list of initial points to a list of final points such that at each step, the initial point that is furthest from its nearest final point is assigned to its nearest final point. That final points is then no longer available to other initial points. I noticed that you can speed up repeated uses of Nearest by calling it with only one argument in order to produce a NearestFunction, and then using that in later calculations. Can anyone give me a clue about how this actually works? Is it possible to manipulate a NearestFunction in order to remove points that have already been assigned? Jason Merrill === Subject: Re: NearestFunction Algorithm I dont know what Mathematica actual does but http://www.cs.umd.edu/~mount/ANN/ may give you a hint .. Jens > Im looking to iteratively assign a list of initial points to a list > of final points such that at each step, the initial point that is > furthest from its nearest final point is assigned to its nearest final > point. That final points is then no longer available to other initial > points. I noticed that you can speed up repeated uses of Nearest by calling it > with only one argument in order to produce a NearestFunction, and then > using that in later calculations. Can anyone give me a clue about how > this actually works? Is it possible to manipulate a NearestFunction in order to remove > points that have already been assigned? > Jason Merrill > === Subject: Mathematica and Google Desktop I uninstalled Google desktop. After reinstalling it, I installed again Wolfram Notebook Indexer, found on: but Wolfram Notebook Indexer doesnt work anymore. Google Desktop doesnt recognise nb files anymore. Is seems as if something got corrupted. Has anyone had the same trouble? Pianiel === Subject: ImageResolution bug In Mathematica 6.0 There is a bug in ImageResolution. In Mathematica 6.0 it seems that it is not possible to increase the resolution when exporting a jpg or a gif file. This function worked fine in previous versions of Mathematica. The following line: Graph2 = Plot[x^2, {x, 0, 3}] Export[Test.jpg, Graph2, ImageResolution -> 400] gives a bad picture. Does anyone have a workaround? (The goal is not increase the size of the picture using ImageSize, which makes the lines thiner...) Pianiel === Subject: Re: Bug Report for DiscreteMath`Combinatorica`Contract It does NOT seem to have been corrected in Mathematica 6: << Combinatorica` gc = Contract[g, {1, 2}]; Directed graph g has an edge from 1 to 3 and an edge from 3 to 2, of course. But gc has two edges from 1 to 2, both directed from 1 to 2. Unfortunately, your Contract2 does not seem to work with the Mathematica 6 Combinatorica package -- it generates a whole bunch of error messages. > The series of commands below describe a bug in > DiscreteMath`Combinatorica`Contract. Contracting vertices 1 and 2 in a > directed graph with edges {1,3} and {3,2} should give a graph with two > vertices and two edges {1,2} and {2,1}. Instead, it gives a graph with edges > {1,2} and {1,2}. The error in the existing version is the Sort command, > which for directed graphs leads to erroneous output. A corrected version of > the Contract function is included below. Please advise if this bug has been previously reported, whether the > existence of the bug and the proposed fix is confirmed, and where such > information is posted. Hunter Monroe < > umber*True,TextStyle*{FontSize*18} > VertexNumberPosition*Center,VertexStyle*Disk[0.05]] Contract2[g_Graph,l_List]:=Module[{v=Vertices[g,All],t=Table[0,{V[g]}],cnt=0 > ,last=V[g]-Length[l]+1},Do[If[MemberQ[l,k],cnt++;t[[k]]=last,t[[k]]=k-cnt],{ > k,V[g]}]; > > Graph[DeleteCases[Edges[g,All]/.{{x_Integer,y_Integer},opts___?OptionQ}*{{t[ > [x]],t[[y]]},opts},{{last,last},opts___?OptionQ}],Append[v[[Complement[Range > [Length[v]],l]]],{Apply[Plus,Map[First,v[[l]]]]/Length[l],Apply[Sequence,App > ly[Intersection,Map[Drop[#,1]&,v[[l]]]]]}],Apply[Sequence,GraphOptions[g]]]] ShowGraph[Contract2[g,{1,2}]] -- 3 545-1801 Amherst, MA 01003-9305 === Subject: Differential Equation I was trying to solve the following second order linear differential equation and got no result from Mathematica. DSolve[(x2-1)*D[y[x],{x,2}]SD[y[x],x]-x2*y[x],y[x],x] Any ideas? Sergio Terrazas This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. === Subject: Re: Differential Equation and what is SD[] ?? and is x2 eventual x^2 Can you please post valid Mathematica syntax or did you expect you find an analytical solution with DSolve[] to an ode with an unknown functional SD[y[x],x] ?? And posting to a public news group with This email and any files transmitted with it are confidential is nonsense. Jens I was trying to solve the following second order linear differential equation and got no result from Mathematica. DSolve[(x2-1)*D[y[x],{x,2}]SD[y[x],x]-x2*y[x],y[x],x] Any ideas? > Sergio Terrazas This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. > === Subject: Help with NMinimize of NIntegrate function Whats wrong with this code: test[t_?NumericQ, J_?NumericQ, m_?NumericQ, (Q3_)?NumericQ, (Q2_)?NumericQ] := NIntegrate[ EAa[t, J, m, Q3, Q2]* HeavisideTheta[EAa[t, J, m, Q3, Q2]], {x, -Pi, Pi}, {y, -Pi, Pi}, {z, -Pi, Pi}, MaxPoints -> 1000000, Method -> LocalAdaptive]/8/(Pi^3) In[75]:= test[10, 1, 1, 1, 1] // Timing Out[75]= {5.819, 2.22142} where EAa[t, J, m, Q3, Q2]:= 1/2 (-3 J - 2 m - 2 t (Cos[x] + Cos[y]) - 2 t (Cos[x]/3 + Cos[y]/3 + (4 Cos[z])/3)) - 1/2 Sqrt[16 (-(Q2/2) - (t Cos[x])/Sqrt[3] + (t Cos[y])/Sqrt[ 3])^2 + (-2 Q3 + 2 t (Cos[x] + Cos[y]) - 2 t (Cos[x]/3 + Cos[y]/3 + (4 Cos[z])/3))^2] with NMinimize[test[10, 1, [Mu], q, Q], {[Mu], q, Q}] I get those inumr errors, have i set anything wrong? Everything should be numerical, x,y,z are integrated out, so what is it? === Subject: problem with Inset moving text I am trying to use Inset but have a problem in 6.0.1 see this code Manipulate[ Graphics[ {Circle[], Inset[Style[StringJoin[value:, ToString[N[c]]], Blue, 20]] } ] , {{c, (2 [Pi])/3, Value c}, -1, 2 Pi, 0.001}] use the slide to go to value 1.609 and then it jumps into value 1.61 the problem I have is that the text jumps horizontaly any way to make the text fix so it will not jump? this happens because the numbers 1.609 and 1.61 are different in leght any solution? === Subject: Re: problem with Inset moving text Hi Camille, the text is centered. Therefore, it will move when the length changes. To prevent this, either make the number always the same size: NumberForm[c // N, {4, 3}] or even better, place the text at an definite location by useing the second and third argument of Inset: Manipulate[Graphics[{Circle[],Inset[Style[StringJoin[value:,ToString[Num berForm[c//N,{4,3}]]],Blue,20],{-.3,0},{-1,-1}]}],{{c,(2 [Pi])/3,Value c},-1,2 Pi,0.001}] hope this helps, Daniel > I am trying to use Inset but have a problem in 6.0.1 see this code Manipulate[ > Graphics[ > {Circle[], > Inset[Style[StringJoin[value:, ToString[N[c]]], Blue, 20]] > } > ] > , {{c, (2 [Pi])/3, Value c}, -1, 2 Pi, 0.001}] use the slide to go to value 1.609 > and then it jumps into value 1.61 > the problem I have is that the text jumps horizontaly any way to make the text fix so it will not jump? > this happens because the numbers 1.609 and 1.61 are different in leght > any solution? > === Subject: Re: problem with Inset moving text from negative to positive or vise versa Any idea how to solve it? === Subject: Re: problem with Inset moving text Manipulate[ Graphics[{Circle[], Inset[Style[ StringJoin[value:, ToString[ NumberForm[N[c], {16, 8}, NumberPadding -> { , 0}, NumberSigns -> {-, }]]], Blue, 20]]}], {{c, (2 [Pi])/3, Value c}, -1, 2 Pi, 0.001}] and you should use a mono spaced font, otherwise the different width of the characters will make problems. Jens > I am trying to use Inset but have a problem in 6.0.1 see this code Manipulate[ > Graphics[ > {Circle[], > Inset[Style[StringJoin[value:, ToString[N[c]]], Blue, 20]] > } > ] > , {{c, (2 [Pi])/3, Value c}, -1, 2 Pi, 0.001}] use the slide to go to value 1.609 > and then it jumps into value 1.61 > the problem I have is that the text jumps horizontaly any way to make the text fix so it will not jump? > this happens because the numbers 1.609 and 1.61 are different in leght > any solution? > === Subject: Mathematica Book and Documentation There were some postings in the How should I get started with Mathematica thread about the lack of a printed book. In August 2007 there were postings on the question of the old book organization and Thomas Muench posted some code that would create a Virtual Mathematica Book from the documentation material. I have pasted his code at the end of this posting. Paste it into a blank notebook and evaluate. It will create a Virtual Book notebook. One nice thing about this virtual book is that it has a listing of all the supplied standard packages, which I find otherwise difficult to find. I do not think an actual printed book is that useful with the new Mathematica 6 because it is impossible to reproduce dynamic behavior on a static printed page. The world changes and the elderly can adapt as well as the young. Weve had more practice. I think that one way to improve the new Version 6 documentation would be to increase the density of information on the index pages. One should not have to go through a number of levels of index pages to get to the required information. I think this would go a long way to decreasing complaints. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{(*, , RowBox[{-=, RowBox[{=, RowBox[{ RowBox[{ RowBox[{ RowBox[{-, Make}], , , , based, , on, , <...Overview.nb>, , files, , in, , the, , tutorials, , directory}], -=}], =, -}]}]}], *)}], RowBox[{ RowBox[{ RowBox[{fn, =, RowBox[{FileNames, [, RowBox[{<*Overview.nb>, ,, RowBox[{ToFileName, [, RowBox[{{, RowBox[{ $InstallationDirectory, ,, , ,, , ,, , ,, }], }}], ]}]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ RowBox[{ Find, , , , files, , in, , the, , tutorials}], -, directory}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{nameList, =, RowBox[{ RowBox[{ RowBox[{{, RowBox[{ RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, 1}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 12}]}], }}]}], ]}], ,, RowBox[{, <>, RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, 1}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 4}]}], }}]}], ]}]}], ,, #}], }}], &}], /@, fn}]}], ;}], n, RowBox[{(*, RowBox[{ create, , a, , list, , of, , strings, , needed, , for, , future, , code}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{ RowBox[{nameList, [, RowBox[{[, RowBox[{i, ,, 1}], ]}], ]}], =, RowBox[{, <>, RowBox[{nameList, [, RowBox[{[, RowBox[{i, ,, 1}], ]}], ]}]}]}], ,, RowBox[{{, RowBox[{i, ,, RowBox[{{, RowBox[{ 3, ,, 6, ,, 7, ,, 8, ,, 18, ,, 28, ,, 29, ,, 40, ,, 41, ,, 46, ,, 48}], }}]}], }}]}], ]}], ;}], n, RowBox[{(*, RowBox[{ mark, , the, , chapter, , not, , present, , in, , v5, .2, , with, , }], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{orderOfChapters, =, RowBox[{{, RowBox[{ RowBox[{{, RowBox[{ 36, ,, 3, ,, 8, ,, 31, ,, 4, ,, 47, ,, 1, ,, 39, ,, 32, ,, 14, ,, 20, ,, 16, ,, 18, ,, 17, ,, 11, ,, 43}], }}], ,, RowBox[{{, RowBox[{ 10, ,, 13, ,, 35, ,, 48, ,, 22, ,, 45, ,, 9, ,, 27, ,, 38, ,, 42, ,, 44, ,, 23, ,, 12, ,, 26, ,, 15, ,, 40, ,, 41}], }}], ,, RowBox[{{, RowBox[{ 30, ,, 25, ,, 2, ,, 21, ,, 5, ,, 7, ,, 37, ,, 19, ,, 33, ,, 34, ,, 28, ,, 29, ,, 6, ,, 46, ,, 24}], }}]}], }}]}], ;}], n, RowBox[{(*, RowBox[{ RowBox[{ The, , file, , list, , is, , alphabetical}], -, RowBox[{ this, , is, , the, , order, , in, , which, , the, , chapters, , should, , appear}]}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{structure, =, RowBox[{Table, [, RowBox[{ RowBox[{nameList, [, RowBox[{[, i, ]}], ]}], ,, RowBox[{{, RowBox[{k, ,, 3}], }}], ,, RowBox[{{, RowBox[{i, ,, RowBox[{orderOfChapters, [, RowBox[{[, k, ]}], ]}]}], }}]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ RowBox[{ needed, , for, , the, , code, , further, , down}], -, RowBox[{ represents, , the, , structure, , of, , the, , Mathematica, , book}]}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{mainChapters, =, RowBox[{{, RowBox[{ , ,, , ,, , ,, , ,, , ,, , ,, }], }}]}], ;}], n, RowBox[{(*, RowBox[{The, , three, , main, , headings}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{ RowBox[{beautify, [, ugly_, ]}], :=, RowBox[{StringReplace, [, RowBox[{ RowBox[{StringReplace, [, RowBox[{ugly, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{l1_, ?, LowerCaseQ}], ~~, RowBox[{l2_, ?, UpperCaseQ}]}], [RuleDelayed], RowBox[{l1, <>, < >, <>, l2}]}], }}]}], ]}], ,, RowBox[{{, RowBox[{ RowBox[{< And >, [Rule], < and >}], ,, RowBox[{< Of >, [Rule], < of >}], ,, RowBox[{< In >, [Rule], < in >}], ,, RowBox[{< The >, [Rule], < the >}], ,, RowBox[{< For >, [Rule], < for >}]}], }}]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ RowBox[{ based, , on, , code, , by, , Selwyn, , Hollis}], -, [IndentingNewLine], RowBox[{ RowBox[{d, [, RowBox[{x_, ,, RowBox[{style_:, ,
}], ,, RowBox[{margin_:, , RowBox[{{, RowBox[{ RowBox[{{, RowBox[{36, ,, 0}], }}], ,, RowBox[{{, RowBox[{5, ,, 5}], }}]}], }}]}]}], ]}], :=, RowBox[{Module, [, RowBox[{ RowBox[{{, RowBox[{sectitle, =, RowBox[{beautify, [, RowBox[{x, [, RowBox[{[, 1, ]}], ]}], ]}]}], }}], ,, RowBox[{Cell, [, RowBox[{ RowBox[{BoxData, [, RowBox[{ButtonBox, [, RowBox[{ RowBox[{PaneSelectorBox, [, RowBox[{ RowBox[{{, RowBox[{ RowBox[{False, [Rule], sectitle}], ,, RowBox[{True, [Rule], RowBox[{StyleBox, [, RowBox[{sectitle, ,, }], ]}]}]}], }}], ,, RowBox[{Dynamic, [, RowBox[{CurrentValue, [, , ]}], ]}]}], ]}], ,, RowBox[{BaseStyle, [Rule], RowBox[{{, RowBox[{, ,, style}], }}]}], ,, RowBox[{ButtonData, [Rule], RowBox[{x, [, RowBox[{[, 2, ]}], ]}]}], ,, RowBox[{ButtonNote, [Rule], RowBox[{x, [, RowBox[{[, 2, ]}], ]}]}]}], ]}], ]}], ,, style, ,, RowBox[{CellDingbat, [Rule], None}], ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], margin}]}], ]}]}], ]}]}], n, RowBox[{(*, RowBox[{ Cell, , representing, , a, , hyperlink, , to, , a, , file}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{nb, =, RowBox[{NotebookPut, [, ]}]}], ;, RowBox[{SetOptions, [, RowBox[{nb, ,, RowBox[{StyleDefinitions, [Rule], RowBox[{ToFileName, [, RowBox[{, ,, }], ]}]}]}], ]}], ;}], [IndentingNewLine], RowBox[{(*, RowBox[{Open, , new, , Notebook}], *)}], [IndentingNewLine], RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{{, RowBox[{ RowBox[{Cell, [, RowBox[{ RowBox[{Row, [, RowBox[{{, RowBox[{ RowBox[{ToBoxes, [, RowBox[{Import, [, RowBox[{ RowBox[{ToFileName, [, RowBox[{ , ,, }], ]}], ,, , ,, RowBox[{ImageSize, [Rule], 70}]}], ]}], ]}], ,, RowBox[{Cell, [, RowBox[{ , ,, , ,, RowBox[{TextAlignment, [Rule], Center}]}], ]}]}], }}], ]}], ,, <Title>, ,, RowBox[{TextAlignment, [Rule], Center}]}], ]}], ,, RowBox[{Cell, [, RowBox[{ <A collection of links to the tutorials present in the Mathematica 6.0 Documentation Center, arranged in the order of chapters in The Mathematica Book.>, ,, <Text>, ,, RowBox[{TextAlignment, [Rule], Center}]}], ]}]}], }}]}], ]}], ;}], n, RowBox[{(*, RowBox[{Print, , the, , titel}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{Cell, [, RowBox[{ RowBox[{StringJoin, [, RowBox[{Table, [, RowBox[{<xxxxxxxxxx>, ,, RowBox[{{, k, }}]}], ]}], ]}], ,, <Text>}], ]}]}], ]}], ;, [IndentingNewLine], RowBox[{If, [, RowBox[{ RowBox[{2, [LessEqual], k, [LessEqual], 4}], ,, RowBox[{Do, [, RowBox[{ RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{d, [, i, ]}]}], ]}], ;, [IndentingNewLine], RowBox[{With, [, RowBox[{ RowBox[{{, RowBox[{nb1, =, RowBox[{NotebookOpen, [, RowBox[{ RowBox[{i, [, RowBox[{[, 3, ]}], ]}], ,, RowBox[{Visible, [Rule], False}]}], ]}]}], }}], ,, RowBox[{ RowBox[{SelectionMove, [, RowBox[{nb1, ,, All, ,, Notebook}], ]}], ;, [IndentingNewLine], RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{ RowBox[{NotebookRead, [, nb1, ]}], //., RowBox[{{, RowBox[{ RowBox[{<TOCChapter>, [Rule], RowBox[{Sequence, @@, RowBox[{{, RowBox[{<Subsection>, ,, RowBox[{CellDingbat, [Rule], None}], ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], RowBox[{{, RowBox[{ RowBox[{{, RowBox[{48, ,, 0}], }}], ,, Inherited}], }}]}]}], }}]}]}], ,, RowBox[{<TOCSection>, [Rule], RowBox[{Sequence, @@, RowBox[{{, RowBox[{<Subsubsection>, ,, RowBox[{CellDingbat, [Rule], None}], ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], RowBox[{{, RowBox[{ RowBox[{{, RowBox[{58, ,, 0}], }}], ,, Inherited}], }}]}]}], }}]}]}], ,, RowBox[{<TOCSubsection>, [Rule], RowBox[{Sequence, @@, RowBox[{{, RowBox[{<Subsubsubsection>, ,, RowBox[{CellDingbat, [Rule], None}], ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], RowBox[{{, RowBox[{ RowBox[{{, RowBox[{68, ,, 0}], }}], ,, Inherited}], }}]}]}], }}]}]}], ,, RowBox[{<TOCSubsubsection>, [Rule], RowBox[{Sequence, @@, RowBox[{{, RowBox[{<Text>, ,, RowBox[{CellDingbat, [Rule], None}], ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], RowBox[{{, RowBox[{ RowBox[{{, RowBox[{78, ,, 0}], }}], ,, Inherited}], }}]}]}], }}]}]}], ,, RowBox[{ShowCellBracket, [Rule], True}]}], }}]}]}], ]}], ;, [IndentingNewLine], RowBox[{NotebookClose, [, nb1, ]}]}]}], ]}]}], ,, RowBox[{{, RowBox[{i, ,, RowBox[{structure, [, RowBox[{[, RowBox[{k, -, 1}], ]}], ]}]}], }}]}], ]}]}], ]}]}], ,, RowBox[{{, RowBox[{k, ,, RowBox[{Length, [, mainChapters, ]}]}], }}]}], ]}], ;}], n, RowBox[{(*, RowBox[{ RowBox[{ write, , all, , the, , links, , to, , the, , main, , chapters}], ,, RowBox[{ RowBox[{as, , well, , as, , to, , sub}], -, chapters}]}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{ RowBox[{NotebookFind, [, RowBox[{ nb, ,, cellsToDelete, ,, All, ,, CellStyle}], ]}], ;, [IndentingNewLine], RowBox[{NotebookDelete, [, nb, ]}]}], ,, RowBox[{{, RowBox[{cellsToDelete, ,, RowBox[{{, RowBox[{ <SymbolColorBar>, ,, <AnchorBarGrid>, ,, <FooterCell>, ,, <TOCDocumentTitle>}], }}]}], }}]}], ]}], ;}], n, RowBox[{(*, RowBox[{ Delete, , unnecessary, , styling, , cells, , that, , are, , part, , of, , the, , tutorial, , notebooks}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{SetOptions, [, RowBox[{nb, ,, RowBox[{StyleDefinitions, [Rule], RowBox[{ToFileName, [, RowBox[{<Book>, ,, <Textbook.nb>}], ]}]}]}], ]}], ;}], n, RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{ RowBox[{NotebookFind, [, RowBox[{nb, ,, RowBox[{StringJoin, [, RowBox[{Table, [, RowBox[{<xxxxxxxxxx>, ,, RowBox[{{, k, }}]}], ]}], ]}], ,, All}], ]}], ;, [IndentingNewLine], RowBox[{SelectionMove, [, RowBox[{nb, ,, All, ,, Cell}], ]}], ;, [IndentingNewLine], RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{Cell, [, RowBox[{ RowBox[{mainChapters, [, RowBox[{[, k, ]}], ]}], ,, <Subtitle>, ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], RowBox[{{, RowBox[{ RowBox[{{, RowBox[{10, ,, 0}], }}], ,, RowBox[{{, RowBox[{5, ,, 10}], }}]}], }}]}], ,, RowBox[{CellTags, [Rule], RowBox[{<Section>, <>, RowBox[{ToString, [, k, ]}]}]}], ,, RowBox[{CellFrame, [Rule], RowBox[{If, [, RowBox[{ RowBox[{MemberQ, [, RowBox[{ RowBox[{{, RowBox[{1, ,, 6, ,, 7}], }}], ,, k}], ]}], ,, RowBox[{{, RowBox[{ RowBox[{{, RowBox[{0, ,, 0}], }}], ,, RowBox[{{, RowBox[{0, ,, 2}], }}]}], }}], ,, False}], ]}]}]}], ]}]}], ]}]}], ,, RowBox[{{, RowBox[{k, ,, RowBox[{Length, [, mainChapters, ]}], ,, 1, ,, RowBox[{-, 1}]}], }}]}], ]}], ;}], [IndentingNewLine], RowBox[{(*, RowBox[{Finishing, , touches}], *)}], [IndentingNewLine], n, RowBox[{(*, , RowBox[{-=, RowBox[{=, RowBox[{ RowBox[{ RowBox[{ RowBox[{-, Add}], , links, , to, , tutorials, , that, , are, , not, , linked, , yet}], -=}], =, -}]}]}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{SelectionMove, [, RowBox[{nb, ,, All, ,, Notebook}], ]}], ;}], n, RowBox[{ RowBox[{links, =, RowBox[{StringCases, [, RowBox[{ RowBox[{ToString, [, RowBox[{ RowBox[{NotebookRead, [, nb, ]}], ,, InputForm}], ]}], ,, RowBox[{ RowBox[{Shortest, [, RowBox[{(, RowBox[{ <paclet:tutorial/>, ~~, y__, ~~, <>}], )}], ]}], [RuleDelayed], y}]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ RowBox[{ Extract, , all, , links, , to, , tutorials, , present, , in, , <The Book>}], ...}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{linkedFiles, =, RowBox[{Union, [, RowBox[{Flatten, [, RowBox[{ RowBox[{ RowBox[{If, [, RowBox[{ RowBox[{StringFreeQ, [, RowBox[{#, ,, RowBox[{<#>, ~~, RowBox[{DigitCharacter, ...}]}]}], ]}], ,, RowBox[{#, <>, <.nb>}], ,, RowBox[{StringCases, [, RowBox[{#, ,, RowBox[{ RowBox[{(, RowBox[{y__, ~~, <#>, ~~, RowBox[{DigitCharacter, ...}]}], )}], [RuleDelayed], RowBox[{y, <>, <.nb>}]}]}], ]}]}], ]}], &}], /@, links}], ]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{..., , and, , their, , filenames}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{allTutorials, =, RowBox[{Flatten, [, RowBox[{ RowBox[{ RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, 1}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 1}]}], }}]}], ]}], &}], /@, RowBox[{FileNames, [, RowBox[{<*.nb>, ,, RowBox[{ToFileName, [, RowBox[{{, RowBox[{ $InstallationDirectory, ,, <Documentation>, ,, <English>, ,, <System>, ,, <Tutorials>}], }}], ]}]}], ]}]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ all, , tutorials, , in, , the, , tutorial, , directory}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{notUsed, =, RowBox[{Complement, [, RowBox[{allTutorials, ,, linkedFiles}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ RowBox[{ all, , tutorials, , not, , linked, , to, , in, , <The Book>, , so, , far, , RowBox[{(, RowBox[{in, , alphabetical, , order}], )}]}], ;, RowBox[{ these, , are, , 76, , tutorial, , notebooks}]}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{nameList, =, RowBox[{ RowBox[{ RowBox[{{, RowBox[{ RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{1, ,, RowBox[{-, 4}]}], }}]}], ]}], ,, RowBox[{<paclet:tutorial/>, <>, RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{1, ,, RowBox[{-, 4}]}], }}]}], ]}]}], ,, RowBox[{ RowBox[{ToFileName, [, RowBox[{{, RowBox[{ $InstallationDirectory, ,, <Documentation>, ,, <English>, ,, <System>, ,, <Tutorials>}], }}], ]}], <>, #}]}], }}], &}], /@, notUsed}]}], ;}], n, RowBox[{(*, RowBox[{ create, , a, , list, , of, , strings, , needed, , for, , future, , code}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{GettingStarted, =, RowBox[{{, RowBox[{21, ,, 18, ,, 75}], }}]}], ;, RowBox[{GraphPlotting, =, RowBox[{{, RowBox[{27, ,, 28, ,, 36, ,, 71}], }}]}], ;, RowBox[{MathematicaReferenceGuide, =, RowBox[{{, RowBox[{ 7, ,, 31, ,, 64, ,, 19, ,, 57, ,, 20, ,, 37, ,, 33, ,, 30}], }}]}], ;, RowBox[{MatrixAndVectorOperations, =, RowBox[{{, RowBox[{ 10, ,, 26, ,, 6, ,, 3, ,, 73, ,, 16, ,, 42, ,, 45, ,, 62, ,, 52, ,, 65, ,, 69}], }}]}], ;, RowBox[{Statistics, =, RowBox[{{, RowBox[{11, ,, 15, ,, 13, ,, 58}], }}]}], ;, RowBox[{DynamicFeatures, =, RowBox[{{, RowBox[{35, ,, 2, ,, 34, ,, 1}], }}]}], ;, RowBox[{SystemSpecificTopics, =, RowBox[{{, RowBox[{ 17, ,, 32, ,, 60, ,, 50, ,, 51, ,, 53, ,, 41, ,, 44, ,, 38, ,, 39, ,, 40}], }}]}], ;, RowBox[{FurtherNDSolveTutorials, =, RowBox[{{, RowBox[{46, ,, 47, ,, 48, ,, 49}], }}]}], ;, RowBox[{FrontendAndFormattingTopics, =, RowBox[{{, RowBox[{ 5, ,, 22, ,, 24, ,, 25, ,, 29, ,, 67, ,, 70, ,, 74}], }}]}], ;}], [IndentingNewLine], RowBox[{ RowBox[{topics, =, RowBox[{{, RowBox[{ GettingStarted, ,, MathematicaReferenceGuide, ,, GraphPlotting, ,, MatrixAndVectorOperations, ,, Statistics, ,, DynamicFeatures, ,, SystemSpecificTopics, ,, FurtherNDSolveTutorials, ,, FrontendAndFormattingTopics}], }}]}], ;}], n, RowBox[{ RowBox[{FurtherTopics, =, RowBox[{Complement, [, RowBox[{ RowBox[{Range, [, RowBox[{Length, [, notUsed, ]}], ]}], ,, RowBox[{Flatten, [, topics, ]}]}], ]}]}], ;}], n, RowBox[{ RowBox[{topics, =, RowBox[{Join, [, RowBox[{topics, ,, RowBox[{{, FurtherTopics, }}]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ trying, , to, , get, , some, , order, , into, , these, , tutorials}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{topicNames, =, RowBox[{{, RowBox[{ <Getting Started>, ,, <Mathematica Reference Guide>, ,, <Graph Plotting>, ,, <Matrix And Vector Operations>, ,, <Statistics>, ,, <Dynamic Features>, ,, <System Specific Topics>, ,, <Further NDSolve Tutorials>, ,, <FrontEnd and Formatting Topics>, ,, <Others>}], }}]}], ;}], [IndentingNewLine], n, RowBox[{ RowBox[{NotebookFind, [, RowBox[{ nb, ,, <Section1>, ,, After, ,, CellTags}], ]}], ;, RowBox[{SelectionMove, [, RowBox[{nb, ,, After, ,, Cell}], ]}], ;}], [IndentingNewLine], RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{d, [, RowBox[{ RowBox[{nameList, [, RowBox[{[, i, ]}], ]}], ,, <Subsection>, ,, RowBox[{{, RowBox[{ RowBox[{{, RowBox[{48, ,, 0}], }}], ,, Inherited}], }}]}], ]}]}], ]}], ,, RowBox[{{, RowBox[{i, ,, GettingStarted}], }}]}], ]}], ;}], n, RowBox[{(*, RowBox[{ Add, , links, , to, , <getting Started>, , topics}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{NotebookFind, [, RowBox[{ nb, ,, <Section5>, ,, After, ,, CellTags}], ]}], ;, RowBox[{SelectionMove, [, RowBox[{nb, ,, After, ,, Cell}], ]}], ;}], [IndentingNewLine], RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{d, [, RowBox[{ RowBox[{nameList, [, RowBox[{[, i, ]}], ]}], ,, <Subsection>, ,, RowBox[{{, RowBox[{ RowBox[{{, RowBox[{48, ,, 0}], }}], ,, Inherited}], }}]}], ]}]}], ]}], ,, RowBox[{{, RowBox[{i, ,, MathematicaReferenceGuide}], }}]}], ]}], ;}], n, RowBox[{(*, RowBox[{ Add, , links, , to, , <Refrence Guides>, , topics}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{NotebookFind, [, RowBox[{ nb, ,, <Section6>, ,, After, ,, CellTags}], ]}], ;, RowBox[{SelectionMove, [, RowBox[{nb, ,, After, ,, Cell}], ]}], ;}], [IndentingNewLine], RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{Cell, [, RowBox[{ RowBox[{topicNames, [, RowBox[{[, i, ]}], ]}], ,, <Section>, ,, RowBox[{CellDingbat, [Rule], None}], ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], RowBox[{{, RowBox[{ RowBox[{{, RowBox[{36, ,, 0}], }}], ,, RowBox[{{, RowBox[{5, ,, 5}], }}]}], }}]}]}], ]}]}], ]}], ;, [IndentingNewLine], RowBox[{Do, [, RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{d, [, RowBox[{ RowBox[{nameList, [, RowBox[{[, k, ]}], ]}], ,, <Subsection>, ,, RowBox[{{, RowBox[{ RowBox[{{, RowBox[{48, ,, 0}], }}], ,, Inherited}], }}]}], ]}]}], ]}], ,, RowBox[{{, RowBox[{k, ,, RowBox[{topics, [, RowBox[{[, i, ]}], ]}]}], }}]}], ]}]}], ,, RowBox[{{, RowBox[{i, ,, 3, ,, RowBox[{Length, [, topics, ]}]}], }}]}], ]}], ;}], [IndentingNewLine], RowBox[{(*, RowBox[{ Add, , links, , to, , all, , other, , topics}], *)}], [IndentingNewLine], n, RowBox[{(*, , RowBox[{-=, RowBox[{=, RowBox[{ RowBox[{ RowBox[{ RowBox[{-, Add}], , links, , to, , Packages}], -=}], =, -}]}]}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{fnpdir, =, RowBox[{FileNames, [, RowBox[{<*>, ,, RowBox[{ToFileName, [, RowBox[{{, RowBox[{ $InstallationDirectory, ,, <Documentation>, ,, <English>, ,, <Packages>}], }}], ]}]}], ]}]}], ;}], n, RowBox[{(*, RowBox[{ Directory, , names, , of, , the, , Packages}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{fnptut, =, RowBox[{ RowBox[{ RowBox[{FileNames, [, RowBox[{<*.nb>, ,, RowBox[{ToFileName, [, RowBox[{{, RowBox[{ #, ,, <Documentation>, ,, <English>, ,, <Tutorials>}], }}], ]}], ,, Infinity}], ]}], &}], /@, fnpdir}]}], ;}], n, RowBox[{(*, RowBox[{ tutorial, , notebooks, , of, , the, , Packages}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{fnpguid, =, RowBox[{ RowBox[{ RowBox[{FileNames, [, RowBox[{<*.nb>, ,, RowBox[{ToFileName, [, RowBox[{{, RowBox[{ #, ,, <Documentation>, ,, <English>, ,, <Guides>}], }}], ]}], ,, Infinity}], ]}], &}], /@, fnpdir}]}], ;}], n, RowBox[{(*, RowBox[{ guide, , notebooks, , of, , the, , Packages}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{NotebookFind, [, RowBox[{ nb, ,, <Section7>, ,, After, ,, CellTags}], ]}], ;, RowBox[{SelectionMove, [, RowBox[{nb, ,, After, ,, Cell}], ]}], ;}], [IndentingNewLine], RowBox[{ RowBox[{Do, [, RowBox[{ RowBox[{With, [, RowBox[{ RowBox[{{, RowBox[{packageName, =, RowBox[{ RowBox[{ RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, 1}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 1}]}], }}]}], ]}], StyleBox[&, FontVariations->{Underline->True}, FontColor->RGBColor[0., 0., 1.]]}], StyleBox[@, FontVariations->{Underline->True}, FontColor->RGBColor[0., 0., 1.]], RowBox[{ StyleBox[fnpdir, FontVariations->{Underline->True}, FontColor->RGBColor[0., 0., 1.]], StyleBox[[, FontVariations->{Underline->True}, FontColor->RGBColor[0., 0., 1.]], RowBox[{ StyleBox[[, FontVariations->{Underline->True}, FontColor->RGBColor[0., 0., 1.]], StyleBox[package, FontVariations->{Underline->True}, FontColor->RGBColor[0., 0., 1.]], ]}], ]}]}]}], }}], ,, RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{Cell, [, RowBox[{ RowBox[{beautify, @, packageName}], ,, <Section>, ,, RowBox[{CellDingbat, [Rule], None}], ,, RowBox[{ShowGroupOpener, [Rule], True}], ,, RowBox[{CellMargins, [Rule], RowBox[{{, RowBox[{ RowBox[{{, RowBox[{36, ,, 0}], }}], ,, RowBox[{{, RowBox[{5, ,, 5}], }}]}], }}]}]}], ]}]}], ]}], ;, n, RowBox[{If, [, RowBox[{ RowBox[{ RowBox[{Length, [, RowBox[{fnptut, [, RowBox[{[, package, ]}], ]}], ]}], >, 0}], ,, RowBox[{ RowBox[{level, =, RowBox[{If, [, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringTake, [, RowBox[{ RowBox[{fnptut, [, RowBox[{[, package, ]}], ]}], ,, RowBox[{ RowBox[{{, RowBox[{1, ,, RowBox[{-, 1}]}], }}], +, RowBox[{ RowBox[{(, RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{Take, [, RowBox[{ RowBox[{#, [, RowBox[{[, 1, ]}], ]}], ,, RowBox[{{, RowBox[{ RowBox[{-, 2}], ,, RowBox[{-, 1}]}], }}]}], ]}], &}], @, RowBox[{Transpose, [, RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], ]}]}], &}], /@, RowBox[{fnptut, [, RowBox[{[, package, ]}], ]}]}], )}], [, RowBox[{[, 1, ]}], ]}]}]}], ]}], [, RowBox[{[, 1, ]}], ]}], [Equal], <Tutorials>}], ,, 1, ,, 2}], ]}]}], ;, [IndentingNewLine], RowBox[{nameList, =, RowBox[{ RowBox[{ RowBox[{{, RowBox[{ RowBox[{<Tutorial: >, <>, RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, level}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 4}]}], }}]}], ]}]}], ,, RowBox[{ <paclet:>, <>, packageName, <>, </tutorial/>, <>, RowBox[{StringReplace, [, RowBox[{ RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, level}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 4}]}], }}]}], ]}], ,, RowBox[{ <>, [Rule], </>}]}], ]}]}]}], }}], &}], /@, RowBox[{fnptut, [, RowBox[{[, package, ]}], ]}]}]}], ;, [IndentingNewLine], RowBox[{Do, [, RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{d, [, RowBox[{ RowBox[{nameList, [, RowBox[{[, k, ]}], ]}], ,, <Subsection>, ,, RowBox[{{, RowBox[{ RowBox[{{, RowBox[{48, ,, 0}], }}], ,, Inherited}], }}]}], ]}]}], ]}], ,, RowBox[{{, RowBox[{k, ,, RowBox[{Length, [, RowBox[{fnptut, [, RowBox[{[, package, ]}], ]}], ]}]}], }}]}], ]}]}]}], ]}], ;, n, RowBox[{If, [, RowBox[{ RowBox[{ RowBox[{Length, [, RowBox[{fnpguid, [, RowBox[{[, package, ]}], ]}], ]}], >, 0}], ,, RowBox[{ RowBox[{level, =, RowBox[{If, [, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringTake, [, RowBox[{ RowBox[{fnpguid, [, RowBox[{[, package, ]}], ]}], ,, RowBox[{ RowBox[{{, RowBox[{1, ,, RowBox[{-, 1}]}], }}], +, RowBox[{ RowBox[{(, RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{Take, [, RowBox[{ RowBox[{#, [, RowBox[{[, 1, ]}], ]}], ,, RowBox[{{, RowBox[{ RowBox[{-, 2}], ,, RowBox[{-, 1}]}], }}]}], ]}], &}], @, RowBox[{Transpose, [, RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], ]}]}], &}], /@, RowBox[{fnpguid, [, RowBox[{[, package, ]}], ]}]}], )}], [, RowBox[{[, 1, ]}], ]}]}]}], ]}], [, RowBox[{[, 1, ]}], ]}], [Equal], <Guides>}], ,, 1, ,, 2}], ]}]}], ;, [IndentingNewLine], RowBox[{nameList, =, RowBox[{ RowBox[{ RowBox[{{, RowBox[{ RowBox[{<Guide: >, <>, RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, 1}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 4}]}], }}]}], ]}]}], ,, RowBox[{ <paclet:>, <>, packageName, <>, </guide/>, <>, RowBox[{StringReplace, [, RowBox[{ RowBox[{StringTake, [, RowBox[{#, ,, RowBox[{{, RowBox[{ RowBox[{ RowBox[{ RowBox[{StringPosition, [, RowBox[{#, ,, $PathnameSeparator}], ]}], [, RowBox[{[, RowBox[{ RowBox[{-, level}], ,, 1}], ]}], ]}], +, 1}], ,, RowBox[{-, 4}]}], }}]}], ]}], ,, RowBox[{ <>, [Rule], </>}]}], ]}]}]}], }}], &}], /@, RowBox[{fnpguid, [, RowBox[{[, package, ]}], ]}]}]}], ;, [IndentingNewLine], RowBox[{Do, [, RowBox[{ RowBox[{NotebookWrite, [, RowBox[{nb, ,, RowBox[{d, [, RowBox[{ RowBox[{nameList, [, RowBox[{[, k, ]}], ]}], ,, <Subsection>, ,, RowBox[{{, RowBox[{ RowBox[{{, RowBox[{48, ,, 0}], }}], ,, Inherited}], }}]}], ]}]}], ]}], ,, RowBox[{{, RowBox[{k, ,, RowBox[{Length, [, RowBox[{fnpguid, [, RowBox[{[, package, ]}], ]}], ]}]}], }}]}], ]}]}]}], ]}]}]}], n, ]}], ,, RowBox[{{, RowBox[{package, ,, RowBox[{Length, [, fnpdir, ]}]}], }}]}], ]}], ;}], n, RowBox[{(*, RowBox[{ Add, , links, , to, , package, , tutorials, , and, , guides}], *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{SelectionMove, [, RowBox[{nb, ,, All, ,, Notebook}], ]}], ;, RowBox[{FrontEndExecute, [, RowBox[{ FrontEndToken, [, <SelectionCloseAllGroups>, ]}], ]}], ;}], [IndentingNewLine], RowBox[{ RowBox[{FrontEndExecute, [, RowBox[{FrontEndToken, [, <OpenCloseGroup>, ]}], ]}], ;}], [IndentingNewLine]}]}]], Input, CellChangeTimes->{3.411770874483*^9}] }, WindowSize->{607, 750}, WindowMargins->{{2, Automatic}, {44, Automatic}}, FrontEndVersion->6.0 for Microsoft Windows (32-bit) (June 19, 2007), StyleDefinitions->Default.nb ] === Subject: Lowest Common Multiple programming Hi All, I am trying to make a programming code to find the LCM between the following numbers. I DO NOT want to use Prime Factorization but wish to setup some kind of table multiplication process until required results are found. Here are the correct results shown using LCM function LCM[Rationalize[1.4137, 0], Rationalize[2.5, 0], 5, Rationalize[12.5, 0]] 353425 N[%/{Rationalize[1.4137, 0], Rationalize[2.5, 0], 5, Rationalize[12.5, 0]}] {250000., 141370., 70685., 28274.} Any help & advice gratefully received. === Subject: Re: Sphere through 4 points Hi Steve, by reduction of parameters and precomputing expressions you can save time. The following takes a list of quadruples of 3-vectors and returns a list of centers and radius: getCircles[v : {{_, _, _, _} ..}] := Module[{x1, x2, x3, y1, y2, y3, z1, z2, z3, v1, v2, v3}, subs := {x1 -> v1[[1]], x2 -> v2[[1]], x3 -> v3[[1]], y1 -> v1[[2]], y2 -> v2[[2]], y3 -> v3[[2]], z1 -> v1[[3]], z2 -> v2[[3]], z3 -> v3[[3]]}; ( {v1, v2, v3} = {#[[1]] - #[[4]], #[[2]] - #[[4]], #[[3]] - #[[4]]} ; x = (x3^2 (y2 z1 - y1 z2) + x2^2 (-y3 z1 + y1 z3) + y2^2 (-y3 z1 + y1 z3) + z2 (y3 (x1^2 + y1^2 - y1 y3 + z1 (z1 - z2)) + y1 z2 z3 - y1 z3^2) + y2 (y3^2 z1 - (x1^2 + y1^2 + z1^2) z3 + z1 z3^2))/(2 (x3 y2 z1 - x2 y3 z1 - x3 y1 z2 + x1 y3 z2 + x2 y1 z3 - x1 y2 z3)) /. subs; y = (x1 x3^2 z2 + x3 (y2^2 z1 - (x1^2 + y1^2 + z1^2) z2 + z1 z2^2) + x2^2 (x3 z1 - x1 z3) + x2 (-(x3^2 + y3^2) z1 + (x1^2 + y1^2 + z1^2) z3 - z1 z3^2) + x1 (y3^2 z2 - (y2^2 + z2^2) z3 + z2 z3^2))/(2 (x3 y2 z1 - x2 y3 z1 - x3 y1 z2 + x1 y3 z2 + x2 y1 z3 - x1 y2 z3)) /. subs; z = (x1^2 x3 y2 + x2^2 (-x3 y1 + x1 y3) + x3 (y1^2 y2 + y2 z1^2 - y1 (y2^2 + z2^2)) + x2 (x3^2 y1 - y3 (x1^2 + y1^2 - y1 y3 + z1^2) + y1 z3^2) - x1 (x3^2 y2 - y3 (y2^2 - y2 y3 + z2^2) + y2 z3^2))/(2 (x3 y2 z1 - x2 y3 z1 - x3 y1 z2 + x1 y3 z2 + x2 y1 z3 - x1 y2 z3)) /. subs; r = Sqrt[x^2 + y^2 + z^2]; {{x, y, z} + #[[4]], r} ) & /@ v ] here we compute 1000 circles: dat=RandomReal[{-1,1},{1000,4,3}]; Timing[getCircles @ dat; ] {1.188,Null} hope this helps, Daniel > Given 4 points in 3-space not lying in a plane, I want the > center and radius of the incident sphere. I know about the elegant > determinant solution (4 or 5 determinants, each 4x4, plus a few > arithmetic operations) and Im using that, but maybe someone has coded > a faster version. Steve Gray > === Subject: Re: Sphere through 4 points >> Given 4 points in 3-space not lying in a plane, I want the >>center and radius of the incident sphere. I know about the elegant >>determinant solution (4 or 5 determinants, each 4x4, plus a few >>arithmetic operations) and Im using that, but maybe someone has coded >>a faster version. >>Steve Gray > Not sure if this is faster, but could do: centerAndRadius[data_] := Module[ > {x, y, z, vars, rsq, coeffs, polys, lpolys, cen}, > vars = {x, y, z}; > polys = (vars.vars - rsq) /. > Thread[vars -> (vars - Transpose[data])]; > lpolys = Expand[Rest[polys] - First[polys]]; > coeffs = CoefficientArrays[lpolys, vars]; > cen = LinearSolve[Last[coeffs], First[coeffs]]; > {cen, Sqrt[rsq]} /. > First[Solve[(First[polys] /. Thread[vars -> cen]) == 0]] > ] In[147]:= SeedRandom[1111]; > data = RandomReal[{-5, 5}, {4, 3}]; > centerAndRadius[data] Out[149]= {{-2.25666, -13.9661, 7.0018}, 15.1774} Can do around 200+ per second, on my laptop. In[150]:= Timing[Do[centerAndRadius[data], {100}]] > Out[150]= {0.421, Null} Daniel Lichtblau > Wolfram Research It was pointed out to me that this code does not work correctly. Ther eason is I forgot to negate the constant terms, in effect moving them to the other side to make equations from linear polynomials. Here is the correct form. centerAndRadius[data_] := Module[{x, y, z, vars, rsq, coeffs, polys, lpolys, cen}, vars = {x, y, z}; polys = (vars.vars - rsq) /. Thread[vars -> (vars - Transpose[data])]; lpolys = Expand[Rest[polys] - First[polys]]; coeffs = CoefficientArrays[lpolys, vars]; cen = LinearSolve[Last[coeffs], -First[coeffs]]; {cen, Sqrt[rsq]} /. First[Solve[(First[polys] /. Thread[vars -> cen]) == 0]]] Check: In[85]:= SeedRandom[1111]; data = RandomReal[{-5, 5}, {4, 3}]; {cen, rad} = centerAndRadius[data] Out[87]= {{2.25666, 13.9661, -7.0018}, 17.9779} In[89]:= Map[Norm[# - cen] - rad &, data] Out[89]= {0., 0., 0., 0.} If raw speed is the issue, the variant below is faster. centerAndRadius2[data_] := Module[{x, y, z, x0, y0, z0, rsqr, coeffs, rules, polys, lpolys, cen}, rules = (Thread[{x, y, z} -> #1] &) /@ data; polys = x^2 - 2*x*x0 + y^2 - 2*y*y0 + z^2 - 2*z*z0 /. rules; lpolys = Rest[polys] - First[polys]; coeffs = Normal[CoefficientArrays[lpolys, {x0, y0, z0}]]; cen = LinearSolve[Last[coeffs], -First[coeffs]]; {cen, Norm[cen - First[data]]}] Daniel Lichtblau Wolfram Research === Subject: Re: Reduce in Ver 6 Hi Dana, Reduce uses results from earlier solutions to simplify expressions. You may prevent this by the option: Backsubstitution -> True hope this helps, Daniel > Hi. I was wondering if anyone knows of a more efficient way to do this. > This issue came up in ver 6.0 with these equations: equ = { > a + b + c == 3, > a^2 + b^2 + c^2 < 10, > a^3 + b^3 + c^3 == 15, > a^4 + b^4 + c^4 == 35 > } I use Reduce, but c is returned as a function of a & b. > What I would like is for c to replace a & b with the appropriate values. r = {ToRules[Reduce[equ, {a, b, c}]]} {{a -> 1, b -> 1 - Sqrt[2], c -> 3 - a - b}, > {a -> 1, b -> 1 + Sqrt[2], c -> 3 - a - b}, > {a -> 1 - Sqrt[2], b -> 1, c -> 3 - a - b}, > {a -> 1 - Sqrt[2], b -> 1 + Sqrt[2], c -> 3 - a - b}, > {a -> 1 + Sqrt[2], b -> 1, c -> 3 - a - b}, > {a -> 1 + Sqrt[2], b -> 1 - Sqrt[2], c -> 3 - a - b}} My workaround is rather tough, especially if this was much larger. convert = {a -> aa_, b -> bb_, c -> cc_} - {a -> aa, b -> bb, c -> 3 - aa - bb}; new = r /. convert {{a -> 1, b -> 1 - Sqrt[2], c -> 1 + Sqrt[2]}, > {a -> 1, b -> 1 + Sqrt[2], c -> 1 - Sqrt[2]}, > {a -> 1 - Sqrt[2], b -> 1, c -> 1 + Sqrt[2]}, Etc.. Any help is much appreciated. I hope Im not overlooking something obvious. Dana > ddelouis@gmail.com === Subject: Re: Reduce in Ver 6 >Hi. I was wondering if anyone knows of a more efficient way to do this. >This issue came up in ver 6.0 with these equations: equ = { >a + b + c == 3, >a^2 + b^2 + c^2 < 10, >a^3 + b^3 + c^3 == 15, >a^4 + b^4 + c^4 == 35 >} I use Reduce, but c is returned as a function of a & b. >What I would like is for c to replace a & b with the appropriate values. r = {ToRules[Reduce[equ, {a, b, c}]]} {{a -> 1, b -> 1 - Sqrt[2], c -> 3 - a - b}, > {a -> 1, b -> 1 + Sqrt[2], c -> 3 - a - b}, > {a -> 1 - Sqrt[2], b -> 1, c -> 3 - a - b}, > {a -> 1 - Sqrt[2], b -> 1 + Sqrt[2], c -> 3 - a - b}, > {a -> 1 + Sqrt[2], b -> 1, c -> 3 - a - b}, > {a -> 1 + Sqrt[2], b -> 1 - Sqrt[2], c -> 3 - a - b}} > > Use the Reduce option Backsubstitution->True. Carl Woll Wolfram Research >My workaround is rather tough, especially if this was much larger. convert = {a -> aa_, b -> bb_, c -> cc_} - {a -> aa, b -> bb, c -> 3 - aa - bb}; new = r /. convert {{a -> 1, b -> 1 - Sqrt[2], c -> 1 + Sqrt[2]}, > {a -> 1, b -> 1 + Sqrt[2], c -> 1 - Sqrt[2]}, > {a -> 1 - Sqrt[2], b -> 1, c -> 1 + Sqrt[2]}, Etc.. Any help is much appreciated. I hope Im not overlooking something obvious. Dana >ddelouis@gmail.com > === Subject: Re: Reduce in Ver 6 > Use the Backsubstitution -> True setting for Reduce[] Darn! Yep! Right there in help under Reduce. VerifySolutions option under Solve. I now understand my mistake. Cant believe Ive missed this all this time. equ = {a + b + c == 3, a^2 + b^2 + c^2 < 10, a^3 + b^3 + c^3 == 15, a^4 + b^4 + c^4 == 35}; sol = {ToRules[Reduce[equ, {a, b, c}, Backsubstitution -> True]]}; Simplify[a^5 + b^5 + c^5 /. sol] {83, 83, 83, 83, 83, 83} -- Dana DeLouis <snip> I use Reduce, but c is returned as a function of a & b. >> What I would like is for c to replace a & b with the appropriate values. >> r = {ToRules[Reduce[equ, {a, b, c}]]} >> {{a -> 1, b -> 1 - Sqrt[2], c -> 3 - a - b}, > Use the Backsubstitution -> True setting for Reduce[] Szabolcs === Subject: Re: Fitting experimental data Here is the way I usually do this for a particular example. I generally roll my own least-squares fit: points={{23400.,273.2},{6800.0,298.2},{2400.0,323.2}}; (*Plot the data points,but dont show the plot*) p1=ListPlot[points,PlotStyle->{Red,PointSize[0.025]}]; (*The function that I wish to fit*) f[B_,Ro_,x_]:=B/Log[x/Ro] (*The LSQ fit function.*) (*Note that you can plot this for a range of B and Ro values*) lsFit[B_,Ro_]:=Plus@@Apply[Abs[f[B,Ro,#1]-#2]^2&,points,1] (*Finally,fit the data by finding the minimum*) (* The output comes in two parts. The first is *) (* the sum of the squares; the second, the best fit parameters *) sol=FindMinimum[lsFit[B,Ro],{B,1},{Ro,1}] (* g[R] is the fitting function with the best fit parameters *) g[x_]=f[B,Ro,x]/.sol[[2]]; (*Plot the fit along with the original data points*) Plot[g[R],{R,1000,25000},PlotStyle->{Blue,AbsoluteThickness[2]}, Epilog->p1[[1]],Frame->True, FrameStyle->AbsoluteThickness[2], GridLines->Automatic, BaseStyle->{FontFamily->Arial,FontSize->12,FontWeight->Bold}, FrameLabel->{R,g(R)},PlotLabel->LSQ Demo ] Hope this helps, Kevin > I am trying to fit experimental data (a list of {x,y} points) with a > model that produces a similar list of points. It seems that FindMinimum > with a Levenberg Marquardt method makes the most sense; unfortunately, I > cant seem to get it to work. soln=FindMinimum[Sum[(xptData[[i,2]]-(simulatedData[xaxis,testInstFunc, > k1auto,a1initauto])[[i]])^2,{i,1,Length[xaxis]}],{{k1auto,0.04},{a1initauto,0 .9}}] In this example, xptData is the list of experimental data. simulatedData > returns just the y axis as a list (assuming the same x axis), and the > resulting list, as you might imagine, depends on k1auto and a1initauto. > However, this results in a number of errors, I think because it tries to > evaluate simulatedData for the general case rather than for specific > instances of k1auto and a1initauto. simulatedData requires the use of > ListConvolve, NDSolve, and a number of other functions that seem to > preclude a general solution rather than a specific solution. > Kevin Ausman > ausman@okstate.edu -- === Subject: Re: Fitting experimental data Hi Kevin, try to define simulatedData more spezifically, so that it does not evaluate with symbolic parameters. E.g: simulatedData[xaxis_List,testInstFunc,k1auto_?Numeric?,a1initauto_?NumericQ] hope this helps, Daniel > I am trying to fit experimental data (a list of {x,y} points) with a > model that produces a similar list of points. It seems that FindMinimum > with a Levenberg Marquardt method makes the most sense; unfortunately, I > cant seem to get it to work. soln=FindMinimum[Sum[(xptData[[i,2]]-(simulatedData[xaxis,testInstFunc, > k1auto,a1initauto])[[i]])^2,{i,1,Length[xaxis]}],{{k1auto,0.04},{a1initauto,0 .9}}] In this example, xptData is the list of experimental data. simulatedData > returns just the y axis as a list (assuming the same x axis), and the > resulting list, as you might imagine, depends on k1auto and a1initauto. > However, this results in a number of errors, I think because it tries to > evaluate simulatedData for the general case rather than for specific > instances of k1auto and a1initauto. simulatedData requires the use of > ListConvolve, NDSolve, and a number of other functions that seem to > preclude a general solution rather than a specific solution. > Kevin Ausman > ausman@okstate.edu === Subject: RE: Fitting experimental data particular problem. I had hoped to avoid going into the full messy problem, but I probably need to, so here we go. GENERAL GOAL: an integrated interactive kinetic fitting routine. GENERAL APPROACH: A module file that has a function which produces a panel with a number of dynamic tabs: 1) Defining the kinetic model: specify the number of time-dependent concentrations to follow (which determines both the number of differential rate equations and the number of initial concentrations to specify), the number of rate constants (which are simply constant parameters in the differential rate equations), and the rate equations themselves. 2) The data to fit: specify the experimental data to fit (which is in the form of a list of {x,y} points) and the instrument function (which is also a list of {x,y} points, and serves as a kernel for a ListConvolve step. General idea is to create a numerically-integrated simulation based on a set of parameters using the user-specified rate equations, convolve it with the instrument function, and then determine the goodness of fit by comparison with the experimental data). 3) The simulation parameters: specifies interactively the initial values for all of the variable parameters (showing a fit to the data at the same time), and determines which of them are variable and which are to be held constant. 4) A close-up of the fit, the residuals, and a button that says, Start automatic fit. WHAT CURRENTLY WORKS: The user interface works perfectly. All the values and the graphs update interactively, as does the numerical integration of the user-defined kinetic model followed by convolution with the instrument function. WHAT DOESNT WORK: The automatic fit. I have extracted the problem from the user-interface portion of the code to try to cut down on how much code must be waded through, though what remains is still pretty long. Lets start with the model itself: model[numRateConst_?NumericQ, rateConst_?(VectorQ[#, NumericQ] &), numInitConc_?NumericQ, ic_?(VectorQ[#, NumericQ] &), rateEq_, finalTime_?NumericQ, t_] := model[numRateConst, rateConst, numInitConc, ic, rateEq, finalTime, t] = Module[{systemOfEquations, speciesToSolveFor, rateReplacementRules = {ToExpression[k1] -> rateConst[[1]], ToExpression[k2] -> rateConst[[2]], ToExpression[k3] -> rateConst[[3]], ToExpression[k4] -> rateConst[[4]], ToExpression[k5] -> rateConst[[5]], ToExpression[k6] -> rateConst[[6]], ToExpression[k7] -> rateConst[[7]], ToExpression[k8] -> rateConst[[8]], ToExpression[k9] -> rateConst[[9]], ToExpression[k10] -> rateConst[[10]]}}, systemOfEquations = Table[ReleaseHold[rateEq][[i]], {i, 1, numInitConc}]~Join~ Table[ToExpression[a <> ToString[i] <> [0][Equal] <> ToString[ic[[i]]]], {i, 1, numInitConc}]; speciesToSolveFor = Table[ToExpression[a <> ToString[i]], {i, 1, numInitConc}]; First[NDSolve[systemOfEquations /. rateReplacementRules, speciesToSolveFor, {ToExpression[t], 0, finalTime}]] ] The approach may seem strange, but its the best way that Ive found to convert the use input of k1, k2, etc. for the rate constants into the internal array representation of k[[1]], etc. The following test code works for this function: numRateConst = 1; rateConst = {7000, 0, 0, 0, 0, 0, 0, 0, 0, 0}; numInitConc = 1; ic = {0.0025, 0, 0, 0, 0, 0, 0, 0, 0, 0}; rateEq = {a1[t] == -k1 a1[t], 0, 0, 0, 0, 0, 0, 0, 0, 0}; finalTime = 500 10^-6; rawsimulation = model[numRateConst, rateConst, numInitConc, ic, = rateEq, finalTime, t] Plot[(a1 /. rawsimulation)[t], {t, 0, finalTime}] The resulting list of replacement rules has a single time-dependent function, a1. The general case I am trying to solve, however, has the experimental signal as a linear combination of multiple time-dependent functions, a1, a2, etc. So, I use the following intermediate function: &), numInitConc_?NumericQ, ic_?(VectorQ[#, NumericQ] &), ec_?(VectorQ[#, NumericQ] &), rateEq_, finalTime_?NumericQ, numInitConc, ic, ec, rateEq, finalTime, t] = (Block[{integratedModel}, integratedModel = model[numRateConst, rateConst, numInitConc, ic, rateEq, finalTime, t]; Total[Table[(ec[[i]]*ToExpression[a <> ToString[i]][t]), {i, 1, numInitConc}]] /. integratedModel ]) The apparent weirdness of the ToExpression bit was the way I found to get around problems with enclosing this function in a module file (otherwise the a1[t] in my function would refer to the module domain, but the one entered in my user interface would refer to a global version). If someone has a better way around this problem, Id love to hear it. Regardless, however, the code above works, as the following test code demonstrates (reusing definitions from the first test code): ec = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; numInitConc, ic, ec, rateEq, finalTime, t] Plot[signalsimulation, {t, 0, finalTime}] The final step in generating true simulated data is to generate the simulation as a set of {x,y} pairs corresponding to the experimental x axis and run ListConvolve with the experimental instrument function. My following routine accomplishes this: simulateData[xptXAxis_, instfn_, xoffset_, mdl_, t_, sln_] := simulateData[xptXAxis, instfn, xoffset, mdl, t, sln] = (Block[{instFnX, instFnY, normalizedinstfn, xAxisStep, modelXAxis, offsetModelXAxis, signalFunction, rawModelYAxis}, instFnX = Transpose[instfn][[1]]; instFnY = Transpose[instfn][[2]]; normalizedinstfn = instFnY/Total[instFnY]; xAxisStep = xptXAxis[[2]] - xptXAxis[[1]]; modelXAxis = Join[Table[t, {t, xptXAxis[[1]] - xAxisStep (Length[normalizedinstfn] - 1), xptXAxis[[1]] - xAxisStep, xAxisStep}], xptXAxis]; offsetModelXAxis = modelXAxis - xoffset; signalFunction = mdl /. sln; rawModelYAxis = Table[Piecewise[{{0, offsetModelXAxis[[i]] < 0}, {signalFunction /. t -> offsetModelXAxis[[i]], offsetModelXAxis[[i]] >= 0}}], {i, 1, Length[offsetModelXAxis]}]; ListConvolve[Transpose[instfn][[2]], rawModelYAxis] ]) There are several steps here that may be confusing, but which I dont think you need to worry about. (a) I normalize the instrument function. (b) I prepend the x-axis with enough data points to ensure that the resulting Convolved model matches the experimental data x-axis. (c) I allow an offset to the x axis to account for signal delays. (d) My experimental data starts before time-zero, and the signal has a sudden onset at that time, so I define my raw Y axis simulation as a piecewise function. Again, regardless of these details, the function works, as this test code demonstrates: tspacing = 10^-6; testInstFunc = Table[{i, 0}, {i, -3 tspacing, -1 tspacing, tspacing}]~Join~ Table[{i, Exp[-i/tspacing]}, {i, 0, 20 tspacing, tspacing}]; ListPlot[testInstFunc, PlotRange -> Full] xptX = Table[i, {i, -50 tspacing, 500 tspacing, tspacing}]; fullSimulation = Transpose[{xptX, simulationY = simulateData[xptX, testInstFunc, rateEq, finalTime, t], t, {}]}]; ListLinePlot[fullSimulation] The last parameter in this function, sln, is there to allow the following alternate notation, which also works: rateConst2 = {kauto, 0, 0, 0, 0, 0, 0, 0, 0, 0}; ic2 = {icauto, 0, 0, 0, 0, 0, 0, 0, 0, 0}; fullSimulation2 = Transpose[{xptX, simulateData[xptX, testInstFunc, 0, = rateEq, finalTime, t], t, {kauto -> 7000, icauto -> 0.0025}]}]; ListLinePlot[fullSimulation2] Now we have built-up enough of the problem to try (and fail) at the automatic fit. First, lets generate some test experimental data (and show the sum of the squared residuals as well just for kicks): xptData = Transpose[{xptX, xptY = (simulationY + Table[RandomReal[NormalDistribution[0, 0.00002]], {i, 1, Length[simulationY]}])}]; Show[ListPlot[xptData], ListLinePlot[fullSimulation2, PlotStyle -> Red]] Sum[(simulationY[[i]] - xptY[[i]])^2, {i, 1, Length[xptY]}] An automatic fit, however, doesnt seem to work here: result = FindMinimum[ (sim = simulateData[xptX, testInstFunc, 0, ic2, ec, rateEq, finalTime, t], t, {kauto -> k1float, icauto -> ic1float}]; Sum[(xptY[[i]] - sim[[i]])^2, {i, 1, Length[xptY]}]), {{k1float, 6000}, {ic1float, 0.003}}, Method -> LevenbergMarquardt] requiring numerical values for the parameters to evaluate. For example, this also does not work: fullSimulation3 = Transpose[{xptX, simulateData[xptX, testInstFunc, 0, = rateEq, finalTime, t], t, {kauto -> ktmp, icauto -> ictmp}]}] /. {ktmp -> 7000, ictmp -> 0.0025}; Unfortunately, I dont see how to get around this problem, and none of my dozens of attempts have improved matters. Help? Kevin Ausman ------------------------- Prof. Kevin Ausman Oklahoma State University Department of Chemistry 342 Physical Science Stillwater, OK 74078 Email: ausman@okstate.edu Office: 405-744-4330 Fax: 405-744-6007 -------------------------- === Subject: Re: MaxFormatDepthExceeded On febr. 10, 11:22, David Bailey <dave@Remove_Thisdbailey.co.uk Any info about this? > What is the built in value? > Is its name $MaxFormatDepth? > How to increase it? > Janos Why not give us a bit of code that generates this problem. Often when you get a message that some Mathematica limit has been > exceeded, the code has gone into some sort of infinite loop, so > increasing the relevant limit is not the answer. BTW, the following command will give you all the symbols that contain > the word format: ?*Format* David Baileyhttp://www.dbaileyconsultancy.co.uk David, I am not really a newcomer :) 1. Try to enter ?*Format*, and wish you saw $MaxFormatDepth. 2. You may get it, if you type enough brackets, like this: If[If[... Please don tell me that I should solve the problem otherwise... Janos === Subject: Re: Troubles with HarmonicNumber, empty sums, and Zeta > In[27]:= N[Zeta[-1/2] - Zeta[-1/2, -2]] > Out[27]= -2.41421 [BTW, is there some reasonably direct way to simplify > Zeta[-1/2] - Zeta[-1/2, -2] to -1 - Sqrt[2] using Mathematica?] David W. Cantrell > It depends on the meaning of direct. But there certainly is a short way: RootApproximant[Zeta[-2^(-1)] - Zeta[-2^(-1), -2]] -1 - Sqrt[2] Andrzej Kozlowski === Subject: Troubles with HarmonicNumber, empty sums, and Zeta Some inconsistencies with HarmonicNumber, empty sums, and Zeta are mentioned. (Im using version 6.0.1 under Windows.) 1. Compare In[2]:= HarmonicNumber[z, 0] Out[2]= z which agrees with the sixth statement at <http://functions.wolfram.com/GammaBetaErf/HarmonicNumber2/03/01/01/>, with In[3]:= HarmonicNumber[-1, 0] Out[3]= 0 rather than -1. Clearly there is an inconsistency. As another example of this sort of inconsistency: In[4]:= HarmonicNumber[z, -2] Out[4]= z/6 + z^2/2 + z^3/3 In[5]:= % /. z -> -4 Out[5]= -14 In[6]:= HarmonicNumber[-4, -2] Out[6]= 0 It seems that, in the current implementation, HarmonicNumber[n, x] is always intended to be 0 when n is a nonpositive integer. This makes sense if one looks at the second primary definition at <http://functions.wolfram.com/GammaBetaErf/HarmonicNumber2/02/> and thinks of it as being valid for n any integer (rather than, as stated, any natural number). It would make sense then because, if n is a nonpositive integer, the sum would normally be understood to be empty, and hence have value 0, regardless of the summand. 2. Although I said that it seems that, in the current implementation, HarmonicNumber[n, x] is always _intended_ to be 0 when n is a nonpositive integer, I do know of two exceptions. a. When the second argument is 1, the result is ComplexInfinity. For example, In[9]:= HarmonicNumber[-2, 1] Out[9]= ComplexInfinity I suspect that is a bug. b. When the second argument is E (or Pi, etc.), we clearly have a bug: In[11]:= HarmonicNumber[-5, E] Out[11]= Zeta[E] - System`HarmonicNumberDump`ZetaClassical[E, -4] 3. Concerning empty sums themselves, note that In[16]:= Clear[x]; Sum[x, {i, 1, -4}] Out[16]= 0 Indeed, Sum[x, {i, 1, n}] yields 0 if n is any specific nonpositive integer, and that is as I think it should be. But In[18]:= Sum[x, {i, 1, n}] Out[18]= n x and obviously, if n is a negative integer (and x is nonzero), then we have an inconsistency because n x would not be 0. I really do not know how -- or even, if -- this inconsistency should be dealt with. One general possibility, but probably not a good suggestion, would be to have Sum[expr, {i, m, n}] return UnitStep[n - m]*(whatever the sum currently returns). 4. Finally, Ill note that the first primary definition given at the previous link, namely, HarmonicNumber[z, r] == Zeta[r] - Zeta[r, z + 1] does not always hold in Mathematica. For example, In[26]:= HarmonicNumber[-3, -1/2] Out[26]= 0 while In[27]:= N[Zeta[-1/2] - Zeta[-1/2, -2]] Out[27]= -2.41421 [BTW, is there some reasonably direct way to simplify Zeta[-1/2] - Zeta[-1/2, -2] to -1 - Sqrt[2] using Mathematica?] David W. Cantrell === Subject: Automatic Differentiation in Mathematica I was wondering if any of you know about packages in Mathematica implementing Automatic Differentiation of algorithms like ADOL-C in C++ or MAD in another system. marco Ing. Marco Gabiccini, PhD Assistant Professor of Applied Mechanics Dept. of Mechanical, Nuclear and Production Engineering University of Pisa Via Diotisalvi, 2, 56126 Pisa (PI) - Italy Phone: +39-050-836.676 E-mail: m.gabiccini@ing.unipi.it === Subject: Re: Re: Reduce in Ver 6 Another approach is to use ReplaceRepeated when using the rules. equ = {a + b + c == 3, a^2 + b^2 + c^2 < 10, a^3 + b^3 + c^3 == 15, a^4 + b^4 + c^4 == 35}; sol = {ToRules[Reduce[equ, {a, b, c}]]}; a^5 + b^5 + c^5 //. sol // Simplify {83,83,83,83,83,83} Bob Hanlon > Use the Backsubstitution -> True setting for Reduce[] Darn! Yep! Right there in help under Reduce. > VerifySolutions option under Solve. I now understand my mistake. Cant > believe Ive missed this all this time. equ = {a + b + c == 3, a^2 + b^2 + c^2 < 10, > a^3 + b^3 + c^3 == 15, a^4 + b^4 + c^4 == 35}; sol = {ToRules[Reduce[equ, {a, b, c}, > Backsubstitution -> True]]}; Simplify[a^5 + b^5 + c^5 /. sol] > {83, 83, 83, 83, 83, 83} -- > Dana DeLouis <snip >> I use Reduce, but c is returned as a function of a & b. >> What I would like is for c to replace a & b with the appropriate values. >> r = {ToRules[Reduce[equ, {a, b, c}]]} >> {{a -> 1, b -> 1 - Sqrt[2], c -> 3 - a - b}, > Use the Backsubstitution -> True setting for Reduce[] Szabolcs > === Subject: Re: FindMaximum query Restrict fun to numeric arguments Clear[fun]; fun[x_?NumericQ] := Module[{y, sol}, sol = FindRoot[Sqrt[y] == Abs[x], {y, 0, 0.001}]; (*AppendTo[list,sol];*) -y /. sol[[1]]] FindMaximum[fun[x], {x, 1, 1.001}] {0., {x -> -1.7585932710058097*^-16}} Bob Hanlon > Consider the following function: fun[x_] := > Module[ > {y, sol}, > sol = FindRoot[Sqrt[y] == Abs[x], {y, 0, 0.001}]; > (* AppendTo[list, sol]; *) > -y /. sol[[1]] > ] Then Plot[fun[x], {x, -2, 2}] works fine, but FindMaximum[fun[x], {x, 1, 1.001}] fails. If I uncomment the debug line in fun and execute list = {}; > FindMaximum[fun[x], {x, 1, 1.001}] Then list contains {FindRoot[Sqrt[y$21471] == Abs[x], {y$21471, 0, 0.001}]} > So, FindRoot fails because x is passed through unevaluated, I think. > I would appreciate any advice on how to get FindMaximum (or NMaximize) > to work in this case. Mathematic 6.0.1.0 x86 32 bit > Mac OS X 10.4.11 > E. Neely Atkinson > Department of Biostatistics > M. D. Anderson Cancer Center neely@pdq.net > === Subject: Re: Re: How should I start with Start the search with either of these forms of commands ?*String* Names[*String*] Bob Hanlon Mathematica book generator and posted it here - if you can, > I will add a link to it on my site, because that is all that > we seem to have for the foreseeable future! I think WRIs approach to documentation is a real mistake. > Newbies must find it almost impossible to get into the > software. Also, some of the new features of 6.0 - such as all > the new capabilities of Import and Export are almost buried > and unusable because of poor, vague, Microsoft-style documentation. David Bailey > http://www.dbaileyconsultancy.co.uk As a newbie I must say, that it is not so difficult to get into Mathemati= ca > 6. The free web seminars are great, I hope, that WRI is preparing the new > ones, as I have already attended most of the now offered. But what Im missing for my work is some structured list of functions. Fo= r > example when Im looking for lets say string manipulation functions, I s= tart > with writing word String and pressing F1 in notebook. Than I use See als= o, > More about or Tutorials sections of the help and after while of click= ing > I usualy find what I need. > But if I had such structured list of functions (may be printed on some bi= gger > format poster), I think this searching could be much faster. Jakub === Subject: Re: Table / TableForm Question Table[i*j, {i, 6}, {j, 7 - i}] // TableForm Bob Hanlon > Hi All, Simple question from the Homework section HW06.nb - Number 7. Use nested Table[] commands to create the following list display: TableForm[{{1, 2, 3, 4, 5, 6}, > {2, 4, 6, 8, 10}, {3, 6, 9, 12}, > {4, 8, 12}, {5, 10}, {6}}] > { > {1, 2, 3, 4, 5, 6}, > {2, 4, 6, 8, 10, }, > {3, 6, 9, 12, , }, > {4, 8, 12, , , }, > {5, 10, , , , }, > {6, , , , , } > } Here is what it should look like Displayed:- > 1 2 3 4 5 6 > 2 4 6 8 10 > 3 6 9 12 > 4 8 12 > 5 10 > 6 > Here is my attempt. Table[i*j, {i, 6}, {j, 6}] > {{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, > 10, 12}, {3, 6, 9, 12, 15, 18}, > {4, 8, 12, 16, 20, 24}, > {5, 10, 15, 20, 25, 30}, > {6, 12, 18, 24, 30, 36}} ... Im not quite there as you can see. > Any help & advice gratefully received. === Subject: Re: Getting the View I want from ListPlot3D and Show I created four 3D lists, and created four ListPlot3D objects(using > interpolation to get nice smooth surfaces), and then combine them with > Show. Each listplot is a difference color, so I can see very nicely > whats going on. When I use the option Viewpoint->Top in Show, I can > see which list has the highest value over the unit square. What I would lake is to just export that top view to an EPS file for > me to discuss in my paper. The problem is that there are a few > artifacts of the view that dont look so nice; Where some of the > surfaces cross there are peaks and valleys, so when viewed from the > top, the Show object bulges and distorts at the edges that have a bit > of slope. Since Ive used Viewpoint-Top, I had hoped there would be > nothing like that, so that all I would see is the color of the > different regions of the unit square, but apparently that doesnt give > me a LITERAL top view; its viewed from some point in 3D space some > distance from the object, so even viewing from the top doesnt fully > eliminate the third dimension. Is there some other way to either get a more perfect top view, Im not sure whether I complete understood what your problem is, but the > following might help. It is from the documentation of ViewPoint where > you can find additional information: Graphics3D[Cylinder[], ViewPoint -> {0, 0, Infinity}] hth, albert Heres the code in question, to clear things up a bit; Three = ListPlot3D[ThreeInformal, InterpolationOrder -> 2, PlotRange - > {0, 1}, PlotStyle -> Yellow]; Two = ListPlot3D[TwoInformal, InterpolationOrder -> 2, PlotRange -> {0, 1}, PlotStyle -> Blue]; One = ListPlot3D[OneInformal, InterpolationOrder -> 2, PlotRange -> {0, 1}, PlotStyle -> Red]; Zero = ListPlot3D[ZeroInformal, InterpolationOrder -> 2, PlotRange -> {0, 1}, PlotStyle -> Green]; Show[Three, Two, One, Zero, AxesLabel -> {a, b}, ViewPoint -> Top] ThreeInformal, TwoInformal, OneInformal, and ZeroInformal are lists of the form {{x1,y1,x1},...,{xn,yn,yn}}, that I construct earlier in the code. So Show creates a 3D object I can rotate, to see how the surfaces defined by those lists vary over [0,1]x[0,1]. If I view it from the top, then I can see which of those four objects has the highest value, by which color is visible, the others being underneath it, and therefore hidden. I could combine these lists into one list, and then generate the surface of the top view- just taking the envelope of the four surfaces, and then do a relief plot of that, but I really want to maintain the visual distinction of where each curve is the max-IE I still want to color those regions. I can get a top view with the Viewpoint option, but the third dimension is still there- I want to suppress it entirely, so that Im only seeing a 2D region, colored according to which of those surfaces is maximal. Dennis === Subject: Using Fourier and InverseFourier instead of Convolve OK, I must admit that I do not understand everything ListConvolve does, but I get the convolution I need when I do ListConvolve[list1, list2, {1, -1}, 0] In particular, the output has the appropriate length: Length[list1]+Length[list2]-1. Now, I would like to get the identical using Fourier and InverseFourier. Is this possible? What is the appropriate syntax? j === Subject: Re: Some interaction in Mathematica 6.0 is there a particular reason why you are only using an InputField? It makes (I feel) better user interface sense to use the InputField to type the filename and then a button to initiate the action. Hope this helps... --David > Hello! Just a little question. Heres some code: ----------- > matrix = Import[C: my_file.xls]; <- import tables > matrix = matrix[[1]] <- we need only the first one and we printing > this table > ----------- What I want to do is insert InputField where I would be able to type a > filename and two lines above will be evaluated automatically. I think there should be something like this: > ----------- > InputField[Dynamic[matrixFile], String]; Dynamic[ > =A0matrix = Import[matrixFile]; > =A0matrix = matrix[[1]] > ] > ----------- This works almost fine. Theres a feeling that the output (the one > with the table) re-counts continuously. Nothing changes but processor > is busy. Not good. I think that the problem is in the second line: matrix = matrix[[1]], > but I do not know exactly what actually causing the problem. Havent found anything in the documentation. Here is the similar example (at least I think its similar) which > works totally fine: > ----------- > x = 1; > y = 2; Dynamic[ > =A0j = {x + y, x + y}; > =A0j = j[[1]] > ] > ----------- That would be really great if anyone could say something about this > problem. Mike. === Subject: Re: IMS IMTEK mailing list Ask Oliver Ruebenkoenig <ruebenko@uni-freiburg.de>, one of the IMS gurus. Hes definitely fluent in English. Then please reply back to the group about what you learned... === Subject: Re: IMS IMTEK mailing list go to the web page of the IMS: http://www.imtek.uni-freiburg.de/simulation/mathematica/IMSweb/ follow the link to the mailing list, which should send you here: https://imtek.uni-freiburg.de/LISTS/ims/List.html at the lower left you will find a link to a mail addresses for different types of subscription. feed, digest, index. choose one. OR send an email to ims-feed@imtek.uni-freiburg.de with subject: Subscribe me! that should do the trick. Oliver > Does anyone know how to join the IMS mailing list? My German is very > rusty. Ive spent time poking around on their web site but cannot find > any way to join, nor for that matter the trustworthy existence of, an > IMS mailing list. There definitely is a mailing list archive, so its to > be expected a mailing list also. Perhaps it is best to simply post questions on this forum? > Skip Egley Oliver Ruebenkoenig, <ruebenko AT uni-freiburg.de> === Subject: PowerExpand in version 6 The ancient function PowerExpand, indispensable before the Assumptions mechanism was introduced in version 4 of Mathematica, became a bit of an embarrassment in later versions and there were even voices, I can remember, arguing that it ought to be deprecated. Instead, PowerExpand was modified in version 6 by making it possible to use the Assumptions mechanism with it and this giving this almost dead function a new lease of life. This is indeed very nice when it works, but unfortunately the implementation still leaves some things to be desired. The main example in the documentation is: PowerExpand[Sqrt[x*y], Assumptions -> True] E^(I*Pi*Floor[-(Arg[x]/(2*Pi)) + 1/2 - Arg[y]/(2*Pi)])* Sqrt[x]*Sqrt[y] which gives a general expansion that is valid for all x and y. But note that the normally equivalent form Assuming will not work: Assuming[True, PowerExpand[Sqrt[x*y]]] Sqrt[x]*Sqrt[y] In fact Assuming is simply ignored and the answer returned is the same as that given by PowerExpand without any assumptions. This is disappointing for those (like myself) who prefer to use Assuming to Assumptions -> , but may perhaps be a matter of deliberate design (why?). But the next problem is certainly a bug. First note that: PowerExpand[Sqrt[x*y], Assumptions -> x > 0] Sqrt[x]*Sqrt[y] which is quite correct but suppose we make an even stronger assumption: PowerExpand[Sqrt[x*y], Assumptions -> x > 0 && y > 0] Sqrt[x*y] We do not get the expansion we should obtain. Curiously we can get the correct expansion if we use a more complicated way of stating the same assumption, e.g. PowerExpand[Sqrt[x*y], Assumptions -> x > 0 && Arg[y] == 0] Sqrt[x]*Sqrt[y] or PowerExpand[Sqrt[x*y], Assumptions -> x > 0 && Re[y] > 0] Sqrt[x]*Sqrt[y] Andrzej Kozlowski === Subject: Re: convex FindMinimum for a large vector Hi Art, I presume youre using Version 6? It sounds like you know what youre doing, but perhaps havent come across the various options for FindMinimum? Paste the following into the Help>Documentation Center address field: tutorial/UnconstrainedOptimizationOverview which should bring up a jump-table of links, including the one pertaining to FindMinimum: Methods for Local Minimization Perhaps tweaking the L-BFGS step memory or switchng to the the ConjugateGradient method? Good luck! === Subject: Module and Manipulate Oddity When I use the Module function, I can combine the graphics with manipulate. Without module, I get an error saying the coordinates need to be in triplet or scaled form. Why does Module have any effect on this? Line 1: sh[a_, u_] := Module[{cube, sp1} , cube = Graphics3D[Cuboid[{u, a, u}], PlotRange -> 5]; sp1 = Graphics3D[Sphere[{u, a, u}], PlotRange -> 5]; Show[cube, sp1]] Line 2: Manipulate[sh[a, u], {a, 0, 2}, {u, 0, 2}] ****************************** And, without module: sh[a_, u_] := cube = Graphics3D[Cuboid[{u, a, u}], PlotRange -> 5]; sp1 = Graphics3D[Sphere[{u, a, u}], PlotRange -> 5]; Show[cube, sp1] Manipulate[sh[a, u], {a, 0, 2}, {u, 0, 2}] === Subject: Re: Re: A Use for Interpretation Whats Inert? Nothing in Documentation Center about it that I see! >> Very nice! Some other places where this might be employed are in laws >> of exponents or laws of logs. Or applying trig identities. Or Laplace >> transform. >> Ideally, this could be used not just by the teacher, but by the student >> who would demonstrate that she knows the rules by teaching them to the >> computer. Yet theres a catch to that: the Mathematica >> sophistication needed, what with ReplaceRepeated, RuleDelayed, HoldForm, >> ReleaseHold, and FreeQ. Not to mention the strange definition of the >> function, like integrate here, which must be defined in terms of itself. > Since Version 6 appeared and I first encountered Interpretation I found it > rather difficult to understand what use it might have. The examples in Help > seem almost bizarre. >> Here is one use where it works rather well. Teachers might often be > frustrated in demonstrating the behavior of basic function such as D, > Integrate or Limit because Mathematica automatically evaluates using its > built-in rules. With Interpretation we can define a pseudo routine that > displays as the real routine and then apply our own basic transformation > rules. Here is an example with a linear breakout of Integrate. >> integrate[integrand_, var_] := > Interpretation[HoldForm[Integrate[integrand, var]], > integrate[integrand, var]] >> We then define rules that breakout sums and constant factors. The rules even > display in a nice form. >> rule1 = integrate[a_ + b_, x_] -> integrate[a, x] + integrate[b, x] > rule2 = integrate[a_?(FreeQ[#, x] &) b_, x_] -> a integrate[b, x] >> Then we can demonstrate how these rules work, performing the actual > integration in the last step. >> integrate[5 a Sin[x] + y Cos[x] + x^2, x] > % //. rule1 > % //. rule2 > % /. Interpretation[a_, b_] :> ReleaseHold[a] >> I think there is a better way to do this. I use > Inert[Integrate]Sin[x],{x,0,Pi}] and use a MakeBoxes rule to display the > result as a grey-shaded integral. The advantage of this method is that > it is possible to edit the contents of the inert integral and re-input > the result. David Bailey > http://www.dbaileyconsultancy.co.uk > -- 3 545-1801 Amherst, MA 01003-9305 === Subject: Re: about scoping in modules >> in the next two modules I would like that the inner module uses a variable from the outer module. >> mfb[oneObj_] := Module[{ttmp = oneObj},AppendTo[ global2mfb, ttmp]] >> mfa[e_] := Module[{global2mfb = e, t = 3},mfb[t] ] >> mfa[{2,3}] gives a message that global2mfb is not a variable with a value, so it can not be changed. >> It means I do not understand the concept of module in Mathematica. My questions are: >> 1. why does it go wrong? >> 2. how can I realize what I want? >> with friendly greetings, >> P_ter > Well, despite its name, global2mfb is local to the Module in which it > appears - so using it elsewhere refers to a global variable of the same > name with no value - hence the diagnostic. This is the purpose of Module > - to stop one use of a variable clashing with another. Take the assignment global2mfb=e outside the list of local > initialisations, and I think you will get what you want. > almost, AppendTo needs a reference not an explicit List such as x={1,2} AppendTo[x,1] AppendTo[{1,2},3] can not work since: Attributes[ AppendTo] you could not access the result. Oliver Oliver Ruebenkoenig, <ruebenko AT uni-freiburg.de> === Subject: Maximize Command - Problem Hello guys I am trying to calculate the Max of a function using the Maximize command in the following way: In[2]:=Maximize[{fun, -Pi/2 < x < Pi/2 && -Pi/2 < y < Pi/2 && 0 < z < 2*Pi}, {x, y, z}] where fun is: In[1]:=4*(a^2 + (b^2 + c^2 + d^2)(Cos[x])^2*(Cos[y])^2*(Cos[z])^2 + (b*Cos[x]*Cos[y]*Cos[z] + Cos[x]*Sin[y] + d*Sin[x])^2); output=Maximize[4*(a^2 + (b^2 + c^2 + d^2)(Cos[x])^2*(Cos[y])^2*(Cos[z])^2 + (b*Cos[x]*Cos[y]*Cos[z] + Cos[x]*Sin[y] + d*Sin[x])^2),-Pi/2 < x < Pi/2 && -Pi/2 < y < Pi/2 && 0 < z < 2*Pi}, {x, y, z}]. I hope you can help me! === Subject: Gudermannian Function I want to evaluate numerically the Gudermannian fonction over a range of values but without any success so far: Table[{x, Gd [x]}, {x, 0, 1, 0.1}] will return me Gd[0], Gd[0.1] .. and so on As Gd may be an unknown function, I try what seems to me, a newcomer to Mathematica 5 - an equivalent mathematical expression: Table[{x, 2 ArcTan Exp [x] - Pi/2}, {x, 0, 1, 0.1}] but then only Exp[x] is numerically evaluated . Sigismond K. === Subject: Re: Constraint visualization > Hallo, I am brand new to Mathematica. I have acquired the program to assist > me in constraints/solution space visualization but the results I got > from my fiddling the past two weeks have been fairly disappointing. (I > must admit that Ive elarnt a lot of wonderful new things but I am > still unable to carry out my initial objective.) If I can find out how to color all the faces/edges of the following > regionplot it will help me a lot. RegionPlot3D[ > Or[And[And[And[Fm <= 120/(8 - y), 8 - y >= 0], > Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]]], > And[Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]], And[Fm <= 112/y, y > 0]]], > And[And[Fm <= 120/(8 - y), y < 0], > Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]]], > And[And[Fm <= 112/y, y > 8], > Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]]]], {x, -2.6, 2.6}, {y, -3, > 9.6}, {Fm, 0, 30}] Hi Neil, RegionPlot has a lot of Options to work with. You didnt outline the specific effects youre after, but theres a lot of machinery built in. Work through the list systematically and keep the parts you like. Its pretty ambitious for a beginner (or anyone for that matter), but you can get to the basics recovering and modifying the GraphicsComplex generated by RegionPlot3D. To get a look at the structure, simplify the picture a little using something like: g = RegionPlot3D[---your code here---, Mesh->None, PlotPoints->5, Axes->None], then look at the full structure with g // InputForm The Doc Center barely hints at the structure. Basically, the GC consists of a list of node positions, followed by lists of graphics primitives that reference the parts of the node list. AFAIK, this country is almost completely undocumented, but there are a couple of nifty and elegant idioms scattered around the Web and Groups for dissecting and modifying the form. You can extract the GC directly with graphicsComplex = g[[1]] Start modifying the GC by hand, displaying the result, (Graphics3D[graphicsComplex,Options])noting the result, and generating your own documentation. The procedure may reveal a lot about the inner workings of functions like RegionPlot3D, and those revelations may point you in the right direction for managing the presentation using the available Options. You can change Options and inspect the effects on the GC. If youre not careful though, it can take over your life. Hth, Fred Klingener === Subject: Re: Constraint visualization All the work is to convert a region specification into a specification for the various faces of the region. I did this plot using the Presentations package from my web site, but this could be done with only slightly more difficulty with regular Mathematica graphics. The following are the specified regions where I have use a >= on the maximum y value. regions = (Fm <= 120/(8 - y) && 8 - y >= 0 && ((Fm <= 69.6`/(2.4`+ 2 x) && x >= 0) || (Fm <= 69.6`/(2.4`- 2 x) && x <= 0)) && ((Fm <= 69.6`/(2.4`+ 2 x) && x >= 0) || (Fm <= 69.6`/(2.4`- 2 x) && x <= 0)) && Fm <= 112/y && y >= 0) || (Fm <= 120/(8 - y) && y <= 0 && ((Fm <= 69.6`/(2.4`+ 2 x) && x >= 0) || (Fm <= 69.6`/(2.4`- 2 x) && x <= 0))) || (Fm <= 112/y && y >= 8 && ((Fm <= 69.6`/(2.4`+ 2 x) && x >= 0) || (Fm <= 69.6`/(2.4`- 2 x) && x <= 0))); We add the desired x and y domains as extra conditions and then do a LogicalExpand to obtain 15 faces. There are 5 more faces that Mathematica misses that we will have to fill in. Reduce[regions [And] -2.6 <= x <= 2.6 [And] -3 <= y <= 9.6 [And] Fm >= 0, Fm] // Quiet; faces = % // LogicalExpand Length[%] The first few faces are points or side faces. We write a cooresponding graphics object for each face. Part[faces, 1] face[1] = {Black, AbsolutePointSize[5], Point[{0, 3.86207, 29}]}; Part[faces, 2] face[2] = ParametricDraw3D[{x, -3, Fm}, {x, -1.99, 1.99}, {Fm, 0, 10.9091}, BoundaryStyle -> Black, Mesh -> None]; Part[faces, 3] face[3] = ParametricDraw3D[{x, -3, Fm}, {x, 1.99, 2.6}, {Fm, 0, 174.`/( 6.`+ 5.` x)}, BoundaryStyle -> Black, Mesh -> None]; Part[faces, 4] face[4] = ParametricDraw3D[{x, -3, Fm}, {x, -2.6, -1.99}, {Fm, 0, -(174.`/(-6.` + 5.` x))}, BoundaryStyle -> Black, Mesh -> None]; Part[faces, 5] face[5] = ParametricDraw3D[{x, 3.86207, Fm}, {x, 0, 2.6}, {Fm, 0, 174.`/( 6.`+ 5.` x)}, BoundaryStyle -> Black, Mesh -> None]; Part[faces, 6] face[6] = ParametricDraw3D[{x, 3.86207, Fm}, {x, -2.6, 0}, {Fm, 0, -(174.`/(-6.` + 5.` x))}, BoundaryStyle -> Black, Mesh -> None]; The remaining faces are all top surfaces. We write a routine to extract t= he parametric parameters for the logic expression and draw the corresponding surface. MakeParametricDraw[andexpression_] := Module[{xmin, xmax, ymin, ymax, Fmfunction}, xmin = First@ Cases[andexpression, ((min_ < x) | (min_ <= x)) -> min, [Infinity]]; xmax = First@ Cases[andexpression, ((x < max_) | (x <= max_)) -> max, [Infinity]]; ymin = First@ Cases[andexpression, ((min_ < y) | (min_ <= y)) -> min, [Infinity]]; ymax = First@ Cases[andexpression, ((y < max_) | (y <= max_)) -> max, [Infinity]]; Fmfunction = First@Cases[ andexpression, ((Fm <= max_) | (Fm < max)) -> max, [Infinity]]; ParametricDraw3D @@ {{x, y, Fmfunction}, {y, ymin, ymax}, {x, xmin, xmax}, BoundaryStyle -> Black, Mesh -> None} ] Then we generate all the remaining Mathematica generated faces. Do[face[i] = MakeParametricDraw[Part[faces, i]], {i, 7, 15}]; We have to obtain the faces at y = 9.6, which Mathematica omitted. It is necessary to do another reduce for this. Reduce[regions [And] y == 9.6 [And] -2.6 <= x <= 2.6, Fm] // Quiet face[16] = ParametricDraw3D[{x, 9.6, Fm}, {x, -1.78286, 1.78286}, {Fm, 0, 11.6667}, BoundaryStyle -> Black, Mesh -> None]; face[17] = ParametricDraw3D[{x, 9.6, Fm}, {x, -2.6, -1.78286}, {Fm, 0, -(174.`/(-6.` + 5.` x))}, BoundaryStyle -> Black, Mesh -> None]; face[18] = ParametricDraw3D[{x, 9.6, Fm}, {x, 1.78286, 2.6}, {Fm, 0, 174.`/( 6.`+ 5.` x)}, BoundaryStyle -> Black, Mesh -> None]; And finally we put in the two remaining sides. 174.`/(6.`+ 5.` x) /. x -> 2.6 9.15789 face[19] = ParametricDraw3D[{-2.6, y, Fm}, {y, -3, 9.6}, {Fm, 0, 9.15789}, BoundaryStyle -> Black, Mesh -> None]; face[20] = ParametricDraw3D[{2.6, y, Fm}, {y, -3, 9.6}, {Fm, 0, 9.15789}, BoundaryStyle -> Black, Mesh -> None]; Finally we draw all the faces. All the faces are smooth surfaces, smoothly joined, and the plot is much cleaner that the RegionPlot3D. I made all the faces the same color, but transparent. Different colors could be specified for each face but I dont know what the best scheme would be. Draw3DItems[ {Opacity[.8], Orange, face[1], face[2], face[3], face[4], face[5], face[6], face[7], face[8], face[9], face[10], face[11], face[12], face[13], face[14], face[15], face[16], face[17], face[18], face[19], face[20] }, NeutralLighting[.0, .5, .2, 50 B0], Axes -> True, AxesLabel -> {x, y, Fm}, NiceRotation, PlotRange -> {{-2.7, 2.7}, {-3.1, 9.7}, {0, All}}, PlotRangePadding -> {.1, .2, .5}, ViewPoint -> {2.45377, -1.7663, 1.5196}, BoxRatios -> {1, 1, 1}, ImageSize -> 500] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > Hallo, I am brand new to Mathematica. I have acquired the program to assist > me in constraints/solution space visualization but the results I got > from my fiddling the past two weeks have been fairly disappointing. (I > must admit that Ive elarnt a lot of wonderful new things but I am > still unable to carry out my initial objective.) If I can find out how to color all the faces/edges of the following > regionplot it will help me a lot. RegionPlot3D[ > Or[And[And[And[Fm <= 120/(8 - y), 8 - y >= 0], > Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]]], > And[Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]], And[Fm <= 112/y, y > 0]= ]], > And[And[Fm <= 120/(8 - y), y < 0], > Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]]], > And[And[Fm <= 112/y, y > 8], > Or[And[Fm <= 69.6/(2.4 + 2 x), x >= 0], > And[Fm <= 69.6/(2.4 - 2 x), x <= 0]]]], {x, -2.6, 2.6}, {y, -3, > 9.6}, {Fm, 0, 30}] Neil Jacobs > === Subject: Re: Extracting the value from Solve > Hola Jens: c) we have answered this several million times. - (I replied directly in Given, that this question is really so frequent: > Couldnt it be possible that the manual (THE BOOK) is not quite as > explicit as it ought to be on this particular topic? Actually this usage pattern is illustrated on the doc page of Solve[] ... Its also among very first examples in the Mathematica book (or the corresponding tutorial in v6) ... I dont think that this could be made any more prominent in the documentation. > (I made Lea Rebanks experience with MATHEMATICA 2.x back in abt. 1992 - > _after_ having read the manual cover to cover.) (Lea Reabanks intention/objective was to obtain the number without ANY > parentheses.) === Subject: Re: Re: Assuming >>[Message also posted to: comp.soft-sys.math.mathematica] >>[...] I intersperse two comments, based on two posts to this thread. > Note also one more thing. Suppose we consider a general rational > function p[x]/q[x], (or even a rational function in several > variables). Should Mathematica be then required always to try to find > if p[x] and q[x] do not have common roots in some algebraic (or even > transcendental inthe case of several variables) extension of the > rationals? This is far from a trivial problem? [...] > Andrzej Kozlowski The only removable singularities, in this context, are in fact from exact divisors. So polynomial gcd extraction (used in, say, Together[]) suffices to remove them. Other cases where numerator and denominator simultaneously vanish will give points of indeterminacy. These are not removable. Im not sure in what way transcendentals snuck in here. If the polynomials have common roots, they are describable as an algebraic set. In particular, isolated common roots will be algebraic numbers. >>[...] But I do know of a case where >>Mathematica goes even further, removing a singularity at which the >>function >>is defined as a number: >>In[17]:= FullSimplify[UnitStep[-x^2]] >>Out[17]= 0 >>despite the fact that correctly >>In[18]:= UnitStep[-x^2] /. x -> 0 >>Out[18]= 1 >>Perhaps the simplification above is considered a bug, perhaps not. >>David A feature, really. That is, its wrong, but FullSimplify can make mistakes on measure zero sets. We do not generally regard this phenomenon as a bug, though we reconsider on case by case basis. Daniel Lichtblau Wolfram Research === Subject: Re: Using Mathematica figures in MS Word documents Using Mathematica Im able to generate lovely graphs and figures. > However, Im almost always disappointed about the quality when I copy > them to Word documents (and I really, really need them in Word; > Mathematica as a wordprocessor is not an option in my case). Copying as WMF (windows meta file) will result in most figures (except > the most simple ones with straight lines) to look ugly. Smooth lines > will be chopped into many wiggly line segments etc. Ive covered the > font problem by having everybody that uses my docs downloading the > Mathematica fonts. Copying as bitmap is also not really an option. On screen its > acceptable, but printed itll look ugly. The only thing that seems to work is to export the graphics as EPS > with a bitmap preview and including this in Word. This yields good > output on the printer, and a somewhat less good (and less accurate) > preview on screen causing my textprocessing department to bug me with > questions about figure quality. Apart from that, its a very clumsy > process, which also increases file size unnecessarily. At least Id > like to have this as a menu option (Copy as EPS with preview). Im > not sure whether a corresponding paste would work in Word, though. I use lots of programs that are able to embed their graphics in word > as an OLE object (Statistica,Excel,Flowcharter). This seems to work > great as far as quality is concerned. Wouldnt this be an option for > Mathematica? Any thoughts or solutions on this? When forced to use MS Word, which is most of the time for my > professional work, I resort to exporting to a bitmap format. PNG works > well for plots with simple colors because it compresses pretty well. > Otherwise, consider JPEG or TIFF. I agree that WMF almost never > produces acceptable output. I really dont understand how people in > technical professions ever bought into standardizing on MS Word. If > your textprocessing department will accept pdf, you can do much better > with LaTeX, and use Postscript formats for your graphics. -- > Dan Looking at Steve Lutrells comments reminds me that you want to set the bitmap resolution to something greater than 150 dpi for acceptable print resolution. This is an export option as in Export[test.png,Plot[Sin[x],{x,0,10},ImageResolution->150] The higher the resolution, the bigger your files, so use it judiciously. 150 is good for inkjet printer quality, 300 for laser printers on standard paper, 600 for photo printers. -- Dan === Subject: Re: The size of a 3D plot > On Mar 16, 3:40 am, Mariano Su=E1rez-Alvarez Hi all, is there a way to have a 3D graphic be sized so that it fits tightly > in its bounding box? I seem to only be able to have it sized so that > the *box* circumscribing it fits in the bounding box, as in Graphics[{Sphere[]}] -- m Heres some code that may do what you need, assuming you have a 3D > graphic with white background: DynamicModule[ > {update, gr, gr2, k = 4, > w = 360, h = 360, xmarg = 0, ymarg = 0, xd = 0, yd = 0, > vp = {1.3, -2.4, 2.}, va = Automatic, vv = {0, 0, 1}}, > update[] := > (gr = Rasterize[ > Graphics3D[Cylinder[], Boxed -> False, ImageSize -> w, > ViewAngle -> va, ViewPoint -> vp, ViewVertical -> vv], > Data, ImageResolution -> 72/k]; > {w, h} = k Dimensions[gr][[{2, 1}]]; > gr2 = Split[gr, Min[##] == 255 &]; > {ymarg, yd} = > k {# + #2 - 2, (#2 - #)/2} & @@ Length /@ gr2[[{1, -1}]]; > gr2 = Split[Transpose@gr, Min[##] == 255 &]; > {xmarg, xd} = > k {# + #2 - 2, (#2 - #)/2} & @@ Length /@ gr2[[{-1, 1}]] > ); > update[]; > EventHandler[ > Graphics[Inset[ > Graphics3D[Cylinder[], Boxed -> False, ImageSize -> w, > RotationAction -> Clip, > ViewAngle -> Dynamic[va], > ViewPoint -> Dynamic[vp], > ViewVertical -> Dynamic[vv]], > {0, 0}, > Dynamic@Offset[{xd, yd}, ImageScaled@{.5, .5}], > Dynamic@Offset@{w, h}, > ContentSelectable -> True], > ImageSize -> Dynamic[{w - xmarg, h - ymarg}, > (w = #[[1]] + xmarg; update[]) &], > ContentSelectable -> True] // > Framed[#, FrameMargins -> 0] &, > {MouseUp :> update[]}] > ] Maxim Rytin > m...@inbox.ru Ah. Very smart ;-) I really cant believe it is that hard and manual to remove the huge margins in Graphics3D[{Sphere[]}, Boxed->False] They take up a good 60 percent of the area! -- m === Subject: Fast way to select those elements from a list that are in another Two lists of integers: {a, b} = Table[RandomInteger[10000, 1000], {2}]; Which elements from a are in b? Select[a, MemberQ[b, #] &]; // Timing >> {0.351, Null} It takes about 0.351 seconds (on my slow laptop). Specialised functions for related tasks, such as Intersection[a, b], are much faster: Intersection[a, b]; // Timing >> {0., Null} Using Intersection, heres a somewhat faster way to select those elements from a that are in b: With[ {c = Intersection[a, b]}, Select[a, MemberQ[c, #] &] ]; // Timing >> {0.09, Null} Is there a better, faster way to do this? === Subject: Re: Fast way to select those elements from a list that are in another To clarify: the list I want to construct is those elements from a that are members of b: Select[a, MemberQ[b, #] &] This is (I think!) the same as With[ {c = Intersection[a, b]}, Select[a, MemberQ[c, #] &] ] but the latter is faster. Two lists of integers: {a, b} = Table[RandomInteger[10000, 1000], {2}]; Which elements from a are in b? Select[a, MemberQ[b, #] &]; // Timing > {0.351, Null} It takes about 0.351 seconds (on my slow laptop). Specialised > functions for related tasks, such as Intersection[a, b], are much > faster: Intersection[a, b]; // Timing > {0., Null} Using Intersection, heres a somewhat faster way to select those > elements from a that are in b: With[ > {c = Intersection[a, b]}, > Select[a, MemberQ[c, #] &] > ]; // Timing > {0.09, Null} Is there a better, faster way to do this? > Hi Andrew, You did not formulate the problem precisely. There are two differences > between c and d = Select[a, MemberQ[c, #] &. One is that c is sorted, > while d is not, and the other is that duplicates are removed from c. > Which of these two are important? If only one of the two is important then I can come up with much faster > solutions, but if *both* are important then the problem becomes more > difficult. > === Subject: Re: Fast way to select those elements from a list that are in another IMO the main problem is that Mathematica does not have a real associative array and/or set datastructure. What we really needed here was a set: With[{c = SetDatastructure[Intersection[a,b]]}, Select[a, # is an element of c &] ] But a real set is not available, so I had to resort to this inverse solution: instead of selecting those elements that are in c, remove those that are not in c. Associative arrays and sets can be emulated in several ways in Mathematica but none of them provide all features of the associative array of other languages: test for membership, add members one by one, add a batch of members, remove members one by one, get a list (or set) of keys, and get a list of values. One can use either a dispatch table, or associate downvalues with a symbol, but neither of these two approaches allows for doing everything I listed above in an easy way. The solution using downvalues would have been Timing[ unsortedIntersection4 = Module[{aa}, (aa[#] = 1) & /@ Intersection[a, b]; Select[a, ValueQ[aa[#]] &] ]; ] but this is not always as fast as the unsortedIntersection3 solution because elements are added one-by-one instead of as a batch. What do other MathGroup members think about this? Have you ever felt the need for an associative array (or set) data structure? Szabolcs === Subject: Re: Fast way to select those elements from a list that are in another >> Two lists of integers: >> {a, b} = Table[RandomInteger[10000, 1000], {2}]; >> Which elements from a are in b? >> Select[a, MemberQ[b, #] &]; // Timing >> {0.351, Null} >> It takes about 0.351 seconds (on my slow laptop). Specialised >> functions for related tasks, such as Intersection[a, b], are much >> faster: >> Intersection[a, b]; // Timing >> {0., Null} >> Using Intersection, heres a somewhat faster way to select those >> elements from a that are in b: >> With[ >> {c = Intersection[a, b]}, >> Select[a, MemberQ[c, #] &] >> ]; // Timing >> {0.09, Null} >> Is there a better, faster way to do this? Hi Andrew, You did not formulate the problem precisely. There are two differences > between c and d = Select[a, MemberQ[c, #] &. One is that c is sorted, > while d is not, and the other is that duplicates are removed from c. > Which of these two are important? If only one of the two is important then I can come up with much faster > solutions, but if *both* are important then the problem becomes more > difficult. > Actually I posted too soon. There is a fast way to achieve this, though whether it is really fast or not depends on the p and q parameters below: In[1]:= {p, q} = {10000, 6000}; In[2]:= {a, b} = Table[RandomInteger[p, q], {2}]; In[3]:= Timing[unsortedIntersection1 = Select[a, MemberQ[b, #] &];] Out[3]= {6.391, Null} In[4]:= Timing[ unsortedIntersection2 = With[{c = Intersection[a, b]}, Select[a, MemberQ[c, #] &]]; ] Out[4]= {2.109, Null} In[5]:= Timing[ unsortedIntersection3 = a /. Dispatch[# -> Sequence[] & /@ Complement[a, b]];] Out[5]= {0.015, Null} unsortedIntersection3 Out[6]= True Szabolcs === Subject: Re: Fast way to select those elements from a list that are in another > Two lists of integers: {a, b} = Table[RandomInteger[10000, 1000], {2}]; Which elements from a are in b? Select[a, MemberQ[b, #] &]; // Timing > {0.351, Null} It takes about 0.351 seconds (on my slow laptop). Specialised > functions for related tasks, such as Intersection[a, b], are much > faster: Intersection[a, b]; // Timing > {0., Null} Using Intersection, heres a somewhat faster way to select those > elements from a that are in b: With[ > {c = Intersection[a, b]}, > Select[a, MemberQ[c, #] &] > ]; // Timing > {0.09, Null} Is there a better, faster way to do this? > Hi Andrew, You did not formulate the problem precisely. There are two differences between c and d = Select[a, MemberQ[c, #] &. One is that c is sorted, while d is not, and the other is that duplicates are removed from c. Which of these two are important? If only one of the two is important then I can come up with much faster solutions, but if *both* are important then the problem becomes more difficult. === Subject: Re: Creating a function that is a derivative of another function?? In your case, dW[0] is trying to compute (more or less) D[a*t + b*t^2 + c*t^3 /. t->0, t /. t->0] == D[0, 0], which naturally gives an error message, since zero is not a valid variable. Heres one way to do what you want: In[1]:= W[t_] := a*t + b*t^2 + c*t^3 In[2]:= dW[t0_] := Derivative[1][W][t0] In[3]:= dW[t] //InputForm Out[3]//InputForm= a + 2*b*t + 3*c*t^2 In[4]:= dW[0] Out[4]= a Bhuvanesh, Wolfram Research === Subject: Re: Exceptions Style Problem This was covered recently on this list. I used Red for better contrast y1 = ParametricPlot[folium[t], {t, -30, 30}, PlotRange -> {{-3, 3}, {-3, 3}}, ExclusionsStyle -> Red, Exclusions -> t == -1] Bob Hanlon > I generated a plot using this code: folium[t_]:={3t/(1+t^3),3t^2/(1+t^3)}; y1=ParametricPlot[folium[t],{t,-30,30},PlotRange->{{-3,3},{-3,3}}] It was a nice folium with the asymptote displayed. Next I plotted y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3}, > {-3,3}},Exclusions->-1 ] As expected this gave me the folium without the asymptote displayed. Finally, I plotted y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3},{-3,3}} > ,ExclusionsStyle->Blue,Exclusions->-1] I expected to see the asymptote displayed in Blue, since the > documentation for ExclusionsStyle says, ExclusionsStyle is an option > to plotting functions that specifies how to render subregions excluded > according to Exclusions. But, instead I get the folium without the asymptote displayed. Can anyone help me understand what I am missing? > Gary Boswell > === Subject: Re: Creating a function that is a derivative of another W[t_] := a*t + b*t^2 + c*t^3 Use Set rather than SetDelayed dW[t_] = D[W[t], t]; dW[0] a Or just use W[0] a Bob Hanlon > I have a function: W[t_] := a*t + b*t^2 + c*t^3 I want the derivative of this funtion wrt t as another function. The following seems like it works: dW[t_] := D[W[t], t] dW[t] > a + 2 b t + 3 c t^2 But something isnt right?? dW[0] > General::ivar: 0 is not a valid variable. > (output line has a partial derivative symbol, subscript 0 followed by a 0) The description of the General::ivar error isnt help either?? Any idea whats going on here?? How can I assign the derivative of a function as another funtion?! Eric > === Subject: floating point issue Hi everyone, I wonder if I can get some opinions on the best way to deal with this precision issue I am having. I define the vectors: K = {111.5, 10.5, 1.5} g={-0.7071068, 0., -0.7071068} And I need this: K.Cross[K, g] to be 0 in accordance with a vector identity. The answer comes out to around 1.3 x 10^(-13), which is certainly close to 0 but not close enough for what Im doing. Ive tried various things like writing out the cross product explicitly without using the functions but the result is the same. And using N in various places doesnt seem to help either. Whats the standard solution for this kind of thing? Chris === Subject: Re: floating point issue Chris > K = Rationalize[{111.5, 10.5, 1.5}, 0]; > g = Rationalize[{-0.7071068, 0., -0.7071068}, 0]; K.Cross[K, g] 0 K = {111.5`25, 10.5`25, 1.5`25}; > g = {-0.7071068`25, 0.`25, -0.7071068`25}; Chop[K.Cross[K, g], 10^-18] 0 > Bob Hanlon >> Hi everyone, >> I wonder if I can get some opinions on the best way to deal with this >> precision issue I am having. I define the vectors: >> K = {111.5, 10.5, 1.5} >> g={-0.7071068, 0., -0.7071068} >> And I need this: >> K.Cross[K, g] >> to be 0 in accordance with a vector identity. The answer comes out to >> around 1.3 x 10^(-13), which is certainly close to 0 but not close >> enough for what Im doing. Ive tried various things like writing out >> the cross product explicitly without using the functions but the result >> is the same. And using N in various places doesnt seem to help either. >> Whats the standard solution for this kind of thing? >> Chris >> === Subject: Re: floating point issue > Hi everyone, I wonder if I can get some opinions on the best way to deal with this > precision issue I am having. I define the vectors: K = {111.5, 10.5, 1.5} > g={-0.7071068, 0., -0.7071068} And I need this: K.Cross[K, g] to be 0 in accordance with a vector identity. The answer comes out to > around 1.3 x 10^(-13), which is certainly close to 0 but not close > enough for what Im doing. Ive tried various things like writing out > the cross product explicitly without using the functions but the > result > is the same. And using N in various places doesnt seem to help > either. > Whats the standard solution for this kind of thing? Chop The larger issue is K and g dont have enough precision to satisfy your identity, but g looks like it came from some trigonometric identities: g = {Cos[3 Pi/4],0,Cos[3 Pi/4]} and Ks entries can be expressed as rational numbers: K = {223/2,21/2,3/2} So thats your other option, dont take floating point approximations to the entries in K and g. In[215]:= {223/2,21/2,3/2}.Cross[{223/2,21/2,3/2},{Cos[3 Pi/4],0,Cos [3 Pi/4]}] Out[215]= 0 Ssezi === Subject: Re: floating point issue > Hi everyone, I wonder if I can get some opinions on the best way to deal with this > precision issue I am having. I define the vectors: K = {111.5, 10.5, 1.5} > g={-0.7071068, 0., -0.7071068} And I need this: K.Cross[K, g] to be 0 in accordance with a vector identity. The answer comes out to > around 1.3 x 10^(-13), which is certainly close to 0 but not close > enough for what Im doing. Ive tried various things like writing out > the cross product explicitly without using the functions but the result > is the same. And using N in various places doesnt seem to help either. > Whats the standard solution for this kind of thing? I cant reproduce the problem with versions 5.2 or 6. But you could consider using exact numbers or symbols instead of machine precision numbers. Also, avoid using identifiers starting with capital letters to prevent collisions with built-in names. K is a built-in symbol. === Subject: Re: floating point issue Its 0 for me (WinXP 64-bit, Mathematica 6.0.2). Antti > Hi everyone, I wonder if I can get some opinions on the best way to deal with this > precision issue I am having. I define the vectors: K = {111.5, 10.5, 1.5} > g={-0.7071068, 0., -0.7071068} And I need this: K.Cross[K, g] to be 0 in accordance with a vector identity. The answer comes out to > around 1.3 x 10^(-13), which is certainly close to 0 but not close > enough for what Im doing. Ive tried various things like writing out > the cross product explicitly without using the functions but the result > is the same. And using N in various places doesnt seem to help either. > Whats the standard solution for this kind of thing? Chris > === Subject: Re: Fast evaluation of modified dot product > I have (below) a vector x and matrix y and would like to compute z > efficiently: {n, m, b} = {10000, 100, 10}; (* n >> m > b *) > x = RandomReal[{-1.,1.}, n - b +1] > y = RandomChoice[{-1,1}, {n, m}]; w = Partition[y, b, 1]; > z = Dot[x, w]; I have to compute z for many different x with w fixed. For large n, w > becomes prohibitively big. Doing the below is much slower but doesnt require large memory > allocation: z2 = Fold[(#1 + x[[#2]] y[[#2;;#2+b-1]]) &, 0., Range[Length[x]] ]; I was wondering if there is a good way to compute z that doesnt > require a lot of memory. Art. Can be done with ListCorrelate. Transpose[Map[ListCorrelate[x, #] &, Transpose[y]]] Compared to your large list dot product approach, the memory hoofprint will be negligeable. Also it is nearly 10x faster. Daniel Lichtblau Wolfram Research === Subject: Re: Fast evaluation of modified dot product >I have (below) a vector x and matrix y and would like to compute z >efficiently: {n, m, b} = {10000, 100, 10}; (* n >> m > b *) >x = RandomReal[{-1.,1.}, n - b +1] >y = RandomChoice[{-1,1}, {n, m}]; w = Partition[y, b, 1]; >z = Dot[x, w]; I have to compute z for many different x with w fixed. For large n, w >becomes prohibitively big. Doing the below is much slower but doesnt require large memory >allocation: z2 = Fold[(#1 + x[[#2]] y[[#2;;#2+b-1]]) &, 0., Range[Length[x]] ]; > > This is slow because y is not packed. If you use: y = Developer`ToPackedArray@RandomChoice[{-1,1}, {n,m}]; and then run z2, it will be a bit faster than your Dot approach. >I was wondering if there is a good way to compute z that doesnt >require a lot of memory. Art. > > If speed is a major concern, and you dont mind a bit more memory usage, then ListCorrelate might be a good option: In[1]:= MemoryInUse[] MaxMemoryUsed[] Out[1]= 5850248 Out[2]= 7176816 Your x, y modified to pack y: In[3]:= {n, m, b} = {10000, 100, 5};(*n>>m>b*) x = RandomReal[{-1., 1.}, n - b + 1]; y = Developer`ToPackedArray@RandomChoice[{-1, 1}, {n, m}]; In[5]:= MemoryInUse[] MaxMemoryUsed[] Out[5]= 10861576 Out[6]= 19951840 Using ListCorrelate: In[7]:= z3 = Transpose@ListCorrelate[{x}, Transpose@y]; // Timing Out[7]= {0.031,Null} In[8]:= MemoryInUse[] MaxMemoryUsed[] Out[8]= 11210072 Out[9]= 23306376 An increase of a bit more than 3 MB in max memory used. The results arent identical, because of the vagaries of machine arithmetic, but z3 runs about 15 times faster on my machine. Carl Woll Wolfram Research === Subject: Re: V.6.0.2 gripes... It happens on machines that are still running Norton, though, > and WRI tech support insists it has nothing to do with NOD32. > I would try the experiment anyway - virus checkers can be very intrusive. Since you are seeing it on a variety of machines, and others such as myself have never seen this problem, it almost has to be related to some software that you have running on your machines. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: finding positions of elements in a list Hi. Having a few problems here with what I think should be a simple operation. I have a list as shown: mylist={{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107},...} Its a list of {x,y} co-ordinates of some data points Im analysing. I want to create a new list which contains only those data points whose y co-ordinate is greater than 80 ie. mylist[[n,2]]>80. Problem is, I cant work out how to use Select to do this when each element in the list has an x and a y co-ordinate. If I split the list into x and y co-ordinates and searched for those y values greater than 80, I would have a list of those y-values but would not know the corresponding x-values. I also tried Position but it wasnt clear to me if a pattern can be used for this. === Subject: Re: finding positions of elements in a list > Hi. Having a few problems here with what I think should be a simple operation. I have a list as shown: mylist={{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107},...} Its a list of {x,y} co-ordinates of some data points Im analysing. I want to create a new list which contains only those data points whose y co-ordinate is greater than 80 ie. mylist[[n,2]]>80. Problem is, I cant work out how to use Select to do this when each element in the list has an x and a y co-ordinate. If I split the list into x and y co-ordinates and searched for those y values greater than 80, I would have a list of those y-values but would not know the corresponding x-values. I also tried Position but it wasnt clear to me if a pattern can be used for this. Two possibilties: Select[mylist, #[[2]] > 80 &] Cases[mylist, {x_, y_} /; y > 80] === Subject: Re: Help with NMinimize of NIntegrate function The definition of the function EAa is wrong. Instead of EAa[t, J, m, Q3, Q2]:= ... it should be EAa[t_, J_, m_, Q3_, Q2_]:=... Then you wont get the NIntegrate::inumr messages. Anton Antonov Wolfram Research, Inc. > Whats wrong with this code: test[t_?NumericQ, J_?NumericQ, > m_?NumericQ, (Q3_)?NumericQ, (Q2_)?NumericQ] := > NIntegrate[ > EAa[t, J, m, Q3, Q2]* > HeavisideTheta[EAa[t, J, m, Q3, Q2]], {x, -Pi, Pi}, {y, -Pi, > Pi}, {z, -Pi, Pi}, MaxPoints -> 1000000, > Method -> LocalAdaptive]/8/(Pi^3) In[75]:= test[10, 1, 1, 1, 1] // Timing Out[75]= {5.819, 2.22142} where > EAa[t, J, m, Q3, Q2]:= 1/2 (-3 J - 2 m - 2 t (Cos[x] + Cos[y]) - > 2 t (Cos[x]/3 + Cos[y]/3 + (4 Cos[z])/3)) - > 1/2 Sqrt[16 (-(Q2/2) - (t Cos[x])/Sqrt[3] + (t Cos[y])/Sqrt[ > 3])^2 + (-2 Q3 + 2 t (Cos[x] + Cos[y]) - > 2 t (Cos[x]/3 + Cos[y]/3 + (4 Cos[z])/3))^2] with > NMinimize[test[10, 1, [Mu], q, Q], {[Mu], q, Q}] > I get those inumr errors, have i set anything wrong? Everything should > be numerical, x,y,z are integrated out, so what is it? === Subject: Re: Creating a function that is a derivative of another function?? Hi Eric, if you say: dW[0] this is replaced by: D[W[0],0], not exactly what you want. But the solution is simple: dW[t_]= W[t] hope this helps, Daniel > I have a function: W[t_] := a*t + b*t^2 + c*t^3 I want the derivative of this funtion wrt t as another function. The following seems like it works: dW[t_] := D[W[t], t] dW[t] > a + 2 b t + 3 c t^2 But something isnt right?? dW[0] > General::ivar: 0 is not a valid variable. > (output line has a partial derivative symbol, subscript 0 followed by a 0) The description of the General::ivar error isnt help either?? Any idea whats going on here?? How can I assign the derivative of a function as another funtion?! Eric > === Subject: Re: Creating a function that is a derivative of another function?? W[t_] := a*t + b*t^2 + c*t^3 dW[t_] = D[W[t], t]; ?? Jens > I have a function: W[t_] := a*t + b*t^2 + c*t^3 I want the derivative of this funtion wrt t as another function. The following seems like it works: dW[t_] := D[W[t], t] dW[t] > a + 2 b t + 3 c t^2 But something isnt right?? dW[0] > General::ivar: 0 is not a valid variable. > (output line has a partial derivative symbol, subscript 0 followed by a 0) The description of the General::ivar error isnt help either?? Any idea whats going on here?? How can I assign the derivative of a function as another funtion?! Eric > === Subject: Re: Creating a function that is a derivative of another function?? > I have a function: W[t_] := a*t + b*t^2 + c*t^3 I want the derivative of this funtion wrt t as another function. The following seems like it works: dW[t_] := D[W[t], t] dW[t] > a + 2 b t + 3 c t^2 But something isnt right?? dW[0] > General::ivar: 0 is not a valid variable. > (output line has a partial derivative symbol, subscript 0 followed by a 0) The description of the General::ivar error isnt help either?? Any idea whats going on here?? How can I assign the derivative of a function as another funtion?! The problem is with the set delayed in the definition of dW. When you substitute 0 for t, it is substituted in the definition of dW, and you wind up with the nonsensical D[W[t],0] Try set instead: dw[t_]=D[W[t],t] and all is well. However, there really isnt any need to do this to begin with, since having defined W[t], you can simply use W[t] W[0] etc. -- Helen Read University of Vermont === Subject: Re: Creating a function that is a derivative of another function?? When Mathematica evaluates your dW statement with 0 it uses D[W[0],0], which makes no sense for the D statement. Use the Derivative construction. W[t_] := a t + b t^2 + c t^3 dW[t_] := Derivative[1][W][t] dW[t] a + 2 b t + 3 c t^2 dW[0] a -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I have a function: W[t_] := a*t + b*t^2 + c*t^3 I want the derivative of this funtion wrt t as another function. The > following seems like it works: dW[t_] := D[W[t], t] dW[t] > a + 2 b t + 3 c t^2 But something isnt right?? dW[0] > General::ivar: 0 is not a valid variable. > (output line has a partial derivative symbol, subscript 0 followed by a 0) The description of the General::ivar error isnt help either?? Any idea whats going on here?? How can I assign the derivative of a > function as another funtion?! Eric > === Subject: Re: Creating a function that is a derivative of another function?? > I have a function: W[t_] := a*t + b*t^2 + c*t^3 I want the derivative of this funtion wrt t as another function. The following seems like it works: dW[t_] := D[W[t], t] dW[t] > a + 2 b t + 3 c t^2 But something isnt right?? dW[0] > General::ivar: 0 is not a valid variable. > (output line has a partial derivative symbol, subscript 0 followed by a 0) The description of the General::ivar error isnt help either?? Any idea whats going on here?? How can I assign the derivative of a function as another funtion?! > You need to read this tutorial: http://reference.wolfram.com/mathematica/tutorial/ImmediateAndDelayedDefinit ions.html The correct solution is dW[t_] = D[W[t],t] === Subject: Re: N::meprec warning with Solve Hi Peter, with version: 6.0 for Microsoft Windows (32-bit) (February 7, 2008) I do not get this warning message. Daniel > consider the function: f[x_] := (x^4 + x^3 + x^2 + 5)/(5 x^2 + 5 x + 5) lsg=Solve[f[x]==0,x] gives the warnings: N::meprec: > Internal precision limit $MaxExtraPrecision = 50.` reached while > evaluating Im[61/(3(<<1>> <<1>>)^(1/3))+1/3 (1/2(<<1>>))^(1/3)]. How can this happen if no Reals are used? Why is N called? BTW the results of Solve are correct Gruss Peter === Subject: Re: N::meprec warning with Solve > consider the function: f[x_] := (x^4 + x^3 + x^2 + 5)/(5 x^2 + 5 x + 5) lsg=Solve[f[x]==0,x] gives the warnings: N::meprec: > Internal precision limit $MaxExtraPrecision = 50.` reached while > evaluating Im[61/(3(<<1>> <<1>>)^(1/3))+1/3 (1/2(<<1>>))^(1/3)]. How can this happen if no Reals are used? Why is N called? BTW the results of Solve are correct > I found the reason myself. I had loaded, but not activated, the packacke SwitchableRealOnly` written by Ted Ersek. It does some changes to built-in functions, including Solve which only should take place, if the package ist not activated. running the code above without this package gave no warnings. Sorry for the post. Gruss Peter -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: N::meprec warning with Solve At least on my system ( 6.0.1.0 on 32-bit Linux), the result of the Solve command is as follows (no application of N apparent): {{x -> -(1/4) - (1/2)*Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)] - (1/4)* Sqrt[(1/3)*(-10 - 244/((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3) - 2*2^(2/3)*(-223 + 9*I*Sqrt[10595])^(1/3) - 9/Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/ 3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)])]}, {x -> -(1/4) - (1/2)*Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)] + (1/4)* Sqrt[(1/3)*(-10 - 244/((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3) - 2*2^(2/3)*(-223 + 9*I*Sqrt[10595])^(1/3) - 9/Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/ 3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)])]}, {x -> -(1/4) + (1/2)*Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)] - (1/4)* Sqrt[(1/3)*(-10 - 244/((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3) - 2*2^(2/3)*(-223 + 9*I*Sqrt[10595])^(1/3) + 9/Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/ 3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)])]}, {x -> -(1/4) + (1/2)*Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)] + (1/4)* Sqrt[(1/3)*(-10 - 244/((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3) - 2*2^(2/3)*(-223 + 9*I*Sqrt[10595])^(1/3) + 9/Sqrt[-(5/12) + 61/(3*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)) + (1/ 3)*((1/2)*(-223 + 9*I*Sqrt[10595]))^(1/3)])]}} Hope that helps! C.O. > consider the function: f[x_] := (x^4 + x^3 + x^2 + 5)/(5 x^2 + 5 x + 5) lsg=Solve[f[x]==0,x] gives the warnings: N::meprec: > Internal precision limit $MaxExtraPrecision = 50.` reached while > evaluating Im[61/(3(<<1>> <<1>>)^(1/3))+1/3 (1/2(<<1>>))^(1/3)]. How can this happen if no Reals are used? Why is N called? BTW the results of Solve are correct Gruss Peter -- 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: Evaluation details thats right the right hand side is not evaluated and x is given the value x+1. You can verify this by using Information[x]. But now comes the pattern matcher and tries to evaluate the resulting expression x+1. And it is here where the recursion happens. hope this helps, Daniel I am quite puzzled why a Mathematica statement > x=x+1; > causes infinite recursion. Since the ducumentation states that the lhs of > this statement is not evaluated, it seems to me that the evaluation of the > rhs should not lead to recursive evaluation. > TIA, Yuri. === Subject: Re: Evaluation details but when x has no value, than x+1 try to evaluate x but find nothing and it try it on and on .. x=4; x=x+1 work as expected. Jens I am quite puzzled why a Mathematica statement > x=x+1; > causes infinite recursion. Since the ducumentation states that the lhs of > this statement is not evaluated, it seems to me that the evaluation of the > rhs should not lead to recursive evaluation. > TIA, Yuri. === Subject: Re: Evaluation details But the right hand side IS evaluated and when it sees x it looks for any rules for x and finds the current definition. Should it behave this way? If it didnt, then what about the delayed set? Clear[x] x := x + 1 Now evaluating x gives the same recursion error. Maybe you really want Increment or PreIncrement? -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I am quite puzzled why a Mathematica statement > x=x+1; > causes infinite recursion. Since the ducumentation states that the lhs of > this statement is not evaluated, it seems to me that the evaluation of the > rhs should not lead to recursive evaluation. > TIA, Yuri. === Subject: Re: Evaluation details I am quite puzzled why a Mathematica statement > x=x+1; > causes infinite recursion. Since the ducumentation states that the > lhs of > this statement is not evaluated, it seems to me that the evaluation > of the > rhs should not lead to recursive evaluation. > TIA, Yuri. The left hand side is not pre-evaluated but an OwnValue for x is created: In[3]:= Block[{$RecursionLimit = 20}, x = x + 1] reclim : Recursion depth of 20 exceeded. Out[3]= Hold[x + 1] + 19 In[4]:= OwnValues[x] Out[4]= {HoldPattern[x] :> Hold[x + 1] + 19} and then the rhs is evaluated, this OwnValue applied, a new OwnValue for x created etc. Andrzej Kozlowski === Subject: Re: Evaluation details >> I am quite puzzled why a Mathematica statement >> x=x+1; >> causes infinite recursion. Since the ducumentation states that the >> lhs of >> this statement is not evaluated, it seems to me that the evaluation >> of the >> rhs should not lead to recursive evaluation. >> TIA, Yuri. The left hand side is not pre-evaluated but an OwnValue for x is > created: In[3]:= Block[{$RecursionLimit = 20}, x = x + 1] > reclim : Recursion depth of 20 exceeded. > Out[3]= Hold[x + 1] + 19 In[4]:= OwnValues[x] > Out[4]= {HoldPattern[x] :> Hold[x + 1] + 19} and then the rhs is evaluated, this OwnValue applied, a new OwnValue > for x created etc. [note: message CCd to MathGroup] I believe that there is a little mistake here. The rhs is evaluated first, and the OwnValue is only created afterwards. However, the return value of Set[] is the same as the result of the evaluation of the rhs. Mathematica keeps evaluating expressions (including the return value of Set[]) until it reaches a fixed point. Now the OwnValue has already been defined, so a fixed point is never reached: Mathematica goes into infinite recursion. So, if the input Block[{$RecursionLimit = 20}, x = x + 1] is evaluated only once, the OwnValue will be simply x + 1 and not Hold[x + 1] + 19 In[1]:= Block[{$RecursionLimit = 20}, x = x + 1] During evaluation of In[1]:= $RecursionLimit::reclim: Recursion depth of 20 exceeded. >> Out[1]= 18 + Hold[1 + x] In[2]:= OwnValues[x] Out[2]= {HoldPattern[x] :> 1 + x} Evaluating the same input again creates the OwnValue cited above: In[3]:= Block[{$RecursionLimit = 20}, x = x + 1] During evaluation of In[3]:= $RecursionLimit::reclim: Recursion depth of 20 exceeded. >> Out[3]= 19 + Hold[1 + x] In[4]:= OwnValues[x] Out[4]= {HoldPattern[x] :> 19 + Hold[1 + x]} Szabolcs Horv.87t === Subject: Re: Evaluation details I am quite puzzled why a Mathematica statement > x=x+1; > causes infinite recursion. Since the ducumentation states that the lhs of > this statement is not evaluated, it seems to me that the evaluation of the > rhs should not lead to recursive evaluation. > TIA, Yuri. Mathematica evaluates expressions for as long as there are rules applying to them. x = x+1 evaluates to x+1, which then evaluates to x+1+1, etc. The ; only prevents printing, not evaluation. === Subject: Ordering function when using ordering within the definition of a pure function and applying this pure function within the definition of another function, which is to be minimized, I have the problem, that the ordering does not only order according to numeric values, but the ordering is already executed on the names of the arguments (probably using some canonical alphabetical order). Does anyone know of a way to suppress this behavior? May be by changing the attributes of the arguments? === Subject: Re: Ordering function when using ordering within the definition of a pure function and applying this pure function within the definition of another function, which is to be minimized, I have the problem, that the ordering does not only order according to numeric values, but the ordering is already executed on the names of the arguments (probably using some canonical alphabetical order). Does anyone know of a way to suppress this behavior? May be by changing the attributes of the arguments? > Use SetDelayed instead of Set. Without a concrete example it is difficult to say more than this. === Subject: Re: Mathematica hangs... > This sounds a lot like an issue were addressing in an upcoming 6.0.2.1 > release, namely a hang on OS X 10.5.2 with plots which have a specific > AxesOrigin and PlotRange options. I cant be a 100% without being able > to load the external file used in your notebook: Import[$HomeDirectory <> /Desktop/vHCO+.dat, Table] If you would like this to be checked, you may reply with this file attached > and I will have someone in my department check that this is indeed the same issue > (and that it is fixed in 6.0.2.1). I apologize for any inconvenience this may have caused you. Arnoud Buzing, > Manager, Quality Assurance, > Wolfram Research Ive included the data file in the zip archive Ive linked above. You should be able to execute the whole notebook after changing the path appearing in the Import[] command to point to wherever the file is on your machine. === Subject: Re: Find roots in a limited interval Viktor, Ted Ersek has a very nice package called RootSearch that you can obtain from MathSource. http://library.wolfram.com/infocenter/MathSource/4482/ Although the Mathematica FindRoot function is more general, RootSearch is by far better and more convenient for cases of searching for a root of a single real function within an interval. These are probably 95% of root finding cases and why WRI doesnt make this a standard part of Mathematica is beyond me. Here is an example. All you have to do is give the equation and the interval in which you want the roots and Teds routine will find all the roots in the interval in order. Needs[Ersek`RootSearch`] f[x_] := 1/2 Sinc[x] - 2 Sinc[3 x] xroots = x /. RootSearch[f[x] == 0, {x, 0, 5}] {0.848062,2.29353,3.14159,3.98965} Using the Presentations package, the following plots the function, the roots as small filled circles and marks the root values along the x-axis along with faint vertical grid lines marking the root locations. In Presentations, one can make believe one is plotting in the complex plane and give point locations as simple complex numbers. Needs[Presentations`Master`] With[ {xticks = CustomTicks[Identity, databased[xroots]]}, Draw2D[ {Draw[f[x], {x, 0, 5}], {Gray, ComplexLine[{0, 5}]}, ComplexCirclePoint[#, 3, Black, White] & /@ xroots}, Frame -> True, FrameTicks -> {xticks, Automatic, xticks // NoTickLabels, Automatic}, GridLines -> {CustomGridLines[Identity, databased@xroots, {LightGray}], None}, PlotLabel -> Row[{Roots of , f[x]}], BaseStyle -> {FontSize -> 12}, ImageSize -> 400] ] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Being a Mathematica beginner I struggle to find a solution to a fairly > simple problem. I have a function (superposition of several weighted > sinc functions) which in principle has infinitely many roots. However I am interested only in lets say roots that are to be found > within the limited interval between 0 and 5. I tried to define a system of inequalities of the type Solve[f[t] && t>0 && t<5, t] but no success. > I played around with the function Reduce but did not have any success > and I am also not sure if this is the right way forward. So the question: Is it possible to define an interval in Mathematica > in which I am looking for the roots? > Viktor === Subject: Re: Find roots in a limited interval Hi Victor, Solve does not take inequalities, but Reduce does. E.g.: Reduce[Sin[x]/x==0&&0<x<10,x] hope this helps, Daniel Being a Mathematica beginner I struggle to find a solution to a fairly > simple problem. I have a function (superposition of several weighted > sinc functions) which in principle has infinitely many roots. However I am interested only in lets say roots that are to be found > within the limited interval between 0 and 5. I tried to define a system of inequalities of the type Solve[f[t] && t>0 && t<5, t] but no success. > I played around with the function Reduce but did not have any success > and I am also not sure if this is the right way forward. So the question: Is it possible to define an interval in Mathematica > in which I am looking for the roots? > Viktor === Subject: Re: Find roots in a limited interval post-process the results of Solve[] ?? and select the ones you like ??? Jens Being a Mathematica beginner I struggle to find a solution to a fairly > simple problem. I have a function (superposition of several weighted > sinc functions) which in principle has infinitely many roots. However I am interested only in lets say roots that are to be found > within the limited interval between 0 and 5. I tried to define a system of inequalities of the type Solve[f[t] && t>0 && t<5, t] but no success. > I played around with the function Reduce but did not have any success > and I am also not sure if this is the right way forward. So the question: Is it possible to define an interval in Mathematica > in which I am looking for the roots? > Viktor === Subject: Re: Find roots in a limited interval You cant have any inequalities in Solve (and the syntax of your example is completely wrong). Reduce, on the other hand, should be able to handle the problem you have described, but as you do not give the slightest idea of what you did, there is no way of telling whether you did not have any success with Reduce also for the same reason (wrong syntax) or because your problem is one that Reduce cant handle. There are also other ways of tackling such problems (if you are satisfied with finding only approximate roots) but again little can be said with the amount of information you have provided. Andrzej Kozlowski Being a Mathematica beginner I struggle to find a solution to a fairly > simple problem. I have a function (superposition of several weighted > sinc functions) which in principle has infinitely many roots. However I am interested only in lets say roots that are to be found > within the limited interval between 0 and 5. I tried to define a system of inequalities of the type Solve[f[t] && t>0 && t<5, t] but no success. > I played around with the function Reduce but did not have any success > and I am also not sure if this is the right way forward. So the question: Is it possible to define an interval in Mathematica > in which I am looking for the roots? > Viktor === Subject: Re: Find roots in a limited interval Being a Mathematica beginner I struggle to find a solution to a fairly > simple problem. I have a function (superposition of several weighted > sinc functions) which in principle has infinitely many roots. However I am interested only in lets say roots that are to be found > within the limited interval between 0 and 5. I tried to define a system of inequalities of the type Solve[f[t] && t>0 && t<5, t] but no success. --------^^^ This doesnt make sense unless f[t] is a logical statement. && means and, so this is like saying 4 and 3 < 5. Perhaps you meant Reduce[f[t] == 0 && t > 0 && t < 5, t, Reals] ? If this doesnt work, then most probably Mathematica cannot solve the equation symbolically, and you need to resort to numerical methods. FindRoot[f[t] == 0, {t, 1, 0, 5}] will give you a single solution between 0 and 5. Tweak the starting value 1 to get different solutions. > I played around with the function Reduce but did not have any success > and I am also not sure if this is the right way forward. Yes, Reduce is the command for solving inequalities or equations with conditions, but next time please show the exact command you used, otherwise it is impossible to guess what went wrong. So the question: Is it possible to define an interval in Mathematica > in which I am looking for the roots? === Subject: How To Export a big-sized Graph? I am facing a problem when I try to export a graph was generated from ContourPlot3D in EPS format. The graph does not take so much time (a few seconds) to get the outpot but the diffeculty appears when I try to export it. I tryied the two ways of exporting: using the menu file (save selection as) and also the another way using the function Export. But in both cases, the graph takes too much time to get it exported. Also, the the eps file I get is too big (57 MB). Any help, please? === Subject: texture mapping/memory leak? Lately, Ive been trying to work out texture mapping with Mathematica. By texture mapping I mean transforming and applying the contents of an image file onto the surface of a 3D object. Ill describe the approach Ive taken, the results so far, then try to pose some questions. The example problem Ill use is a more-or-less standard one - mapping a Mercator global map onto a sphere. I copied a map image from Google Images (earth map Mercator), picking a small thumbnail, maybe 100 or 130 pixels wide, and using it to define a variable map = First[*paste image here*] map is a Raster, in my case specified as a List of 3-Lists interpreted as RGBColors. After a long time foundering around, I discovered that the specification for the Option Mesh-> has to be: grid = Take[Dimensions[map[[1]], 2] - 1 This gives a pixel count of the form {width, height}. Testing with a rectangular mapping: RegionPlot[-2<=x<=2&&-1<=y<=1,{x,-3,3},{y,-2,2} ,MeshStyle->None ,Mesh->Reverse[grid] ,MeshShading->Map[RGBColor,map[[1]],{2}]] seems to do what I want after, for completely inscrutable reasons, I Reverse the Mesh Option spec to represent {height, width}. Then I tried a sphere, added a red axis line, and finally got this: grid = Take[Dimensions[map[[1]]], 2]-1; Timing[Graphics3D[{ First[SphericalPlot3D[ 1.0, ,{[Theta],0,Pi} ,{[CurlyPhi],0,2 Pi} ,Mesh->Reverse[grid] ,MeshStyle->None ,MeshFunctions->{#5 &,-#4&} ,MeshShading->Map[RGBColor,map[[1]],{2}] ]] ,Red,Thick,Line[{{0,0,-1.5},{0,0,1.5}}] } ,ImageSize->{400,400} ]] and the result is at least recognizable. If you choose an image thats not a true Mercator, Greenland and South America might extend to the poles - insignificant details. At least North, South, East, and West are right. To get this to work required a vast amount of thrashing, not helped at all by SphericalPlot3Ds parameterization inverting that advanced by Mathworld. I cant even dope out whether SP3D is internally consistent, considering the odd form required for the MeshFunctions. The (/[CurlyPhi]) is the azimuth, the second in the SP3D parameter list, but first in the return order (#4 before the #5 (/[Theta]) elevation.) I cant quite make sense of the minus sign in front of the #4 either. Even though [Theta] runs the direction opposite to latitude, its direction is consistent with the direction of x in the 2D example, which seemed to work ok. Converting #5 to latitude is evidently not necessary, because the image rows count from the top. Im left, though, with a pile of imponderables. 1. Why so slow? As written, Timing[] in the code fragment above reports around 1.5 seconds, but the actual meat clock elapsed time is more like a minute. How come? 2. Is there a pattern I cant discern in the way the coordinate defnitions relate to the MeshFunctions and the orientation of the MeshShading. 3. Are there any reported memory leakage problems associated with these calculations? When I work with MeshShading, my page file usage (as reported in my Windows Task Manager) gradually climbs to a point where the system hangs. If I put it into a Manipulate, Ive had to pull the power and the battery. 4. Is there a faster or otherwise preferred way to do this? TIA, Fred Klingener === Subject: Re: texture mapping/memory leak? Lately, Ive been trying to work out texture mapping with Mathematica. > By texture mapping I mean transforming and applying the contents of > an image file onto the surface of a 3D object. Ill describe the approach Ive taken, the results so far, then try to pose > some questions. The example problem Ill use is a more-or-less standard > one - mapping a Mercator global map onto a sphere. I copied a map image from Google Images (earth map Mercator), picking a > small thumbnail, maybe 100 or 130 pixels wide, and using it to define a > variable map = First[*paste image here*] map is a Raster, in my case specified as a List of 3-Lists interpreted as > RGBColors. After a long time foundering around, I discovered that the > specification for the Option Mesh-> has to be: grid = Take[Dimensions[map[[1]], 2] - 1 This gives a pixel count of the form {width, height}. Testing with a rectangular mapping: RegionPlot[-2<=x<=2&&-1<=y<=1,{x,-3,3},{y,-2,2} > ,MeshStyle->None > ,Mesh->Reverse[grid] > ,MeshShading->Map[RGBColor,map[[1]],{2}]] seems to do what I want after, for completely inscrutable reasons, I Reverse > the Mesh Option spec to represent {height, width}. Then I tried a sphere, added a red axis line, and finally got this: grid = Take[Dimensions[map[[1]]], 2]-1; > Timing[Graphics3D[{ > First[SphericalPlot3D[ > 1.0, > ,{[Theta],0,Pi} > ,{[CurlyPhi],0,2 Pi} > ,Mesh->Reverse[grid] > ,MeshStyle->None > ,MeshFunctions->{#5 &,-#4&} > ,MeshShading->Map[RGBColor,map[[1]],{2}] > ]] > ,Red,Thick,Line[{{0,0,-1.5},{0,0,1.5}}]} ,ImageSize->{400,400} > ]] and the result is at least recognizable. If you choose an image thats not a > true Mercator, Greenland and South America might extend to the poles - > insignificant details. At least North, South, East, and West are right. To get this to work required a vast amount of thrashing, not helped at all > by SphericalPlot3Ds parameterization inverting that advanced by Mathworld. > I cant even dope out whether SP3D is internally consistent, considering the > odd form required for the MeshFunctions. The (/[CurlyPhi]) is the azimuth, > the second in the SP3D parameter list, but first in the return order (#4 > before the #5 (/[Theta]) elevation.) I cant quite make sense of the minus sign in front of the #4 either. Even > though [Theta] runs the direction opposite to latitude, its direction is > consistent with the direction of x in the 2D example, which seemed to work > ok. Converting #5 to latitude is evidently not necessary, because the image rows > count from the top. Im left, though, with a pile of imponderables. 1. Why so slow? As written, Timing[] in the code fragment above reports > around 1.5 seconds, but the actual meat clock elapsed time is more like a > minute. How come? 2. Is there a pattern I cant discern in the way the coordinate defnitions > relate to the MeshFunctions and the orientation of the MeshShading. 3. Are there any reported memory leakage problems associated with these > calculations? When I work with MeshShading, my page file usage (as reported > in my Windows Task Manager) gradually climbs to a point where the system > hangs. If I put it into a Manipulate, Ive had to pull the power and the > battery. 4. Is there a faster or otherwise preferred way to do this? TIA, > Fred Klingener Hi Fred I recently did something like this while mucking around with Easter Eggs. No idea if its any better or worse than what you have done but you may find it useful - Essentially I make use of color function to take care of the mapping. Its very hackish and I made no attempt to optimise it or anything but the details can be found here http://www.walkingrandomly.com/?p=79 Mike === Subject: Problems on definit integratiion of gaussian profiles I dont understand the behavoir of Mathematica integrating exponential functions. I try to integrate the same functions in different forms. The integrands are Power[E, Plus[Times[-1, Power[a, 2], Power[c, -2]], Times[-1, Power [d, -2], Power[Plus[b, Times[-1, x]], 2]]]] or Power[E, Plus[Times[-1, Power[a, 2], Power[c, -2]], Times[-1, Power [b, 2], Power[d, -2]], Times[2, b, Power[d, -1], x], Times[-1, Power[d, -2], Power[x, 2]]]] which are the same, but the results will differ. Indeed calculating definit integral in a -Infinity to Infinity domain, assuming that all variables are larger than 0, the result will be completly different! 1st case the result will be: Times[d, Power[E, Times[-1, Power[a, 2], Power[c, -2]]], Power[Pi, Rational[1, 2]]] while in the 2nd case Times[d, Power[E, Plus[Power[b, 2], Times[-1, Power[a, 2], Power[c, -2]], Times[-1, Power[b, 2], Power[d, -2]]]], Power[Pi, Rational[1, 2]]] As You can see the 1st result is completly independent of b! I dont understand. How can it be fixed? Zsolt Regaly === Subject: Re: Exceptions Style Problem What is the second item, Blue, doing in ExclusionsStyle? I dont see any difference in the plot if I just use ExclusionsStyle -> Red in this example. y1 = ParametricPlot[folium[t], {t, -30, 30}, > PlotRange -> {{-3, 3}, {-3, 3}}, ExclusionsStyle -> {Red, Blue}, > Exclusions -> {t == -1}] ?? Jens > I generated a plot using this code: >> folium[t_]:={3t/(1+t^3),3t^2/(1+t^3)}; >> y1=ParametricPlot[folium[t],{t,-30,30},PlotRange->{{-3,3},{-3,3}}] >> It was a nice folium with the asymptote displayed. >> Next I plotted >> y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3}, >> {-3,3}},Exclusions->-1 ] >> As expected this gave me the folium without the asymptote displayed. >> Finally, I plotted >> y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3},{-3,3}} >> ,ExclusionsStyle->Blue,Exclusions->-1] >> I expected to see the asymptote displayed in Blue, since the >> documentation for ExclusionsStyle says, ExclusionsStyle is an option >> to plotting functions that specifies how to render subregions excluded >> according to Exclusions. >> But, instead I get the folium without the asymptote displayed. >> Can anyone help me understand what I am missing? >> Gary Boswell > -- 3 545-1801 Amherst, MA 01003-9305 === Subject: Re: Exceptions Style Problem y1 = ParametricPlot[folium[t], {t, -30, 30}, PlotRange -> {{-3, 3}, {-3, 3}}, ExclusionsStyle -> {Red, Blue}, Exclusions -> {t == -1}] ?? Jens > I generated a plot using this code: folium[t_]:={3t/(1+t^3),3t^2/(1+t^3)}; y1=ParametricPlot[folium[t],{t,-30,30},PlotRange->{{-3,3},{-3,3}}] It was a nice folium with the asymptote displayed. Next I plotted y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3}, > {-3,3}},Exclusions->-1 ] As expected this gave me the folium without the asymptote displayed. Finally, I plotted y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3},{-3,3}} > ,ExclusionsStyle->Blue,Exclusions->-1] I expected to see the asymptote displayed in Blue, since the > documentation for ExclusionsStyle says, ExclusionsStyle is an option > to plotting functions that specifies how to render subregions excluded > according to Exclusions. But, instead I get the folium without the asymptote displayed. Can anyone help me understand what I am missing? > Gary Boswell > === Subject: Re: Exceptions Style Problem Gary, This is a little trip wire that WRI has inadvertently left in the path and almost everyone trips over it. Either it is a bug or it is a feature that needs clearer explanation in the documentation. Basically you have to use the equation form of Exclusions to make it work correctly. folium[t_] := {3 t/(1 + t^3), 3 t^2/(1 + t^3)}; ParametricPlot[folium[t], {t, -30, 30}, PlotRange -> {{-3, 3}, {-3, 3}}, PlotStyle -> Black, ExclusionsStyle -> Blue, Exclusions -> {t == -1}] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I generated a plot using this code: folium[t_]:={3t/(1+t^3),3t^2/(1+t^3)}; y1=ParametricPlot[folium[t],{t,-30,30},PlotRange->{{-3,3},{-3,3}}] It was a nice folium with the asymptote displayed. Next I plotted y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3}, > {-3,3}},Exclusions->-1 ] As expected this gave me the folium without the asymptote displayed. Finally, I plotted y1= ParametricPlot[folium[t], {t,-30,30},PlotRange->{{-3,3},{-3,3}} > ,ExclusionsStyle->Blue,Exclusions->-1] I expected to see the asymptote displayed in Blue, since the > documentation for ExclusionsStyle says, ExclusionsStyle is an option > to plotting functions that specifies how to render subregions excluded > according to Exclusions. But, instead I get the folium without the asymptote displayed. Can anyone help me understand what I am missing? > Gary Boswell > === Subject: Re: Unwanted lined in PDF-exported Graphics3D Yes, I can confirm the problem on 6.0.2 (AdobeAcrobat8 is installed too). And it gets worse when using an online viewer https://share.adobe.com/adc/adc.do?docid=86ab9d5b-f681-11dc-8d05-e59350926= 3b8 Igor On Mar 20, 8:00 am, Mariano Su=E1rez-Alvarez > Simple code as > Export[test.pdf, > > Graphics3D[{ > > Polygon[Table[Chop[{Cos[t], Sin[t], 0}], {t, 0, 2 Pi, 0.1}]] > > }] > > ] > results in a PDF file which has lots of extra lines on the surface. > Is there a way to get rid of them? In this specific case I cannot see any lines with Adobe Reader 8.1.2. > However I think I know the problem that you are referring to. The lines= > are an artifact of antialiasing, so there is not way to get rid of them > (apart from using a different PDF reader). For some reason Mathematica likes to break up large polygons into many > small ones and their edges become visible. See this thread: > I guessed it was antialiasing. It very much > destroys the esthetics of these graphics Im > working on (sets of symmetry planes of polyhedra, > each one drawn as a disc), sadly, for PDF output. I guess I was wondering if there is some way > to tell Mathematica to work harder and not use that > many polygons. Rasterizing in order to include > in a PDF seems like a very wrong path... Oh well. -- m === Subject: Re: Unwanted lined in PDF-exported Graphics3D > Simple code as Export[test.pdf, > Graphics3D[{ > Polygon[Table[Chop[{Cos[t], Sin[t], 0}], {t, 0, 2 Pi, 0.1}]] > }] > ] results in a PDF file which has lots of extra lines on the surface. Is there a way to get rid of them? In this specific case I cannot see any lines with Adobe Reader 8.1.2. > However I think I know the problem that you are referring to. The lines > are an artifact of antialiasing, so there is not way to get rid of them > (apart from using a different PDF reader). For some reason Mathematica likes to break up large polygons into many > small ones and their edges become visible. See this thread: > I guessed it was antialiasing. It very much destroys the esthetics of these graphics Im working on (sets of symmetry planes of polyhedra, each one drawn as a disc), sadly, for PDF output. I guess I was wondering if there is some way to tell Mathematica to work harder and not use that many polygons. Rasterizing in order to include in a PDF seems like a very wrong path... Oh well. -- m === Subject: Re: finding positions of elements in a list Select is my first approach. Note that I stuck some values into mylist for which the y-coordinates are less than 80, just to test: In[29]:= mylist = {{20, 109}, {20, 110}, {22, 18}, {20, 111}, {21, 105}, {21, 106}, {21, 107}, {22, 34}, {21, 12}} Out[29]= {{20, 109}, {20, 110}, {22, 18}, {20, 111}, {21, 105}, {21, 106}, {21, 107}, {22, 34}, {21, 12}} In[30]:= myNewList = Select[mylist, #1[[2]] > 80 & ] Out[30]= {{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}} Hope that helps! C.O. > Hi. Having a few problems here with what I think should be a simple operation. > I have a list as shown: mylist={{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, > 107},...} Its a list of {x,y} co-ordinates of some data points Im analysing. I want to create a new list which contains only those data points whose y > co-ordinate is greater than 80 ie. mylist[[n,2]]>80. Problem is, I cant work out how to use Select to do this when each element > in the list has an x and a y co-ordinate. If I split the list into x and y > co-ordinates and searched for those y values greater than 80, I would have > a list of those y-values but would not know the corresponding x-values. I also tried Position but it wasnt clear to me if a pattern can be used > for this. > -- 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: finding positions of elements in a list Maybe something like the following? mylistnew = {{20, 79}, {20, 80}, {20, 81}, {20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}} With Select: Select[mylistnew , Part[#, 2] > 80 & ] Out[59]= {{20, 81}, {20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}} With Cases Cases[mylistnew, {_, x_ /; x > 80}] Out[84]= {{20, 81}, {20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}} Perhaps DeleteCases also worth considering? DeleteCases[mylistnew, {_, x_ /; x <= 80}] Out[83]= {{20, 81}, {20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}} Tom Dowling > Hi. Having a few problems here with what I think should be a simple operation. > I have a list as shown: mylist={{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, > 107},...} Its a list of {x,y} co-ordinates of some data points Im analysing. I want to create a new list which contains only those data points whose y > co-ordinate is greater than 80 ie. mylist[[n,2]]>80. Problem is, I cant work out how to use Select to do this when each > element in the list has an x and a y co-ordinate. If I split the list into x > and y co-ordinates and searched for those y values greater than 80, I would > have a list of those y-values but would not know the corresponding x-values. I also tried Position but it wasnt clear to me if a pattern can be used > for this. > === Subject: Re: finding positions of elements in a list Hi Peter, mylist={{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, > 106}, {21, 107},...} Its a list of {x,y} co-ordinates of some data points Im analysing. I want to create a new list which contains only those data > points whose y co-ordinate is greater than 80 ie. mylist[[n,2]]>80. You can use Select. You want to select everything based on the second part of every element in the list. Given mylist = {{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}}; The command Select[mylist, #[[2]] > 109 &] gets everything with a y-coordinate > 109. Dave. No virus found in this outgoing message. Checked by AVG. 09:54 === Subject: Re: finding positions of elements in a list Thats simple with slots : mylist = {{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}}; Select[mylist, (#[[2]] > 106) &] Claude === Subject: Re: Saving Packages (was: Re: importing nb files) Make a=2 an initialization cell. Bobby > Update: Starting by creating a new package window, the a=2 definition > generates a .m file containing: (* ::Package:: *) a=2 so: without the (* ::Input:: *) line, and with the definition not > commented. BUT - this remains a problem, if one doesnt want to start right from > scratch with a package, but instead convert a notebook to a package: > this seems impossible! > Alessandro ______________ oh, damn, youre right - now I remember! Yet... > 1) creating a notebook containing just: > a=2 2) savinga as package file as test.m 3) importing it: <<test.m I get no error, but a remains undefined. (version 6.0.2 here) Looking for the problem, I noticed that the source of test.m is: > (* ::Package:: *) (* ::Input:: *) > (*a:=2*) commented out !!! I saved as package another bigger .nb file, and it did the same: it > comments out everything. When I took away the (* *) of course Get[] > worked. So? Maybe the right question is How do I create a Package? Because > obviously Save As->Mathematica Package (.m) is crippled. > David Bailey ha scritto: > a very basic question - sorry for that... >> probably its me, almost never having programmed large projects tha= t >> needed breaking up in different notebooks, so I seldom used the Get= >> (<<) function, but I seemed to remember this function would allow m= e >> to Import&evaluate a notebook in another. >> So, defining simply a=2 in a notebook test.nb, when I executed: >> <<test.nb >> I obtained: >> Notebook[{Cell[ >> CellGroupData[{Cell[BoxData[RowBox[{a, =, 2}]], Input,= >> CellChangeTimes -> {{3.41474*10^9, 3.41474*10^9}}], >> Cell[BoxData[2], Output, CellChangeTimes -> {3.41474*10^9}= ]}, >> Open]]}, WindowSize -> {640, 750}, >> WindowMargins -> {{150, Automatic}, {Automatic, 52}}, >> FrontEndVersion -> 6.0 for Linux x86 (32-bit) (February 7, 2008)= , >> StyleDefinitions -> Default.nb] >> (a verbose output which I didnt remember) and, moreover, my a >> variable still remains undefined! >> What Im missing (or forgetting)? >> Alessandro >> You are forgetting that Get reads .m files (sometimes known as packag= e >> files), not notebooks. However, in 6.0 .m files can be edited almost = as >> if they were notebooks and non-code information such as headings is >> stored in the .m file as comments. >> Note also, that if you open a notebook and evaluate it, and then open= >> another and evaluate that also, the second evaluation will use any >> relevant definitions from the first one. >> David Bailey >> http://www.dbaileyconsultancy.co.uk -- = DrMajorBob@longhorns.com === Subject: Saving Packages (was: Re: importing nb files) Update: Starting by creating a new package window, the a=2 definition generates a .m file containing: (* ::Package:: *) a=2 so: without the (* ::Input:: *) line, and with the definition not commented. BUT - this remains a problem, if one doesnt want to start right from scratch with a package, but instead convert a notebook to a package: this seems impossible! Alessandro ______________ oh, damn, youre right - now I remember! Yet... 1) creating a notebook containing just: a=2 2) savinga as package file as test.m 3) importing it: <<test.m I get no error, but a remains undefined. (version 6.0.2 here) Looking for the problem, I noticed that the source of test.m is: (* ::Package:: *) (* ::Input:: *) (*a:=2*) commented out !!! I saved as package another bigger .nb file, and it did the same: it comments out everything. When I took away the (* *) of course Get[] worked. So? Maybe the right question is How do I create a Package? Because obviously Save As->Mathematica Package (.m) is crippled. David Bailey ha scritto: > a very basic question - sorry for that... probably its me, almost never having programmed large projects that > needed breaking up in different notebooks, so I seldom used the Get > (<<) function, but I seemed to remember this function would allow me > to Import&evaluate a notebook in another. So, defining simply a=2 in a notebook test.nb, when I executed: <<test.nb I obtained: Notebook[{Cell[ > CellGroupData[{Cell[BoxData[RowBox[{a, =, 2}]], Input, > CellChangeTimes -> {{3.41474*10^9, 3.41474*10^9}}], > Cell[BoxData[2], Output, CellChangeTimes -> {3.41474*10^9}]}, > Open]]}, WindowSize -> {640, 750}, > WindowMargins -> {{150, Automatic}, {Automatic, 52}}, > FrontEndVersion -> 6.0 for Linux x86 (32-bit) (February 7, 2008), > StyleDefinitions -> Default.nb] (a verbose output which I didnt remember) and, moreover, my a > variable still remains undefined! > What Im missing (or forgetting)? > Alessandro You are forgetting that Get reads .m files (sometimes known as package > files), not notebooks. However, in 6.0 .m files can be edited almost as > if they were notebooks and non-code information such as headings is > stored in the .m file as comments. Note also, that if you open a notebook and evaluate it, and then open > another and evaluate that also, the second evaluation will use any > relevant definitions from the first one. David Bailey > http://www.dbaileyconsultancy.co.uk === Subject: Re: Saving Packages > Update: Starting by creating a new package window, the a=2 definition > generates a .m file containing: (* ::Package:: *) a=2 so: without the (* ::Input:: *) line, and with the definition not > commented. BUT - this remains a problem, if one doesnt want to start right from > scratch with a package, but instead convert a notebook to a package: > this seems impossible! > Alessandro ______________ oh, damn, youre right - now I remember! Yet... > 1) creating a notebook containing just: > a=2 2) savinga as package file as test.m 3) importing it: <<test.m I get no error, but a remains undefined. (version 6.0.2 here) Looking for the problem, I noticed that the source of test.m is: > (* ::Package:: *) (* ::Input:: *) > (*a:=2*) commented out !!! I saved as package another bigger .nb file, and it did the same: it > comments out everything. When I took away the (* *) of course Get[] > worked. So? Maybe the right question is How do I create a Package? Because > obviously Save As->Mathematica Package (.m) is crippled. > David Bailey ha scritto: a very basic question - sorry for that... >> probably its me, almost never having programmed large projects that > needed breaking up in different notebooks, so I seldom used the Get > (<<) function, but I seemed to remember this function would allow me > to Import&evaluate a notebook in another. >> So, defining simply a=2 in a notebook test.nb, when I executed: >> <<test.nb >> I obtained: >> Notebook[{Cell[ > CellGroupData[{Cell[BoxData[RowBox[{a, =, 2}]], Input, > CellChangeTimes -> {{3.41474*10^9, 3.41474*10^9}}], > Cell[BoxData[2], Output, CellChangeTimes -> {3.41474*10^9}]}, > Open]]}, WindowSize -> {640, 750}, > WindowMargins -> {{150, Automatic}, {Automatic, 52}}, > FrontEndVersion -> 6.0 for Linux x86 (32-bit) (February 7, 2008), > StyleDefinitions -> Default.nb] >> (a verbose output which I didnt remember) and, moreover, my a > variable still remains undefined! > What Im missing (or forgetting)? > Alessandro > You are forgetting that Get reads .m files (sometimes known as package >> files), not notebooks. However, in 6.0 .m files can be edited almost as >> if they were notebooks and non-code information such as headings is >> stored in the .m file as comments. >> Note also, that if you open a notebook and evaluate it, and then open >> another and evaluate that also, the second evaluation will use any >> relevant definitions from the first one. >> David Bailey >> http://www.dbaileyconsultancy.co.uk > Change the style of every cell that is executable to style Code. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Saving Packages >> (a verbose output which I didnt remember) and, moreover, my a > variable still remains undefined! > What Im missing (or forgetting)? I have not investigated this in detail, but I think you should just make all your input cells (that is the ones you want to appear in the package) as InitializationCells, then I think the autogenerated packages and most probably the exported package files will contain these cells. This has been explained in detail in other threads in this newsgroup. > So? Maybe the right question is How do I create a Package? Because > obviously Save As->Mathematica Package (.m) is crippled. Since I use this all the time I am quite sure that it works and is not too crippled... hth, albert === Subject: Saving Packages (was: Re: importing nb files) oh, damn, youre right - now I remember! Yet... 1) creating a notebook containing just: a=2 2) savinga as package file as test.m 3) importing it: <<test.m I get no error, but a remains undefined. (version 6.0.2 here) Looking for the problem, I noticed that the source of test.m is: (* ::Package:: *) (* ::Input:: *) (*a:=2*) commented out !!! I saved as package another bigger .nb file, and it did the same: it comments out everything. When I took away the (* *) of course Get[] worked. So? Maybe the right question is How do I create a Package? Because obviously Save As->Mathematica Package (.m) is crippled. David Bailey ha scritto: > a very basic question - sorry for that... probably its me, almost never having programmed large projects that > needed breaking up in different notebooks, so I seldom used the Get > (<<) function, but I seemed to remember this function would allow me > to Import&evaluate a notebook in another. So, defining simply a=2 in a notebook test.nb, when I executed: <<test.nb I obtained: Notebook[{Cell[ > CellGroupData[{Cell[BoxData[RowBox[{a, =, 2}]], Input, > CellChangeTimes -> {{3.41474*10^9, 3.41474*10^9}}], > Cell[BoxData[2], Output, CellChangeTimes -> {3.41474*10^9}]}, > Open]]}, WindowSize -> {640, 750}, > WindowMargins -> {{150, Automatic}, {Automatic, 52}}, > FrontEndVersion -> 6.0 for Linux x86 (32-bit) (February 7, 2008), > StyleDefinitions -> Default.nb] (a verbose output which I didnt remember) and, moreover, my a > variable still remains undefined! > What Im missing (or forgetting)? > Alessandro You are forgetting that Get reads .m files (sometimes known as package > files), not notebooks. However, in 6.0 .m files can be edited almost as > if they were notebooks and non-code information such as headings is > stored in the .m file as comments. Note also, that if you open a notebook and evaluate it, and then open > another and evaluate that also, the second evaluation will use any > relevant definitions from the first one. David Bailey > http://www.dbaileyconsultancy.co.uk === Subject: Re: choose elements from list based on elements in different list Inner does SEEM a natural way to go, but see below, where my bt is a bit faster than Davids dp. n= 10^6; Clear[ dp,bt,zeroQ] SetAttributes[ zeroQ,Listable] zeroQ[0]=True; zeroQ[_]=False; dp[ a_List,b_List]:= Inner[ If[ #1==0[And] #2!=0,#2, Unevaluated@ Sequence[]]&,a,b,List] bt[ a_List,b_List]:= Pick[ b, Transpose[ zeroQ/@ { a,b}], { True,False}] one= RandomInteger[ GeometricDistribution[0.1],n]; two= RandomInteger[ GeometricDistribution[0.1],n]; test[ a_List,b_List]:= Module[ { t1,t2,r1,r2}, { t1,r1}= Timing@ dp[ a,b]; { t2,r2}= Timing@ bt[ a,b]; { t1,t2, r1==r2}] test[ one,two] {5.53549000000001, 1.3797390000000007, True} test[two, one] {5.561236000000008, 1.3858140000000105, True} Oddly enough, BTW, replacing zeroQ by the built-in PossibleZeroQ slows b by a factor of more than 30. Still and all, Inner is the far simpler way to think of it, I suppose. Bobby > Whenever one wants to do operations on two equal length structures the > Inner > statement is a good choice. Reihe1 = {22, 33, 44, 0, 0, 16, 5, 0, 0, 0}; > Reihe2 = {16, 27, 0, 0, 5, 11, 5, 0, 0, 12}; Here we do the two tests and either insert the nonzero number in a new > list, > or insert an empty Sequence. The empty Sequence must be Unevaluated in > the > If statement or it would simply disappear for there. Inner[If[#1 == 0 [And] #2 != 0, #2, > Unevaluated@Sequence[]] &, Reihe1, Reihe2, List] > {5, 12} Inner[If[#2 == 0 [And] #1 != 0, #1, > Unevaluated@Sequence[]] &, Reihe1, Reihe2, List] > {44} This construction is also useful for the combination of equations. eqn1 = x == a + b; > eqn2 = y == a - b; Inner[#1 + #2 &, eqn1, eqn2, Equal] > x + y == 2 a Inner[Expand[2 #1 - #2] &, eqn1, eqn2, Equal] > 2 x - y == a + 3 b > -- = DrMajorBob@longhorns.com === Subject: Re: choose elements from list based on elements in different list Maybe ... tlist = Transpose[{Reihe1, Reihe2}]; Case3 = #2 & @@@ Cases[tlist, {0 , Except[0]}] Out[220]= {5, 12} Case4 = #1 & @@@ Cases[tlist, {Except[0] , 0}] Out[222]= {44} Tom Dowling > Im trying to choose elements from list based on elements in different > list and I came up with the ideas listed below. It seems to me that > there are a few too many steps involved here, and I need to run this on > larger lists (~20000 entries). > Are there ways to improve this? > Claus Here is the mathematica code: Reihe1={22,33,44,0,0,16,5,0,0,0} > Reihe2={16,27,0,0,5,11,5,0,0,12} {22, 33, 44, 0, 0, 16, 5, 0, 0, 0} {16, 27, 0, 0, 5, 11, 5, 0, 0, 12} (*Find out where in Reihe1 and in Reihe2 are Zeros and notZeros*) Reihe1Is0 = Thread[Reihe1 == 0] > Reihe1Not0 = Thread[Reihe1 != 0] > Reihe2Is0 = Thread[Reihe2 == 0] > Reihe2Not0 = Thread[Reihe2 != 0] {False, False, False, True, True, False, False, True, True, True} {True, True, True, False, False, True, True, False, False, False} {False, False, True, True, False, False, False, True, True, False} {True, True, False, False, True, True, True, False, False, True} (*Select the values of Reihe1 and Reihe2 which are of interest There are 4 Cases (not all of them calculated later) : > Case1 : Reihe1 and Reihe2 are 0 > Case2 : Reihe1 and Reihe2 are NOT 0 > Case3 : (Reihe2 is NOT 0) AND (Reihe1 is 0) > Case4 : (Reihe1 is NOT 0) AND (Reihe2 is 0)*) PreCase3=Pick[Reihe2,Reihe1Is0] > PreCase4=Pick[Reihe1,Reihe2Is0] {0, 5, 0, 0, 12} {44, 0, 0, 0} Case3=Select[PreCase3,#>0&] > Case4=Select[PreCase4,#>0&] {5, 12} {44} === Subject: Re: choose elements from list based on elements in different list Reihe1 = {22, 33, 44, 0, 0, 16, 5, 0, 0, 0}; Reihe2 = {16, 27, 0, 0, 5, 11, 5, 0, 0, 12}; try for PreCase3 Last /@ Select[Transpose[{Reihe1, Reihe2}], #[[1]] == 0 &] and First /@ Select[Transpose[{Reihe1, Reihe2}], #[[2]] == 0 &] for PreCase4 Jens > Im trying to choose elements from list based on elements in different > list and I came up with the ideas listed below. It seems to me that > there are a few too many steps involved here, and I need to run this on > larger lists (~20000 entries). > Are there ways to improve this? > Claus Here is the mathematica code: Reihe1={22,33,44,0,0,16,5,0,0,0} > Reihe2={16,27,0,0,5,11,5,0,0,12} {22, 33, 44, 0, 0, 16, 5, 0, 0, 0} {16, 27, 0, 0, 5, 11, 5, 0, 0, 12} (*Find out where in Reihe1 and in Reihe2 are Zeros and notZeros*) Reihe1Is0 = Thread[Reihe1 == 0] > Reihe1Not0 = Thread[Reihe1 != 0] > Reihe2Is0 = Thread[Reihe2 == 0] > Reihe2Not0 = Thread[Reihe2 != 0] {False, False, False, True, True, False, False, True, True, True} {True, True, True, False, False, True, True, False, False, False} {False, False, True, True, False, False, False, True, True, False} {True, True, False, False, True, True, True, False, False, True} (*Select the values of Reihe1 and Reihe2 which are of interest There are 4 Cases (not all of them calculated later) : > Case1 : Reihe1 and Reihe2 are 0 > Case2 : Reihe1 and Reihe2 are NOT 0 > Case3 : (Reihe2 is NOT 0) AND (Reihe1 is 0) > Case4 : (Reihe1 is NOT 0) AND (Reihe2 is 0)*) PreCase3=Pick[Reihe2,Reihe1Is0] > PreCase4=Pick[Reihe1,Reihe2Is0] {0, 5, 0, 0, 12} {44, 0, 0, 0} Case3=Select[PreCase3,#>0&] > Case4=Select[PreCase4,#>0&] {5, 12} {44} > === Subject: Re: choose elements from list based on elements in different list > It seems to me that there are a few too many steps involved here, We cant possibly guess which steps were necessary and which were not, as you havent told us what answers you actually needed... and which you did not. Bobby > Im trying to choose elements from list based on elements in different > list and I came up with the ideas listed below. It seems to me that > there are a few too many steps involved here, and I need to run this on > larger lists (~20000 entries). > Are there ways to improve this? > Claus Here is the mathematica code: Reihe1={22,33,44,0,0,16,5,0,0,0} > Reihe2={16,27,0,0,5,11,5,0,0,12} {22, 33, 44, 0, 0, 16, 5, 0, 0, 0} {16, 27, 0, 0, 5, 11, 5, 0, 0, 12} (*Find out where in Reihe1 and in Reihe2 are Zeros and notZeros*) Reihe1Is0 = Thread[Reihe1 == 0] > Reihe1Not0 = Thread[Reihe1 != 0] > Reihe2Is0 = Thread[Reihe2 == 0] > Reihe2Not0 = Thread[Reihe2 != 0] {False, False, False, True, True, False, False, True, True, True} {True, True, True, False, False, True, True, False, False, False} {False, False, True, True, False, False, False, True, True, False} {True, True, False, False, True, True, True, False, False, True} (*Select the values of Reihe1 and Reihe2 which are of interest There are 4 Cases (not all of them calculated later) : > Case1 : Reihe1 and Reihe2 are 0 > Case2 : Reihe1 and Reihe2 are NOT 0 > Case3 : (Reihe2 is NOT 0) AND (Reihe1 is 0) > Case4 : (Reihe1 is NOT 0) AND (Reihe2 is 0)*) PreCase3=Pick[Reihe2,Reihe1Is0] > PreCase4=Pick[Reihe1,Reihe2Is0] {0, 5, 0, 0, 12} {44, 0, 0, 0} Case3=Select[PreCase3,#>0&] > Case4=Select[PreCase4,#>0&] {5, 12} {44} -- DrMajorBob@longhorns.com === Subject: Re: choose elements from list based on elements in different list > Im trying to choose elements from list based on elements in different > list and I came up with the ideas listed below. It seems to me that > there are a few too many steps involved here, and I need to run this on > larger lists (~20000 entries). > Are there ways to improve this? > Claus Here is the mathematica code: Reihe1={22,33,44,0,0,16,5,0,0,0} > Reihe2={16,27,0,0,5,11,5,0,0,12} {22, 33, 44, 0, 0, 16, 5, 0, 0, 0} {16, 27, 0, 0, 5, 11, 5, 0, 0, 12} (*Find out where in Reihe1 and in Reihe2 are Zeros and notZeros*) Reihe1Is0 = Thread[Reihe1 == 0] > Reihe1Not0 = Thread[Reihe1 != 0] > Reihe2Is0 = Thread[Reihe2 == 0] > Reihe2Not0 = Thread[Reihe2 != 0] {False, False, False, True, True, False, False, True, True, True} {True, True, True, False, False, True, True, False, False, False} {False, False, True, True, False, False, False, True, True, False} {True, True, False, False, True, True, True, False, False, True} (*Select the values of Reihe1 and Reihe2 which are of interest There are 4 Cases (not all of them calculated later) : > Case1 : Reihe1 and Reihe2 are 0 > Case2 : Reihe1 and Reihe2 are NOT 0 > Case3 : (Reihe2 is NOT 0) AND (Reihe1 is 0) > Case4 : (Reihe1 is NOT 0) AND (Reihe2 is 0)*) PreCase3=Pick[Reihe2,Reihe1Is0] > PreCase4=Pick[Reihe1,Reihe2Is0] {0, 5, 0, 0, 12} {44, 0, 0, 0} Case3=Select[PreCase3,#>0&] > Case4=Select[PreCase4,#>0&] {5, 12} {44} > You didnt actually say what you are trying to achieve. Are you trying to pick those elements from Reihe1 for which the corresponding element of Reihe2 is nonzero? Then use Pick[Reihe1, Reihe2, Except[0, _Integer]] (The _Integer part was necessary because Except[0] matches the entire list.) === Subject: Re: choose elements from list based on elements in different list Whenever one wants to do operations on two equal length structures the Inner statement is a good choice. Reihe1 = {22, 33, 44, 0, 0, 16, 5, 0, 0, 0}; Reihe2 = {16, 27, 0, 0, 5, 11, 5, 0, 0, 12}; Here we do the two tests and either insert the nonzero number in a new list, or insert an empty Sequence. The empty Sequence must be Unevaluated in the If statement or it would simply disappear for there. Inner[If[#1 == 0 [And] #2 != 0, #2, Unevaluated@Sequence[]] &, Reihe1, Reihe2, List] {5, 12} Inner[If[#2 == 0 [And] #1 != 0, #1, Unevaluated@Sequence[]] &, Reihe1, Reihe2, List] {44} This construction is also useful for the combination of equations. eqn1 = x == a + b; eqn2 = y == a - b; Inner[#1 + #2 &, eqn1, eqn2, Equal] x + y == 2 a Inner[Expand[2 #1 - #2] &, eqn1, eqn2, Equal] 2 x - y == a + 3 b -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > Im trying to choose elements from list based on elements in different > list and I came up with the ideas listed below. It seems to me that > there are a few too many steps involved here, and I need to run this on > larger lists (~20000 entries). > Are there ways to improve this? > Claus Here is the mathematica code: Reihe1={22,33,44,0,0,16,5,0,0,0} > Reihe2={16,27,0,0,5,11,5,0,0,12} {22, 33, 44, 0, 0, 16, 5, 0, 0, 0} {16, 27, 0, 0, 5, 11, 5, 0, 0, 12} (*Find out where in Reihe1 and in Reihe2 are Zeros and notZeros*) Reihe1Is0 = Thread[Reihe1 == 0] > Reihe1Not0 = Thread[Reihe1 != 0] > Reihe2Is0 = Thread[Reihe2 == 0] > Reihe2Not0 = Thread[Reihe2 != 0] {False, False, False, True, True, False, False, True, True, True} {True, True, True, False, False, True, True, False, False, False} {False, False, True, True, False, False, False, True, True, False} {True, True, False, False, True, True, True, False, False, True} (*Select the values of Reihe1 and Reihe2 which are of interest There are 4 Cases (not all of them calculated later) : > Case1 : Reihe1 and Reihe2 are 0 > Case2 : Reihe1 and Reihe2 are NOT 0 > Case3 : (Reihe2 is NOT 0) AND (Reihe1 is 0) > Case4 : (Reihe1 is NOT 0) AND (Reihe2 is 0)*) PreCase3=Pick[Reihe2,Reihe1Is0] > PreCase4=Pick[Reihe1,Reihe2Is0] {0, 5, 0, 0, 12} {44, 0, 0, 0} Case3=Select[PreCase3,#>0&] > Case4=Select[PreCase4,#>0&] {5, 12} {44} > === Subject: Mixing graphics and text What is the easiest way to get an equation like the one below, but with + and = symbols being about 6 times larger? graphs = GraphData[]; n = 3; Riffle[GraphData /@ graphs[[2 ;; 1 + n]], Table[+, {n - 1}]]~ Join~{=, GraphData[graphs // First]} // Row === Subject: Variable Order Markov Models in Mathematica Does anyone know any implementation of the Variable Order Markov Models in Mathematica? Im particularly interested on the code of the following site: On Prediction Using Variable Order Markov Models http://www.cs.technion.ac.il/~ronbeg/vmm/index.html === Subject: Nice Mathematica stylestyle for Book Appendix Does anyone know a nice stylesheet ( at least to start with ) for adding some Mathematica notebooks as nice appendices to a book ( B5 format). I am using Mathematica 5.2 and the book is written in Adobe Framemaker 7.2 (all Windows) Printing as PDF and Importing into framemaker is possible but only page by page. Maybe there are other ways ?? Eternal glory for some help, Ger de Graaf . === Subject: Mixing immediate assignment and delayed assignment Hello I have some code akin to this: In[261]:= list1 = Table[Null, {j, 1, 5}]; For[i = 1, i <= 5, i++, list1[[i]] := some_list[[i]]; ] Which after its execution will have list1 filled with these references: {some_list[[6]], some_list[[6]], some_list[[6]], some_list[[6]], some_list[[6]]} But I would like the list to be filled with: {some_list[[1]], some_list[[2]], some_list[[3]], some_list[[4]], some_list[[5]]} In other words, I would like the assignment of i to be immediate, but the assignment of some_list to be delayed, as the list will be updated periodically. === Subject: Re: smallest fraction > hi suppose that we have an interval I belong to [0,1] I want to know how to calculate a fraction p/q > belong to I and p+q is the smallest possible One method is to use Minimize over integers, setting up appropriate bounding constraints. minFraction[lo_Rational, hi_Rational] /; 0 < lo < hi := Minimize[{p + q, {Denominator[lo]*p - Numerator[lo]*q >= 0, Denominator[hi]*p - Numerator[hi]*q <= 0, p >= 1, q >= 1}}, {p, q}, Integers] For example, well work with the interval from 2/7 to 4/9 inclusive. In[11]:= minFraction[2/7, 4/9] Out[11]= {4, {p -> 1, q -> 3}} If you want to enforce that the interval be strictly inside (0,1) you can have constraint q>=2. More generally you might try to strengthen constraints based on the input, should speed become an issue. Daniel Lichtblau Wolfram Research === Subject: Re: smallest fraction I doubt this is in the spirit of the problem, but if p and q (assumed integers) arent restricted to be _positive_, then taking them both to be very large negative numbers would both fit the p/q in I requirement, and p+q as small as possible. C.O. > hi suppose that we have an interval I belong to [0,1] I want to know how to calculate a fraction p/q > belong to I and p+q is the smallest possible -- 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: smallest fraction hi suppose that we have an interval I belong to [0,1] I want to know how to calculate a fraction p/q belong to I and p+q is the smallest possible === Subject: Poisson equation with boundary conditions on rectangle Im currently trying to solve the following pde with rectangle boundary (I better already use mathematica code here): The equation (Poisson equation): D[u[y, z], y, y] + D[u[y, z], z, z] + 1 == 0 The boundary conditions on the rectangle(y in [0,0.1] and z in [-0.4,0.4]): u[y, 0.4] == 0, u[y, -0.4] == 0, u[0, z] == 0, Derivative[1, 0][u][0.1, z] == 0 I tried the following in mathematica: eqn = D[u[y, z], y, y] + D[u[y, z], z, z] + 1 == 0; //defining equation NDSolve[{eqn, u[y, 0.4] == 0, u[y, -0.4] == 0, u[0, z] == 0, Derivative[1, 0][u][0.1, z] == 0 }, u, {y, 0, 0.1}, {z, -0.4, 0.4}] //using NDSolve to solve the boundary problem But, as you might guess, I get an error using NDSolve the way above: NDSolve::ivone: Boundary values may only be specified for one independent variable. Initial values may only be specified at one value of the other independent variable. When I lookup the description of that error I realize that in my example the following error condition matches: This input generates a message because the equations specify values for the solution on all sides of the solution region. Does this mean, that mathematica cant approximate the solution to my problem with NDSolve or am I doing something wrong? So overall question is: How can I solve my problem using mathematica without writing my own numerical pde solver for my problem? === Subject: Re: finding positions of elements in a list There are many different ways mylist = {{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}}; threshold = 108; Select[mylist, #[[2]] > threshold &] Cases[mylist, _?(#[[2]] > threshold &)] Cases[mylist, {_, _?(# > threshold &)}] DeleteCases[mylist, _?(#[[2]] <= threshold &)] mylist /. {_, _?(# <= threshold &)} -> Sequence[] Pick[mylist, Thread[mylist[[All, 2]] > threshold]] Bob Hanlon > Hi. Having a few problems here with what I think should be a simple operation. I have a list as shown: mylist={{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107},...} Its a list of {x,y} co-ordinates of some data points Im analysing. I want to create a new list which contains only those data points whose y co-ordinate is greater than 80 ie. mylist[[n,2]]>80. Problem is, I cant work out how to use Select to do this when each element in the list has an x and a y co-ordinate. If I split the list into x and y co-ordinates and searched for those y values greater than 80, I would have a list of those y-values but would not know the corresponding x-values. I also tried Position but it wasnt clear to me if a pattern can be used for this. === Subject: Re: floating point issue K = Rationalize[{111.5, 10.5, 1.5}, 0]; g = Rationalize[{-0.7071068, 0., -0.7071068}, 0]; K.Cross[K, g] 0 K = {111.5`25, 10.5`25, 1.5`25}; g = {-0.7071068`25, 0.`25, -0.7071068`25}; Chop[K.Cross[K, g], 10^-18] 0 Bob Hanlon > Hi everyone, I wonder if I can get some opinions on the best way to deal with this > precision issue I am having. I define the vectors: K = {111.5, 10.5, 1.5} > g={-0.7071068, 0., -0.7071068} And I need this: K.Cross[K, g] to be 0 in accordance with a vector identity. The answer comes out to > around 1.3 x 10^(-13), which is certainly close to 0 but not close > enough for what Im doing. Ive tried various things like writing out > the cross product explicitly without using the functions but the result > is the same. And using N in various places doesnt seem to help either. > Whats the standard solution for this kind of thing? Chris > === Subject: Re: Bug: symbol recreates itself suddenly Unfortunately - it doesnt work (at least in my Win32 6.0 version). Trying to do SetAttributes[E,Locked] leads to lock symbol E as Euler constant, not to lock it as Removed E. Severin Posta yes, because E is used in so many mathematical expressions > like Exp[] that Mathematica cant live without it. > To avoid such nonsense add > SetAttributes[E,Locked] Jens > It seems to me that after Remove[symbol] some times the symbol is >> recreated without notice. Consider the following example. >> How to repeat: >> In[1]:= $Version >> Out[1]= 6.0 for Microsoft Windows (32-bit) (April 20, 2007) >> In[2]:= Unprotect[E]; ClearAttributes[E, {Constant, Protected, >> ReadProtected}]; Remove[E]; >> In[4]:= ?E >> During evaluation of In[4]:= Information::notfound: Symbol E not found. >> >> In[5]:= Solve[E == 2] >> Out[5]= {{Global`E -> 2}} >> (* ?! *) >> In[6]:= ?E >> E is the exponential constant e (base of natural logarithms), with >> numerical value [TildeEqual]2.71828. >> (* THIS IS NOT CORRECT ANSWER *) >> Severin Posta > === Subject: Re: Bug: symbol recreates itself suddenly This is definitely NOT the correct answer. The correct answer is (should be) Symbol E not found. By all means this is really a bug. It has far-reaching consequences. Using symbol E afterwards can lead to mistakes because Mathematica thinks (suddenly!) this is again Euler constant, not general symbol. Please dont ask why am I doing this. This is not forbidden according to manual - and it worked in 4.0, 5.0, 5.2 versions. It should work in 6.0 either. (Or it should be documented.) Severin Posta > In[6]:= ?E E is the exponential constant e (base of natural logarithms), with > numerical value [TildeEqual]2.71828. > > (* THIS IS NOT CORRECT ANSWER *) Oh yes, it certainly IS the correct answer. Why do you want to Remove built-in constants? (Regardless of whether it > might or might not work to do so?) Bobby > It seems to me that after Remove[symbol] some times the symbol is >> recreated without notice. Consider the following example. >> How to repeat: >> In[1]:= $Version >> Out[1]= 6.0 for Microsoft Windows (32-bit) (April 20, 2007) >> In[2]:= Unprotect[E]; ClearAttributes[E, {Constant, Protected, >> ReadProtected}]; Remove[E]; >> In[4]:= ?E >> During evaluation of In[4]:= Information::notfound: Symbol E not >> found. >> In[5]:= Solve[E == 2] >> Out[5]= {{Global`E -> 2}} >> (* ?! *) >> In[6]:= ?E >> E is the exponential constant e (base of natural logarithms), with >> numerical value [TildeEqual]2.71828. >> (* THIS IS NOT CORRECT ANSWER *) >> Severin Posta > > -- = DrMajorBob@longhorns.com > === Subject: 6.0.2: Input cells font darker now? I just installed 6.0.2 under Windows XP on a new system (when my old system died that had been running 6.0.1). Now the font in Input cells seems much darker and thicker than I am accustomed to seeing -- on many different systems. Did something change in this regard, either in the fonts themselves or in the default settings for Input cells? Im using a different graphics card now (although at the same resolution and on the same LCD monitor). And at the moment I havent yet installed Adobe Type Manager (although since Mathematica does not use PostScript fonts under Windows, I cannot imagine why thats an issue). -- 3 545-1801 Amherst, MA 01003-9305 === Subject: Re: Compiled function slowdown mm1q === Subject: Re: How to import a Matlab mat-file > I have some data that I received from a colleague that > is a rather large mat file. Data.mat. The file was > generated with Matlab 2007b. Mathematica 6.0.1 cannot import version 7 .mat files. Ideally, your colleague should export the files using the following syntax: >> save -v6 Data.mat; If that is not an option, you can download Octave, an open source Matlab clone, from http://www.octave.org/. You can then read the .mat file into Octave and save it in the correct format via: >> load Data.mat; >> save -v6 Data2.mat; Mark === Subject: What is the fastest way to threshold data? I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to set the z-values to zero if they fall below zero. More generally, I would like to set z to a threshold value if it is at or below a threshold. This seems as though it should be an easy enough thing to do, but the only way I have figured out is to parse out the z-vector, do mask=((#<thresh&) /@ zdata)/.True->0/.False->1; then zvector = zvector*mask; and rebuild the {x,y,z} data. Kevin -- === Subject: Re: What is the fastest way to threshold data? > I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to set > the z-values to zero if they fall below zero. More generally, I would > like to set z to a threshold value if it is at or below a threshold. > This seems as though it should be an easy enough thing to do, but the > only way I have figured out is to parse out the z-vector, do mask=((#<thresh&) /@ zdata)/.True->0/.False->1; then > zvector = zvector*mask; and rebuild the {x,y,z} data. Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 You probably need Clip: L[[All,3]]=Clip[L[[All,3]],{0,Infinity}] Raj === Subject: Re: What is the fastest way to threshold data? responding to my query. I looked at each and they all work as expected, of course. The fastest is the suggestion due to Carl to use Clip: threshold = 0.75; data = RandomReal[{-1, 1}, {1000000, 3}]; Timing[data[[All, 3]] = Clip[data[[All, 3]], {threshold, Infinity}];] This runs in about 0.1s on my computer and is at least 10 times faster Kevin > I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to set > the z-values to zero if they fall below zero. More generally, I would > like to set z to a threshold value if it is at or below a threshold. > This seems as though it should be an easy enough thing to do, but the > only way I have figured out is to parse out the z-vector, do mask=((#<thresh&) /@ zdata)/.True->0/.False->1; then > zvector = zvector*mask; and rebuild the {x,y,z} data. Kevin -- === Subject: Re: What is the fastest way to threshold data? > I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to > set > the z-values to zero if they fall below zero. More generally, I would > like to set z to a threshold value if it is at or below a threshold. > This seems as though it should be an easy enough thing to do, but the > only way I have figured out is to parse out the z-vector, do mask=((#<thresh&) /@ zdata)/.True->0/.False->1; then > zvector = zvector*mask; and rebuild the {x,y,z} data. I would apply a function to each point: If[#3<=thresh,{#1,#2,thresh},{##}]&@@@data Ssezi === Subject: Re: What is the fastest way to threshold data? >I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to set >the z-values to zero if they fall below zero. More generally, I would >like to set z to a threshold value if it is at or below a threshold. >This seems as though it should be an easy enough thing to do, but the >only way I have figured out is to parse out the z-vector, do mask=((#<thresh&) /@ zdata)/.True->0/.False->1; then >zvector = zvector*mask; and rebuild the {x,y,z} data. Kevin > > I would do this as follows: In[101]:= mat = RandomReal[{-1, 1}, {10, 3}] Out[101]= {{-0.574316, 0.0429482, 0.679336}, {0.696716, 0.0813526, -0.886499}, {0.622524, 0.687576, 0.197264}, {-0.196498, -0.263147, -0.538339}, {0.454982, 0.0226721, -0.609805}, {-0.116741, -0.491716, -0.561586}, {0.760373, -0.482596, 0.46804}, {-0.125821, 0.899048, 0.606259}, {0.760627, -0.441741, -0.668888}, {-0.767075, 0.646638, 0.737813}} In[102]:= mat[[All, 3]] = Clip[mat[[All, 3]], {0, Infinity}]; In[103]:= mat Out[103]= {{-0.574316, 0.0429482, 0.679336}, {0.696716, 0.0813526, 0.}, {0.622524, 0.687576, 0.197264}, {-0.196498, -0.263147, 0.}, {0.454982, 0.0226721, 0.}, {-0.116741, -0.491716, 0.}, {0.760373, -0.482596, 0.46804}, {-0.125821, 0.899048, 0.606259}, {0.760627, -0.441741, 0.}, {-0.767075, 0.646638, 0.737813}} Carl Woll Wolfram Research === Subject: Re: What is the fastest way to threshold data? With[{nn = 64}, data = Table[RandomReal[{-1, 1}], {nn}, {nn}, {nn}, {3}] ]; and thdata = Map[If[#[[3]] > 0, #, {1, 1, 0}*#] &, data, {3}]; may help Jens > I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to set > the z-values to zero if they fall below zero. More generally, I would > like to set z to a threshold value if it is at or below a threshold. > This seems as though it should be an easy enough thing to do, but the > only way I have figured out is to parse out the z-vector, do mask=((#<thresh&) /@ zdata)/.True->0/.False->1; then > zvector = zvector*mask; and rebuild the {x,y,z} data. Kevin === Subject: Re: Findroot for large data sets bump... Mods posted with a 3 day delay. John === Subject: Export Data from Mathematica to Excel I have a Mathematica matrix format by (5*2) below Var1, 12 Var2, 3 Var3, 45 Var4, 78 Var5, 6 How can I export this matrix to an Excel file? Tugrul === Subject: Re: How to import a Matlab mat-file >colleague that is a rather large mat file. Data.mat. The file was >generated with Matlab 2007b. Per the documentation that can be found at ref/format/MAT, Import can deal with MAT files produced by version 4 and 5 of Matlab. Possibly this is the issue? If the default save format of the version your colleague is using differers from what Import expects, that would account for your difficulty. The phrasing in the documentation for the MAT format used by Mathematica implicitly assumes later versions of Matlab will create either level 4 or level 5 MAT files. It does not and cannot guarantee later versions of Matlab by default create such files. -- To reply via email subtract one hundred and four === Subject: Labeling axes in VectorFieldPlot3D? This works OK in V6 << VectorFieldPlots` m = {1, 0, 0}; r = {x, y, z}/Sqrt[x^2 + y^2 + z^2]; B = (3 (m.r) r - m) VectorFieldPlot3D[B, {x, -1, 1}, {y, -1, 1}, {z, 0.01, 1}, VectorHeads -> True] listed. But inserting that option in the plot statement is ignored -- and AxesLabel is made red -- apparently something it doesnt like. Sure would like to identify the 3 axes, === Subject: Re: Labeling axes in VectorFieldPlot3D? The following works: VectorFieldPlot3D[B, {x, -1, 1}, {y, -1, 1}, {z, 0.01, 1}, VectorHeads -> True, Axes -> True, AxesLabel -> {x, y, z}] You had to put in Axes -> True. However, the Axes options do appear in red and that is because WRI did not define the options for VectorFieldPlot3D properly for use in the SyntaxInformation statement. Nevertheless, they work. Those who have Presentations and want much nicer looking 3D arrows, with colored arrowcones, can use: Needs[Presentations`Master`] Draw3DItems[ {ColorData[Legacy][IndianRed], VectorFieldDraw3D[B, {x, -1, 1}, {y, -1, 1}, {z, 0.01, 1}, VectorHeads -> False, ScaleFunction -> (#/5 &)] /. Line[{tail_, head_}] :> Arrow3D[tail, head, {0.30, 0.07, 12, AbsoluteWidth}, {AbsoluteThickness[1], Black}]}, NeutralLighting[0.2, 0.6, 0.1], NiceRotation, Axes -> True, AxesLabel -> {x, y, z}, ImageSize -> 400] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > This works OK in V6 << VectorFieldPlots` m = {1, 0, 0}; > r = {x, y, z}/Sqrt[x^2 + y^2 + z^2]; > B = (3 (m.r) r - m) > VectorFieldPlot3D[B, {x, -1, 1}, {y, -1, 1}, {z, 0.01, 1}, > VectorHeads -> True] listed. But inserting that option in the plot statement is > ignored -- and AxesLabel is made red -- apparently something > it doesnt like. Sure would like to identify the 3 axes, > === Subject: Re: Maximize Command - Problem > Well, Syd sent me an email and told me to try this:(well, I forgot to ment= ion that we have to define a=1;b=1;c=1;d=1;) fun[x_, y_, z_] =4*(a^2 + (b^2 + c^2 +d^2) (Cos[x])^2*(Cos[y])^2*(Cos[z= ])^2 + (b*Cos[x]*Cos[y]*Cos[z] +Cos[x]*Sin[y] + d*Sin[x])^2); And then: Maximize[{fun, -Pi/2 < x < Pi/2 && -Pi/2 < y < Pi/2 && 0 < z < 2*Pi}, {x,= y,z}] It displayed an error. So I modified to Maximize[{fun[x, y, z], -Pi/2 < x < Pi/2 && -Pi/ =A0 =A0 2 < y < Pi/2 && 0 < z < 2*Pi}, {x, y, z}] And the command runs for a while and then it displays my input. > Omg, this is frustrating, I dont know what=B4s the problem. > Theres probably an easy way to prove that the maximum will be attained for Cos[z] == 1, but theres also the brute force way: In[1]:= fun[x_, y_, z_] = 4 (a^2 + (b^2 + c^2 +d^2) (Cos[x])^2 (Cos[y])^2 (Cos[z])^2 + (b Cos[x] Cos[y] Cos[z] + Cos[x] Sin[y] + d Sin[x])^2) /. a|b|c|d -> 1; Maximize[fun[x, y, z] /. s:x|y|z -> 2 ArcTan[s] // TrigExpand, {x, y, z}] Out[2]= {16 + 4 Sqrt[3], {x -> Root[1 - 44 #1^2 + 294 #1^4 - 44 #1^6 + #1^8 &, 1], y -> Root[1 - 4 #1 - 10 #1^2 + 4 #1^3 + #1^4 &, 3], z -> 0}} Then it can be verified that {x -> ArcSin[1/2 Sqrt[1 - 1/Sqrt[3]]], y - > ArcSin[Sqrt[1/13 (5 - 2 Sqrt[3])]], z -> 0} gives the same value and satisfies the constraints for x and y, with z being on the boundary. Maxim Rytin m.r@inbox.ru === Subject: Re: Localizing Large Numbers of Variables in a DynamicModule: << With[{args = {x1,x2,x3,x4,x5}}, DynamicModule[args, foo@@args; goo@@args; ... ] ] < Yes this allows the arguments to be referred to within the body of the With but the question really came in two parts, the first relating to the ability to externally group these variables and the second, to make these variables available to all functions during the evaluation of the DynamicModule. It is the second part that seems to be the challenge. As the following examples show, in some specialized cases these local variables can be made without explicit passing but, in general, DynamicModules scoping is not sufficiently Block-like for this to occur. In particular, the scoping seems to be a Module-Block hybrid that depends on whether or not a Dynamic subsequently wraps around a declared loca variable somewhere in the DynamicModules initial evaluation. * DynamicModule local variables can sometimes (but unreliably) be Block-like in relation to their local variables in the initial execution, Module-like in terms of generating new variables and DynamicModule-like in their subsequent behaviour in the Front-end. * Mixing Block & DynamicModule can lead to unexpected behaviour especially with any variable shadowing. * Despite the resulting code-bloat and inconvenience, passing all dynamic variables to nested functions appears safer mainly due to more predictable scoping and predictable updating. * Even with passing all DynamicModule variables there are some subtleties that distinguish it from With, Module and Block .* Much flexibility would be gained if we had Meta Scoping - the ability to functionally add scoped variables to DynamicModule code blocks. This would not only allow eliminate the aforementioned code-bloat but assist with engineering and controlling Dynamic updating, maintain Syntax Coloring and finally also allow more flexible and interactive Dynamic Code generation. Just to recap the initial question and its motivation. The DynamicModule construct is very useful for creating Interfaces whose dynamic variables are made spacially local. Most of the examples of DynamicalModule Ive observed however, seem to include the body of the code (lexically) within the DynamicalModule definition (i.e. directly between the [ and ]). This simplifies initialization, scoping and intended Dynamic Updating. In designing more complex interfaces however, this lexical placement quickly becomes unwieldy and one way of managing (and parallelizing) this complexity is to instead place function calls within the body of the DynamicModule. These functions could, for example, be thought of as corresponding to different components in an overarching interface. This process however, significantly affects the initialization, scoping and intended updating of these DynamicModule variables and one of the points of the following is to see what these effects are and how they can be managed. Hence in some of these toy examples the demonstrated idioms may appear unnecessary or unmotivated but it needs to remembered that the point here is to consider the usefulness of the idioms for large numbers of variables and functions and where any global variables can be considered to be in the Private` namespace of an associated package. Firstly here is the idiom Im after VARS = {x1, x2, x3, x4}; f[] := Interface Component A that accesses some or all of VARS; g[] := An Interface Component B that accesses some or all of VARS; DynamicModule[ VARS, OverArchingInterface[ f[], g[] ] ] (* NOT VALID *) So essentially I want Blocks temporary globalization to apply to DynamicModules local variables so that other evaluated function (f and g ) have access to these variables even if they are not explicitly passed. The With idiom of insertion without evaluation as initially suggested in the reply certainly allows one to define all the arguments in the one place but, in general (as will be shown) this does not produce Block-like scoping. One might wonder why one would want to this Block-like behaviour since all the arguments, can be passed at once (and in some situations is good programming practice -especially when not done in a package namespace while the extra overhead of passing a variable space is neglible). For example, ARGS = {x1, x2}; f1[args_] := With[{x1 = args[[1]], x2 = args[[2]]}, {Slider2D[Dynamic[{x1, x2}]], {Dynamic@x1, Dynamic@x2}}]; With[{args = ARGS}, DynamicModule[args, f1[args]]] The point though here is when VARS contains a large number of variables that are required by many functions often deeply placed. In these cases the variables need to eventually extracted from within the nested function and hence in a sense the unwieldeness has just been deferred. At first, the Block-like behaviour appears to already be present. ARGS = {x1, x2}; f2[] := {Slider2D[Dynamic[{x1, x2}]], {Dynamic@x1, Dynamic@x2}}; With[{args = ARGS}, DynamicModule[args, f2[]]] That is, both x1 and x2 were not passed explicitly but remain completely local to the DynamicModule. That is, if you copy and paste this output the 2D slider are not linked via global variables x1, x2. This however does not work in general. Since this is a scoping issue of DynamicModule it is easier to observe without the With clutter (which also adds complications in any initializations). Take the following: Clear@x1; g1[] := x1; f3[] := Dynamic@x1; DynamicModule[{x1}, {g1[], f3[]}] ---> {x1$$, FE`x1$$14} In the evaluation of DynamicModules body the locally declared variable is cast as local if it is wrapped in a Dynamic. Otherwise it is is cast as a global variable. Initiallizing with some values can make this clearer. Clear@x1; g1[] := x1; x1 = 1; f4[] := Dynamic@x1; DynamicModule[{x1 = 0}, {g1[], f4[]}] --> {1,0} That is, within g1 the local variable is cast as global whereas within f4 the Dynamic wrapper ensures that x1 is cast to the local DynamicModule variable. Hence it order to ensure that a variable is cast as the local DynamicModule variable it must be wrapped in a Dynamic wrapper and evaluated with the initial DynamicModule evaluation. Take the following f5[] := {Slider[Dynamic@x], {Dynamic@x}}; DynamicModule[{x}, {f5[], Dynamic[f5[]]}] The output shows two sliders and with their respective linked variable. The first behaves as desired with x being cast to the locally declared DynamicalModule variable. The second slider however, while initially showing the same functionality, is actually using a global value of x without any casting taking place. This can be confirmed by copying and pasting the output to another part of the notebook and observing that the second sliders are coupled. This is because casting doesnt take place since in the Dynamic[f5[]] because the f5[] expression is not immediately evaluated due to Dynamics HoldAll Attribute. In this case, it can be avoided by pushing the First Dynamic deeper in order to ensure that the local variables are seen in the initial valuation thus enabling casting. f6[] := Dynamic[{Slider[Dynamic@x], {Dynamic@x}}]; DynamicModule[{x}, f6[]] A more fundamental problem however, is that since the scope of a local variable depending on its initial evaluation this is not something a programmer will either want or sometimes be able to trace. In particular, it can depend on the logical control which can lead to unexpected results. For example in the following the intention is for z to be cast as a local DynamicModule variable. g2[] := {SetterBar[Dynamic@z, {z1, z2, z3}], Dynamic@z}; f7[] := Dynamic[If[x, nothing, g2[]]]; DynamicModule[{x = True, z}, {Checkbox[Dynamic@x], f7[]}] At first, the output may appear to work as intended however, note that the Dynamic@z term in g2 is not seen in the initial evaluation of the DynamicModule. This means that the variable z remains global not being cast to its local DynamicModule namesake. This can be observed by placing another copy of the output into another cell, unchecking both checkboxes and observing that the two SetterBars are linked via this global variable. This seems to pretty much be the death knell for any hopes for Block-like behaviour from DynamicModule. One can try to co-opt but Blocks behaviour directly but as the following examples show (apart from some unexpected Block variables interaction) this doesnt provide a solution either: g2[] := {SetterBar[Dynamic@z, {z1, z2, z3}], Dynamic@z}; f7[] := Dynamic[If[x, nothing, g2[]]]; Block[{x, z}, DynamicModule[{x = True, z}, {Checkbox[Dynamic@x], f7[]}]] nor does g2[] := {SetterBar[Dynamic@z, {z1, z2, z3}], Dynamic@z}; f7[] := Dynamic[If[x, nothing, g2[]]]; DynamicModule[{x = True, z}, Block[{x = False, z}, {Checkbox[Dynamic@x], f7[]}]] Curiously in the last example, the inner Block initializations do not over-ride the outer DynamicModule. There are other possibilites that may simulate this behaviour - use of Preread to pre parse this list of arguments and the use of Interpretation but all seem to get stuck on Mathematica lexical scoping. Therefore it seems that trying to create a Block-like variable space is not really viable under the current DynamicModule scoping since such scoping depends on the control flow in the evaluation of the body of the DynamicModule. Hence, unfortunately it appears if that one is forced to adopt the potentially unweildy process of passing all relevant arguments to subfunctions in order to avoid this automatic casting. Ultimately then the issue here seems to be Mathematicas exclusive use of lexical scoping rather than what Ill coin meta scoping. Adding meta scoping to DynamicModule (with Refresh integration) - the ability to functionally assign variable scoping to a function (say via its Attribute property) - would, I think, do several things - it would allow greater flexibity in organizing and managing argument spaces, the maintainenance of syntax coloring, the production of more readable code and the ability to interactively fashion dynamic interfaces. Even with performing normal argument passing however, there are several points worth noting in relation to DynamicModule local variable behaviour. Some of these are related to finding workarounds to the earlier examples and hence are added here for completeness The position of a wrapping Dynamic can DynamicModules scope and lead to unintended behaviour. Imagine in the following f represents - say an updateable sub-inteface f8[x_] := {Slider[Dynamic@x], {Dynamic@x}}; DynamicModule[{x}, Dynamic[f8[x]]] Moving the right-hand slider produces an error about not being able to assign to a raw object - in this case the current local value of the DynamicModule x. This is due to to, during a dynamical update of f8, xs lastest value of 0 being inserted into Dynamic[x]. Further movement of this slider results in an assignment being attempted to this number instead of x. As before, this can be resolved by placing placing the Dynamic more deeply. f8[x_] := Dynamic[ {Slider[Dynamic@x], {Dynamic@x}}]; DynamicModule[{x}, f8[x]] Another point in modularizing code for dynamic interfaces is that initialising DynamicModule local variables can lead to premature evaluations. For example, take the following DynamicModule[{x = True}, {Checkbox[Dynamic@x], Dynamic@x}] to be broken down idiomatically as follows f9[x_] := {Checkbox[Dynamic@x], Dynamic@x}; DynamicModule[{x = True}, f9[x]] Clicking the CheckBox creates an error as the box attempts to change the protected True Symbol. One straightforward way of dealing with this is to create an Initialization wrapper that performs any initializations after the interface has been created (N.B. this collects all the initializations in one spot - ControlObjects can perform their own initializations if distributing these in the code is not a problem) f9[x_] := {Checkbox[Dynamic@x], Dynamic@x}; Initializations[x_] := {x = True}; DynamicModule[{x}, With[{pre = f9[x]}, Initializations[x]; pre]] Even without initializations within the DynamicModule variable declarations, a premature evaluation can result. This can be managed, with the normal HoldAll Attribute setting.For example, recall the earlier example, that demonstrated how logical dependencies in the DynamicModules body can affect the scope of its local variables. To avoid this with variable passing one might at a first pass try the following g2a[z_] := {SetterBar[Dynamic@z, {z1, z2, z3}], Dynamic@z}; f7a[x_, z_] := Dynamic[If[x, nothing, g2a[z]]]; DynamicModule[{x, z}, {Checkbox[Dynamic@x], With[{pre = f7a[x, z]}, x = True; pre]}] Now de-select the checkbox to reveal the z-setter and then try and set z to z1. Youll get that familiar complaint about the setting of raw objects. This is because this value of z is being inserted into the setter bar. This can be delayed by changing g2as HoldAll Attribute g2a[z_] := {SetterBar[Dynamic@z, {z1, z2, z3}], Dynamic@z}; SetAttributes[g2a, HoldAll]; f7a[x_, z_] := Dynamic[If[x, nothing, g2a[z]]]; DynamicModule[{x, z}, {Checkbox[Dynamic@x], With[{pre = f7a[x, z]}, x = True; pre]}] And the output works with all variables being suitably localized (which again can be checked by the decoupling of any pasted copies) Ron > > Im wondering if anyone can see a shorter way of localising a large number of variables within a DynamicModule? For example, instead of > DynamicModule[{x1,x2,x3,x4,x5}, > oo[x1,x2,x3,x4,x5]; > oo[x1,x2,x3,x4,x5]; > something with an idiom along the lines of > args={x1,x2,x3,x4,x5}; > DynamicModule[args, > oo[args]; > oo[args] > I really dont understand what you are trying to achieve here ... but perhaps you will find some inspiration in this: With[{args = {x1,x2,x3,x4,x5}}, DynamicModule[args, oo@@args; oo@@args; ... ] ] With[] will just subsitute {x1,x2,x3,x4,x5} for every instance of args before it evaluates its body. Szabolcs === Subject: Re: about scoping in modules >> in the next two modules I would like that the inner module uses a variable from the outer module. >> mfb[oneObj_] := Module[{ttmp = oneObj},AppendTo[ global2mfb, ttmp]] >> mfa[e_] := Module[{global2mfb = e, t = 3},mfb[t] ] >> mfa[{2,3}] gives a message that global2mfb is not a variable with a value, so it can not be changed. >> It means I do not understand the concept of module in Mathematica. My questions are: >> 1. why does it go wrong? >> 2. how can I realize what I want? >> with friendly greetings, >> P_ter > Well, despite its name, global2mfb is local to the Module in which it > appears - so using it elsewhere refers to a global variable of the same > name with no value - hence the diagnostic. This is the purpose of Module > - to stop one use of a variable clashing with another. >> Take the assignment global2mfb=e outside the list of local > initialisations, and I think you will get what you want. > almost, >> AppendTo needs a reference not an explicit List >> such as >> x={1,2} >> AppendTo[x,1] >> AppendTo[{1,2},3] can not work since: >> Attributes[ AppendTo] >> you could not access the result. >> Oliver >> Oliver Ruebenkoenig, <ruebenko AT uni-freiburg.de Sorry, I dont know what you mean. Here is the original code modified as > I suggested: In[86]:= mfb[oneObj_]:=Module[{ttmp=oneObj},AppendTo[global2mfb,ttmp]]; > mfa[e_]:=Module[{t=3}, > global2mfb=e; > mfb[t]] > In[88]:= mfa[{2,3}] > Out[88]= {2,3,3} AppendTo is operating on a variable (or reference, if you prefer)! David Bailey > http://www.dbaileyconsultancy.co.uk Sorry, David, you are right. I do not know what I was thinking - probably not at all :-( Oliver Oliver Ruebenkoenig, <ruebenko AT uni-freiburg.de> === Subject: Re: input style within a text style cell > Hi Mariano, If in a text style cell I select some words and go to Format -> Style- > Input, the words I select end up being formatted as, well, Input > cells. If, on the other hand, I select some text in a cell in text > style and then hit Alt-9 (which is the shortcut for that menu item) > the _whole_ cell becomes converted to Input style. which version/OS do you use? It works for me with version 6 on Windows > XP as you (we) expect... oh, one thing, using Shift-Alt-9 does what you describe for me, but it > still works as it should even with Caps Lock switched on... This is the Linux 6.0.1 version. Shift-Alt-9 results in a beep with the message `You used a Command or Control Key combination which is not defined to do anything (Hint to WRIs UI people: its always nice to have the text in message boxes like the one in Help -> Why the Beep? be selectable, so that one does not need to copy it by hand like I just did ;-) ) Also, from what I can tell NumLock does not have an effect on this. -- m === Subject: Re: Another question on Assuming > The first example in the Mathematica Help on Assuming is (in part) Assuming[a > 0, Refine[Sqrt[a^2]]] which results in the answer a, as it should; however if I type instead Assuming[a > 0, Sqrt[a^2]] I get back Sqrt[a^2]], but I should get a, since there is no other > correct answer, because the assumption that a > 0 implies that it a > is a > positive real. Bug? Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 > This is not a bug but a design feature. Assuming works only with functions such as Simplify, Refine, Integrate, Limit etc., that have Assumptions among their options (the one exception is PowerExpand). Youve got to use one of such functions, so, for example, even this will work: Assuming[a > 0, Limit[Sqrt[a^2], x -> b]] a However, in the case of a function like Sqrt, which does admit the Assumptions option (in fact, it admits no options) Assuming does nothing at all. Andrzej Kozlowski === Subject: Re: Another question on Assuming Dont have that much experience with Assuming[], but from the documentation: Assuming[assum,expr] evaluates expr with assum appended to $Assumptions, so that assum is included in the default assumptions used by functions such as Refine, Simplify and Integrate. So it seems to me like perhaps only certain functions can take assumptions, and Sqrt cant you need to use refine around it. Kajetan Sikorski > The first example in the Mathematica Help on Assuming is (in part) Assuming[a > 0, Refine[Sqrt[a^2]]] which results in the answer a, as it should; however if I type instead Assuming[a > 0, Sqrt[a^2]] I get back Sqrt[a^2]], but I should get a, since there is no other > correct answer, because the assumption that a > 0 implies that it a is a > positive real. Bug? Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 === Subject: Re: Another question on Assuming > The first example in the Mathematica Help on Assuming is (in part) Assuming[a > 0, Refine[Sqrt[a^2]]] which results in the answer a, as it should; however if I type instead Assuming[a > 0, Sqrt[a^2]] I get back Sqrt[a^2]], But you didnt ask that anything be _done_ to Sqrt[a^2]. Note that we can use Simplify instead of Refine: In[5]:= Assuming[a > 0, Simplify[Sqrt[a^2]]] Out[5]= a > but I should get a, since there is no other correct answer, No. Sqrt[a^2] is correct also; its just not as simple as you want. David > because the assumption that a > 0 implies that it a is a > positive real. Bug? Kevin === Subject: Re: Another question on Assuming Hi Kevin, the manual tells you that Assuming does nothing else than append the assumptions to $Assumptions and then evaluates expr. Your expression is Sqrt[a^2] that does not care about $Assumptions. Therefore, you need Refine that will care. hope this helps, Daniel > The first example in the Mathematica Help on Assuming is (in part) Assuming[a > 0, Refine[Sqrt[a^2]]] which results in the answer a, as it should; however if I type instead Assuming[a > 0, Sqrt[a^2]] I get back Sqrt[a^2]], but I should get a, since there is no other > correct answer, because the assumption that a > 0 implies that it a is a > positive real. Bug? Kevin === Subject: How to select terms wanted in a series I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! === Subject: Re: How to select terms wanted in a series I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! There are many ways to do this. I prefer the next one: Apply[List,Expand[Coefficient[e1, x*y]*x*y]]. === Subject: Re: How to select terms wanted in a series I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! In[1]:= expression = x + 2x*y - x*y*z + u*x*y + 3u^2; In[2]:= Select[expression, MatchQ[#, c_.*x*y]&] Out[2]= 2 x y + u x y - x y z In[3]:= List@@% Out[3]= {2 x y, u x y, -(x y z)} Bhuvanesh, Wolfram Research === Subject: Re: How to select terms wanted in a series I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! > Cases[expression, _?( ! FreeQ[#1, x*y] & )] {2*x*y, u*x*y, (-x)*y*z} or Select[List @@ expression, Not[FreeQ[#, x*y]] &] {2 x y, u x y, -x y z} or even x*y*List @@ (GroebnerBasis`DistributedTermsList[expression, {x, y}] [[1, 1, 2]]) {2 x y, u x y, -x y z} and many more. Andrzej Kozlowski === Subject: Re: How to select terms wanted in a series Personally, I would not convert to a list but use a combination of Select, MemberQ and FreeQ. Something like as follows (where the hash, #, is the pure function symbol) : Select[expression,MemberQ[#1,y]&&MemberQ[#1,x]&&FreeQ[#1,z]&&FreeQ[#1,u]&] Out[95]= 2 x y Select [expression, MemberQ[#1,u^2 ] &] Out[97]= 3 u^2 Select [expression, MemberQ[#,x]&] Out[99]= 2 x y+u x y-x y z Or the following, perhaps: Apply[List, Select [expression, MemberQ[#,x]&]] Out[107]= {2 x y,u x y,-x y z} Select[expression,MemberQ[#1,x]&&MemberQ[#1,y]&&MemberQ[#1,z]&&FreeQ[#1,u]&] Out[100]= -x y z Please let me know if this is not exactly what you want. Perhaps it is not what you want at all! Tom Dowling (thomasgdowling@gmail.com) I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! === Subject: Re: How to select terms wanted in a series > I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! > this would work in this case: Cases[allterms, HoldPattern[Times[___, x, ___, y, ___]]] Note that there are many pitfalls when working with patterns on mathematical expressions, so it is usually better to use functions that do the right thing. Here the following should be much more robust, I think: subterm=x*y; subterm*List@@Coefficient[expression,subterm] Depending on what you are trying to achieve I would recommend to look up Coefficient and CoefficientList in the Help. hth, albert === Subject: Re: How to select terms wanted in a series I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. > I would use Coefficient: List@@Coefficient[expression,x y] x y Ssezi === Subject: Re: How to select terms wanted in a series I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! try Coefficient[expression, Times[x,y]] Fabian === Subject: Re: Matrix Differentiation Hi Mark, you got what you asked for. The syntax you used gives the gradient, see the manual. What you want is written as: D[M,x1,x2,x3,x4] hope this helps, Daniel > Hi all, I need to differentiate a 4x4 matrix M with respect to four variables > x1,x2,x3 and x4. I have tried to use the function D as follows: D[M,{{x1,x2,x3,x4}}] what I get is a 4x4 matrix and each term in this matrix is a vector. Am I right when I used this function or there is another function to > do so? === Subject: Re: Matrix Differentiation This seems to work for me. I defined a simple test matrix: M = Table[x^i y^j z^(i + j) v^(i - j), {i, 1, 4}, {j, 1, 4}] and then did D[#, x, y, z, v] & /@ M Kajetan Sikorski > Hi all, I need to differentiate a 4x4 matrix M with respect to four variables > x1,x2,x3 and x4. I have tried to use the function D as follows: D[M,{{x1,x2,x3,x4}}] what I get is a 4x4 matrix and each term in this matrix is a vector. Am I right when I used this function or there is another function to > do so? > === Subject: Re: Plotting Time Series something like the following? d={{label1,0,0},{label2,1,0},{label3,0,1},{label4,1,1},{la bel5,.5,.5}}; labels=d[[All,1]]; dat=MapThread[Prepend,{d[[All,{2,3}]],Range[Length[d]]}]; ListPointPlot3D[dat,Ticks->{Transpose[{Range[Length[d]],labels}],Automatic,A utomatic},PlotStyle->{PointSize[0.03]}] hope this helps, Daniel > Is it possible to plot 3D time series where one axis is text, i.e., April-07, May-07, ... The file will be something like > xyzdata={{Nov-07,1%,2%},{Dec-07,3%,4%}, ... > === Subject: Re: PointSize (and shape) frustration This is a case where you want to show a global view and a detailed view at the same time. Nice if you can do it, but it depends on the details of screen resolution, or print resolution or the acuity of viewers eyes. I know that this is not totally responsive to your question, but a standard solution to this kind of problem is to use multiple images, a global view and perhaps several local views in higher detail. lm[r_]:=NestList[r # (1-#)&,.5,50000] bif=Join@@Table[{r,#}&/@Union[Take[lm[r],-100],SameTest->(Abs[#1-#2]<1*^-3&) ],{r,2.0,3.98,.001}]; ListPlot[bif, PlotRange -> All, PlotStyle -> AbsolutePointSize[.05]] With[{xmin = 3.4, xmax = 3.7, ymin = .3, ymax = .4}, bif2 = Cases[ bif, {x_, y_} /; xmin <= x <= xmax [And] ymin <= y <= ymax]; Length[bif2]] ListPlot[bif2, PlotRange -> All, PlotStyle -> AbsolutePointSize[2], ImageSize -> 600] Again, I know that you are looking for printed output, but this is just the type of situation where Mathematica notebooks are so much superior with their dynamic capabilities. The following is a Manipulate definition that allows both global and detailed views. Manipulate[ Graphics[{AbsolutePointSize[2], Point[bif]}, AspectRatio -> 1, PlotRange -> {{xcenter - xwidth/2, xcenter + xwidth/2}, {ycenter - ywidth/2, ycenter + ywidth/2}}, Frame -> True, ImageSize -> {400, 400}], Style[Logistics Map Explorer, 20], Delimiter, {xcenter, 3.1, InputField}, {xwidth, 4, InputField}, Delimiter, {ycenter, .6, InputField}, {ywidth, 1.5, InputField} ] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > While Mathematica 6 can display beautiful graphics on screen compared to > previous versions, graphics export became extremely frustrating and buggy. I complained about several issues before, now heres one more: I am trying to plot the bifurcation diagram for the logistic map, point > by point. The point size needs to be tuned precisely to get a nice plot > (for print). Mathematica refuses to export *circular* points to PDF/EPS > below a certain size, but in this case I can live with that. However, > Mathematica refuses to draw points below a certain size, no matter what > the value of PointSize or AbsolutePointSize is!! If the points overlap, > the plot is completely ruined. Then I tried using Disk[]s instead of points. On screen it looks fine, > but when exported to PDF, Mathematica does something very strange, and > the result doesnt even have the disks any more! Instead there are some > little crosses on a *regular* grid, approximating the shape of the plot. I *know* that 30000 points can inflate the file size, and I know that > arbitrarily small points are not printable/displayable, but I can solve > these problems on my own. I dont want Mathematica to try to be smart > and make its own decisions about this, because it will just cause trouble. Heres the code to experiment with (I know that it doesnt produce a > precise result): lm[r_] := NestList[r # (1 - #) &, .5, 50000] bif = Join @@ Table[ > {r, #} & /@ > Union[Take[lm[r], -100], SameTest -> (Abs[#1 - #2] < 1*^-3 &)], > {r, 2.0, 3.98, .001} > ]; plot = ListPlot[bif, PlotRange -> All, PlotStyle - AbsolutePointSize[.05]] plot = Graphics[{PointSize[.0001], Point[bif]}] plot = Graphics[Disk[#, 1/1000] & /@ bif] Now try exporting each of these plots at reasonable sizes (i.e. not hal= f > a metre). Remember that exporting PDFs at different sizes only works a= s > Export[plot.pdf, Show[plot, ImageSize -> someValue]] because Export i= s > buggy and does not respect the ImageSize options for PDFs! > === Subject: Re: PointSize (and shape) frustration > While Mathematica 6 can display beautiful graphics on screen compared to > previous versions, graphics export became extremely frustrating and buggy.= I complained about several issues before, now heres one more: I am trying to plot the bifurcation diagram for the logistic map, point > by point. =A0The point size needs to be tuned precisely to get a nice plot= > (for print). =A0Mathematica refuses to export *circular* points to PDF/EPS= > below a certain size, but in this case I can live with that. =A0However, > Mathematica refuses to draw points below a certain size, no matter what > the value of PointSize or AbsolutePointSize is!! =A0If the points overlap,= > the plot is completely ruined. Then I tried using Disk[]s instead of points. =A0On screen it looks fine, > but when exported to PDF, Mathematica does something very strange, and > the result doesnt even have the disks any more! =A0Instead there are some= > little crosses on a *regular* grid, approximating the shape of the plot. I *know* that 30000 points can inflate the file size, and I know that > arbitrarily small points are not printable/displayable, but I can solve > these problems on my own. =A0I dont want Mathematica to try to be smart > and make its own decisions about this, because it will just cause trouble.= Heres the code to experiment with (I know that it doesnt produce a > precise result): lm[r_] := NestList[r # (1 - #) &, .5, 50000] bif = Join @@ Table[ > =A0 =A0 =A0{r, #} & /@ > =A0 =A0 =A0 Union[Take[lm[r], -100], SameTest -> (Abs[#1 - #2] < 1*^-3 &)]= , > =A0 =A0 =A0{r, 2.0, 3.98, .001} > =A0 =A0 =A0]; plot = ListPlot[bif, PlotRange -> All, PlotStyle -> AbsolutePointSize[.0= 5]] plot = Graphics[{PointSize[.0001], Point[bif]}] plot = Graphics[Disk[#, 1/1000] & /@ bif] Now try exporting each of these plots at reasonable sizes (i.e. not half > a metre). =A0Remember that exporting PDFs at different sizes only works as= > Export[plot.pdf, Show[plot, ImageSize -> someValue]] because Export is > buggy and does not respect the ImageSize options for PDFs! Unfortunately I dont have any suggestions for you, I just wanted to echo your complaints. Getting Export to do anything right has been practically impossible for me, and Im glad to know that at least others are having the same problems. -Daniel === Subject: v6: Input Cell Word Wrapping: how to set global default? I would like to repeat the following question to which no answer given when it was posed in August 2007. I have the same problem as the original sender: In v6 (for Linux), how can I set the global default Word Wrapping for Input cells to Wrap at Window Width? Thomas. === Subject: Re: find and count partially identical sublist > Hello group, I am trying to find and count sublists that are partially identical to > each other and then modify parts of this sublist with the > multiplicity. Its easier to understand if I give an example. Say I have an array (strings and numbers mixed) like: {{B, A, 0, 1}, {A, B, 6, 1}, {B, A, 4, 1}, {B, A, 4, > =A0 1}, {A, B, 1, 1}, {B, A, 5, 1}, {B, A, 2, 1}, {A, B,= > 10, 1}} I need to find successive sublists which have the same first two > elements (here {3,4} and {7,6}). Depending on > how many repetitions occur I want to divide the 4th element of each > sublist by the number of repetitions. In the example the result would > be: {{B, A, 0, 1}, {A, B, 6, 1}, {B, A, 4, 1/2}, {B, A, 4, > =A0 =A01/2}, {A, B, 1, 1}, {B, A, 5, 1/2}, {B, A, 2, 1/ > =A0 2}, {A, B, 10, 1}} The code I came up with is: tst = Table[{RandomChoice[{A, B}], RandomChoice[{A, B}], > =A0 =A0 RandomInteger[{0, 10}], 1}, {i, 1, 30}]; orm > tab = Table[tstSplt[[1, i]] // Length, {i, 1, Length[tstSplt[[1]]]}] > rpl = MapThread[#1[[All, 4]]/#2 &, {tstSplt[[1, All]], tab}] // > =A0 Flatten > tst[[All, 4]] = tst[[#, 4]] & @@@ rpl; > tst This works, but I am somewhat concerned with run speed (my actual > array is much larger, roughly 50000x20). And I have the feeling that I > am wasting too much memory. One additional comment: The above code only finds successive > duplicates. How would I have to modify it to find all occurences ? I dont have time to benchmark this, so I cannot make any guarantees > about performance ... but I suspect that this will be useful: Ill take the case when all duplicates are taken into account (not only > successive ones). Extract the relevant part of the data, i.e. the first 2 elements, and > the last element of the sublists: dat1 = data[[All, {1,2}]] > dat2 = data[[All, -1]] It may (or may not) help performance to work with simple integers > instead of strings. =A0Can you transform the strings into integers? =A0If > yes, integers can be stored in a packed array ... but Im not sure that > this will help a lot. Anyway, lets generate something that looks like dat1: dat1 = Table[RandomChoice[{A, B}, 2], {50000}]; And replace all elements with their multiplicities: mult = dat1 /. Dispatch[Rule @@@ Tally[dat1]]; // Timing {0.219, Null} Now you only need to divide dat2 by mult (dat2/mult) and assemble the > lists again: Tranpose[Append[Transpose[dat1], dat2/mult]] I hope this helps, > Szabolcs P.S. =A0Do you actually need only successive duplicates or all duplicates?= - Zitierten Text ausblenden - - Zitierten Text anzeigen - > P.S. Do you actually need only successive duplicates or all duplicates? Actually, what would be the way to search for all (not only successive) duplicates if I dont want to use Sort? Markus === Subject: Re: Normalize a collection of arrays on a specific column >(Note: this is a re-send of a message. I havent seen the message show up in >the list (or its archives), so Im assuming its lost in the aether. I >apologize if this shows up twice.) Im looking for a relatively efficient (read: not doing so >element-by-element) way of taking a collection of several matrices, all of >the same m x n dimensions (say), and normalizing all of them in >whatever column I choose. If possible, it would be nice to extend this >to any number of dimensions, but thats not necessary now. For example, Im looking for a function, normalizeColumn[listOfLists_, >p_] which would normalize the pth column of all of the lists, not >individually, but over the whole set, returning the whole set with just >the pth column changed in each of its constituent lists. Let dat1 = {{1,3,4}, {2,2,-5}, {1,1,1}} and dat2 = {{0, 3, 6}, >{2,1,4}, {5, 3, -5}}. Then if dat3 = {dat1, dat2}, the normalizeColumn >function should return normalizeColumn[dat3, 2] = {{{1, 1, 4}, {2, 1/2, -5}, {1, 0, 1}}, >{{0, 1, 6}, {2, 0, 4}, {5, 1, -5}}}. Im quite certain theres an easy way to do it; I should be able to do >something analogous on several hundred, 200 x 200 matrices at the same >time. Curtis O. > > Something like: normalizeColumn[data_, p_] := Module[{tmp = data}, tmp[[All, All, 2]] = (tmp[[All, All, 2]] - 1)/2; tmp] perrhaps? In[149]:= normalizeColumn[{dat1, dat2}, 2] Out[149]= {{{1, 1, 4}, {2, 1/2, -5}, {1, 0, 1}}, {{0, 1, 6}, {2, 0, 4}, {5, 1, -5}}} Carl Woll Wolfram Research === Subject: Normalize a collection of arrays on a specific column (Note: this is a re-send of a message. I havent seen the message show up in the list (or its archives), so Im assuming its lost in the aether. I apologize if this shows up twice.) Im looking for a relatively efficient (read: not doing so element-by-element) way of taking a collection of several matrices, all of the same m x n dimensions (say), and normalizing all of them in whatever column I choose. If possible, it would be nice to extend this to any number of dimensions, but thats not necessary now. For example, Im looking for a function, normalizeColumn[listOfLists_, p_] which would normalize the pth column of all of the lists, not individually, but over the whole set, returning the whole set with just the pth column changed in each of its constituent lists. Let dat1 = {{1,3,4}, {2,2,-5}, {1,1,1}} and dat2 = {{0, 3, 6}, {2,1,4}, {5, 3, -5}}. Then if dat3 = {dat1, dat2}, the normalizeColumn function should return normalizeColumn[dat3, 2] = {{{1, 1, 4}, {2, 1/2, -5}, {1, 0, 1}}, {{0, 1, 6}, {2, 0, 4}, {5, 1, -5}}}. Im quite certain theres an easy way to do it; I should be able to do something analogous on several hundred, 200 x 200 matrices at the same time. Curtis 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: Troubles with HarmonicNumber, empty sums, and Zeta > Heres another bug, which might be unrelated to the other troubles I had > mentioned: In[8]:= Limit[Zeta[z, 9/10] - Zeta[z, 9/10 + z], z -> 1] Out[8]= Infinity But its easy to guess the correct result: In[16]:= N[Zeta[z, 9/10] - Zeta[z, 9/10 + z] /. z -> 9999/10000, 12] > Out[16]= 1.11103060226 > In[17]:= N[Zeta[z, 9/10] - Zeta[z, 9/10 + z] /. z -> 10001/10000, 12] > Out[17]= 1.11119161012 > In[18]:= (% + %%)/2 > Out[18]= 1.11111110619 and so our guess would be 10/9. Furthermore, we can get the correct exact result by converting to > HarmonicNumber by hand (and then there is no need of Limit): In[19]:= -HarmonicNumber[-1/10, z] + HarmonicNumber[-1/10 + z, z] /. z - 1 Out[19]= -HarmonicNumber[-1/10] + HarmonicNumber[9/10] > In[20]:= FullSimplify[%] > Out[20]= 10/9 Finally, I wonder about things like ZetaClassical and > ZetaClassicalRegularized. They are used at the Wolfram Functions site. > For example, the third and fourth entries at > <http://functions.wolfram.com/ZetaFunctionsandPolylogarithms/Zeta2/02/ concern ZetaClassical and ZetaClassicalRegularized, resp. And in the > output from one of the bugs mentioned in my original post in this thread, > there was mention of ZetaClassical in a system dump. So are ZetaClassical > and ZetaClassicalRegularized things that users of Mathematica have access > to, or are they strictly for internal work, to be hidden from the user? Having just now updated to version 6.0.2, Im sorry to note that bugs mentioned earlier in this thread still exist. And heres another bug related to Zeta (but probably not directly related to bugs previously mentioned in this thread): In[27]:= Sum[i*(1/(i - 1/10)^2 - 1/(i + 9/10)^2), {i, 1, Infinity}] Out[27]= EulerGamma - (2*Sqrt[5/8 + Sqrt[5]/8]*Pi)/(-1 + Sqrt[5]) - (100/361)*HypergeometricPFQ[{19/10, 19/10, 2}, {29/10, 29/10}, 1] + 2*Log[4] + Log[5] + (1/4)*Log[5/8 - Sqrt[5]/8] - (1/4)*Sqrt[5]*Log[5/8 - Sqrt[5]/8] + (1/4)*Log[5/8 + Sqrt[5]/8] + (1/4)*Sqrt[5]*Log[5/8 + Sqrt[5]/8] - (1/2)*Log[-1 + Sqrt[5]] - (1/2)*Sqrt[5]*Log[-1 + Sqrt[5]] - (1/2)*Log[1 + Sqrt[5]] + (1/2)*Sqrt[5]*Log[1 + Sqrt[5]] + (1/10)*PolyGamma[1, 9/10] In[28]:= N[%] Out[28]= ComplexInfinity In[29]:= FullSimplify[%%] Out[29]= Indeterminate Out[27] is incorrect. (BTW, it seems strange to me that N[Out[27]] is ComplexInfinity while FullSimplify[Out[27]] is Indeterminate. But that is not my point.) A correct result from In[27] would have been simply Zeta[2, 9/10], and thats why I had said this bug is related to Zeta. In[37]:= N[Zeta[2, 9/10]] Out[37]= 1.92254 In[38]:= NSum[i*(1/(i - 1/10)^2 - 1/(i + 9/10)^2), {i, 1, Infinity}] Out[38]= 1.92254 David W. Cantrell === Subject: Re: Assuming > [Message also posted to: comp.soft-sys.math.mathematica] >> Here is an example of the behavior in question. I do not pass > judgement on whether it should be regarded as a bug or a feature. I > simply wanted to give a concrete example where the behavior arises > and is difficult to supress. >> In[2]:= i1 = Integrate[Sin[m*x]*Sin[n*x], {x,0,2*Pi}, Assumptions- >> Element[{m,n},Reals]]; >> Check what happens when we assign n->1 and then take limit as m->1. >> In[3]:= l1 = Limit[i1 /. n->1, m->1] > Out[3]= Pi >> That was fine. Yes, that limit was fine. But i1 was not valid for all m and n. And > indeed > it is that very lack of validity when |m| = |n| which is the common > reason > for wishing to find a limit such as l1. This situation can be > avoided if we > use an antiderivative for Sin[m*x]*Sin[n*x] which is valid for all m > and n: x/2 (Sinc[(m - n) x] - Sinc[(m + n) x]) Then, applying Newton-Leibniz, we would have gotten i1alt = Pi (Sinc[2 (m - n) Pi] - Sinc[2 (m + n) Pi]) as an alternative for the definite integral, valid for all m and n. >> Now see what happens if we assign n->1 and simplify > under assumption that m is an arbitrary integer. >> In[4]:= l2 = Simplify[i1 /. n->1, Element[m,Integers]] > Out[4]= 0 In[13]:= Simplify[i1alt /. n -> 1, Element[m, Integers]] > Out[13]= Pi (Sinc[2 (-1 + m) Pi] - Sinc[2 (1 + m) Pi]) In[14]:= FullSimplify[%, Element[m, Integers]] > Out[14]= 0 Thus, Simplify to 0 happened to have been suppressed, but FullSimplify > still gave 0, which I would call a misdemeanor. > Unless I am missing something obvious (which is possible as I have >> not >> yet fully woken up) the problem amounts simply to this: >> x = (1/2)*(Sin[2*(m - 1)*Pi]/(m - 1) - Sin[2*(m + 1)*Pi]/(m + 1)); >> In[2]:= Limit[x, m -> 1] >> Out[2]= Pi >> In[3]:= Limit[x, m -> 1, Assumptions -> Element[m, Integers]] >> Out[3]= 0 >> The last answer maybe slightly dubious because it is not perfectly >> clear in what sense the limit is taken here. But it seems to me a >> very >> minor point and no cause for concern ? Your In[3] and Daniels In[4] are asking for different things, a > fact which > you probably already noticed, having been awake longer now. David Actually, Daniels In[4] and my In[3] are (essentially) equivalent, since what happens when my In[3] is evaluated by Mathematica is that first Daniels In[4] is evaluated, returning 0 and then the Limit of 0 is taken as m goes to Infinity, returning again 0. The Limit is therefore irrelevant except for the problem of mathematical interpretation of what it all actually means, since of course the assumption that m is an integer and the assumption that m ->1 are incompatible in Mathematica, which does not consider limits of sequences. As it was very early in the morning I could not see anything else in Daniels message that was problematic and could not understand what the point of his example was. I think I can see that now, but I have to confess I am still quite unable to take it at all seriously. Andrzej Kozlowski === Subject: Re: Re: Assuming > [...] >> Ive seen cases where the FullSimplify[something] result differs > from > something on a finite set of integers. This motivated me several > months > ago to alter assumptions of integrality, to reality (realness? > realhood?), in processing of Integrate. >> Daniel Lichtblau > Wolfram Research > Formally speaking, reasonable measures (e.g. Radon measures) are >> either diffuse or Dirac measures (or linear combinations of >> these). However, for the former, the entire set of integers has >> measure zero, and for the latter certain finite sets will have a >> non-zero measure. So none of these seems to fit the intended >> meaning of measure zero. >> More seriously; I think the intended meaning is that in >> Simplify[thing1] -> thing2 thing1 and thing2 should both be >> functions of some variable that is defined on an uncountable set, >> then they may be are allowed to differ for a finite number of >> values. But, if the functions are defined only on countable sets >> (e.g. the set of all integers, as is the case with many number >> theoretic functions) then the failure of thing2 to be equal to >> thing1 on a finite set could be very serious. I think in such >> situations the set of measure zero should really be the empty >> set, or perhaps in really exceptional cases a set that contains no >> more than a single point. >> Andrzej Kozlowski Here is an example of the behavior in question. I do not pass > judgement on whether it should be regarded as a bug or a feature. I > simply wanted to give a concrete example where the behavior arises > and is difficult to supress. In[2]:= i1 = Integrate[Sin[m*x]*Sin[n*x], {x,0,2*Pi}, Assumptions- >Element[{m,n},Reals]]; Check what happens when we assign n->1 and then take limit as m->1. In[3]:= l1 = Limit[i1 /. n->1, m->1] > Out[3]= Pi That was fine. Now see what happens if we assign n->1 and simplify > under assumption that m is an arbitrary integer. In[4]:= l2 = Simplify[i1 /. n->1, Element[m,Integers]] > Out[4]= 0 Daniel Lichtblau > Wolfram Research Unless I am missing something obvious (which is possible as I have not yet fully woken up) the problem amounts simply to this: x = (1/2)*(Sin[2*(m - 1)*Pi]/(m - 1) - Sin[2*(m + 1)*Pi]/(m + 1)); In[2]:= Limit[x, m -> 1] Out[2]= Pi In[3]:= Limit[x, m -> 1, Assumptions -> Element[m, Integers]] Out[3]= 0 The last answer maybe slightly dubious because it is not perfectly clear in what sense the limit is taken here. But it seems to me a very minor point and no cause for concern ? Andrzej Kozlowski === Subject: Re: Assuming > Here is an example of the behavior in question. I do not pass > judgement on whether it should be regarded as a bug or a feature. I > simply wanted to give a concrete example where the behavior arises > and is difficult to supress. In[2]:= i1 = Integrate[Sin[m*x]*Sin[n*x], {x,0,2*Pi}, Assumptions- > >Element[{m,n},Reals]]; Check what happens when we assign n->1 and then take limit as m->1. In[3]:= l1 = Limit[i1 /. n->1, m->1] > Out[3]= Pi That was fine. Yes, that limit was fine. But i1 was not valid for all m and n. And indeed it is that very lack of validity when |m| = |n| which is the common reason for wishing to find a limit such as l1. This situation can be avoided if we use an antiderivative for Sin[m*x]*Sin[n*x] which is valid for all m and n: x/2 (Sinc[(m - n) x] - Sinc[(m + n) x]) Then, applying Newton-Leibniz, we would have gotten i1alt = Pi (Sinc[2 (m - n) Pi] - Sinc[2 (m + n) Pi]) as an alternative for the definite integral, valid for all m and n. > Now see what happens if we assign n->1 and simplify > under assumption that m is an arbitrary integer. In[4]:= l2 = Simplify[i1 /. n->1, Element[m,Integers]] > Out[4]= 0 In[13]:= Simplify[i1alt /. n -> 1, Element[m, Integers]] Out[13]= Pi (Sinc[2 (-1 + m) Pi] - Sinc[2 (1 + m) Pi]) In[14]:= FullSimplify[%, Element[m, Integers]] Out[14]= 0 Thus, Simplify to 0 happened to have been suppressed, but FullSimplify still gave 0, which I would call a misdemeanor. > Unless I am missing something obvious (which is possible as I have not > yet fully woken up) the problem amounts simply to this: x = (1/2)*(Sin[2*(m - 1)*Pi]/(m - 1) - Sin[2*(m + 1)*Pi]/(m + 1)); In[2]:= Limit[x, m -> 1] > Out[2]= Pi In[3]:= Limit[x, m -> 1, Assumptions -> Element[m, Integers]] > Out[3]= 0 The last answer maybe slightly dubious because it is not perfectly > clear in what sense the limit is taken here. But it seems to me a very > minor point and no cause for concern ? Your In[3] and Daniels In[4] are asking for different things, a fact which you probably already noticed, having been awake longer now. David === Subject: Re: Re: Assuming >> [...] >> Ive seen cases where the FullSimplify[something] result differs from >> something on a finite set of integers. This motivated me several months >> ago to alter assumptions of integrality, to reality (realness? >> realhood?), in processing of Integrate. >> Daniel Lichtblau >> Wolfram Research Formally speaking, reasonable measures (e.g. Radon measures) are either > diffuse or Dirac measures (or linear combinations of these). However, > for the former, the entire set of integers has measure zero, and for > the latter certain finite sets will have a non-zero measure. So none of > these seems to fit the intended meaning of measure zero. More seriously; I think the intended meaning is that in > Simplify[thing1] -> thing2 thing1 and thing2 should both be functions > of some variable that is defined on an uncountable set, then they may > be are allowed to differ for a finite number of values. But, if the > functions are defined only on countable sets (e.g. the set of all > integers, as is the case with many number theoretic functions) then the > failure of thing2 to be equal to thing1 on a finite set could be very > serious. I think in such situations the set of measure zero should > really be the empty set, or perhaps in really exceptional cases a set > that contains no more than a single point. Andrzej Kozlowski Here is an example of the behavior in question. I do not pass judgement on whether it should be regarded as a bug or a feature. I simply wanted to give a concrete example where the behavior arises and is difficult to supress. In[2]:= i1 = Integrate[Sin[m*x]*Sin[n*x], {x,0,2*Pi}, Assumptions->Element[{m,n},Reals]]; Check what happens when we assign n->1 and then take limit as m->1. In[3]:= l1 = Limit[i1 /. n->1, m->1] Out[3]= Pi That was fine. Now see what happens if we assign n->1 and simplify under assumption that m is an arbitrary integer. In[4]:= l2 = Simplify[i1 /. n->1, Element[m,Integers]] Out[4]= 0 Daniel Lichtblau Wolfram Research === Subject: Re: Re: Assuming >> [...] > [...] But I do know of a case where > Mathematica goes even further, removing a singularity at which the > function > is defined as a number: >> In[17]:= FullSimplify[UnitStep[-x^2]] > Out[17]= 0 >> despite the fact that correctly >> In[18]:= UnitStep[-x^2] /. x -> 0 > Out[18]= 1 >> Perhaps the simplification above is considered a bug, perhaps not. >> David >> A feature, really. That is, its wrong, but FullSimplify can make > mistakes on measure zero sets. We do not generally regard this > phenomenon as a bug, though we reconsider on case by case basis. >> How does that `measure zero allowance work in a context >> of something like >> Assuming[Element[x, Integers], FullSimplify[something]] >> ? >> -- m Ive seen cases where the FullSimplify[something] result differs from > something on a finite set of integers. This motivated me several > months > ago to alter assumptions of integrality, to reality (realness? > realhood?), in processing of Integrate. Daniel Lichtblau > Wolfram Research > Formally speaking, reasonable measures (e.g. Radon measures) are either diffuse or Dirac measures (or linear combinations of these). However, for the former, the entire set of integers has measure zero, and for the latter certain finite sets will have a non-zero measure. So none of these seems to fit the intended meaning of measure zero. More seriously; I think the intended meaning is that in Simplify[thing1] -> thing2 thing1 and thing2 should both be functions of some variable that is defined on an uncountable set, then they may be are allowed to differ for a finite number of values. But, if the functions are defined only on countable sets (e.g. the set of all integers, as is the case with many number theoretic functions) then the failure of thing2 to be equal to thing1 on a finite set could be very serious. I think in such situations the set of measure zero should really be the empty set, or perhaps in really exceptional cases a set that contains no more than a single point. Andrzej Kozlowski === Subject: RE: Text does not scale with size of graphic The following code is based in a previous answer to a similar question in this forum. The original answer was given by Carl Woll [carlw@wolfram.com]. This is the code: myplot = Plot[BesselJ[0, x], {x, 0, 10}]; First@ImportString[ExportString[myplot, PDF], PDF] The image that is produced with this code, when resized, the text and the ticks are also resized. Jose Mexico -----Mensaje original----- De: D. Grady [mailto:D.C.Grady@gmail.com] Enviado el: Mi=E9rcoles, 27 de Febrero de 2008 03:23 a.m. Para: mathgroup@smc.vnet.net Asunto: Text does not scale with size of graphic This is probably a silly question, but I was wondering why it is that text in a graphic remains the same size when the graphic is resized. For example, if you look at Plot[BesselJ[0, x], {x, 0, 10}] and drag the resizing handles around, you see that, independent of all the other graphic elements, the tick labels stay the same size no matter what size you make the plot. What is the reason for this? I often want to make an array of relatively small graphics, but a problem with doing this is that the tick labels can crowd out the rest of the graphic. In the past Ive just eliminated the tick labels; is there a way to introduce text that does scale with the size of the graphic? -Daniel === Subject: Text does not scale with size of graphic This is probably a silly question, but I was wondering why it is that text in a graphic remains the same size when the graphic is resized. For example, if you look at Plot[BesselJ[0, x], {x, 0, 10}] and drag the resizing handles around, you see that, independent of all the other graphic elements, the tick labels stay the same size no matter what size you make the plot. What is the reason for this? I often want to make an array of relatively small graphics, but a problem with doing this is that the tick labels can crowd out the rest of the graphic. In the past Ive just eliminated the tick labels; is there a way to introduce text that does scale with the size of the graphic? -Daniel === Subject: Re: Text does not scale with size of graphic > This is probably a silly question, but I was wondering why it is that > text in a graphic remains the same size when the graphic is resized. > For example, if you look at Plot[BesselJ[0, x], {x, 0, 10}] and drag the resizing handles around, you see that, independent of all > the other graphic elements, the tick labels stay the same size no > matter what size you make the plot. What is the reason for this? I often want to make an array of relatively small graphics, but a > problem with doing this is that the tick labels can crowd out the rest > of the graphic. In the past Ive just eliminated the tick labels; is > there a way to introduce text that does scale with the size of the > graphic? In Version 6 the following works: Plot[ BesselJ[0, x], {x, 0, 10}, BaseStyle -> {FontSize -> Scaled[0.05]} ] I dont think that this was possible with prior versions... hth, albert === Subject: Question for David Park I got this file from this discussion group and it looks useful, but I dont know how to use it in its present form. This is only a tiny bit of the file. Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{(*, , RowBox[{-=, RowBox[{=, RowBox[{ RowBox[{ RowBox[{ RowBox[{-, Make}], , <The Mathematica Book>, , based, , on, , <...Overview.nb>, , files, , in, , the, , tutorials, , directory}], -=}], =, -}]}]}], *)}], Steve Gray === Subject: Re: Question for David Park > I got this file from this discussion group and it looks useful, but I > dont know how to use it in its present form. This is only a tiny bit > of the file. Notebook[{ > Cell[BoxData[ > RowBox[{ > RowBox[{(*, , > RowBox[{-=, > RowBox[{=, > RowBox[{ > RowBox[{ > RowBox[{ > RowBox[{-, Make}], , <The Mathematica Book>, > , based, , on, , <...Overview.nb>, , > files, , in, , the, , tutorials, , > directory}], -=}], =, -}]}]}], *)}], > Copy the text, paste it into a notebook, and Mathematica will offer to interpret it as a new notebook. === Subject: Series solution for complicated function I am trying to find the series for MeijerG[{{1}, {3/2}}, {{1, 1}, {0, 1/2}}, x^2]/(4 x^2) using my current version of Mathematica 5.0, and it fails. Does anyone know the series solution for this up to 2nd order, or how I can implement this in my current version of Mathematica? Klaus. === Subject: Re: Series solution for complicated function The function you quote is defined by the following sum 1/(2 Pi) Sum[ (((-1)^k) (x^(2 k)) )/((1 + 2 k)(k+1) (k!)^2)* (2/(2*k+1) + 1/(k+1) - Log[x^2] + 2 PolyGamma[0,k+1]), {k, 0, [Infinity]}] small x series expansion follows from here. Oleksandr Pavlyk Wolfram Research > I am trying to find the series for MeijerG[{{1}, {3/2}}, {{1, 1}, {0, > 1/2}}, x^2]/(4 x^2) using my current version of Mathematica 5.0, and > it fails. Does anyone know the series solution for this up to 2nd > order, or how I can implement this in my current version of > Mathematica? > Klaus. === Subject: Re: Series solution for complicated function this works in Mathematica 6, and 5.2 f = MeijerG[{{1}, {3/2}}, {{1, 1}, {0, 1/2}}, x^2]/(4 x^2); Series[f, {x, 0, 2}] gives SeriesData[x, 0, {MeijerG[{{1}, {3/2}}, {{1, 1}, {0, 1/2}}, 0]/4, 0, Derivative[0, 0, 1][MeijerG][{{1}, {3/2}}, {{1, 1}, {0, 1/2}}, 0]/4, 0, Derivative[0, 0, 2][MeijerG][{{1}, {3/2}}, {{1, 1}, {0, 1/2}}, 0]/8}, -2, 3, 1] Jens > I am trying to find the series for MeijerG[{{1}, {3/2}}, {{1, 1}, {0, > 1/2}}, x^2]/(4 x^2) using my current version of Mathematica 5.0, and > it fails. Does anyone know the series solution for this up to 2nd > order, or how I can implement this in my current version of > Mathematica? Klaus. > === Subject: Re: Finding a continuous solution of a cubic > I am investigating the maxima and minima of the expression, e, below. > The expression is a quartic in x and has two parameters a and b which, > for my problem, are restricted to the range -1 < a < 1 and 0 < b (the > interesting part is 0<b<1). I start with a simple approach and take the derivative with respect to > x and solve to find the three turning points. The solution is > complicated and not easy to examine. I work out the discriminant to > see when I will have three real roots or one and plot the region. I > work out three functions for the three roots r1, r2 and r3, and three > functions for the value of e at the roots, f1, f2, and f3. I am > expecting three real functions when within the region defined by the > discriminant and one outside this region. I plot the three roots and > the three functions (there are some artifacts where the functions turn > from real to complex, this is not a problem). Now my problem. The function f3 is continuous in the region where > there are three solutions and this I like. Functions f1 and f2 are not > continuous but contain holes. If functions f1 and f2 are plotted > together then they each fill in the others holes. The holes makes my > life difficult because I do not have continuous functions. Is it possible to make Solve find roots that will give rise to three > functions one corresponding to the maxima and two corresponding to > each minima without the functions crossing over and jumping between > the turning points? I also notice, from the plots when shown together, that my desired > functions are even with respect to the parameter a. Is this correct > and how would I show this if I cant assemble them as continuous > functions? > Hugh Goyder e = ((1 - x)^2 + b*(-1 + a)^2)*((1 + x)^2 + > b*(1 + a)^2); d = Simplify[D[e, x]]; dis = Discriminant[d, x]; ContourPlot[dis, {a, -1, 1}, {b, 0, 1}, > ContourShading -> False, Contours -> {0}, > FrameLabel -> {a, b}] sol = Solve[d == 0, x]; ClearAll[x1, x2, x3, f1, f2, f3]; > x1[a_, b_] := Evaluate[x /. sol[[1]]]; > x2[a_, b_] := Evaluate[x /. sol[[2]]]; > x3[a_, b_] := Evaluate[x /. sol[[3]]]; > f1[a_, b_] := Evaluate[e /. sol[[1]]]; > f2[a_, b_] := Evaluate[e /. sol[[2]]]; > f3[a_, b_] := Evaluate[e /. sol[[3]]]; r1 = Plot3D[x1[a, b], {a, -1, 1}, {b, 0, 1}] r2 = Plot3D[x2[a, b], {a, -1, 1}, {b, 0, 1}] r3 = Plot3D[x3[a, b], {a, -1, 1}, {b, 0, 1}] Show[r1, r2, r3, PlotRange -> All] s1 = Plot3D[f1[a, b], {a, -1, 1}, {b, 0, 1}] s2 = Plot3D[f2[a, b], {a, -1, 1}, {b, 0, 1}] s3 = Plot3D[f3[a, b], {a, -1, 1}, {b, 0, 2}] Before using Solve, do SetOptions[Roots, Cubics -> False]; This will force Solve to use Root[] objects instead of Cardano formulas. The latter can jump around due to branch cut structure of (nested) radicals. Also I think Plot might prefer the former because it always knows when they are real valued. With the radicals there might be spurious imaginary part artifacts upon numerical evaluation. Daniel Lichtblau Wolfram Research === Subject: Re: Finding a continuous solution of a cubic >> I am investigating the maxima and minima of the expression, e, below. >> The expression is a quartic in x and has two parameters a and b >> which, >> for my problem, are restricted to the range -1 < a < 1 and 0 < b (the >> interesting part is 0<b<1). >> I start with a simple approach and take the derivative with respect >> to >> x and solve to find the three turning points. The solution is >> complicated and not easy to examine. I work out the discriminant to >> see when I will have three real roots or one and plot the region. I >> work out three functions for the three roots r1, r2 and r3, and three >> functions for the value of e at the roots, f1, f2, and f3. I am >> expecting three real functions when within the region defined by the >> discriminant and one outside this region. I plot the three roots and >> the three functions (there are some artifacts where the functions >> turn >> from real to complex, this is not a problem). >> Now my problem. The function f3 is continuous in the region where >> there are three solutions and this I like. Functions f1 and f2 are >> not >> continuous but contain holes. If functions f1 and f2 are plotted >> together then they each fill in the others holes. The holes makes my >> life difficult because I do not have continuous functions. >> Is it possible to make Solve find roots that will give rise to three >> functions one corresponding to the maxima and two corresponding to >> each minima without the functions crossing over and jumping between >> the turning points? >> I also notice, from the plots when shown together, that my desired >> functions are even with respect to the parameter a. Is this correct >> and how would I show this if I cant assemble them as continuous >> functions? >> Hugh Goyder >> e = ((1 - x)^2 + b*(-1 + a)^2)*((1 + x)^2 + >> b*(1 + a)^2); >> d = Simplify[D[e, x]]; >> dis = Discriminant[d, x]; >> ContourPlot[dis, {a, -1, 1}, {b, 0, 1}, >> ContourShading -> False, Contours -> {0}, >> FrameLabel -> {a, b}] >> sol = Solve[d == 0, x]; >> ClearAll[x1, x2, x3, f1, f2, f3]; >> x1[a_, b_] := Evaluate[x /. sol[[1]]]; >> x2[a_, b_] := Evaluate[x /. sol[[2]]]; >> x3[a_, b_] := Evaluate[x /. sol[[3]]]; >> f1[a_, b_] := Evaluate[e /. sol[[1]]]; >> f2[a_, b_] := Evaluate[e /. sol[[2]]]; >> f3[a_, b_] := Evaluate[e /. sol[[3]]]; >> r1 = Plot3D[x1[a, b], {a, -1, 1}, {b, 0, 1}] >> r2 = Plot3D[x2[a, b], {a, -1, 1}, {b, 0, 1}] >> r3 = Plot3D[x3[a, b], {a, -1, 1}, {b, 0, 1}] >> Show[r1, r2, r3, PlotRange -> All] >> s1 = Plot3D[f1[a, b], {a, -1, 1}, {b, 0, 1}] >> s2 = Plot3D[f2[a, b], {a, -1, 1}, {b, 0, 1}] >> s3 = Plot3D[f3[a, b], {a, -1, 1}, {b, 0, 2}] >> Show[s1, s2] > > Mathematica will certainly not give you such a formula. I think in > your case it will be quite hard to obtian one, and I cant at the > moment suggest a good way to do so, but it may be helpful to first > consider the the cubic geometrically and understand how Mathematica > deals with the ordering of its roots. In general a cubic (with real > coefficients) can have either 1 or all 3 real roots. If the cubic > ir represented by a polynomial poly (in your case poly = d) in the > variable x then these roots can are given by the Mathematica > functions Root[poly,x,1], Root[poly,x,2] and Root[poly,x,3]. > For example: In[31]:= Root[x^3 + x + 1, x, 1] > Out[31]= Root[#1^3 + #1 + 1 &, 1] In[32]:= ToRadicals[%] > Out[32]= -(2/(3*(-9 + Sqrt[93])))^(1/3) + ((1/2)*(-9 + > Sqrt[93]))^(1/3)/3^(2/3) Root[poly,x,1],Root[poly,x,2] and Root[poly,x,3] are your functions > f1,f2, and f3. What Mathematica counts as the first root of a cubic, as mentioned > above, is always real. So suppose you define your real root > function as Root[poly,x,1] and also suppose that we start in a > situation (a set of parameter values) where we have one real root > and two conjugate non-real ones. The real root is our Root[poly,x, > 1]. Now, however, as we vary the parameters, the two non-real roots > Root[poly,x,2] and Root[poly,x,3] will at some point coalesce to > form a double real root, which may be smaller than your original > root. At this point the roots are renamed, in other words these > two roots become Root[poly,x,1] and Root[poly,x,2] and the original > root then becomes Root[poly,x,3]. So if we stick to the function > Root[poly,x,1] we will have a discontinuous jump. In order to avoid > it, we should take Root[poly,x,3] as the value of our function after > the jump point. So in fact, to construct a continuous function you only need to > consider Root[poly,x,1] and Rot[poly,x,3] for the root will never > jump from the first to second place, because whenever two complex > roots coalesce, two new real of the same magnitude roots are created > and so what used to be root number one will become root number 3. As you noted, all the jumps take place on the curve > dis=Discriminant[d, x] = 0, because the choice of a smallest root > can only be changed once a double root appears. However, not every > appearance of a double root will result in a jump, because the two > real roots that appear due to the merging of two complex ones may be > larger than the real root we had before their merger. Now, in the case of a cubic with a single parameter, the equation > dis can actually be solved numerically so we can find all the jump > points and use the function Piecewise to combine them to get a > continuous function of the parameter. This is easy and has been > considered more than once on this list in the past. Your two > parameter case seems much more complicated (however, I have not > considered it very carefully!) since the discriminant is now a real > curve of degree 9 in the parameter space so at this time I have no > good idea to suggest. Still, I hope you can find something useful in > the above remarks. Andrzej Kozlowski Just one more thing. You can see graphically how the jumping takes place by plotting together just the first and the third root of the cubic. Here is one way to do it: F[a_, b_] := Module[{poly, x}, poly = 4 x^3 + 4 a^2 b x + 4 b x - 4 x - 8 a b; Piecewise[{{{Root[poly, x, 1], Root[poly, x, 1]}, Im[Root[poly, x, 3]] != 0}}, {Root[poly, x, 1], Root[poly, x, 3]}]] Plot3D[F[a, b], {a, 0, 1}, {b, -1, 1}] Of course the vertical part should not be there. The single sheeted surface is the part given by Root[poly,x,1], which I had to tell Mathematica do draw twice, in order to have two values for every pair {a,b}. The double sheeted part of the surface consists of Root[poly,x, 1] and Root[poly,x,3] over the part of the parameter space where there are three real roots. The upper part, that joins continusly onto the single sheeted part is Root[poly,x,3]. The lower part which ought to be isolated from the rest of the graph (but is to it connected by vertical lines) is Root[poly,x,1], so you can see where one has to change the choice of root to obtain a continuous graph. Andrzej Kozlowski === Subject: Re: Finding a continuous solution of a cubic > I am investigating the maxima and minima of the expression, e, below. > The expression is a quartic in x and has two parameters a and b which, > for my problem, are restricted to the range -1 < a < 1 and 0 < b (the > interesting part is 0<b<1). I start with a simple approach and take the derivative with respect to > x and solve to find the three turning points. The solution is > complicated and not easy to examine. I work out the discriminant to > see when I will have three real roots or one and plot the region. I > work out three functions for the three roots r1, r2 and r3, and three > functions for the value of e at the roots, f1, f2, and f3. I am > expecting three real functions when within the region defined by the > discriminant and one outside this region. I plot the three roots and > the three functions (there are some artifacts where the functions turn > from real to complex, this is not a problem). Now my problem. The function f3 is continuous in the region where > there are three solutions and this I like. Functions f1 and f2 are not > continuous but contain holes. If functions f1 and f2 are plotted > together then they each fill in the others holes. The holes makes my > life difficult because I do not have continuous functions. Is it possible to make Solve find roots that will give rise to three > functions one corresponding to the maxima and two corresponding to > each minima without the functions crossing over and jumping between > the turning points? I also notice, from the plots when shown together, that my desired > functions are even with respect to the parameter a. Is this correct > and how would I show this if I cant assemble them as continuous > functions? > Hugh Goyder e = ((1 - x)^2 + b*(-1 + a)^2)*((1 + x)^2 + > b*(1 + a)^2); d = Simplify[D[e, x]]; dis = Discriminant[d, x]; ContourPlot[dis, {a, -1, 1}, {b, 0, 1}, > ContourShading -> False, Contours -> {0}, > FrameLabel -> {a, b}] sol = Solve[d == 0, x]; ClearAll[x1, x2, x3, f1, f2, f3]; > x1[a_, b_] := Evaluate[x /. sol[[1]]]; > x2[a_, b_] := Evaluate[x /. sol[[2]]]; > x3[a_, b_] := Evaluate[x /. sol[[3]]]; > f1[a_, b_] := Evaluate[e /. sol[[1]]]; > f2[a_, b_] := Evaluate[e /. sol[[2]]]; > f3[a_, b_] := Evaluate[e /. sol[[3]]]; r1 = Plot3D[x1[a, b], {a, -1, 1}, {b, 0, 1}] r2 = Plot3D[x2[a, b], {a, -1, 1}, {b, 0, 1}] r3 = Plot3D[x3[a, b], {a, -1, 1}, {b, 0, 1}] Show[r1, r2, r3, PlotRange -> All] s1 = Plot3D[f1[a, b], {a, -1, 1}, {b, 0, 1}] s2 = Plot3D[f2[a, b], {a, -1, 1}, {b, 0, 1}] s3 = Plot3D[f3[a, b], {a, -1, 1}, {b, 0, 2}] Show[s1, s2] > Mathematica will certainly not give you such a formula. I think in your case it will be quite hard to obtian one, and I cant at the moment suggest a good way to do so, but it may be helpful to first consider the the cubic geometrically and understand how Mathematica deals with the ordering of its roots. In general a cubic (with real coefficients) can have either 1 or all 3 real roots. If the cubic ir represented by a polynomial poly (in your case poly = d) in the variable x then these roots can are given by the Mathematica functions Root[poly,x,1], Root[poly,x,2] and Root[poly,x,3]. For example: In[31]:= Root[x^3 + x + 1, x, 1] Out[31]= Root[#1^3 + #1 + 1 &, 1] In[32]:= ToRadicals[%] Out[32]= -(2/(3*(-9 + Sqrt[93])))^(1/3) + ((1/2)*(-9 + Sqrt[93]))^(1/3)/3^(2/3) Root[poly,x,1],Root[poly,x,2] and Root[poly,x,3] are your functions f1,f2, and f3. What Mathematica counts as the first root of a cubic, as mentioned above, is always real. So suppose you define your real root function as Root[poly,x,1] and also suppose that we start in a situation (a set of parameter values) where we have one real root and two conjugate non-real ones. The real root is our Root[poly,x,1]. Now, however, as we vary the parameters, the two non-real roots Root[poly,x, 2] and Root[poly,x,3] will at some point coalesce to form a double real root, which may be smaller than your original root. At this point the roots are renamed, in other words these two roots become Root[poly,x,1] and Root[poly,x,2] and the original root then becomes Root[poly,x,3]. So if we stick to the function Root[poly,x,1] we will have a discontinuous jump. In order to avoid it, we should take Root[poly,x,3] as the value of our function after the jump point. So in fact, to construct a continuous function you only need to consider Root[poly,x,1] and Rot[poly,x,3] for the root will never jump from the first to second place, because whenever two complex roots coalesce, two new real of the same magnitude roots are created and so what used to be root number one will become root number 3. As you noted, all the jumps take place on the curve dis=Discriminant[d, x] = 0, because the choice of a smallest root can only be changed once a double root appears. However, not every appearance of a double root will result in a jump, because the two real roots that appear due to the merging of two complex ones may be larger than the real root we had before their merger. Now, in the case of a cubic with a single parameter, the equation dis can actually be solved numerically so we can find all the jump points and use the function Piecewise to combine them to get a continuous function of the parameter. This is easy and has been considered more than once on this list in the past. Your two parameter case seems much more complicated (however, I have not considered it very carefully!) since the discriminant is now a real curve of degree 9 in the parameter space so at this time I have no good idea to suggest. Still, I hope you can find something useful in the above remarks. Andrzej Kozlowski === Subject: Finding a continuous solution of a cubic I am investigating the maxima and minima of the expression, e, below. The expression is a quartic in x and has two parameters a and b which, for my problem, are restricted to the range -1 < a < 1 and 0 < b (the interesting part is 0<b<1). I start with a simple approach and take the derivative with respect to x and solve to find the three turning points. The solution is complicated and not easy to examine. I work out the discriminant to see when I will have three real roots or one and plot the region. I work out three functions for the three roots r1, r2 and r3, and three functions for the value of e at the roots, f1, f2, and f3. I am expecting three real functions when within the region defined by the discriminant and one outside this region. I plot the three roots and the three functions (there are some artifacts where the functions turn from real to complex, this is not a problem). Now my problem. The function f3 is continuous in the region where there are three solutions and this I like. Functions f1 and f2 are not continuous but contain holes. If functions f1 and f2 are plotted together then they each fill in the others holes. The holes makes my life difficult because I do not have continuous functions. Is it possible to make Solve find roots that will give rise to three functions one corresponding to the maxima and two corresponding to each minima without the functions crossing over and jumping between the turning points? I also notice, from the plots when shown together, that my desired functions are even with respect to the parameter a. Is this correct and how would I show this if I cant assemble them as continuous functions? Hugh Goyder e = ((1 - x)^2 + b*(-1 + a)^2)*((1 + x)^2 + b*(1 + a)^2); d = Simplify[D[e, x]]; dis = Discriminant[d, x]; ContourPlot[dis, {a, -1, 1}, {b, 0, 1}, ContourShading -> False, Contours -> {0}, FrameLabel -> {a, b}] sol = Solve[d == 0, x]; ClearAll[x1, x2, x3, f1, f2, f3]; x1[a_, b_] := Evaluate[x /. sol[[1]]]; x2[a_, b_] := Evaluate[x /. sol[[2]]]; x3[a_, b_] := Evaluate[x /. sol[[3]]]; f1[a_, b_] := Evaluate[e /. sol[[1]]]; f2[a_, b_] := Evaluate[e /. sol[[2]]]; f3[a_, b_] := Evaluate[e /. sol[[3]]]; r1 = Plot3D[x1[a, b], {a, -1, 1}, {b, 0, 1}] r2 = Plot3D[x2[a, b], {a, -1, 1}, {b, 0, 1}] r3 = Plot3D[x3[a, b], {a, -1, 1}, {b, 0, 1}] Show[r1, r2, r3, PlotRange -> All] s1 = Plot3D[f1[a, b], {a, -1, 1}, {b, 0, 1}] s2 = Plot3D[f2[a, b], {a, -1, 1}, {b, 0, 1}] s3 = Plot3D[f3[a, b], {a, -1, 1}, {b, 0, 2}] Show[s1, s2] === Subject: Re: Efficiency and ReplacePart? Two more options, one of which seems faster: n = 500000; ftemp = Table[{RandomReal[1, {2}], RandomReal[1, {2}]}, {n}]; First@Timing[one = ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, 0}}] First@Timing[two = Map[{#[[1]], {0, 0}} &, ftemp]] First@Timing[three = Map[ReplacePart[#, 2 -> {0, 0}] &, ftemp]] First@Timing[four = Map[MapAt[{0, 0} &, #, 2] &, ftemp]] First@Timing[five = (ftemp[[All, 2]] *= 0; ftemp)] one == two == three == four == five 0.943361 1.31027 3.20808 1.40886 0.536861 True Bobby If someone can answer the following question, I will have > learned something about efficiency in mathematica... Id like each second part of a list to a zero-list: ftemp = Table[{RandomReal[1, {2}], RandomReal[1, {2}]}, {50000}]; Compare: > 1) > Timing[ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, 0}}][[1]] 2) > Timing[Map[(# = {#[[1]], {0, 0}} &), ftemp]][[1]] 3) Timing[Map[ReplacePart[#, 2 -> {0, 0}] &, ftemp]][[1]] (* > or if you like: > times[n_] := > Module[{ftemp = > Table[{RandomReal[1, {2}], RandomReal[1, {2}]}, {n}]}, > {Timing[ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, > 0}}][[1]], > Timing[Map[(# = {#[[1]], {0, 0}} &), ftemp]][[1]]}] ListPlot[Table[times[i], {i, 100, 10000, 100}]] > *) > 1 is faster than 2 is faster than 3. Why? Craig > -- = DrMajorBob@bigfoot.com === Subject: Re: Efficiency and ReplacePart? >If someone can answer the following question, I will have >learned something about efficiency in mathematica... Id like each second part of a list to a zero-list: ftemp = Table[{RandomReal[1, {2}], RandomReal[1, {2}]}, {50000}]; Compare: >1) >Timing[ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, 0}}][[1]] 2) >Timing[Map[(# = {#[[1]], {0, 0}} &), ftemp]][[1]] 3) Timing[Map[ReplacePart[#, 2 -> {0, 0}] &, ftemp]][[1]] (* >or if you like: >times[n_] := > Module[{ftemp = > Table[{RandomReal[1, {2}], RandomReal[1, {2}]}, {n}]}, > {Timing[ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, >0}}][[1]], > Timing[Map[(# = {#[[1]], {0, 0}} &), ftemp]][[1]]}] ListPlot[Table[times[i], {i, 100, 10000, 100}]] >*) >1 is faster than 2 is faster than 3. Why? Craig > This doesnt answer your question, but if you are working with large data sets you should turn them into packed arrays and make sure they stay packed. So, if instead of replacing the second column with {0,0} you wanted to replace it with {0.,0.}, then a much faster technique is the following. First use: ftemp = RandomReal[1, {50000, 2, 2}]; so that you create a packed array. In[144]:= Developer`PackedArrayQ@ftemp Out[144]= True Then: In[145]:= (gtemp = ftemp; gtemp[[All, 2]] = ConstantArray[0., Dimensions[gtemp[[All, 2]]]]; r1 = gtemp); // Timing Out[145]= {0.016, Null} Compare with: In[146]:= Timing[r2 = ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, 0}}][[1]] Out[146]= 0.265 Carl Woll Wolfram Research === Subject: Efficiency and ReplacePart? If someone can answer the following question, I will have learned something about efficiency in mathematica... Id like each second part of a list to a zero-list: ftemp = Table[{RandomReal[1, {2}], RandomReal[1, {2}]}, {50000}]; Compare: 1) Timing[ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, 0}}][[1]] 2) Timing[Map[(# = {#[[1]], {0, 0}} &), ftemp]][[1]] 3) Timing[Map[ReplacePart[#, 2 -> {0, 0}] &, ftemp]][[1]] (* or if you like: times[n_] := Module[{ftemp = Table[{RandomReal[1, {2}], RandomReal[1, {2}]}, {n}]}, {Timing[ftemp /. {{a_, b_}, {c_, d_}} :> {{a, b}, {0, 0}}][[1]], Timing[Map[(# = {#[[1]], {0, 0}} &), ftemp]][[1]]}] ListPlot[Table[times[i], {i, 100, 10000, 100}]] *) 1 is faster than 2 is faster than 3. Why? Craig === Subject: Re: How to select terms wanted in a series >I have an expression, which is a sum of large number of terms, e.g. >expression = x + 2x*y - x*y*z + u*x*y + 3u^2 >And I want to select out terms with the factor (x*y). e.g. >The terms in expression that I want are 2x*y, -x*y*z, u*x*y Try using Coefficient, i.e. In[5]:= Coefficient[x + 2 x*y - x*y*z + u*x*y + 3 u^2, x y] Out[5]= u-z+2 or if you want a list List@@Coefficient[[x + 2 x*y - x*y*z + u*x*y + 3 u^2, x y] -- To reply via email subtract one hundred and four === Subject: Should RotationMatrix work with symbolic vectors? It works fine when the source and destination vectors are numeric (it gives a matrix, say rm2, such that rm2.a2 is parallel to b2): a2 = {1, 2, 3}; b2 = {3, 5, 7}; rm2 = N[RotationMatrix[{a2, b2}]] {{0.997846, 0.028474, 0.059102}, {-0.0301974, 0.999138, 0.028474}, {-0.0582406,-0.0301974,0.997846}} and Normalize[rm2.a2] (* rm2.Normalize[a2] also works *) {0.329293, 0.548821, 0.76835} which is a unit vector parallel to b2. So far, great. But unless a2 and b2 have numeric values, RotationMatrix does nothing. avec = {a2x, a2y}; bvec = {b2x, b2y}; RotationMatrix[{avec, bvec}] (* gives *) RotationMatrix[{{a2x, a2y}, {b2x, b2y}}] Cant it handle symbolics like most functions? While Im asking about vectors, consider this example: av = {avx, avy, avz}; bv = {bvx, bvy, bvz}; Normalize[av[Cross]bv] (* which gives *) {(-avz bvy + avy bvz)/Sqrt[Abs[-avy bvx + avx bvy]^2 + Abs[avz bvx -avx bvz]^2 + Abs[-avz bvy + avy bvz]^2], (avz bvx - avx bvz)/Sqrt[Abs[-avy bvx + avx bvy]^2 + Abs[avz bvx - avx bvz]^2 + Abs[-avz bvy + avy bvz]^2], (-avy bvx + avx bvy)/Sqrt[ Abs[-avy bvx + avx bvy]^2 + Abs[avz bvx - avx bvz]^2 + Abs[-avz bvy + avy bvz]^2]} All three vector components have the same denominator. Whats a good way to automatically show that for clarity and speed? Id appreciate any information. Steve Gray === Subject: Re: Should RotationMatrix work with symbolic vectors? Hi Steve, I have no answer why RotationMatrix doesnt work with symbolic arguments. Perhaps it is simply too messy? As for your display question, while perhaps not the most elegant solution, the following seems to work: av = {avx, avy, avz}; bv = {bvx, bvy, bvz}; crsprd = Normalize[av[Cross]bv]; denominator = Mean[Denominator[crsprd]]; HoldForm[num/den] /. {den -> denominator, num -> crsprd*denominator} Good luck! > It works fine when the source and destination vectors are =A0numeric > (it gives a matrix, say rm2, such that rm2.a2 is parallel to b2): a2 = {1, 2, 3}; > b2 = {3, 5, 7}; > rm2 = N[RotationMatrix[{a2, b2}]] {{0.997846, =A00.028474, 0.059102}, > {-0.0301974, 0.999138, 0.028474}, > {-0.0582406,-0.0301974,0.997846}} and Normalize[rm2.a2] =A0 =A0 =A0 =A0 =A0 =A0 =A0(* rm2.Normalize[a2] also wor= ks *) > {0.329293, 0.548821, 0.76835} which is a unit vector parallel to b2. So far, great. But unless a2 > and b2 have numeric values, RotationMatrix does nothing. avec = {a2x, a2y}; > bvec = {b2x, b2y}; > RotationMatrix[{avec, bvec}] =A0 (* gives *) RotationMatrix[{{a2x, a2y}, {b2x, b2y}}] Cant it handle symbolics like most functions? While Im asking about vectors, consider this example: av = {avx, avy, avz}; > bv = {bvx, bvy, bvz}; > Normalize[av[Cross]bv] =A0(* which gives *) {(-avz bvy + avy bvz)/Sqrt[Abs[-avy bvx + avx bvy]^2 + > =A0 Abs[avz bvx -avx bvz]^2 + Abs[-avz bvy + avy bvz]^2], =A0(avz bvx - avx bvz)/Sqrt[Abs[-avy bvx + avx bvy]^2 + > =A0 Abs[avz bvx - avx bvz]^2 + Abs[-avz bvy + avy bvz]^2], =A0(-avy bvx + avx bvy)/Sqrt[ Abs[-avy bvx + avx bvy]^2 + > Abs[avz bvx - avx bvz]^2 + Abs[-avz bvy + avy bvz]^2]} All three vector components have the same denominator. Whats a good > way to automatically show that for clarity and speed? =A0Id appreciate any information. Steve Gray === Subject: Re: Export Data from Mathematica to Excel >I have a Mathematica matrix format by (5*2) below >How can I export this matrix to an Excel file? Export[filename.xls, data, XLS] where data is a variable containing the matrix you want to export. This will export it to a native Excel file. An alternative would be, Export[filename.csv, data, CVS] This will export the matrix to a comma separated file. While this isnt a native Excel file, under Windows with the default installation, double clicking it will cause Excel to open it and load it automatically. -- To reply via email subtract one hundred and four === Subject: Re: What is the fastest way to threshold data? >I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to >set the z-values to zero if they fall below zero. More generally, I >would like to set z to a threshold value if it is at or below a >threshold. This seems as though it should be an easy enough thing to >do, but the only way I have figured out is to parse out the >z-vector, do >mask=((#<thresh&) /@ zdata)/.True->0/.False->1; >then zvector = zvector*mask; >and rebuild the {x,y,z} data. Using the built in function Clip is undoubtedly faster. Clip[zvector,{0, Infinity}] will return the values you want. -- To reply via email subtract one hundred and four === Subject: option to fix the speed of exported avi file I would like to ask, if when exporting a list of graphics into avi movie, Mathematica has an option that enables to decrease (or in general, to fix) a speed with which the movie will be then played outside the Mathematica? My problem is the following. I made a movie from a set of imax graphic images (denoted as graph[i] below) as follows: tab=Table[graph[i],{i,1,imax}]; Export[pathmovie.avi,tab] This however, yields a movie which is played too rapidly. I tried to slow the movie down by making a list in which each image is included several times as follows: tab=Flatten[Table[{graph[i], graph[i], ...graph[i]},{i,1,imax}]]; Export[pathmovie.avi,tab] This helps, but produces a too large avi file. Is there a better way? Alexei -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. Material Development, ZAE Weiergewan 11, rue Edmond Reuter, L-5326 Contern, Luxembourg Tel.: +352 2454-2566 Fax: +352 2454-3566 e-mail: alexei.boulbitch@iee.lu -- t is strictly prohibited. Please inform us immediately and destroy the original === Subject: Re: How to select terms wanted in a series Cases[expression, x*y*_.] Bob Hanlon I have an expression, which is a sum of large number of terms, e.g. expression = x + 2x*y - x*y*z + u*x*y + 3u^2 And I want to select out terms with the factor (x*y). e.g. The terms in expression that I want are 2x*y, -x*y*z, u*x*y My first step is, allterms = Apply[List, expression] Then, I dont know how to extract the terms I want, I use Select[allterms, (# == x*y*_)&] But It doesnt work. Anyone has some good ideas? any help will be appreciated much! > === Subject: Re: Using Fourier and InverseFourier instead of Convolve First, let me thank all who responded to my query! Second, no, Daniel, your code works fine for me. Finally, FWIW here is code that does what I really wanted, which was to quickly convolve a long list of lists (each having the same length). Possibly not the most elegant code ever, but it works, as I said, FWIW: cv[listOfLists_]:=With[{dims=Dimensions[listOfLists]}, (dims[[1]]dims[[2]]-dims[[1]]+1)^((dims[[1]]-1)/2) InverseFourier[Times[##]]&@@( Fourier[PadRight[#,dims[[1]]dims[[2]]-dims[[1]]+1] ]&/@listOfLists)] > d1 = Table[If[Abs[i] < 3, 1, 0], {i, -5, 5}]; ListLinePlot[{InverseFourier[Fourier[d1] Fourier[d1 ]] Sqrt[10] ,d1}] ListLinePlot[{ListConvolve[d1, d1, 1], d1}] ListLinePlot[{ListConvolve[d1, d1, -1], d1}] Note that the innocent code above crashes my mathematica kernel (version 6.1, does this happen to you too? ) === Subject: Re: Using Fourier and InverseFourier instead of Convolve Just to add. You may want to adjust FourierParameters to signal processing list1 = {3, 1, 4, 2}; list2 = {1, 2, 3, 4}; Out1 = ListConvolve[list1, list2, {1, -1}, 0] {3, 7, 15, 25, 20, 22, 8} SetOptions[{Fourier, InverseFourier}, FourierParameters -> {1, -1}]; n = Length[list1] + Length[list2] - 1 7 v1 = PadRight[list1, n, 0] {3, 1, 4, 2, 0, 0, 0} v2 = PadRight[list2, n, 0] {1, 2, 3, 4, 0, 0, 0} Out2 = Round[InverseFourier[Chop[Fourier[v1]*Fourier[v2]]]] {3, 7, 15, 25, 20, 22, 8} Out1 == Out2 True -- Dana DeLouis > OK, I must admit that I do not understand everything ListConvolve does, but > I get the convolution I need when I do > ListConvolve[list1, list2, {1, -1}, 0] > In particular, the output has the appropriate length: > Length[list1]+Length[list2]-1. > Now, I would like to get the identical using Fourier and InverseFourier. > Is this possible? What is the appropriate syntax? > j === Subject: Re: What is the fastest way to threshold data? data /. {x_, y_, z_?Negative} -> {x, y, 0} or more generally for a threshold data /. {x_, y_, z_ /; z < threshold} -> {x, y, threshold} Bob Hanlon > I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to set > the z-values to zero if they fall below zero. More generally, I would > like to set z to a threshold value if it is at or below a threshold. > This seems as though it should be an easy enough thing to do, but the > only way I have figured out is to parse out the z-vector, do mask=((#<thresh&) /@ zdata)/.True->0/.False->1; then > zvector = zvector*mask; and rebuild the {x,y,z} data. Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 > === Subject: Re: Series solution for complicated function Here are the results with a later version $Version 6.0 for Mac OS X x86 (64-bit) (February 7, 2008) expr = MeijerG[{{1}, {3/2}}, {{1, 1}, {0, 1/2}}, x^2]/(4 x^2); expr2 = FullSimplify[Normal[Series[expr, {x, 0, 2}]]] -((2*I*Pi*Floor[1/2 - Arg[x]/Pi] + 2*Log[x] + 2*EulerGamma - 3)/(2*Pi)) expr4 = FullSimplify[Normal[Series[expr, {x, 0, 4}]]] (-((19*x^2)/3) + 4*EulerGamma*(x^2 - 6) + 4*I*Pi*(x^2 - 6)*Floor[ 1/2 - Arg[x]/Pi] + 4*(x^2 - 6)* Log[x] + 36)/(24*Pi) Bob Hanlon > I am trying to find the series for MeijerG[{{1}, {3/2}}, {{1, 1}, {0, > 1/2}}, x^2]/(4 x^2) using my current version of Mathematica 5.0, and > it fails. Does anyone know the series solution for this up to 2nd > order, or how I can implement this in my current version of > Mathematica? Klaus. > === Subject: Hiding/Restoring Palettes? Adobe Illustrator has a huge set of several dozen info boxes and palettes (theyre called Windows) and free-standing toolbars that you can turn on individually and position around the screen. Hitting a single key (happens to be the Tab key) hides all of them and gives you an unobstructed view of the image youre editing (whatever tool you have currently selected still functions); hitting this key again toggles them all back on, in the same locations. Any comparable capability for palettes in Mathematica? [P.S. -- Adobe Acrobat has a single button at the bottom of each document that similarly toggles on and off all the Acrobat toolbars and special menu bars with a single keystroke. Very handy -- Safari could use a similar capability.] === Subject: Creating Palettes Ive just tried to create a palette in v6, it is much harder than it was in v5- is there a reason I can no longer create a palette from the edit menu, and then generate from selection? Anyway, I figured out the tedious way to do it v6, but it wont create buttons I want: CreatePalette[{PasteButton[a^2], PasteButton[b^2], PasteButton[a^3], PasteButton[b^3], PasteButton[(1 - a)], PasteButton[(1 - b)], PasteButton[(1 - a)^2], PasteButton[(1 - b)^2], PasteButton[(1 - a)^3], PasteButton[(1 - b)^3] } ]; The parentheses around (1-a) and (1-b) are never created when I press the buttons, only 1-a and 1-b, which is obviously a problem if Im multiplying things. This defeats the purpose of the palette saving keystrokes. Is there anyway to do this? === Subject: Magnification? 1) Changing the magnification value in the small drop-down menu at the bottom left of a notebook window obviously magnifies the on-screen display (but presumably NOT the printed page contents resulting from a Print command?) For example, select all the cells in a NB; set this magnification number to, say, 150%; the whole notebook expands as above. 2) Now, type the word Magnification into a new Input cell, then select *anything* else in the NB -- another cell, a word in another cell, all the cells in the NB; then again change the magnification value in the little bottom drop-down menu: **Only the word Magnification in that one input cell changes (even though its no longer selected). Nothing else -- including any other selection you make -- changes size.** In fact, you can run the word Magnification way up, or way down, in size this way. The value in the little menu and the size of the word Magnification in the one NB cell change to various values; the rest of notebook doesnt change at all. At least thats what Im seeing, right now . . . 3) OK, now shrink the Magnification word to 50% as above, leaving the rest of the NB at, say, 150% (though the little menu says 50%). Then select all cells; go to the Format >> Magnification menu; and select various values, say 100%, then 200%, etc. **The entire notebook changes to those new sizes -- including the word Magnification, which jumps into sync with rest of notebook and follows along through all size changes.** 4) Having done the preceding, leave the display at some new size; select all cells; then return to the little drop-down menu at the bottom of the NB window and try to further change NB magnification from there, as you had done earlier. Result: **The little magnification menu has now apparently ceased to function AT ALL: Neither the entire NB nor the word Magnification any longer change size (though the number in the menu field changes value appropriately).** ----- At this point, I give up . . . === Subject: export grid to pdf string problem hi, export to pdf converts strings to some kind of internal form (which looks like a notebook viewed in a text editor) when exporting a Grid (not a GraphicsGrid), ie. what i want ... Off-road use of diesel 50.12% Heavy-duty diesel vehicles 17.61% Marine Transportation 7.63% what i get ... Off-road use of diesel !(50.12)% Heavy-duty diesel vehicles !(17.61)% Marine Transportation !(7.63)% any suggestions? how do i get rid of all the crud? Mitch === Subject: Word wrapping oddity/bug? [Im starting to think my substantial personal hostility toward the Mathematica 6.0 upgrade is causing my installation to play hostile tricks on me, just to get back at me!] * Open Mathematica 6.0.1.0 on a MacBook running OS 10.4.11. * Open new NB using Cmd-N; drag window wider than initial setting. * Set Format >> Stylesheet menu command to Default (only do this because I have a very slightly modified myDefault stylesheet for my usual NBs, and I dont it to be involved). * Check that Format >> Word Wrapping >> Wrap to Window Width menu command is checked. * Type Cmd-4 to make first line of input a Section header. * Type in some long string, obviously wider than page width (but not wide enough to wrap in window). * Hit, or dont hit, Enter key. * Use Format >> Word Wrapping menu command to change to Wrap to Page Width: *** All text beyond page width disappears; cell height does not increase * Start another === Subject: Re: NDSolve of a 3rd Order Nonlinear equation > Hey all-- Im extremely new to Mathematica, but an desperately trying to > numerically solve a 3rd order, non linear differential equation: (h[x]/hf)^3*h[x] == (1 - (h[x]/hf)^3)*ohmegasqr*hf/w - s[x] > h[x1] == h[x2] == hf, h[x1] == 0 x1, x2, hf, ohmegasqr, and w are defined values. > s[x] is a defined function. Unfortunately, I keep getting a Infinite expression 1/0.^3 > encountered. and then NDSolve::ndnum: Encountered non-numerical > value for a derivative at x == -0.0508. >> error. Ive traced the problem to the initial (h[x]/hf)^3 term, but dont > really know how to fix it. Any ideas? Ive pasted the content of the notebook below, and the > actual Notebook file below that. David > --- (* hf=film thickness.Likely,thickness of SU8*) hf = 4*10^-6;(* meters *) (* w=width/length of feature along spinning direction (+x). Likely, > length of funnel *) > w = 100*10^-6;(* meters *) (* ro=radial position of feature on wafer *) ro = 2.5*10^-2;(* meters *) (* rf=radius of wafer,for normalization of x for fcn s *) rf = 0.0508;(* meters *) (* precision for step *) > xstep = 0.001; (* d=feature step height *) > d = 1.05*10^-6; (* solving bounds *) > x1 = -rf; > x2 = rf; s[x_] := -d/[Pi] (ArcTan[(x/w - 1/2)/xstep] + > ArcTan[(-(x/w) - 1/2)/xstep]); > Plot[s[x], {x, -w, w}, PlotRange -> {0, hf}, AxesLabel -> {x, s}] > (* rot=rotational speed. Likely,SU8 spinning speed *) > rot = (2 [Pi])/ > 60*4100;(* radians/second *) (* rho=fluid density.Density *) > rho = 1000;(* kg/m^3 *) (* gamma=surface tension of fluid *) > gamma = 0.03;(* N/m *) ohmegasqr = (rho*w^3*rot^2*ro)/(hf*gamma) > solution = > NDSolve[{(h[x]/hf)^3*h[x] == (1 - (h[x]/hf)^3)*ohmegasqr*hf/w - > s[x], h[x1] == h[x2] == hf, h[x1] == 0}, h, {x, x1, x2}]; > Plot[h[x] /. solution, {x, x1, x2}] > I also do not know exactly what is going wrong with this. As an alternative approach, I had seeming success by making all constants exact (so I could use higher precision in the solving later), and using an explicit shooting approach with pure initial conditions. I do not guarantee that I did all conversions correctly so youll need to check. hf = 4*10^(-6); w = 100*10^(-6); ro = 25*10^(-3); rf = 508/10^4; xstep = 1/1000; d = 105*10^(-8); x1 = -rf; x2 = rf; rot = (2*Pi)/60*4100; rho = 1000; gamma = 3/100; ohmegasqr = (rho*w^3*rot^2*ro)/(hf*gamma); Now define a function that produces solutions to the ode, given an initial condition for the second derivative. I use high precision because I had troubles getting this to stabilize at machine precision. Which might not be a surprise. sol[mm_?NumberQ] := NDSolve[{(h[x]/hf)^3*h[x] == (1 - (h[x]/hf)^3)*ohmegasqr*(hf/w) - s[x], h[x1] == hf, h[x1] == mm, h[x1] == 0}, h, {x, x1, x2}, WorkingPrecision -> 30] Here we have a simple function that finds h[x2], given a solution to the above initial value problem. shoot[y_?NumberQ] := h[x2] /. sol[y][[1, 1]] Now I solve this for a second derivative initial value (that is, h[x1]) that will cause h[x2]==hf. Trial and error convinced me that 1/25 would be a good place to start for the left endpoint second derivative h[x1]. In[171]:= h2 = y /. FindRoot[shoot[y] == hf, {y, 1/25}, WorkingPrecision -> 30] Out[171]= 0.0405585482678178231787435666966 The result can be visualized with this plot. Plot[Evaluate[h[x] /. sol[h2]], {x, x1, x2}] Daniel Lichtblau Wolfram Research === Subject: NDSolve of a 3rd Order Nonlinear equation Hey all-- Im extremely new to Mathematica, but an desperately trying to numerically solve a 3rd order, non linear differential equation: (h[x]/hf)^3*h[x] == (1 - (h[x]/hf)^3)*ohmegasqr*hf/w - s[x] h[x1] == h[x2] == hf, h[x1] == 0 x1, x2, hf, ohmegasqr, and w are defined values. s[x] is a defined function. Unfortunately, I keep getting a Infinite expression 1/0.^3 encountered. and then NDSolve::ndnum: Encountered non-numerical value for a derivative at x == -0.0508. >> error. Ive traced the problem to the initial (h[x]/hf)^3 term, but dont really know how to fix it. Any ideas? Ive pasted the content of the notebook below, and the actual Notebook file below that. David --- (* hf=film thickness.Likely,thickness of SU8*) hf = 4*10^-6;(* meters *) (* w=width/length of feature along spinning direction (+x). Likely, length of funnel *) w = 100*10^-6;(* meters *) (* ro=radial position of feature on wafer *) ro = 2.5*10^-2;(* meters *) (* rf=radius of wafer,for normalization of x for fcn s *) rf = 0.0508;(* meters *) (* precision for step *) xstep = 0.001; (* d=feature step height *) d = 1.05*10^-6; (* solving bounds *) x1 = -rf; x2 = rf; s[x_] := -d/[Pi] (ArcTan[(x/w - 1/2)/xstep] + ArcTan[(-(x/w) - 1/2)/xstep]); Plot[s[x], {x, -w, w}, PlotRange -> {0, hf}, AxesLabel -> {x, s}] (* rot=rotational speed. Likely,SU8 spinning speed *) rot = (2 [Pi])/ 60*4100;(* radians/second *) (* rho=fluid density.Density *) rho = 1000;(* kg/m^3 *) (* gamma=surface tension of fluid *) gamma = 0.03;(* N/m *) ohmegasqr = (rho*w^3*rot^2*ro)/(hf*gamma) solution = NDSolve[{(h[x]/hf)^3*h[x] == (1 - (h[x]/hf)^3)*ohmegasqr*hf/w - s[x], h[x1] == h[x2] == hf, h[x1] == 0}, h, {x, x1, x2}]; Plot[h[x] /. solution, {x, x1, x2}] ---- (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy=Mathematica 6.0 *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 9811, 259] NotebookOptionsPosition[ 9564, 246] NotebookOutlinePosition[ 9899, 261] CellTagsIndexPosition[ 9856, 258] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{(*, , RowBox[{ RowBox[{hf, =, RowBox[{film, , RowBox[{thickness, ., Likely}]}]}], ,, RowBox[{thickness, , of, , SU8}]}], *)}], n, RowBox[{ RowBox[{ RowBox[{hf, =, RowBox[{4, *, SuperscriptBox[10, RowBox[{-, 6}]]}]}], ;}], RowBox[{(*, , meters, , *)}], [IndentingNewLine], n, RowBox[{(*, , RowBox[{ RowBox[{w, =, RowBox[{ RowBox[{width, /, length}], , of, , feature, , along, , spinning, , direction, , RowBox[{ RowBox[{(, RowBox[{+, x}], )}], ., , Likely}]}]}], ,, , RowBox[{length, , of, , funnel}]}], , *)}], [IndentingNewLine], RowBox[{ RowBox[{w, =, RowBox[{100, *, SuperscriptBox[10, RowBox[{-, 6}]]}]}], ;}], RowBox[{(*, , meters, , *)}], n, [IndentingNewLine], RowBox[{(*, , RowBox[{ro, =, RowBox[{ radial, , position, , of, , feature, , on, , wafer}]}], , *)}], n, RowBox[{ RowBox[{ro, =, RowBox[{2.5, *, SuperscriptBox[10, RowBox[{-, 2}]]}]}], ;}], RowBox[{(*, , meters, , *)}], [IndentingNewLine], n, RowBox[{(*, , RowBox[{ RowBox[{rf, =, RowBox[{radius, , of, , wafer}]}], ,, RowBox[{ for, , normalization, , of, , x, , for, , fcn, , s}]}], , *)}], n, RowBox[{ RowBox[{rf, =, 0.0508}], ;}], RowBox[{(*, , meters, , *)}], n, n, RowBox[{(*, , RowBox[{precision, , for, , step}], , *)}], [IndentingNewLine], RowBox[{ RowBox[{xstep, =, 0.001}], ;}], n, [IndentingNewLine], RowBox[{(*, , RowBox[{d, =, RowBox[{feature, , step, , height}]}], , *)}], n, RowBox[{ RowBox[{d, =, RowBox[{1.05, *, SuperscriptBox[10, RowBox[{-, 6}]]}]}], ;}], [IndentingNewLine], [IndentingNewLine], RowBox[{(*, , RowBox[{solving, , bounds}], , *)}], n, RowBox[{ RowBox[{x1, , =, , RowBox[{-, rf}]}], ;}], [IndentingNewLine], RowBox[{ RowBox[{x2, , =, , rf}], ;}], [IndentingNewLine], [IndentingNewLine], RowBox[{ RowBox[{ RowBox[{s, [, x_, ]}], :=, RowBox[{ FractionBox[ RowBox[{-, d}], [Pi]], RowBox[{(, RowBox[{ RowBox[{ArcTan, [, FractionBox[ RowBox[{(, RowBox[{ FractionBox[x, w], -, FractionBox[1, 2]}], )}], xstep], ]}], +, RowBox[{ArcTan, [, FractionBox[ RowBox[{(, RowBox[{ RowBox[{-, FractionBox[x, w]}], -, FractionBox[1, 2]}], )}], xstep], ]}]}], )}]}]}], ;}], [IndentingNewLine], RowBox[{Plot, [, RowBox[{ RowBox[{s, [, x, ]}], ,, RowBox[{{, RowBox[{x, ,, RowBox[{-, w}], ,, w}], }}], ,, RowBox[{PlotRange, [Rule], RowBox[{{, RowBox[{0, ,, hf}], }}]}], ,, RowBox[{AxesLabel, [Rule], RowBox[{{, RowBox[{<x>, ,, <s>}], }}]}]}], ]}], [IndentingNewLine], n, [IndentingNewLine], RowBox[{(*, , RowBox[{ RowBox[{rot, =, RowBox[{rotational, , RowBox[{speed, ., , Likely}]}]}], ,, RowBox[{SU8, , spinning, , speed}]}], , *)}], [IndentingNewLine], RowBox[{ RowBox[{rot, =, RowBox[{ FractionBox[ RowBox[{2, [Pi]}], 60], *, 4100}]}], ;, RowBox[{(*, , RowBox[{radians, /, second}], , *)}], n, n, RowBox[{(*, , RowBox[{rho, =, RowBox[{fluid, , RowBox[{density, ., Density}]}]}], , *)}], [IndentingNewLine], RowBox[{rho, =, 1000}], ;, RowBox[{(*, , RowBox[{kg, /, RowBox[{m, ^, 3}]}], , *)}], n, n, RowBox[{(*, , RowBox[{gamma, =, RowBox[{surface, , tension, , of, , fluid}]}], , *)}], [IndentingNewLine], RowBox[{gamma, =, 0.03}], ;, RowBox[{(*, , RowBox[{N, /, m}], , *)}], [IndentingNewLine], [IndentingNewLine], RowBox[{ohmegasqr, =, FractionBox[ RowBox[{rho, *, SuperscriptBox[w, 3], *, SuperscriptBox[rot, 2], *, ro}], RowBox[{hf, *, gamma}]]}]}], [IndentingNewLine], RowBox[{ RowBox[{solution, , =, RowBox[{NDSolve, [, RowBox[{ RowBox[{{, RowBox[{ RowBox[{ RowBox[{ SuperscriptBox[ RowBox[{(, FractionBox[ RowBox[{h, [, x, ]}], hf], )}], 3], *, RowBox[{ RowBox[{h, }], [, x, ]}]}], [Equal], RowBox[{ RowBox[{ RowBox[{(, RowBox[{1, -, SuperscriptBox[ RowBox[{(, FractionBox[ RowBox[{h, [, x, ]}], hf], )}], 3]}], )}], *, ohmegasqr, *, FractionBox[hf, w]}], -, RowBox[{ RowBox[{s, }], [, x, ]}]}]}], ,, RowBox[{ RowBox[{h, [, x1, ]}], [Equal], RowBox[{h, [, x2, ]}], ==, hf}], ,, RowBox[{ RowBox[{ RowBox[{h, }], [, x1, ]}], [Equal], 0}]}], }}], ,, h, ,, RowBox[{{, RowBox[{x, ,, x1, ,, x2}], }}]}], ]}]}], ;}], [IndentingNewLine], RowBox[{Plot, [, RowBox[{ RowBox[{ RowBox[{h, [, x, ]}], /., solution}], ,, RowBox[{{, RowBox[{x, ,, x1, ,, x2}], }}]}], ]}], [IndentingNewLine]}]}]], Input, CellChangeTimes->{ 3.413111430927577*^9, {3.4131115373881207`*^9, 3.413111666237986*^9}, { 3.413111726935742*^9, 3.413111840075963*^9}, {3.413111887010826*^9, 3.4131119092610703`*^9}, {3.4131119714608307`*^9, 3.413111971748232*^9}, { 3.413112046539139*^9, 3.413112102719515*^9}, {3.4131121733772*^9, 3.4131123597867413`*^9}, {3.413112400416985*^9, 3.413112410218919*^9}, { 3.413112453929551*^9, 3.413112465297611*^9}, {3.413112710892577*^9, 3.413112899381797*^9}, {3.413112946916642*^9, 3.4131129658870277`*^9}, { 3.4131130083127003`*^9, 3.413113237415053*^9}, {3.413113292176826*^9, 3.4131133110063562`*^9}, {3.413113363615012*^9, 3.41311337520851*^9}, { 3.413113497026219*^9, 3.413113512331257*^9}, {3.413113644184579*^9, 3.413113650163204*^9}, {3.413113705184865*^9, 3.413113739659149*^9}, { 3.413113787270136*^9, 3.4131138327395487`*^9}, {3.4131139375450974`*^9, 3.413113981999775*^9}, 3.4131140168228292`*^9, {3.413114053449093*^9, 3.413114054388459*^9}, {3.413114254952673*^9, 3.41311431278682*^9}, { 3.413114432900443*^9, 3.413114440811491*^9}, {3.4131144827067957`*^9, 3.4131144908759727`*^9}, {3.413114542574057*^9, 3.413114543058976*^9}, { 3.413114621849752*^9, 3.413114644727951*^9}, {3.4131147254059563`*^9, 3.413114730205886*^9}, {3.413114771616315*^9, 3.4131147746457453`*^9}, { 3.413125436154814*^9, 3.413125479168673*^9}, {3.413125578877687*^9, 3.41312559656024*^9}, {3.413125800269329*^9, 3.413125840812818*^9}, { 3.413125912006034*^9, 3.4131259521773653`*^9}, {3.4131259965893717`*^9, 3.4131260082581587`*^9}, {3.41312608880905*^9, 3.413126131536799*^9}, { 3.413126509426512*^9, 3.413126525384309*^9}, {3.4131266902347593`*^9, 3.413126725333584*^9}, {3.4131267657553463`*^9, 3.413126766816489*^9}, { 3.4131269095066757`*^9, 3.413126910430483*^9}, {3.4131269529771442`*^9, 3.413126986186933*^9}, {3.413127060814258*^9, 3.4131271285331383`*^9}, { 3.413127177228231*^9, 3.413127197233301*^9}, {3.4131272464956093`*^9, 3.41312725325977*^9}, {3.413127291470043*^9, 3.413127331901906*^9}, { 3.413127372028913*^9, 3.4131274594266853`*^9}, {3.413127495978286*^9, 3.413127503296323*^9}, {3.413127732756802*^9, 3.413127863964082*^9}, { 3.413129926444252*^9, 3.413130011417639*^9}, {3.4131316497119637`*^9, 3.413131668619741*^9}, {3.4131317199983807`*^9, 3.4131317267565603`*^9}, { 3.413131830293474*^9, 3.413131830827696*^9}, 3.413131985466963*^9}] }, WindowSize->{1068, 853}, WindowMargins->{{6, Automatic}, {Automatic, 0}}, FrontEndVersion->6.0 for Mac OS X x86 (32-bit) (June 19, 2007), StyleDefinitions->Default.nb ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 8992, 223, 730, Input] } ] *) (* End of internal cache information *) === Subject: Re: nesting pure functions I have figured out how to do this in one manner. What I want is this: g = Function[{x,y,f},f[x,y,#]&] Now, the question remains: is there a way to do this without naming variables explicitly? I would not be surprised if the answer is no. Ryan > Im trying to define a function, g, such that given some parameters and > a function as arguments, it returns a pure function: g[x_,y_,f_Function] = Function[f[x,y,#]] However, I need to define g itself as a pure function. Im not sure how > to do this. It may be something like this: g = Function[Function[#3[#1,#2,#?????]]] Obviously, I want #?????? to be the argument of the of the outermost > Function, and #1, #2, #3 of the innermost function. Is there a way of defining g as a pure function (of a pure function) in > Mathematica? I appreciate your help, > Ryan === Subject: nesting pure functions Im trying to define a function, g, such that given some parameters and a function as arguments, it returns a pure function: g[x_,y_,f_Function] = Function[f[x,y,#]] However, I need to define g itself as a pure function. Im not sure how to do this. It may be something like this: g = Function[Function[#3[#1,#2,#?????]]] Obviously, I want #?????? to be the argument of the of the outermost Function, and #1, #2, #3 of the innermost function. Is there a way of defining g as a pure function (of a pure function) in Mathematica? I appreciate your help, Ryan === Subject: Bug in Interpolation for multi-d data? Interpolation on multi-d data gives different answers depending on the order in which the elements are *ordered* in the list. As far as I can tell, this is not documented. The sorted element order seems to produce the right results. Example 1: dat = Flatten[ Table[{{x, y}, Sin[x] Sin[2 y]}, {x, -3, 3, 0.1}, {y, -3, 3, 0.1}], 1]; dat[[{1, 2, 3}]] intp = Interpolation[dat]; ListPlot3D[Flatten /@ dat] Plot3D[intp[x, y], {x, -3, 3}, {y, -3, 3}] Example 2: dat = Flatten[ Table[{{x, y}, Sin[x] Sin[2 y]}, {y, -3, 3, 0.1}, {x, -3, 3, 0.1}], 1]; dat[[{1, 2, 3}]] intp = Interpolation[dat]; ListPlot3D[Flatten /@ dat] Plot3D[intp[x, y], {x, -3, 3}, {y, -3, 3}] Example 3: dat = Flatten[ Table[{{x, y}, Sin[x] Sin[2 y]}, {y, -3, 3, 0.1}, {x, -3, 3, 0.1}], 1]//Sort; dat[[{1, 2, 3}]] intp = Interpolation[dat]; ListPlot3D[Flatten /@ dat] Plot3D[intp[x, y], {x, -3, 3}, {y, -3, 3}] Am I missing something obvious in the documentation? === Subject: FindRoot solving of Excel input columns numerically, and all my datas in excel. Ive successfully created a FindRoot to solve eqns for one set of data points. However, I really need to automate this... Ive read through help to no avail. Heres what Im working on: As are columns of excel data with a several hundred rows of data. ks are constants ts are variables to solve and plot. Eqn1 = t1 - k1*Log[ 1 + (A1/A3)*(1 - exp(-t3)*(exp(-t2) ] Eqn2 = t2 - k2*Log[ 1 + (A2/A3)*(1 - exp(-t3/) ] Eqn3 = t3 -k3*t2 FindRoot[{Eqn1==0,Eqn2==0,Eqn3==0}, { {t1,1},{t2,1},(t3,1} } ] What Id like to do is... 1. import 4 column (A1,A2,A3,A4) excel sheet, where A4 is carried through and not processed. 2. export 4 column results for (t1,t2,t3,A4) to xls, and plot t1 vs A4, t2 vs A4, t3 vs A4 in mathematica. Ive read through help to no avail... and have tried some kind of For loop on this FindRoot, and havent been successful. Much appreciate anybodys help. John === Subject: reduce spacing between axes and framelabel is there a way to reduce the spacing between a framelabel and axes for ListPlot (and Plot, ...) ? ive looked at ImageMargins and ImagePadding without success. Mitch === Subject: Re: Deleting elements from a Table > TabIN /. {a___,{q_,_},b___,{q_,_},c___}:> {a,b,c} > no need for Sort On 26 Feb, 13:56, Jens-Peer Kuska <ku...@informatik.uni-leipzig.de > > TabIN /. {a___,{q_,_},{q_,_},b___}:> {a,b} > if the second element are not follow the first, you may > > Sort[] the list. > Jens > I have go the following problem: > > I have a table of elements like {{x1,y1},{x2,y2}....}. Occasionally, > > two elements have the same x. I would like to drop these elements with > > a rule-based function. > > Example: > TabIN={{1,1},{1,2},{2,2}}; > my desired output is: > TabOUT={{2,2}} > Any help? > >Luigi but what if (time-wise) I want to skip the Sort of the input table? ciao >Luigi It works fine. Luigi === Subject: Re: Re: Deleting elements from a Table TabIN /. {a___,{q_,_},b___,{q_,_},c___}:> {a,b,c} no need for Sort > On 26 Feb, 13:56, Jens-Peer Kuska <ku...@informatik.uni-leipzig.de > TabIN /. {a___,{q_,_},{q_,_},b___}:> {a,b} if the second element are not follow the first, you may > Sort[] the list. Jens > I have go the following problem: > > I have a table of elements like {{x1,y1},{x2,y2}....}. Occasionally, > > two elements have the same x. I would like to drop these elements with > > a rule-based function. > > Example: > TabIN={{1,1},{1,2},{2,2}}; > my desired output is: > TabOUT={{2,2}} > Any help? > > Luigi but what if (time-wise) I want to skip the Sort of the input table? ciao > Luigi === Subject: Re: Deleting elements from a Table On 26 Feb, 13:56, Jens-Peer Kuska <ku...@informatik.uni-leipzig.de > TabIN /. {a___,{q_,_},{q_,_},b___}:> {a,b} if the second element are not follow the first, you may > Sort[] the list. Jens I have go the following problem: > I have a table of elements like {{x1,y1},{x2,y2}....}. Occasionally, > two elements have the same x. I would like to drop these elements with > a rule-based function. > Example: TabIN={{1,1},{1,2},{2,2}}; my desired output is: TabOUT={{2,2}} Any help? > Luigi but what if (time-wise) I want to skip the Sort of the input table? ciao Luigi === Subject: Re: Deleting elements from a Table this may be very time expensive. But TabIN /. {a___,{q_,_},c___,{q_,_},b___}:> {a,c,b} will do that. Jens > On 26 Feb, 13:56, Jens-Peer Kuska <ku...@informatik.uni-leipzig.de> TabIN /. {a___,{q_,_},{q_,_},b___}:> {a,b} >> if the second element are not follow the first, you may >> Sort[] the list. >> Jens > I have go the following problem: > I have a table of elements like {{x1,y1},{x2,y2}....}. Occasionally, > two elements have the same x. I would like to drop these elements with > a rule-based function. > Example: > TabIN={{1,1},{1,2},{2,2}}; > my desired output is: > TabOUT={{2,2}} > Any help? > Luigi but what if (time-wise) I want to skip the Sort of the input table? ciao > Luigi > === Subject: Re: Series solution for complicated function Klaus. === Subject: Re: Version 6.0.2 theyre a bit slow with this; I phoned my vendor and asked for a link.Peter how do I get the update? I have a premium license and have received > no notice of the release? > hi BobI thought > http://support.wolfram.com/mathematica > /systems/macintosh/osx/32bitratherthan64bit.html previously gave 64 bit on 6.01 on Mac ? Peter > On the PLUS side, 6.0.2 gives me a 64-bit install on my Intel Mac, > where 6 > > and 6.01 did not. > > Bobby > > My initial impression of Mathematica Version 6.0.2 is a > disappointment. > > 1) There is still no easy access to the list of standard packages > > that > > come with Mathematica. It quite difficult to find them. The Virtual > > Book > > that was posted on this group did have a list of these packages but > the > > WRI > > Virtual Book does not have them. (An indirect way to get links to > > standard > > packages is to search *Package in the Documentation Center. But this > > gives a > > lot of other stuff also.) > > 2) The worse new feature is that the palettes that come with > Mathematica > > will no longer remember their position and condition. If they are > not > > where > > you like them then each time you start up Mathematica you will > either > > have > > to live with it or adjust them anew. With 6.0 and 6.0.1 I was able > to > > change > > the preferences for the ColorScheme palette so it would remember its > > condition. I can no longer do this and none of the other palettes > > remember > > thier state either. (One improved feature is that the > SpecialCharacters > > palette will now directly paste instead of select and then paste.) > If > > you > > like to control where the palettes are stay with 6.0.1, > > 3) I was hoping that the Format/StyleSheet menu would put a check by > the > > current style sheet in use for a notebook but this still has not > been > > fixed. > > And aside from this we still dont have the ability to write Version > 6 > > style > > documentation. > > -- > > DrMajorBob@bigfoot.com > -- > peter lindsay > Computing Officer > Mathematical Institute > University of St Andrews > KY16 9SS > 01334463756 > -- > Richard Palmer Home 508 877-3862 > Cell 508 982-7266 > -- peter lindsay Computing Officer Mathematical Institute University of St Andrews KY16 9SS 01334463756 ------=_Part_26713_16568786.1204216222229 > hi BobI thought<br> > <a href=http://support.wolfram.com/mathematica>http://support.wolfram.com/ma thematica</a><br> > /systems/macintosh/osx/32bitratherthan64bit.html<br> ><br> > previously gave 64 bit on 6.01 on Mac ?<br> > > that<br> > > > come with Mathematica. It quite difficult to find them. The 'Virtual<br> > > > Book'<br> > > > that was posted on this group did have a list of these packages but the<br> > > > WRI<br> > > > Virtual Book does not have them. (An indirect way to get links to<br> > > > standard<br> > > > packages is to search *Package in the Documentation Center. But this<br> > > > gives a<br> > > > lot of other stuff also.)<br> > > ><br> > > > 2) The worse new feature is that the palettes that come with Mathematica<br> > > > will no longer remember their position and condition. If they are not<br> > > > where<br> > > > you like them then each time you start up Mathematica you will either<br> > > > have<br> > > > to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to<br> > > > change<br> > > > the preferences for the ColorScheme palette so it would remember its<br> > > > condition. I can no longer do this and none of the other palettes<br> > > > remember<br> > > > thier state either. (One improved feature is that the SpecialCharacters<br> > > > palette will now directly paste instead of select and then paste.) If<br> > > you<br> > > > like to control where the palettes are stay with 6.0.1,<br> > > ><br> > > > 3) I was hoping that the Format/StyleSheet menu would put a check by the<br> > > > current style sheet in use for a notebook but this still has not been<br> > > > fixed.<br> > > ><br> > > > And aside from this we still don't have the ability to write Version 6<br> > > > style<br> > > > documentation.<br> > > ><br> > ><br> > ><br> > ><br> > > --<br> > ><br> > > <a href=mailto:DrMajorBob@bigfoot.com>DrMajorBob@bigfoot.com</a><br> > ><br> > ><br> ><br> ><br> > --<br> > peter lindsay<br> > Computing Officer<br> > Mathematical Institute<br> > University of St Andrews<br> > KY16 9SS<br> > 01334463756<br> ><br> ><br> ><br> <br> <br> <br>--<br> Richard Palmer<br> <br> Home 508 877-3862<br> Cell 508 982-7266<br> </blockquote></div><br><br clear=all> <br>-- <br>peter lindsay<br>Computing Officer<br>Mathematical Institute<br>University of St Andrews<br>KY16 9SS<br>01334463756 </div> ------=_Part_26713_16568786.1204216222229-- === Subject: Re: Version 6.0.2 how do I get the update? I have a premium license and have received no notice of the release? > hi BobI thought > http://support.wolfram.com/mathematica > /systems/macintosh/osx/32bitratherthan64bit.html previously gave 64 bit on 6.01 on Mac ? Peter > On the PLUS side, 6.0.2 gives me a 64-bit install on my Intel Mac, where 6 > and 6.01 did not. Bobby > My initial impression of Mathematica Version 6.0.2 is a disappointment. > > 1) There is still no easy access to the list of standard packages > that > > come with Mathematica. It quite difficult to find them. The Virtual > > Book > > that was posted on this group did have a list of these packages but the > > WRI > > Virtual Book does not have them. (An indirect way to get links to > > standard > > packages is to search *Package in the Documentation Center. But this > > gives a > > lot of other stuff also.) > > 2) The worse new feature is that the palettes that come with Mathematica > > will no longer remember their position and condition. If they are not > > where > > you like them then each time you start up Mathematica you will either > > have > > to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to > > change > > the preferences for the ColorScheme palette so it would remember its > > condition. I can no longer do this and none of the other palettes > > remember > > thier state either. (One improved feature is that the SpecialCharacters > > palette will now directly paste instead of select and then paste.) If > you > > like to control where the palettes are stay with 6.0.1, > > 3) I was hoping that the Format/StyleSheet menu would put a check by the > > current style sheet in use for a notebook but this still has not been > > fixed. > > And aside from this we still dont have the ability to write Version 6 > > style > > documentation. > > -- DrMajorBob@bigfoot.com > -- > peter lindsay > Computing Officer > Mathematical Institute > University of St Andrews > KY16 9SS > 01334463756 > -- Richard Palmer Home 508 877-3862 Cell 508 982-7266 === Subject: Re: Version 6.0.2 Bobby, dead right: I only found out from one of our many stars, karl unterkoflerwhen, when I replied to his request on this group for benchmark test results. The wolfram guys are guilty of poor communication with their fans ;) Peter Good to know, but a LITTLE late. The installer should have taken care of this automatically. Bobby hi BobI thought > http://support.wolfram.com/mathematica > /systems/macintosh/osx/32bitratherthan64bit.html previously gave 64 bit on 6.01 on Mac ? Peter > On the PLUS side, 6.0.2 gives me a 64-bit install on my Intel Mac, >> where 6 >> and 6.01 did not. >> Bobby >> My initial impression of Mathematica Version 6.0.2 is a >> disappointment. >> 1) There is still no easy access to the list of standard packages >> that >> come with Mathematica. It quite difficult to find them. The Virtual >> Book >> that was posted on this group did have a list of these packages but >> the >> WRI >> Virtual Book does not have them. (An indirect way to get links to >> standard >> packages is to search *Package in the Documentation Center. But this >> gives a >> lot of other stuff also.) >> 2) The worse new feature is that the palettes that come with >> Mathematica >> will no longer remember their position and condition. If they are not >> where >> you like them then each time you start up Mathematica you will either >> have >> to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to >> change >> the preferences for the ColorScheme palette so it would remember its >> condition. I can no longer do this and none of the other palettes >> remember >> thier state either. (One improved feature is that the >> SpecialCharacters >> palette will now directly paste instead of select and then paste.) If >> you >> like to control where the palettes are stay with 6.0.1, >> 3) I was hoping that the Format/StyleSheet menu would put a check by >> the >> current style sheet in use for a notebook but this still has not been >> fixed. >> And aside from this we still dont have the ability to write Version > 6 >> style >> documentation. >> -- >> DrMajorBob@bigfoot.com > > -- DrMajorBob@bigfoot.com > -- peter lindsay Computing Officer Mathematical Institute University of St Andrews KY16 9SS 01334463756 ------=_Part_379_16558466.1204233849915 <div>Bobby,</div><div>dead right: I only found out from one of our many stars, karl unterkoflerwhen, when I replied to his request on this group for benchmark test results.</div><div>The wolfram guys are guilty of poor communication with their fans ;)</div> <br> > hi BobI thought<br> > <a href=http://support.wolfram.com/mathematica target=_blank onclick=return top.js.OpenExtLink(window,event,this)>http://support.wolfram.com/mathematic a</a><br> > /systems/macintosh/osx/32bitratherthan64bit.html<br> ><br> > previously gave 64 bit on 6.01 on Mac ?<br> >><br> >> On the PLUS side, 6.0.2 gives me a 64-bit install on my Intel Mac,<br> >> that<br> >> > come with Mathematica. It quite difficult to find them. The 'Virtual<br> >> > Book'<br> >> > that was posted on this group did have a list of these packages but<br> >> the<br> >> > WRI<br> >> > Virtual Book does not have them. (An indirect way to get links to<br> >> > standard<br> >> > packages is to search *Package in the Documentation Center. But this<br> >> > gives a<br> >> > lot of other stuff also.)<br> >> ><br> >> > 2) The worse new feature is that the palettes that come with<br> >> Mathematica<br> >> > will no longer remember their position and condition. If they are not<br> >> > where<br> >> > you like them then each time you start up Mathematica you will either<br> >> > have<br> >> > to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to<br> >> > change<br> >> > the preferences for the ColorScheme palette so it would remember its<br> >> > condition. I can no longer do this and none of the other palettes<br> >> > remember<br> >> > thier state either. (One improved feature is that the<br> >> SpecialCharacters<br> >> > palette will now directly paste instead of select and then paste.) If<br> >> you<br> >> > like to control where the palettes are stay with 6.0.1,<br> >> ><br> >> > 3) I was hoping that the Format/StyleSheet menu would put a check by<br> >> the<br> >> > current style sheet in use for a notebook but this still has not been<br> >> > fixed.<br> >> ><br> >> > And aside from this we still don't have the ability to write Version 6<br> >> > style<br> >> > documentation.<br> >> ><br> >><br> >><br> >><br> >> --<br> >><br> >> <a href=mailto:DrMajorBob@bigfoot.com target=_blank onclick=return top.js.OpenExtLink(window,event,this)>DrMajorBob@bigfoot.com</a><br> >><br> >><br> ><br> ><br> <br> <br> <br> --<br> <br><a href=mailto:DrMajorBob@bigfoot.com target=_blank onclick=return top.js.OpenExtLink(window,event,this)>DrMajorBob@bigfoot.com</a><br> </blockquote></div><br><br clear=all><br>-- <br>peter lindsay<br>Computing Officer<br>Mathematical Institute<br>University of St Andrews<br>KY16 9SS<br>01334463756 </div></div></div></div> ------=_Part_379_16558466.1204233849915-- === Subject: Re: Version 6.0.2 Good to know, but a LITTLE late. The installer should have taken care of this automatically. Bobby > hi BobI thought > http://support.wolfram.com/mathematica > /systems/macintosh/osx/32bitratherthan64bit.html previously gave 64 bit on 6.01 on Mac ? Peter > On the PLUS side, 6.0.2 gives me a 64-bit install on my Intel Mac, >> where 6 >> and 6.01 did not. >> Bobby >> My initial impression of Mathematica Version 6.0.2 is a >> disappointment. >> 1) There is still no easy access to the list of standard packages >> that >> come with Mathematica. It quite difficult to find them. The Virtual >> Book >> that was posted on this group did have a list of these packages but >> the >> WRI >> Virtual Book does not have them. (An indirect way to get links to >> standard >> packages is to search *Package in the Documentation Center. But this >> gives a >> lot of other stuff also.) >> 2) The worse new feature is that the palettes that come with >> Mathematica >> will no longer remember their position and condition. If they are not >> where >> you like them then each time you start up Mathematica you will either >> have >> to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to >> change >> the preferences for the ColorScheme palette so it would remember its >> condition. I can no longer do this and none of the other palettes >> remember >> thier state either. (One improved feature is that the >> SpecialCharacters >> palette will now directly paste instead of select and then paste.) If >> you >> like to control where the palettes are stay with 6.0.1, >> 3) I was hoping that the Format/StyleSheet menu would put a check by >> the >> current style sheet in use for a notebook but this still has not been >> fixed. >> And aside from this we still dont have the ability to write Version 6 >> style >> documentation. >> -- >> DrMajorBob@bigfoot.com > > -- DrMajorBob@bigfoot.com === Subject: Re: Version 6.0.2 hi BobI thought http://support.wolfram.com/mathematica /systems/macintosh/osx/32bitratherthan64bit.html previously gave 64 bit on 6.01 on Mac ? Peter On the PLUS side, 6.0.2 gives me a 64-bit install on my Intel Mac, where 6 > and 6.01 did not. Bobby My initial impression of Mathematica Version 6.0.2 is a disappointment. 1) There is still no easy access to the list of standard packages > that > come with Mathematica. It quite difficult to find them. The Virtual > Book > that was posted on this group did have a list of these packages but the > WRI > Virtual Book does not have them. (An indirect way to get links to > standard > packages is to search *Package in the Documentation Center. But this > gives a > lot of other stuff also.) 2) The worse new feature is that the palettes that come with Mathematica > will no longer remember their position and condition. If they are not > where > you like them then each time you start up Mathematica you will either > have > to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to > change > the preferences for the ColorScheme palette so it would remember its > condition. I can no longer do this and none of the other palettes > remember > thier state either. (One improved feature is that the SpecialCharacters > palette will now directly paste instead of select and then paste.) If > you > like to control where the palettes are stay with 6.0.1, 3) I was hoping that the Format/StyleSheet menu would put a check by the > current style sheet in use for a notebook but this still has not been > fixed. And aside from this we still dont have the ability to write Version 6 > style > documentation. > -- DrMajorBob@bigfoot.com -- peter lindsay Computing Officer Mathematical Institute University of St Andrews KY16 9SS 01334463756 === Subject: Re: Version 6.0.2 On the PLUS side, 6.0.2 gives me a 64-bit install on my Intel Mac, where 6 and 6.01 did not. Bobby > My initial impression of Mathematica Version 6.0.2 is a disappointment. 1) There is still no easy access to the list of standard packages that > come with Mathematica. It quite difficult to find them. The Virtual > Book > that was posted on this group did have a list of these packages but the > WRI > Virtual Book does not have them. (An indirect way to get links to > standard > packages is to search *Package in the Documentation Center. But this > gives a > lot of other stuff also.) 2) The worse new feature is that the palettes that come with Mathematica > will no longer remember their position and condition. If they are not > where > you like them then each time you start up Mathematica you will either > have > to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to > change > the preferences for the ColorScheme palette so it would remember its > condition. I can no longer do this and none of the other palettes > remember > thier state either. (One improved feature is that the SpecialCharacters > palette will now directly paste instead of select and then paste.) If you > like to control where the palettes are stay with 6.0.1, 3) I was hoping that the Format/StyleSheet menu would put a check by the > current style sheet in use for a notebook but this still has not been > fixed. And aside from this we still dont have the ability to write Version 6 > style > documentation. > -- DrMajorBob@bigfoot.com === Subject: Re: Version 6.0.2 I dont seem to be able to find the release notes. Besides the cosmetic change of the documentation system, the only thing I see of essence is some improvement of import/export. What about bug fixes? It there a list of changes? Bo > My initial impression of Mathematica Version 6.0.2 is a > disappointment. 1) There is still no easy access to the list of standard > packages that > come with Mathematica. It quite difficult to find them. The > Virtual Book > that was posted on this group did have a list of these packages but > the WRI > Virtual Book does not have them. (An indirect way to get links to > standard > packages is to search *Package in the Documentation Center. But > this gives a > lot of other stuff also.) 2) The worse new feature is that the palettes that come with > Mathematica > will no longer remember their position and condition. If they are > not where > you like them then each time you start up Mathematica you will > either have > to live with it or adjust them anew. With 6.0 and 6.0.1 I was able > to change > the preferences for the ColorScheme palette so it would remember its > condition. I can no longer do this and none of the other palettes > remember > thier state either. (One improved feature is that the > SpecialCharacters > palette will now directly paste instead of select and then paste.) > If you > like to control where the palettes are stay with 6.0.1, 3) I was hoping that the Format/StyleSheet menu would put a check > by the > current style sheet in use for a notebook but this still has not > been fixed. And aside from this we still dont have the ability to write > Version 6 style > documentation. -- > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ > === Subject: Version 6.0.2 My initial impression of Mathematica Version 6.0.2 is a disappointment. 1) There is still no easy access to the list of standard packages that come with Mathematica. It quite difficult to find them. The Virtual Book that was posted on this group did have a list of these packages but the WRI Virtual Book does not have them. (An indirect way to get links to standard packages is to search *Package in the Documentation Center. But this gives a lot of other stuff also.) 2) The worse new feature is that the palettes that come with Mathematica will no longer remember their position and condition. If they are not where you like them then each time you start up Mathematica you will either have to live with it or adjust them anew. With 6.0 and 6.0.1 I was able to change the preferences for the ColorScheme palette so it would remember its condition. I can no longer do this and none of the other palettes remember thier state either. (One improved feature is that the SpecialCharacters palette will now directly paste instead of select and then paste.) If you like to control where the palettes are stay with 6.0.1, 3) I was hoping that the Format/StyleSheet menu would put a check by the current style sheet in use for a notebook but this still has not been fixed. And aside from this we still dont have the ability to write Version 6 style documentation. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Using Fourier and InverseFourier instead of Convolve > dims[[1]]dims[[2]]-dims[[1]]+1)^((dims[[1]]-1)/2)....etc Hi. This does pretty much the same as your code, but uses a different FourierParameters. LC[v_List] := Module[{r, c, m, signal}, signal = FourierParameters -> {1, -1}; {r, c} = Dimensions[v]; m = PadRight[v, {r, r*c - r + 1}]; m = Map[Chop[Fourier[#, signal]] &, m]; m = Times @@ m; m = Chop[InverseFourier[m, signal]]; If[MatrixQ[v, IntegerQ], Round[m], m] ] /; ArrayDepth[v] == 2 v = {{1, 2}, {3, 4}, {5, 6}}; LC[v] {15, 68, 100, 48} Fold[ListConvolve[#1, #2, {1, -1}, 0] &, First[v], Rest[v]] {15, 68, 100, 48} -- HTH :>) Dana DeLouis > First, let me thank all who responded to my query! > Second, no, Daniel, your code works fine for me. > Finally, FWIW here is code that does what I really wanted, which was to > quickly convolve a long list of lists (each having the same length). > Possibly not the most elegant code ever, but it works, as I said, FWIW: cv[listOfLists_]:=With[{dims=Dimensions[listOfLists]}, > (dims[[1]]dims[[2]]-dims[[1]]+1)^((dims[[1]]-1)/2) > InverseFourier[Times[##]]&@@( > Fourier[PadRight[#,dims[[1]]dims[[2]]-dims[[1]]+1] > ]&/@listOfLists)] > <snip> === Subject: problem with Inset moving text I am trying to use Inset but have a problem in 6.0.1 see this code Manipulate[ Graphics[ {Circle[], Inset[Style[StringJoin[value:, ToString[N[c]]], Blue, 20]] } ] , {{c, (2 [Pi])/3, Value c}, -1, 2 Pi, 0.001}] use the slide to go to value 1.609 and then it jumps into value 1.61 the problem I have is that the text jumps horizontaly any way to make the text fix so it will not jump? this happens because the numbers 1.609 and 1.61 are different in leght any solution? thank you, === Subject: what corresponds to work folder in mathematica hello As in another system , we have work folder, where I can keep the .m file with the function i have created and use it directly in my other code. Is ther any thing such in Mathematica, where I can keep the .nb file having the code of my function and call it in any other file Gracias === Subject: Mathematica 6.0.2 update Mathematica 6.0.2 is now available and features several improvements to Mathematicas performance and functionality. This update includes: * New Virtual Book documentation with updated Mathematica Book content * New Function Navigator, an easily browsable overview of all Mathematica objects * Several additional documentation enhancements, including performance improvements, indexing, and link trails * Full 64-bit performance on Intel Macs * Improved performance of Import/Export converters on Mac and Unix * Significant speedup in import of binary data files * Improved handling of graphics when exporting to TeX and PDF * Enhanced import of metadata from FITS astronomical image files * New coordinate-picking tool and improved highlighting of graphical selections for interactive graphics Mathematica users with Premier Service will receive email in the next few days with instructions on how to obtain their free copies. More information about Premier Service is available at: http://www.wolfram.com/service Further details about Mathematica are available at: http://www.wolfram.com/mathematica