Thread: [q-lang-users] newbie question
Brought to you by:
agraef
From: Á. C. C. <alv...@gm...> - 2008-07-08 15:37:04
|
Hello, I'm taking a look at this programming language and I'm trying to figure out some of its uses. I've read about equations in this programming language and pattern rewriting. I find it really interesting. I would like to ask a very simple question. Is it possible to use this language for solving symbolic equations? if so, could you give me a quick example with two linear equations? Than you very much, Best Regards, álvaro |
From: Rob H. <hub...@gm...> - 2008-07-09 10:01:21
|
Hello Álvaro, > I'm taking a look at this programming language and I'm trying to > figure out some of its uses. I've read about equations in this > programming language and pattern rewriting. I find it really > interesting. > > I would like to ask a very simple question. Is it possible to use this > language for solving symbolic equations? if so, could you give me a > quick example with two linear equations? I myself first got interested in Q whilst looking to do some symbolic mathematics. I think the first thing to say is that Q is *not* a CAS (computer algebra system). There are very many out there. Amongst the free and/or open source tools, I would recommend taking a look at Axiom <http://wiki.axiom-developer.org/> and wxMaxima <http://wxmaxima.sourceforge.net/wiki/index.php/Main_Page>. Axiom is the most comprehensive and sophisticated CAS that I've encountered, but has quite a steep learning curve; its type system is extraordinary. wxMaxima, on the other hand, is a very easy tool to get started with. I'd highly recommend taking a look at both. That said, Q, too is a very useful tool with which to do some mathematics. I spent some time working with (univariate, numerical) polynomials, particularly those with rational coefficients, and that resulted in the creation of Q's rational number and polynomial libraries (now distributed with Q). Q has very useful features for working symbolically, such as the quote operator (a single ' prefix), and the string / quoted-expression conversion functions strq and valq. Q (or Pure) would both be perfectly suitable languages in which to write a CAS, but are not in themselves CASs. To represent mathematical expressions and other objects, you really need a more sophisticated set of data structures than just the parse trees. For example, it might be appropriate to store expressions modulo associativity, or to reduce an expression internally to some specific normal form. To manipulate an expression in Q, you will need to explicitly handle associativity and commutativity in all possible contexts. For example, notice that (B+C) is not a sub-expression of (A+B+C), as the latter is ((A+B)+C). If you're specifically interested in solving linear equations, then what you need is probably a matrix library. I hope you remain interested in Q. Please also take a look at Qpad (Windows only), Qcalc (not available for Windows yet) and Pure (an alpha(?) version of a replacement for Q). Regards, Rob. Rob Hubbard |
From: Albert G. <Dr....@t-...> - 2008-07-10 00:08:55
|
Hi Rob, nice to hear from you. :) > I hope you remain interested in Q. Please also take a look at Qpad > (Windows only), Qcalc (not available for Windows yet) and Pure (an > alpha(?) version of a replacement for Q). I wouldn't consider Pure alpha any more. :) Jiri Spitz just ported the Q container data structures, and complex and rational numbers are already in the library, too (current svn, soon to be released as Pure 0.5). So it should soon be possible to port your rational and polynomial libraries! If you're still interested in this kind of stuff, Pure has its own mailing list, see http://pure-lang.sourceforge.net/ Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-07-10 00:00:39
|
Hi Álvaro, sorry for the late reply. Rob answered your question already I guess. I just wanted to point out that most of the action is now with "Pure", the "next generation Q" which compiles to native code, hence programs are much faster. It also offers quite a few new features which make the language much easier to use. Pure still lacks most of Q's 3rd party library interfaces, but we're working on that. I'd say that the current version of the Pure interpreter is already quite usable, and Pure 0.5 is around the corner. You can find more information and a pointer to the Pure mailing list here: http://pure-lang.sourceforge.net/ Best, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Á. C. C. <alv...@gm...> - 2008-07-10 09:12:25
|
2008/7/10 Albert Graef <Dr....@t-...>: > Hi Álvaro, > > sorry for the late reply. Rob answered your question already I guess. I > just wanted to point out that most of the action is now with "Pure", the > "next generation Q" which compiles to native code, hence programs are > much faster. It also offers quite a few new features which make the > language much easier to use. Pure still lacks most of Q's 3rd party > library interfaces, but we're working on that. I'd say that the current > version of the Pure interpreter is already quite usable, and Pure 0.5 is > around the corner. Hi, Thanks for your answers! All the explanations were quite useful! I tried axiom and wxmaxima, and actually helped me solve the problem I had. Anyway I'm far more interested in languages than learning programs. Actually I first got to know Pure than Q, and it was a couple of days ago that I saw them connected. I knew it from llvm list I guess, since I'm a llvm user. I saw Q related to K, which are supposed to be good languages for matrix multiplication, and somewhere said that it was faster than plain C (well, because it vectorizes). At least K was able to do it. In a couple of days I'll make a Gentoo ebuild for Pure, as I couldn't find one. There is one for Q that took me long to find (due to its name! ;) ). If necessary, I'll update the llvm ebuild, too. My machine is amd64, I tried to compile Q but I couldn't. Anyway, Q (pure) first got my attention because of the concept of rewriting. I'll check the code when I have time to try to understand how is it implemented, and what "rewriting" means here. I was some time ago interested in "homoiconic" languages. Indeed, I'm working on languages for automatic code generation, so I wanted to try Q-Pure in this respect, especially using this "rewriting" ability. I'll think more on this, so I can speak properly. Regards, álvaro -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||| > http://www.alvarocastro.es |
From: Albert G. <Dr....@t-...> - 2008-07-10 16:59:38
|
Álvaro Castro Castilla wrote: > I saw Q related to K, which are supposed to be good > languages for matrix multiplication, and somewhere said that it was > faster than plain C (well, because it vectorizes). That Q and K are completely different languages, they have nothing to do with my Q. > In a couple of days I'll make a Gentoo ebuild for Pure, as I couldn't > find one. That will be much appreciated. :) Please let me know when it's available, so I can add a note to the Pure website. > My machine is amd64, I tried to compile Q but I couldn't. Q won't work there as it's never been ported to 64 bit. That was planned for Q 8.0, but instead I decided to start Pure, so updates to Q will probably be limited to bugfixes and applying user-supplied patches in the future. > Anyway, Q (pure) first got my attention because of the concept of > rewriting. I'll check the code when I have time to try to understand > how is it implemented, and what "rewriting" means here. It's basically just term rewriting in the sense of universal algebra, i.e., your programs are collections of rules of the form l -> r (where l and r are terms with variables) which are used to reduce terms to normal form (using eager evaluation by default). But I've added some conveniences, e.g. Pure also has guards, lambdas and lexical block structure with local functions and variables (much like Haskell and ML, but it's a dynamically typed language like Lisp), and will soon also have Lisp-like macros. I'll let you find out about the rest on your own. ;-) The Pure manual is still a bit terse, so if you have any questions just ask. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |