q-lang-users Mailing List for Q - Equational Programming Language (Page 17)
Brought to you by:
agraef
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
(27) |
Mar
|
Apr
(4) |
May
(11) |
Jun
(5) |
Jul
(5) |
Aug
(6) |
Sep
(15) |
Oct
(28) |
Nov
(8) |
Dec
|
2005 |
Jan
(9) |
Feb
(5) |
Mar
(10) |
Apr
(43) |
May
(8) |
Jun
(31) |
Jul
(45) |
Aug
(17) |
Sep
(8) |
Oct
(30) |
Nov
(2) |
Dec
(6) |
2006 |
Jan
(4) |
Feb
(20) |
Mar
(1) |
Apr
|
May
(92) |
Jun
(179) |
Jul
(26) |
Aug
(65) |
Sep
(36) |
Oct
(38) |
Nov
(44) |
Dec
(68) |
2007 |
Jan
(11) |
Feb
(25) |
Mar
(37) |
Apr
(7) |
May
(83) |
Jun
(77) |
Jul
(44) |
Aug
(4) |
Sep
(28) |
Oct
(53) |
Nov
(12) |
Dec
(21) |
2008 |
Jan
(66) |
Feb
(45) |
Mar
(30) |
Apr
(50) |
May
(9) |
Jun
(18) |
Jul
(11) |
Aug
(6) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <ed...@ri...> - 2007-07-01 12:51:54
|
<html>=0D =0D <P>sf.net account name: eddier</P>=0D <P>Eddie<BR> <BR> <BR> <B>On Sun Jul 1 5:15 , Keith Trenton <kaz...@ea...> sent:<B= R> <BR> </P></B>=0D <BLOCKQUOTE style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5p= x; BORDER-LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px"><BR> --- Albert Graef <<A href=3D"javascript:top.opencompose('Dr.Graef@t-onli= ne.de','','','')">Dr....@t-...</A>> writes:<BR> - So, is everyone else ok with that policy?<BR> - I'd then need your sf.net ids to give anyone who's<BR> - interested write access to the wiki.<BR> <BR> Works for me. Here's my sf.net account name: kazemori.<BR> <BR> Cheers,<BR> Keith <BR> <BR> <BR> -------------------------------------------------------------------------<B= R> This SF.net email is sponsored by DB2 Express<BR> Download DB2 Express C - the FREE version of DB2 express and take<BR> control of your XML. No limits. Just data. Click to get it now.<BR> <A href=3D"parse.pl?redirect=3Dhttp%3A%2F%2Fsourceforge.net%2Fpowerbar%2Fdb= 2%2F" target=3D_blank><FONT color=3Dred>http://sourceforge.net/powerbar/db2= /</FONT></A><BR> _______________________________________________<BR> q-lang-users mailing list<BR> <A href=3D"javascript:top.opencompose('q-l...@li...',= '','','')">q-l...@li...</A><BR> <A href=3D"parse.pl?redirect=3Dhttps%3A%2F%2Flists.sourceforge.net%2Flists%= 2Flistinfo%2Fq-lang-users" target=3D_blank><FONT color=3Dred>https://lists.= sourceforge.net/lists/listinfo/q-lang-users</FONT></A><BR> </BLOCKQUOTE>=0D </html><BR>= |
From: <ed...@ri...> - 2007-07-01 12:49:19
|
<html>=0D I have a bunch of different types of scripts but they mostly operate on fil= es, so it doesn't make any difference to me. However, if I were ever to cha= nge my CGI scripting language on our intranet server to Q, I'd po= sitively want the slim version.<BR> =0D <P style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER= -LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px"><FONT color=3Dred>> What do= es everybody else think about this? Are you all running little Q</FONT><BR> <FONT color=3Dred>> scripts in tight loops from the shell, or do you rat= her use them</FONT><BR> <FONT color=3Dred>> interactively? I.e., how do you want your prelude: "= slim" or "fat"? :)</FONT><BR> </P>=0D <P style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER= -LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px">Eddie</P>=0D </html><BR>= |
From: Keith T. <kaz...@ea...> - 2007-07-01 10:15:24
|
--- Albert Graef <Dr....@t-...> writes: - So, is everyone else ok with that policy? - I'd then need your sf.net ids to give anyone who's - interested write access to the wiki. Works for me. Here's my sf.net account name: kazemori. Cheers, Keith |
From: Albert G. <Dr....@t-...> - 2007-07-01 08:26:33
|
John Cowan wrote: > My experience is maintaining wikis for small communities is that this is > Not A Good Thing. The wiki quickly becomes covered with vandalism and > spam, which you then spend time cleaning up. You're better off > letting community members apply, and then approving them as author/editors. Frankly, I'd feel better with that, too, but, from my experience with the old wikispaces wiki, I don't want to make that a barrier to entry if it's too annoying for everybody. So, is everyone else ok with that policy? I'd then need your sf.net ids to give anyone who's interested write access to the wiki. 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: John C. <co...@cc...> - 2007-07-01 07:39:10
|
Albert Graef scripsit: > Well, considering namespace pollution, clib is probably the worst single > offender. But starting the interpreter with the full library takes some > 0.35 secs on my devel box (Athlon 2500+ running Linux, so not really a > fast computer by today's standards), and clib takes maybe 0.12 secs from > that. So I don't know whether it's really worth the hassle. Startup is rather slower on my Cygwin-based laptop: comparing average wall-clock times for "q </dev/null" and "q --no-prelude </dev/null" gives me a library load time of 1.8 seconds, long enough to be quite annoying (the interpreter itself starts up in just 0.12 seconds). > Still, by unbundling *both* the POSIX interface part of clib (maybe > moving that to a system.q module, along with the stuff in getopt.q) and > stdtypes.q from the prelude, we might be able to shave off almost 80% of > the interpreter's default startup time and clean up the namespace > considerably. Could be worth the hassle after all. I'd agree with factoring Clib into Posix and non-Posix parts. For the rest, I'd remove everythin in prelude.q except the library includes to another file, and then people can include or exclude whatever they like just by changing prelude.q. That would preserve backward compatibility but make it easy to change a local installation. > What does everybody else think about this? Are you all running little Q > scripts in tight loops from the shell, or do you rather use them > interactively? I.e., how do you want your prelude: "slim" or "fat"? :) I tend to start Q with a small script and then evaluate a few expressions, then shut down, using Q as a sort of more-capable calculator. -- The experiences of the past show John Cowan that there has always been a discrepancy co...@cc... between plans and performance. http://www.ccil.org/~cowan --Emperor Hirohito, August 1945 |
From: John C. <co...@cc...> - 2007-07-01 07:10:16
|
Albert Graef scripsit: > It's open for everybody to edit right now, so please make use of that. My experience is maintaining wikis for small communities is that this is Not A Good Thing. The wiki quickly becomes covered with vandalism and spam, which you then spend time cleaning up. You're better off letting community members apply, and then approving them as author/editors. -- Winter: MIT, John Cowan Keio, INRIA, co...@cc... Issue lots of Drafts. http://www.ccil.org/~cowan So much more to understand! Might simplicity return? (A "tanka", or extended haiku) |
From: Albert G. <Dr....@t-...> - 2007-07-01 05:28:03
|
ed...@ri... wrote: > I tried to save something at the wiki under tips and tricks. I erased > the entire page when I saved it. Well, it seems to be fixed now. Congrats for adding the first real content to the wiki. :) BTW, I added a bit of formatting to the headings, and a toc to the "Tips+Tricks" page. I also linked to the source script you uploaded. Many thanks, 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: <ed...@ri...> - 2007-07-01 00:02:54
|
<html>=0D =0D <P><BR> Albert, Guys:</P>=0D <P>I tried to save something at the wiki under tips and tricks. I erased th= e entire page when I saved it.</P>=0D <P>Boo and hiss! This sux!</P>=0D <P>Eddie</P>=0D </html><BR>= |
From: Albert G. <Dr....@t-...> - 2007-06-30 21:45:43
|
John Cowan wrote: > Maybe you could export your TODO list, either to the website or by > keeping it in the CVS project directory (which is what I do for > my projects). My internal TODO list isn't really that suitable for publication ;-), and I just found that KOrganizer messes up the format in html export anyway. But when I have the time, I'll manually add at least the main TODO items to the wiki. > It's kind of slow, too. If I were going to cut anything, I'd cut clib. Well, considering namespace pollution, clib is probably the worst single offender. But starting the interpreter with the full library takes some 0.35 secs on my devel box (Athlon 2500+ running Linux, so not really a fast computer by today's standards), and clib takes maybe 0.12 secs from that. So I don't know whether it's really worth the hassle. Also, on second thought I realized that clib also provides some fairly essential stuff besides the system interface, like the C versions of important list and string routines, and the extra integer functions which are used and extended in rational.q. I'm afraid that it will be quite a task to untangle this, and I'd have to chop clib into smaller pieces for that. I don't like that idea very much, since right now clib is a nice central repository for all "C things" in the standard library. The only other obvious candidate I see would be stdtypes.q and the stuff that it includes, which shaves away a whopping 0.16 secs from the startup time, but namespace-wise it's probably not much more than a few dozen public operations. Still, by unbundling *both* the POSIX interface part of clib (maybe moving that to a system.q module, along with the stuff in getopt.q) and stdtypes.q from the prelude, we might be able to shave off almost 80% of the interpreter's default startup time and clean up the namespace considerably. Could be worth the hassle after all. But of course it also breaks backward compatibility big time. :( What does everybody else think about this? Are you all running little Q scripts in tight loops from the shell, or do you rather use them interactively? I.e., how do you want your prelude: "slim" or "fat"? :) > The proposed R6RS Scheme bytevectors provide read-write access to > any point in a bytevector as signed and unsigned {8,16,32}-bit values, > single and double floats, and strings using a specified character code. I was thinking more about a data structure which also carries type tags and dimensions, so that you don't accidentally use wrong indices or access the wrong type of information, and conversion between different number types could happen on the fly (e.g., if you read a bytevector with floating point samples from an audio file and then play it back on an audio device which only understands 16 bit integer samples). Of course, these objects could still provide the "raw" bytevector interface you sketched out at the same time. In fact we could probably make all of these new types subtypes of the existing ByteString type and extend ByteString's interface so that it provides all the needed raw operations and the appropriate conversions between different subtypes. Concerning matrices, there's of course the row- or column-major issue. Most C codes probably use row-major matrices nowadays, but column-major would be good for interfacing to legacy Fortran code. ;-) 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-...> - 2007-06-30 19:48:34
|
ed...@ri... wrote: > This is something I've been playing with here and there. My intention is > to find a Taylor's series for certain functions (mostly statistical > ones, probability density functions) integrate them term by term to get > an approximation of the cumulative density functions, and then maybe, > add some equations to convert the integrated polynomials to Horner's > scheme for quick approximations. Looks nice and useful. How about uploading it to the wiki? There's a "Tips and Tricks" section there to which you could add it, or you could start a new programming examples page or something like that. Also, if you don't mind, I could add the script to the examples folder of the core package so that it's included in the next Q release. 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-...> - 2007-06-30 19:40:56
|
Albert Graef wrote: > I hope that I find some time to move the Q wiki over to sf.net this > weekend. Done. You can find it here: http://q-lang.wiki.sourceforge.net/ It's open for everybody to edit right now, so please make use of that. ;-) There's some initial content there, but it's rather rudimentary, so feel free to reorganize and add new stuff as you see fit. Note that the sf.net wikis are really powered by wikispaces, so if you used that before, you should feel right at home. There's a WYSIWYG editor for editing the pages, but you can also switch to plain text editing if you prefer that. Some information about how to use the wiki can be found here: http://www.wiki.sourceforge.net/help It should also be possible to upload files (source code, images, etc.) to the wiki (see the "List and Upload Files" option in the "Wiki" menu), so that you can link to them directly, but AFAICT you need to be logged in to sf.net to do that. Apparently there are still some bugs in sf.net's wiki implementation, so if something doesn't work please let me know. Also, please send me a notice if you find that the wiki gets spammed. 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: Keith T. <kaz...@ea...> - 2007-06-30 12:23:29
|
--- Albert Graef <Dr....@t-...> writes: - I will open up the wiki for everybody, so that maybe - some kind souls will start editing it... Wiki-humour: Kitty cat will be very happy to have me out of her *sandbox*. Cheers! Keith |
From: Keith T. <kaz...@ea...> - 2007-06-30 12:18:46
|
--- Albert Graef <Dr....@t-...> writes: - BTW, in math we often use somewhat sloppy convenience notations - that don't hold water if we want to be really rigorous, but in - a programming language you can't do that... I think that you may have hit the nail on the head with this one. D'accord! =) Cheers, Keith |
From: Albert G. <Dr....@t-...> - 2007-06-30 12:03:37
|
Keith Trenton wrote: > As an aside, I have *never* heard of someone complaining about reading an overstuffed FAQ, but I have frequently encountered "skeleton" FAQs! ;-) Well, for many developers it's hard to put together a really good FAQ, since they have their heads so deep inside the motor that they cannot explain very well what the wheels are good for. ;-) I hope that I find some time to move the Q wiki over to sf.net this weekend. There is a rudimentary FAQ in the wiki already, and I will open up the wiki for everybody, so that maybe some kind souls will start editing it... 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-...> - 2007-06-30 11:50:37
|
Keith Trenton wrote: > It just strikes me that something is "not right": Python (a *widely* used language), Haskell (a well known, but not widely used language), and even our very own Q will either be wrong, or easily yield *surprising* results when complex numbers are introduced into trivial mathematical expressions. Well, I'd rather say that it depends on what your expectations are. ;-) BTW, in math we often use somewhat sloppy convenience notations that don't hold water if we want to be really rigorous, but in a programming language you can't do that (at least until computers really start thinking in a human way). I seriously hope that at least the obvious warts of Q have been ironed out by now... 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: Keith T. <kaz...@ea...> - 2007-06-30 01:51:45
|
--- Albert Graef <Dr....@t-...> writes: - Maybe this should go into the FAQ? OWA: YES. :-D As an aside, I have *never* heard of someone complaining about reading an overstuffed FAQ, but I have frequently encountered "skeleton" FAQs! ;-) Cheers, Keith |
From: Keith T. <kaz...@ea...> - 2007-06-30 01:43:08
|
--- Albert Graef <Dr....@t-...> writes: - I could maybe add a few more examples... It just strikes me that something is "not right": Python (a *widely* used language), Haskell (a well known, but not widely used language), and even our very own Q will either be wrong, or easily yield *surprising* results when complex numbers are introduced into trivial mathematical expressions. Is this a problem that we must solve by application of braces '()'? Fugly. If so, then so be it. :-/ Please note that I am _not_ picking on Q! Cheers, Keith |
From: Albert G. <Dr....@t-...> - 2007-06-29 22:25:06
|
Keith Trenton wrote: > However, is there an explanation, implementation note, or a warning that should be added to the manual so that programmers (from all backgrounds) can be confident when using '+:' (i.e., prevent unexpected math errors)? Well, the manual clearly states that +: has the same precedence as +. I could maybe add a few more examples... 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-...> - 2007-06-29 22:05:22
|
ed...@ri... wrote: > I think I'm confused about what a "constructor" > is. I've been trying to look up constructor but I've only found > "object oriented" stuff so far. Would anyone send back a definition? Hi Eddie, you should also take a look at "algebraic types" at Wikipedia, but I'll try to give an informal explanation below. (Maybe this should go into the FAQ?) A constructor is just a function which doesn't evaluate to something else, but simply stands for itself. (When I'm talking about "functions" here, you might as well substitute "operators"; I'm sure you already know that operators are just functions with some extra chocolate coating.) So, for instance, a constant (nullary) symbol 'nil' may be used to denote, say, an empty binary tree, while the 'bin' constructor might be used to construct objects of the form 'bin X L R' where X is the value at the root node of the binary tree and L and R are the left and right subtrees. Q (and term rewriting in general) doesn't actually distinguish between "defined" functions (which evaluate to "something else") and constructors (which evaluate to themselves). Any function symbol may act as a constructor if it occurs in a normal form (completely evaluated expression). A function symbol without any defining equations will *always* act as a constructor; we can also call such a symbol a *pure* constructor. Q allows you to explicitly declare a function symbol as a pure constructor (that's what the 'const' modifier in a declaration is for), so that you do not accidentally define it in an equation. Nobody forces you to do this in Q (you can just happily use 'nil' and 'bin' as constructors without ever declaring them), but if you declare them as 'const' then the compiler can verify that there are no equations for the constructor. This is a bit different in languages like ML and Haskell, where constructors and defined functions are disjoint. You can apply both to a given number of arguments, just as in Q, but they are treated differently; defined functions always evaluate to something else, while constructurs are always used to construct literal data objects. In Q there is no such segregation between the two kinds of functions. Ok, let's get to data types now. In modern FP languages like Haskell, ML and Q there often is a single construct to create new aggregate data types (besides the built-in list and tuple types), namely *algebraic types*. An algebraic data type is essentially specified by a type symbol associated with a number of constructor symbols with given arities (numbers of arguments). The set of data objects of the type consists of all terms of the form 'f X1 ... Xn', where f is one of the constructor symbols of the type, n its arity, and X1 ... Xn are argument terms of the appropriate types (as a dynamically typed language, Q places no restrictions whatsoever on the types of the arguments, but Haskell and ML of course do, although they allow generic types where the component types may be variable). Mathematically, this corresponds to the "free term algebra" of a given "signature" of function symbols, hence the name "algebraic type". From the programmer's POV, a data element 'f X1 ... Xn' just works like a "record" or "structure" with component values X1 ... Xn, except that you usually extract the component values by pattern matching rather than with "field names". A data type may have more than one constructor, of course, which roughly corresponds to "records with variants", where you have the constructor as a kind of "variant selector". NB: As already mentioned, in Q nobody forces you to declare a data type to be able to work with constructors, whereas in Haskell and ML a data type declaration is the only way to get your hands on them. In Q you *can* declare a data type, however, which allows you to use the type symbol as a "guard" on left-hand side variables of equations if you want to make sure that only objects of the given type (i.e., created with the appropriate constructors) match the variable. Ok, I'm slowly getting back to the Complex type now. Just like in conventional programming languages, where you can make a record data type "opaque", i.e., an abstract data type (ADT), by just hiding the record definition, you can also turn a (concrete) algebraic data type into an ADT by hiding its constructors. In Q you can do this by declaring the constructors 'private' while the type itself is 'public'. This is what Rob and I have done for the Rational and Complex types which are both algebraic types with hidden constructors, so that people do not mess around with the internal representation. This is all good and fine, but wouldn't it be convenient if Rational and Complex actually exposed their constructors, so that you can do at least pattern-matching on objects of the type? Still, for safety reasons you want to keep the internal representation hidden. What to do? Wadler proposed an answer to this problem in 1987 already, the so-called "views". Q supports these since version 7.7. They allow you to have your cake and eat it, too. That is, you can hide the internal representation (i.e., the "real" constructors of the type), but at the same time expose some "virtual" constructors which can be used for pattern-matching just like the real ones, so that you don't have to fiddle around with special access operations to get at the component values. For the Complex type, the virtual constructor is '+:'. In your program it works just like a real constructor, so that you can write something like: swap (X+:Y) = Y+:X; just like you would write, e.g., swap (bin X T1 T2) = bin X T2 T1; In reality, however, (+:) is not a constructor at all, but an ordinary function which internally uses the real (and hidden) constructor 'complex' of the Complex type to create a Complex object. Complex's view definition (which is implemented by a corresponding equation for the built-in 'view' function; for the standard library you can find all the view definitions in the prelude.q script) just makes it look and feel like a real constructor. Rob's Rational type is defined analogously (there, the virtual constructor is the "exact division" (%) function, which produces normalized representations of rational numbers constructed with the hidden 'rat' constructor). Normally, you won't ever see the real constructors, such as 'complex' and 'rat', unless you're working in the debugger. Or you can say 'unparse off' in the interpreter which removes the rose-colored glasses, and makes the pretty-printer an "ugly-printer" which prints the real objects. ;-) Ok, that was quite a long-winded explanation. :-) I could have given a much conciser mathematical definition, but I realize that these concepts are probably not that well-known outside of computer algebra and modern FP circles, so I hope that I could shed some light on how this stuff actually works. Note that I left out the bit about inheritance which is a speciality of Q's algebraic types, because it wasn't really relevant in this context. But you can find more about this in the "Nutshell" and in the manual, of course. 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-...> - 2007-06-29 19:46:43
|
Rob Hubbard wrote: > Okay, (+:) at the precedence of (+) it is then. Ok, I'm happy that we agree on this now. A precedence system is almost always a compromise, and I agree that Q's is not perfect either. Actually I've mostly adopted it from Pascal, because I just can't remember the precedence of all C operators for more than five minutes. ;-) 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: <ed...@ri...> - 2007-06-29 19:44:53
|
<p> <br />Hello all,</p><p>This is something I've been playing with he= re and there. My intention is to find a Taylor's series for certain functio= ns (mostly statistical ones, probability density functions) integrate them = term by term to get an approximation of the cumulative density functions, a= nd then maybe, add some equations to convert the integrated polynomials to = Horner's scheme for quick approximations.</p><p>I'm after comments, critici= sm, and suggestions.</p><p>Eddie </p><p>source: </p><p>/* Derivat= ives and Taylor's series stuff by Eddie Rucker <br />Fri Jun 29 14:53:09 CD= T 2007<br /><br />Use at your own risk!<br /><br />All derivatives are with= respect to (WRT) some symbol.<br />Also, expressions must be in parenthesi= s, i.e. "dd (Expression) symbol."<br />dd_lambda will return the = derivative of a lambda.<br />dd_lambda_nth will return the nth derivative o= f a lambda.<br />taylor F A N will return a lambda that is a series about p= oint A with N terms.<br />Make sure you use analytic functions with the tay= lors series expansion or it <br />will blow up on you!<br />I'm sure there = are some warts and please overlook the hackery of the algebra<br />simplifi= cations.<br /><br /> Examples:<br /> <br /> &n= bsp; =3D=3D> dd (2*X^3+3*X*Y^2+4) X<br /> 6*X^2+3*Y^2<br />&= nbsp; <br /> =3D=3D> dd (2*X^3+3*X*Y^2+4) Y<br /> = ; 6*X*Y<br /> <br /> =3D=3D> dd (exp (2*X)= ) X<br /> 2*exp (2*X)<br /><br /> =3D=3D> dd (co= s (2*X^2+X*Y)^2) X<br /> -2*(4*X+Y)*sin (2*X^2+X*Y)*cos (2*X^2+= X*Y)<br /><br /> =3D=3D> dd (cos (2*X^2+X*Y)^2) Y<br /> = ; -2*X*sin (2*X^2+X*Y)*cos (2*X^2+X*Y)<br /><br /> =3D=3D= > dd (ln (2*X)) X<br /> 1/X<br /><br /> =3D=3D&g= t; dd_nth (X^(1%2)) X 3 // take the third derivative<br /> = ; 3%8*X^(-5%2)<br /><br /> =3D=3D> dd_nth (ln (2*X)) X= 2<br /> -X^(-2)<br /><br /> =3D=3D> dd (2^(2*X)= ) X<br /> 1.38629436111989*2^(2*X)<br /><br />  = ; =3D=3D> dd_lambda (\X . sin X) 3.141597<br /> -0.999= 999999990554<br /><br /> =3D=3D> taylor (\X . sin X) 0 7 // = taylor series of sin about the point 0, terms up to X^7<br /> &n= bsp; \X1 . X1 + -0.166666666666667*X1^3+0.00833333333333333*X1^5 + -0.00019= 8412698412698*X1^7<br /><br /> =3D=3D> var f =3D taylor (\X = . sin X) 0 7 // assign the series to a function<br /> =3D=3D>= ; f 2<br /> 0.907936507936508<br /> =3D=3D>= ; sin 2<br /> 0.909297426825682<br /> =3D=3D&= gt; var f =3D taylor (\X . sin X) 2 7 // better approximation about 2<br />= =3D=3D> f 2<br /> 0.909297426825682<br />= <br /> =3D=3D> taylor (\X . exp X) 0 7<br /> &nbs= p; \X1 . 1.0+X1+0.5*X1^2+0.166666666666667*X1^3+0.0416666666666667*X1^4+0.0= 0833333333333333*X1^5+0.00138888888888889*X1^6+0.000198412698412698*X1^7<br= /><br /> =3D=3D> var g =3D taylor (\X . ln X) 2 7 // be car= eful not to make a series about 0 but 2 is okay<br /> =3D=3D>= ; g 2 <br /> 0.693147180559945<br /><br /> = =3D=3D> ln 2<br /> 0.693147180559945<br /><br /> = =3D=3D> taylor (\X . exp (X^2)) 0 9<br /> \X1 .= 1.0+X1^2+0.5*X1^4+0.166666666666667*X1^6+0.0416666666666667*X1^8<br />*/<b= r /><br />// Some of these simplification rules are in the Q in a nutshell<= br /><br />(X^N)^M =3D X^(N*M); // added<br /= >X^N*X^M =3D X^(N+M); // added<br />Y^1 =3D Y= ; &n= bsp; // added<br />Y^1.0 =3D Y; &n= bsp; // added<br />Y^0 =3D _FAIL_= if (isnum Y) and then (Y=3D0); /= / added<br /> =3D 1 otherwi= se;<br />Y^0.0 =3D _FAIL_ if (isnum Y) and then (Y=3D0.0);  = ; // this isn't the proper way to deal with floats!<br /> = =3D 1 otherwise;<br />X*(Y= *Z) =3D (X*Y)*Z;<br />X+(Y+Z) =3D (X+Y)+Z;<br />X*Y+X*Z =3D X*(Y+Z); &= nbsp; // changed direction<br />Y*X+Z*X =3D (Y+Z)*X; = ; // changed direction<br />0*X =3D 0;<br />0.0*X = =3D 0.0; = // this isn't the proper way to deal with floats!<br />X*0 =3D 0;<br />X*0.= 0 =3D 0.0;  = ; // this isn't the proper way to deal with floats!<br />1*X =3D X;<br />1.= 0*X =3D X;<br />X*1 =3D X;<br />X*1.0 =3D X;<br />0+X =3D X;<br />0.0+X =3D= X;<br />X+0 =3D X;<br />X+0.0 =3D X;<br />0-X =3D -X;<br />0.0-X =3D X;<br= />X-0 =3D X;<br />X-0.0 =3D X;<br />(-1)*X =3D -X; = // added and maybe questionable<= br />(-1.0)*X =3D -X;<br />X*(-1) =3D -X; &nbs= p; // same here<br />X*(-1.0) =3D -X;<br />X*= A =3D A*X if isnum A; // added<br />-(-X) =3D X; &nb= sp; // added<br= />X*-Y =3D -X*Y; &nbs= p; // added<br />X/(X*Y) =3D 1/Y; = // added<br />X/(Y*X) =3D 1/Y; &n= bsp; // added<br />N*X+X =3D (N+1)*X;&n= bsp; // added<br />X+N*X =3D (N+1)*X;&n= bsp; // added<br /><br />// some derivative functio= ns -- taken from my calculus textbook.<br /><br />dd (exp X) WRT =3D (dd X = WRT) * exp X;<br /><br />dd (ln X) WRT =3D (dd X WRT) * 1/X;<br /><br />dd = (sin X) WRT =3D (dd X WRT) * cos X;<br /><br />dd (cos X) WRT =3D - (dd X W= RT) * sin X;<br /><br />dd (tan X) WRT =3D (dd X WRT) / ((cos X)^2);<br /><= br />dd (sinh X) WRT =3D (dd X WRT) / (cosh X);<br /><br />dd (cosh X) WRT = =3D (dd X WRT) / (sinh X);<br /><br />dd (tanh X) WRT =3D (dd X WRT) / ((co= sh X)^2);<br /><br />dd (asin X) WRT =3D (dd X WRT) / sqrt (1 - X^2);<br />= <br />dd (acos X) WRT =3D - (dd X WRT) / sqrt (1 - X^2);<br /><br />dd (ata= n X) WRT =3D (dd X WRT) / (1 + X^2);<br /><br />dd (asinh X) WRT =3D (dd X = WRT) / sqrt (X^2 + 1);<br /><br />dd (acosh X) WRT =3D (dd X WRT) / sqrt (X= ^2 - 1);<br /><br />dd (atanh X) WRT =3D (dd X WRT) / (1 - X^2);<br /><br /= >dd (U*V) WRT =3D (dd U WRT)*V + (dd V WRT)*U; // product rule<br /><br />d= d (U/V) WRT =3D dd (U*V^(-1)) WRT; // product rule<br /><br />dd (U+V) WRT = =3D (dd U WRT) + (dd V WRT); // addition rule<br /><br />dd (U-V) WRT =3D (= dd U WRT) - (dd V WRT); // addition rule<br /><br />dd (U^V) WRT =3D (dd V = WRT) * ln U * U^V if isnum U;<br /> &nb= sp; =3D (dd U WRT) * V * U^(V-1); // power and chain rule<br /><br />dd (-U= ) WRT =3D - (dd U WRT); // derivative function is odd<br /><br />dd U WRT = =3D 1 if U =3D=3D WRT; // constant or symbol<br /> = =3D 0 otherwise;<br /><br />// higher order derivatives<br />dd_nth U WRT N= =3D dd U WRT &n= bsp; if N =3D 1; <br />&nbs= p; =3D dd (dd_nth U WRT (N= -1)) WRT otherwise;<br /><br />dd_lambda (\X. Expr) =3D \X. `(dd (Expr) X);= <br /><br />dd_lambda_nth (\X. Expr) N =3D \X. `(dd_nth (Expr) X N);<br /><= br />taylor F A N =3D \X . `(taylor_ F A 0 N 1 0);<br />taylor_ F A I N Fac= t Sum<br /> =3D (Sum + (F A)/Fac= t * (X-A)^I) if I =3D N;<br /> = =3D taylor_ (DD) A (I+1) N (Fact*(I+1)) (Sum + (F A)/Fact * (X-A)^I)<br />&= nbsp; where DD =3D dd_lambda F;<br /><= br /> =0D </p><BR>= |
From: <ed...@ri...> - 2007-06-29 12:05:55
|
<html>=0D <BR> <BR> =0D <BLOCKQUOTE style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5p= x; BORDER-LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px">=0D <P>>Rob Hubbard wrote:<BR> <FONT color=3Dred>>> This is a rare occasion where I *strongly* disag= ree. The purpose of</FONT><BR> <FONT color=3Dred>>> (+:) is to form complex numbers syntactically, w= hen they are in some</FONT><BR> <FONT color=3Dred>>> sense 'atomic' or 'literal' semantically.</FONT>= <BR> <BR> >I see your point, but note that in common mathematical notation complex= <BR> >numbers aren't atomic either (unless you write them as pairs), so you<B= R> >face the same kind of problem.</P>=0D <P>>I have no problem with that if I read '1+:2*3+:4' as '1+i*2*3+i*4'.<= /P>=0D <P>In common mathematical notation, complex multiplication, for the rectang= ular form, is always written, at least as far as any of my complex&nbs= p;analysis books go, as</P>=0D <P>(a+bi)(c+di)</P>=0D <P>and simplified using the distributive law of multiplication over additio= n. </P>=0D <P>(ac-bd)+(ad+b)i </P>=0D <P>Hence, + is regular old real addition and multiplication is regular old = real multiplication. Albert is right about saying + in (a+bi) is not atomic= and neither is the multipliation. If multiplication were different, we wou= ldn't write bi as in b*i.</P>=0D <P>IIRC, Albert interpreted "a+:b" as "a+b*i" but somewhere else = I saw "+:" as a constructor for complex numbers. Wouldn't a constructo= r be defined as</P>=0D <P>a+bi =3D (a,b)</P>=0D <P>as in ordered pairs? I think I'm confused about what a "constructor" is.= I've been trying to look up constructor but I've only found "object orient= ed" stuff so far. Would anyone send back a definition?</P>=0D <P>Eddie</P></BLOCKQUOTE>=0D </html><BR>= |
From: Rob H. <hub...@gm...> - 2007-06-29 08:23:39
|
Hello Albert, On 29/06/07, Albert Graef <Dr....@t-...> wrote: > But let's assume, just for fun, that X+:Y really is atomic, how should > foo 2 +: 3 be parsed? Or -2+:3 ? I think that it would be rather > surprising if -2+:3 returned (-2)+:(-3). Note the parentheses; these > would be obligatory if (+:) had, say, the same precedence as (.). Ah, yes. That's a good point. Okay, (+:) at the precedence of (+) it is then. Thanks, Rob. |
From: Keith T. <kaz...@ea...> - 2007-06-29 07:16:16
|
--- Albert Graef <Dr....@t-...> writes: - ...'X+:Y' should be seen as an abbreviation for 'X+i*Y'... - - Why should we arbitrarily limit the scope of Q's '+:' - when it can be applied to complex operands just as easily? Okay. I understand you *much* better now, and will abandon my objection. However, is there an explanation, implementation note, or a warning that should be added to the manual so that programmers (from all backgrounds) can be confident when using '+:' (i.e., prevent unexpected math errors)? Cheers, Keith |
From: John C. <co...@cc...> - 2007-06-29 05:07:23
|
Albert Graef scripsit: > Yes, the syntax seems reasonable, I already have this on my TODO list. Maybe you could export your TODO list, either to the website or by keeping it in the CVS project directory (which is what I do for my projects). It might lead to some interesting discussions. > One related question is whether prelude.q should really import all the > standard library modules. This is convenient, but also a source of > "namespace pollution". It's kind of slow, too. If I were going to cut anything, I'd cut clib. > Which operations do you have in mind? I mean, you can already create a > tuple of references, e.g., like this: 'tuple [ref ():I in [1..N]]', and > then assign with 'put (V!I) X' and retrieve a value with 'get (V!I)'. Sure. Just sugar them with "vget V I" and "vput V I X", I guess. Then you can add vmap, vfold, vunfold, .... > > Following that, byte vectors (mutable byte strings) would also be > > a useful addition for dealing with large quantities of homogeneous > > data; these have to be done in C, but would be far more efficient > > than any alternative representation. > > Yes, actually I've had something like this on my TODO list for a while, > in order to provide better support for numeric and signal processing > applications. The proposed R6RS Scheme bytevectors provide read-write access to any point in a bytevector as signed and unsigned {8,16,32}-bit values, single and double floats, and strings using a specified character code. -- John Cowan co...@cc... http://ccil.org/~cowan No man is an island, entire of itself; every man is a piece of the continent, a part of the main. If a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were: any man's death diminishes me, because I am involved in mankind, and therefore never send to know for whom the bell tolls; it tolls for thee. --John Donne |