mm-689 === Subject: Re: 5.2 on suse 10.0 error Hi Steven, I just installed a fresh SUSE 10.0 on a new computer. Then I installed Mathematica. On the first activation on mathematica a sterr window is opened with the known Warning: Actions not found: delete-next-character message appearing SEVERAL times (6 lines, to be accurate). I used the very same steps I gave in my previous email + the xrdb .Xdefaults added to the .bashrc file This solves the problem once and for all yehuda > I had the same problem but the solution that worked out with earlier SUSE > versions was not sufficient. > The first part remains as is given in http://support.wolfram.com/mathematica/systems/linux/intel/deletenext51.html > you need only parts 1 and 2. part 3 will only work once in each session > and you wiil either need to write this command manually on you shell or > make this happen each time you log in. > For the second option just (I use the bash shell) enter the command > xrdb .XMathematica into you .bashrc file > use any text editor you like. You will find this file is in your home > directory > good luck > yehuda > I do not believe I ever saw the errors Masrur posted. I believe this is > all > I have done to my system to get Mathematica to work correctly. > $ touch ~/.Xdefaults > $ echo $MMA_ADDONS > /usr/local/Wolfram/Mathematica/5.2/AddOns > $ echo $MMA_APPS > /usr/local/Wolfram/Mathematica/5.2/AddOns/Applications > $ cat ~/bin/mma > #!/bin/bash > pushd $MMA_CODE > export CLASSPATH= > :$MMA_ADDONS/JLink/JLink.jar > :$MMA_APPS/GUIKit/Java/GUIKit.jar > :$MMA_APPS/GUIKit/Java/bsf.jar > :$MMA_APPS/GUIKit/Java/OculusLayout.jar > :$MMA_APPS/GUIKit/Java/diva-canvas-core.jar > :$MMA_APPS/GUIKit/Java/xercesImpl.jar > :$MMA_APPS/GUIKit/Java/concurrent.jar > :$MMA_APPS/GUIKit/Java/bsf-Wolfram.jar > :$MMA_APPS/GUIKit/Java/xmlParserAPIs.jar > :/download/de/uni-stutgart/live.jar > :. > xrdb ~/.Xdefaults > nohup mathematica > -font 10x20 > -geometry 800x600+80+60 > -singleLaunch $@ > ~/.Mathematica/mma.log & > ########### EOF #################### > $ chmod 755 ~/bin/mma > $ ~/bin/mma > I recently reinstalled Mathematica, so everything in the install directory > which I might have modified should be back to default settings. I do not > have an XMathematica under /usr/X11R6. > $ grep -r XMathematica * 2> /dev/null > $ grep -r Xmathematica * 2> /dev/null > The 2> /dev/null just sends the permission denied errors to /dev/null > -- > The Mathematica Wiki: http://www.mathematica-users.org/ > Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html > Math for the WWW: http://www.w3.org/Math/ === Subject: Re: 5.2 on suse 10.0 error > Hi Steven, > I just installed a fresh SUSE 10.0 on a new computer. Then I installed > Mathematica. > On the first activation on mathematica a sterr window is opened with > the known > Warning: Actions not found: delete-next-character > message appearing SEVERAL times (6 lines, to be accurate). > I used the very same steps I gave in my previous email + the xrdb > .Xdefaults added to the .bashrc file > This solves the problem once and for all > yehuda Do you need anything other than an empty .Xdefaults and the xrdb invocation? The only reason I have the .Xdefaults is because xrdb complains when it's not there, and I didn't feel like trying to figure out how to give it a commandline option to shut it up. Steven -- The Mathematica Wiki: http://www.mathematica-users.org/ Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html Math for the WWW: http://www.w3.org/Math/ === Subject: Re: Plot Angle between Vectors > Agreed. Mr. Park's solutions are invariably helpful and interesting. > I've seen, several other people from the list could do analogous > marketing. As for myself, I might be able to afford some of the packages > once I get out of grad. school! > Curtis O. What I'd like to see is a Lite version of the package, for the occasional user (like me and many others). E.g. I hardly use the 3D features in DrawGraphics, so there could be a 2D-only version of DrawGraphics that is cheaper. -- MSN: wizard_of_yendor@hotmail.com Orkut: http://www.orkut.com/Profile.aspx?uid=2202360379963855296 === Subject: not a homework assignment >Since your question looks like a homework assignment and you did not >show whatever you tried, I will show you one possible approaches with a >working solution and using a combination of *Mod* built-in functions >you should be able to answer your original problem. Hi Jean-Marc, It is certainly not a homework assignment. I'm more interested in number theory than Mathematica and I have little time to give to it. I didn't know that I was supposed to show what I tried, but in any case it wasn't worth exhibiting. Your approach is very helpful. Andrea I received about at least three different approaches -- all interesting. Bob Hanlon sent me the same one as Jean-Marc, and that is the one I am modifying to use. Great group! Andrea === Subject: Re: extract from list and keep track Here's a two liner that is a little easier to understand: data = {3, 7, 9, 21, 43, 57, 63, 71, 75, 99} a = Delete[Union[Table[If[Mod[data[[n]], 8] == 1 || Mod[data[[n]], 8] == 7, {n, data[[n]]}, {}], {n, 1, Length[data]}]], 1] Union sorts the extra {} to the front and Delete gets ride of it. || means or Using an If like this makes the clause more like a regular programing or mathematical statement. > I'm trying to write a program for the following. Seems simple, but I'm > unable to to do it: > I have a list of increasing odd numbers. I want to create a table that > indicates which numbers in this list are 1(mod 8) and 7(mod 8) and what > position in the list these numbers have. > Then I would like to have them removed form the list to get a new (reduced) > list. > Example: 3, 7, 9, 21, 43, 57, 63, 71, 75, 99. I want to form this a Table: > 2 7 > 3 9 > 6 57 > 7 63 > 8 71 > 7 is 7(mod 8) and is the 2nd member in the list, 9 is 1(mod 8) and is the > 3rd member in the list, etc. > The next list would become, having removed the ones in the table: > 3, 21, 43, 75, 99 > And I would be using some other congruence criteria. Etc. > Andrea === Subject: Re: extract from list and keep track Andrea ha scritto nel messaggio > I'm trying to write a program for the following. Seems simple, but I'm > unable to to do it: > I have a list of increasing odd numbers. I want to create a table that > indicates which numbers in this list are 1(mod 8) and 7(mod 8) and what > position in the list these numbers have. > Then I would like to have them removed form the list to get a new > (reduced) > list. > Example: 3, 7, 9, 21, 43, 57, 63, 71, 75, 99. I want to form this a > Table: > 2 7 > 3 9 > 6 57 > 7 63 > 8 71 > 7 is 7(mod 8) and is the 2nd member in the list, 9 is 1(mod 8) and is the > 3rd member in the list, etc. > The next list would become, having removed the ones in the table: > 3, 21, 43, 75, 99 > And I would be using some other congruence criteria. Etc. > Andrea Hi Andrea, there are many ways to solve the problem. I've tried this: In[1]:= data={3,7,9,21,43,57,63,71,75,99}; In[2]:= myQ[x_]:=MemberQ[{1,7},x]; In[3]:= mat=Transpose[{Range[Length[data]],data}]; In[4]:= Pick[mat,Mod[data,8],_?myQ] Out[4]= {{2,7},{3,9},{6,57},{7,63},{8,71}} In[5]:= Complement[mat,%] Out[5]= {{1,3},{4,21},{5,43},{9,75},{10,99}} ~Scout~ === Subject: Re: extract from list and keep track Èé ¬Éseems that you describe your needs in terms of a procedural programming ìáîçõáçå áîtelling exactly what you need to do. Ùïneed to remove all occurrences of numbers which are 1(mod 8) or 7(mod ¸©(saying that you want to Keep all the remaining) Ô÷immediate and rather simple solutions will give you the result you need ì.bdû.b37, 9, 21, 43, 57, 63, 71, 75, 99}; ÓåìåãôÛ[IGr ave](Mod[#, 8] $B!b(B 1 && Mod[#, 8] $B!b(B 7) &] ïò ÃáóåóÛì[ Not] øß ¯» ÍïäÛø¬ ¸[CapitalYAcute] ¤Â¡â¨Â && Mod[x, 8] $B!b(B 7] Çïïä ìõãë ùåèõäá .be.be ɧtrying to write a program for the following. Seems simple, but I'm unable to to do it: .be.be have a list of increasing odd numbers. I want to create a table that indicates which numbers in this list are 1(mod 8) and 7(mod 8) and what position in the list these numbers have. Then I would like to have them removed form the list to get a new (reduced) list. .be.be Example: 3, 7, 9, 21, 43, 57, 63, 71, 75, 99. I want to form this a Table: .be.be 7 3 9 6 57 7 63 8 71 .be.be is 7(mod 8) and is the 2nd member in the list, 9 is 1(mod 8) and is the 3rd member in the list, etc. .be.be Ôènext list would become, having removed the ones in the table: .be.be .b3¬ .b2±43, 75, 99 .be.be ÁîI would be using some other congruence criteria. Etc. .be.be Ôèáîëó ¬.be Áîäòåá .be.be === Subject: Re: Re: Plot Angle between Vectors Purchasers will have extended, perhaps indefinite access to updates. The main Mathematica page at my site dates the latest release. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I second this. I think WRI should buy the DrawGraphics software, copyright, etc. from David Park (or develop thier own), because theirs is severely lacking in terms of needed features... side note: The Kagi site does not mention anything about updates for the package... What about people who buy the package shortly before a new version is released? Maybe Mr. Park would consider a pricing and upgrade scheme like the one linked below: http://www.xmlmind.com/xmleditor/price_list.html -- http://chrischiasson.com/contact/chris_chiasson === Subject: FullSimplify Hang? I run FullSimplify on expression with LeafCount of 89281. It runs for 80 hours already , and I have no idea if it ever going to complete. Is there any way to estimate its progress % ? It is possible it just in some king of dead loop? It would be nice for Mathematica to have ability to indicate current progress or possibility to interrupt current simplification and obtain intermediate result. === Subject: Re: Defining variables in $UserBaseDirectory/init.m >>Can I define my own variables in the startup init.m file? > Yes. For example in my init.m file I have a the line > $Landscape = 760; > in my init.m file that I use to set the size of plots I intend to have > printed in landscape mode. >>I tried by simply putting a variable assignment at the end of the >>file, and the result was that Mathematica erraced the entire contents >>of the file. > erraced = erased? > Simply adding variables to your init.m file should not cause Mathematica > to delete the contents of any file. I put this at the end of the init.m, outside of all other expressions $GuideBooksTOC = /usr/share/Mathematica/AddOns/GuideBooks/TableOfContents.nb , and when Mathematica starts it behaves as if I had done `mathematica -cleanStart'. Even before I close Mathematica, `cat init.m' shows SetOptions[$FrontEnd]. With no new line at the end of the file, I will add. -- The Mathematica Wiki: http://www.mathematica-users.org/ Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html Math for the WWW: http://www.w3.org/Math/ === Subject: Absolute value of a symbolic complex expression I have a long complex equation with all symbols real. How do I get the Abs of that equation. For example, Abs[a + i b] =Sqrt[a^2 +b^2] === Subject: Re: mathcode I am not sure if you have any experience using format.m I have just tried to install it but are having some problems. < Has anybody a notebook for caculating the Borel-Tanner distribution? I > know there is something in the book of Michael Trott The Mathematica > Guide Book for Numerics but I do not want to spend that much money for > a couple of pages. === Subject: Re: Re: Mathematica 1 >> I don't know about the Mac version of Mathematica, however. > I remember that the original Mathematica and Mathematica II came > for the > Mac. > -- > Per Erik R¿nne I am not sure what you mean by Mathematica II? Mathematica 1 was, of course, from the start available on numerous platforms, though it is possible that the Mac version might have been the earliest by a small margin. I remember being told that Wolfram wanted Apple to bundle Mathematica with Mac IIs but Apple refused and instead Steve Jobs did it with the first Next work stations. The first part of the above is only a rumour I heard in those days so I do not guarantee its truth but the second was definitely true. Of course Mac and Next were the only systems with a graphical front end for Mathematica in those early days. Andrzej Kozlowski === Subject: Re: Mathematica 1 > I used to have a copy of 1.0, but the Mac II it was on is long gone. If programmed correctly, it should be able to run on any current Mac. In the Classic environment which also supports the 68000 processor of the first Mac from 1984. It will, however, not be able to run on the forthcoming MacIntel computers. -- Per Erik R¿nne === Subject: Re: Mathematica 1 > I don't know about the Mac version of Mathematica, however. I remember that the original Mathematica and Mathematica II came for the Mac. -- Per Erik R¿nne === Subject: Re: Re: Mathematica 1 > Remember to use CTRL F7/F8 to slowdown/speedup frameskip and > CTRLF11/F12 to slowdown/speedup processor cycles in DosBox. This is useful; but DOSBox is made mainly for running old games, so Mathematica will still be a bit slow. -- MSN: wizard_of_yendor@hotmail.com Orkut: http://www.orkut.com/Profile.aspx?uid=2202360379963855296 === Subject: Re: Bug in pattern parsing? >> >> I may have discovered a bug in pattern parsing or applying >> transformation >> rules. >> >> The following two rules should be equivalent: >> >> rule1 = c_.*X_.Y_ -> X.Y >> >> with c an optional variable, and >> >> rule2 = c_.*Dot[X_, Y_] -> X.Y >> >> Yet applying rule1 on a.b as >> >> a.b/.rule1 >> >> gives >> >> 1.a.b >> >> (the same result obtains for the optional factor actually present as >> in >> const a.b), but >> >> a.b/.rule2 >> >> gives >> >> a.b >> >> as it should. >> >> I think that it has to do with the dot in c_., but curiously I get the >> same result when writing the LHS of rule1 as Optional[c]*Y.Z and that >> confuses me... >> >> Any thoughts? >> >> Kristjan Kannike >> >> >> Hi Kristjan, >> the parser can not know what the user has in mind (and vice versa ;-) ). >> Try a space between X_ and the dot or write c_.(X_).Y_ >> Peter > rule1 = c_.*X_.Y_ -> X.Y > that the Mathematica parser does not consider c_. as part of a dot > product (as I had guessed), but thinks that X_. is optional, too. > If not a bug, it is at best a very ambiguous syntax. > And intuitively, I would think the parser should consider a dot to be a > dot product, unless explicitly indicated otherwise as in c_.*X_ > Kristjan Kannike > Some languages use a simple rule which says that the lexical analyzer is greedy. That is, if the input string is a+++b, the first token is a, the second could be +, but ++ is a token too, so assume that the user wants ++. +++ is not a token, and the final result is (a++)+b. Generally Mathematica uses that rule too, except that 'forms' seem to have precedence over operators: _.1 is parsed as (_.)1 because both _. and .1 are 'forms', but 1/.1->2 is interpreted as 1/(.1)->2 because /. is an operator and .1 is a form. So this time the lexeme /. has been split. A greedy analyzer would parse this expression as 1/.(1) -> 2. Maxim Rytin m.r@inbox.ru === Subject: Re: Re: Timing runs for the last part of my previous post > Here's yet another way which is about 30% faster then testFunc4: > Pick[values, Plus @@ Sign[#] & /@ values, -2] > At some point you'll need to process all pairs in the list, so it's > faster > to do this up front, in an effective way, and then use Pick to get the > elements you want. > Oyvind Tafjord > Wolfram Research An even more efficient (and contrived) way is to make all the loops over the list elements implicit: In[1]:= L = Array[Random[Integer, {-10, 10}]&, {10^6, 2}]; Cases[L, {_?Negative, _?Negative}]; // Timing Pick[L, Plus@@ Sign@ #& /@ L, -2]; // Timing Pick[L, Total@ Transpose@ Sign@ L, -2]; // Timing Out[2]= {1.563*Second, Null} Out[3]= {1.062*Second, Null} Out[4]= {0.468*Second, Null} The second version uses Map, which is fairly efficient but still not as good as applying listable functions to vectors. Maxim Rytin m.r@inbox.ru === Subject: Re: Absolute value of a symbolic complex expression 1) You must use capital I for the unit imaginary instead of small i. 2) Then use ComplexExpand, your best friend in working with complex expressions. You will also sometimes want to use the TargetFunctions option. Abs[a + I b] ComplexExpand[%] giving.. Abs[a + I*b] Sqrt[a^2 + b^2] David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I have a long complex equation with all symbols real. How do I get the Abs of that equation. For example, Abs[a + i b] =Sqrt[a^2 +b^2] === Subject: Re: Defining variables in $UserBaseDirectory/init.m On 11/13/05 at 9:16 PM, hattons@globalsymmetry.com (Steven T. >I put this at the end of the init.m, outside of all other >expressions >$GuideBooksTOC = >/usr/share/Mathematica/AddOns/GuideBooks/TableOfContents.nb >, and when Mathematica starts it behaves as if I had done >`mathematica -cleanStart'. Even before I close Mathematica, `cat >init.m' shows SetOptions[$FrontEnd]. With no new line at the end >of the file, I will add. I don't know what to tell you. I just copied the line you posted to the end of my init.m file and started Mathematica to get the following results: In[1]:=$GuideBooksTOC Out[1]= /usr/share/Mathematica/AddOns/GuideBooks/TableOfContents.nb In[2]:=$Version Out[2]=5.2 for Mac OS X (June 20, 2005) -- To reply via email subtract one hundred and four === Subject: Re: Defining variables in $UserBaseDirectory/init.m > I don't know what to tell you. I just copied the line you posted to the > end of my init.m file and started Mathematica to get the following > results: > In[1]:=$GuideBooksTOC > Out[1]= > /usr/share/Mathematica/AddOns/GuideBooks/TableOfContents.nb > In[2]:=$Version > Out[2]=5.2 for Mac OS X (June 20, 2005) Wolfram tech support folks probably already hate me... -- The Mathematica Wiki: http://www.mathematica-users.org/ Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html Math for the WWW: http://www.w3.org/Math/ === Subject: Re: Types in Mathematica >I may be mistaken, but I believe 5.2 comes with an independent indexing >facility which acts something like htdig. I have the usual helpbrowser index >functionality, but I don't believe that provides a full text search. >Steven It certainly doesn't provide a full-text search. One might very well go for YEARS (as I've done) without knowing of many of Mathematica's built-in functionalities, such as many of the Optimization packages. They're built-in, they have extensive example notebooks available if you know where to look (try, for just one example, loading Optimization`UnconstrainedProblems`), and yet one can't really find references to them anywhere in the HelpBrowser Index. I'm VERY glad that they're around, as they've saved me many hours (probably days or more) of work, and helped me to think about some optimization problems in different ways. I just wish that they were more obvious. Is it that Wolfram doesn't think they're ready to reveal? If that's the case, why ship them in current versions? (Again, I'm glad they're there; don't get me wrong!). Curtis O. === Subject: Re: Types in Mathematica First, the general issue: My experience with Mathematica is that I simply don't need typing as much as I did when when I was programming in a strictly procedural language -- because I try to use meaningful names throughout and just don't have as much trouble passing arguments between various subsidiary functions. (Maybe things are helped by Mathematica's expressive combination of functional programming, pattern-matching, and array-handling.) Second, the particulars: As to being of type Boolean: I don't think there is any Head of Boolean built-in to Mathematica, that is, as a primitive, so that part of your definiton of BooleanQ does not seem to be needed. As to VectorQ: As I recall, I showed it in the form VectorQ[expr, test]. But you can also use it in its simpler form VectorQ[expr]. As the documentation about the later says, VectorQ[expr] gives True if expr is a list or a one-dimensional SparseArray object, none of whose elements are themselves lists, and gives False otherwise. VectorQ[expr, test] gives True only if test yields True when applied to each of the elements in expr. As to search: You must be referring to the Wolfram Notebook Indexer, which was available separately for download from www.wolfram.com but which was then shipped with Mathematica 5.2. It can be used as a plug-in for Google Desktop Search (as well as Apple Spotlight and Windows Desktop Search). Google says it's considering making its Desktop Search available for Linux, although they don't have it now. Perhaps if enough Linux users pester them (politely), they'll create that. But you can, as I originally said, still use the indexing within the Mathematica HelpBrowser to do searching of the HelpBrowser notebooks (only). >>Every function you write can be made to type its variables. E.g., >> f[x_?NumberQ] := x^2 >> g[lis_List] := Most[lis] >> normalize[v_ /; VectorQ[v, NumberQ]] := v/Norm[v] >>use: the built-in NumberQ function to test a property of the input x, >>and the pattern test for having a head of List, respectively. > Looking at the builtin types is what got me thinking about this topic. I > wanted a type Boolean for variables and boolean values. It seems that in > Mathematica, a variable, in and of itself, does not really have a type in the > sense of c++. That is, you don't say > Integer a=1; > You just say > a=1; > and that makes it an integer. > You can reassign to that variable an change the type bound to it. In that > sense Mathematica seems more like Lisp. I guess I can do something like > BooleanQ[b_]:= b==True||b==False||Head[b]==Boolean > I'll admit, that really isn't something that has a C++ counterpart. > One thing about your example of VectorQ is that it requires the members of the > List to be Number types. What happens if they are functions which will > evaluate to numbers? >>Sections 2.3.4 and 2.3.5 of The Mathematica Book are two places to find >>this subject discussed. > This is not the discussion I had in mind. Somewhere there is an example of > creating an expression with a head Vector, and using the head of the > expression as a type. >>I don't understand why you don't have access to search in your Linux >>installation: Whenever I've installed in Linux and selected to install >>the documentation, the usual HelpBrowser becomes available, including >>its search capability. > I may be mistaken, but I believe 5.2 comes with an independent indexing > facility which acts something like htdig. I have the usual helpbrowser index > functionality, but I don't believe that provides a full text search. > Steven -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Types in Mathematica >Every function you write can be made to type its variables. E.g., > f[x_?NumberQ] := x^2 > g[lis_List] := Most[lis] > normalize[v_ /; VectorQ[v, NumberQ]] := v/Norm[v] >use: the built-in NumberQ function to test a property of the input x, >and the pattern test for having a head of List, respectively. >Sections 2.3.4 and 2.3.5 of The Mathematica Book are two places to find >this subject discussed. >I don't understand why you don't have access to search in your Linux >installation: Whenever I've installed in Linux and selected to install >the documentation, the usual HelpBrowser becomes available, including >its search capability. >The difficulty is, of course, in figuring out what to search for. To >find section 2.3.4, I searched for Types in the MasterIndex of the >HelpBrowser; the relevant entry was for Types, using patterns to >constrain. To find section 2.3.5, I looked for Constraints; the >relevant entry was for Constraints, on transformation rules, Condition. >>I know there are reasons for Mathematica not being a strongly typed >>language, but I'm wondering if there are places where a type system might >>be of use, and how it might be implemented, or simulated. >> One suggestion from The Mathematica Book is that we could create something >>like >>Vector3[x_,y_,z_], and test the head of variables to determine if they are >>Vector3. I'm not sure exactly where in the book that is, and the Linux >>version does not have a desktop search, AFAIK. >>Observations? Suggestions? >> How about something like this Clear[List3Q] Vector3[m_?List3Q] := Norm[m] Vector3[{1,2,4}] >>Sqrt[21] Vector3[{1,2,4,5}] >Vector3[{1, 2, 4, 5}] Hope this helps Pratik . -- Pratik Desai Graduate Student UMBC Department of Mechanical Engineering Phone: 410 455 8134 === Subject: Re: Types in Mathematica I warmly recommend you of Roman Maeder books, especially the The Mathematica Programmer I look at http://www.mathconsult.ch/showroom/pubs/MathProg/ you can see there about all types of programming style implemented with mathematica. In addition, the combinatorica package uses the Graph[] head for their implementation in object oriented fashion, so exploring a little bit the combinatorica package files will help you to see how other are using this style. yehuda > I know there are reasons for Mathematica not being a strongly typed > language, but I'm wondering if there are places where a type system might > be of use, and how it might be implemented, or simulated. > One suggestion from The Mathematica Book is that we could create somethin= g > like > Vector3[x_,y_,z_], and test the head of variables to determine if they ar= e > Vector3. I'm not sure exactly where in the book that is, and the Linux > version does not have a desktop search, AFAIK. > Observations? Suggestions? > -- > The Mathematica Wiki: http://www.mathematica-users.org/ > Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html > Math for the WWW: http://www.w3.org/Math/ === Subject: Re: Types in Mathematica > Every function you write can be made to type its variables. E.g., > f[x_?NumberQ] := x^2 > g[lis_List] := Most[lis] > normalize[v_ /; VectorQ[v, NumberQ]] := v/Norm[v] > use: the built-in NumberQ function to test a property of the input x, > and the pattern test for having a head of List, respectively. Looking at the builtin types is what got me thinking about this topic. I wanted a type Boolean for variables and boolean values. It seems that in Mathematica, a variable, in and of itself, does not really have a type in the sense of c++. That is, you don't say Integer a=1; You just say a=1; and that makes it an integer. You can reassign to that variable an change the type bound to it. In that sense Mathematica seems more like Lisp. I guess I can do something like BooleanQ[b_]:= b==True||b==False||Head[b]==Boolean I'll admit, that really isn't something that has a C++ counterpart. One thing about your example of VectorQ is that it requires the members of the List to be Number types. What happens if they are functions which will evaluate to numbers? > Sections 2.3.4 and 2.3.5 of The Mathematica Book are two places to find > this subject discussed. This is not the discussion I had in mind. Somewhere there is an example of creating an expression with a head Vector, and using the head of the expression as a type. > I don't understand why you don't have access to search in your Linux > installation: Whenever I've installed in Linux and selected to install > the documentation, the usual HelpBrowser becomes available, including > its search capability. I may be mistaken, but I believe 5.2 comes with an independent indexing facility which acts something like htdig. I have the usual helpbrowser index functionality, but I don't believe that provides a full text search. Steven === Subject: Re: Types in Mathematica >>Every function you write can be made to type its variables. E.g., >> f[x_?NumberQ] := x^2 >> g[lis_List] := Most[lis] >> normalize[v_ /; VectorQ[v, NumberQ]] := v/Norm[v] >>use: the built-in NumberQ function to test a property of the input x, >>and the pattern test for having a head of List, respectively. > Looking at the builtin types is what got me thinking about this topic. I > wanted a type Boolean for variables and boolean values. It seems that in > Mathematica, a variable, in and of itself, does not really have a type in the > sense of c++. That is, you don't say > Integer a=1; > You just say > a=1; > and that makes it an integer. FORGET CC++. You will *never* understand Mathematica by analogy with C++. Mathematica's more like sed than C++: it works by recognizing patterns in input and replacing them. a=1; simply means whenever you see a, replace it with 1. That's all. No type. > You can reassign to that variable an change the type bound to it. In that > sense Mathematica seems more like Lisp. Mathematica has, in general, no idea what a variable is. a is a Symbol. It might be a variable, it might be something else. For specific tthings like Integrate, you get to designate particular Symbols as variables (using the meaning of the word variable in mathematics, *not* computer science). > I guess I can do something like > BooleanQ[b_]:= b==True||b==False||Head[b]==Boolean > I'll admit, that really isn't something that has a C++ counterpart. FORGET C++. > One thing about your example of VectorQ is that it requires the members of the > List to be Number types. What happens if they are functions which will > evaluate to numbers? You get to specify this behavior at whatever level of detail you wish. Or not: much Mathematica code is evaluated only a handful of times. Get the answer, the notebook becomes documentation for how you got it. >>Sections 2.3.4 and 2.3.5 of The Mathematica Book are two places to find >>this subject discussed. > This is not the discussion I had in mind. Somewhere there is an example of > creating an expression with a head Vector, and using the head of the > expression as a type. >>I don't understand why you don't have access to search in your Linux >>installation: Whenever I've installed in Linux and selected to install >>the documentation, the usual HelpBrowser becomes available, including >>its search capability. > I may be mistaken, but I believe 5.2 comes with an independent indexing > facility which acts something like htdig. I have the usual helpbrowser index > functionality, but I don't believe that provides a full text search. Stop trying to make Mathematica behave like tools you know. Use it on its own terms: in its domain it's better than anything you know. -jpd === Subject: Re: Types in Mathematica >> and that makes it an integer. > FORGET CC++. You will *never* understand Mathematica by analogy with C++. Yes, but contrast may be useful. Ironically, I spent several years occasionally visiting Mathematica, and never really understood it until I spent a little over a year studying C++ very intensely. I also read a good part of the _GNU Emacs Lisp Reference Manual_ in that period. When I returned to Mathematica, everything started to fall into place. > Mathematica's more like sed than C++: it works by recognizing patterns > in input and replacing them. I would say it's like a combination of sed and Lisp. > a=1; > simply means whenever you see a, replace it with 1. That's all. No > type. But there is IntegerQ. >> You can reassign to that variable an change the type bound to it. In >> that sense Mathematica seems more like Lisp. > Mathematica has, in general, no idea what a variable is. a is a > Symbol. It might be a variable, it might be something else. For specific > tthings like Integrate, you get to designate particular Symbols as > variables (using the meaning of the word variable in mathematics, > *not* computer science). One can view all symbols in Mathematica as variables in the sense of computer science. The Mathematica Book says: All expressions in Mathematica are ultimately made up from a small number of basic or atomic types of objects. These objects have heads which are symbols that can be thought of as [OpenCurlyDoubleQuote]tagging[CloseCurlyDoubleQuote] their types. The objects contain [OpenCurlyDoubleQuote]raw data[CloseCurlyDoubleQuote], which can usually be accessed only by functions specific to the particular type of object. You can extract the head of the object using Head, but you cannot directly extract any of its other parts. >> I guess I can do something like >> BooleanQ[b_]:= b==True||b==False||Head[b]==Boolean >> I'll admit, that really isn't something that has a C++ counterpart. > FORGET C++. Why? Just because Mathematica doesn't behave like C++, doesn't mean there is no value in comparing the two languages. I find that C++ templates and template metaprogramming feel a lot like Mathematica, and there are some other aspects of C++ which have analogs in Mathematica. There is even: The Boost Lambda Library (BLL in the sequel) is a C++ template library, which implements [a] form of lambda abstractions for C++. The term originates from functional programming and lambda calculus, where a lambda abstraction defines an unnamed function. The primary motivation for the BLL is to provide flexible and convenient means to define unnamed function objects for STL algorithms. >> I may be mistaken, but I believe 5.2 comes with an independent indexing >> facility which acts something like htdig. I have the usual helpbrowser >> index functionality, but I don't believe that provides a full text >> search. > Stop trying to make Mathematica behave like tools you know. Use it on > its own terms: in its domain it's better than anything you know. > -jpd http://www.wolfram.com/products/mathematica/newin52/desktopsearch.html -- The Mathematica Wiki: http://www.mathematica-users.org/ Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html Math for the WWW: http://www.w3.org/Math/ === Subject: MathTensor notational form Does MathTensor provide a means of expressing tensors in the way we find in, say, Einstein's _The Meaning of Relativity_? That is, with raised and lowered indices as well as implied summation? Are there any examples I could look at? [The answer is yes. See http://smc.vnet.net/mathtensor.html. - Steve Christensen - Moderator and MathTensor co-author] -- The Mathematica Wiki: http://www.mathematica-users.org/ Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html Math for the WWW: http://www.w3.org/Math/