[sage-devel] Re: Solving equations involving exp, Maxima
Alan Posting a reply to repay all the help Ive received from the Sage folk. Im a software guy more than a math guy and no Sage expert but hopefully this is accurate. 1. Why do the following equations give different answers? sage:solve([exp(x)==exp(0)],x) [x == 0] sage:solve([exp(x)==exp(-x)],x) [x == I*pi, x == 0] Not sure what youre asking here but the answers you got seem to me to be the right solutions for the equations you used. (1 solution of x==0 for the 1st equation and 2 solutions for the 2nd - you can check that in other math software) sage:solve([exp(x+1)==exp(-x+1)],x) [e^(x + 1) == e^(-x + 1)] I think not getting an answer back just means solve called maxima (one of Sage's symbolic engines) and maxima couldnt solve this. (I confirmed this by entering this directly in my copy of Maxima) 2. Is there any way to make 'solve' recognize obvious solutions. For example, sage:solve([x==exp(-x+1)],x) [x == e^(-x + 1)] In Mathematica we get:Solve[ ...(some warnings)... {{x-1}} In Maple we get:solve(x=exp(-x+1),x) 1 I confirmed again that maxima returned this unsolved but the answer isnt as obvious as it seems. If you use Reduce[x==Exp[-x+1],x] in Mathematica youll see that there is an infinite number of solutions involving the ProductLog function (1 is only one of those solutions) Hopefully that helps somewhat (and corrections are welcome) -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: sage-4.6.1.alpha2 failed to build on Ubuntu 10.10
On Nov 16, 12:54 pm, François Bissey f.r.bis...@massey.ac.nz wrote: Thought you might like to know that sage-4.6.1.alpha1 built with no probs but alpha2 failed to build on Ubuntu 10.10 (linux 2.6.35-23-generic) (PC = 2GB Ram, Intel Pentium 4 CPU 3.2GHz) Error was... make[2]: *** [all] Error 2 make[2]: Leaving directory `/home/kyprir/sage-4.6.1.alpha2/spkg/build/ ecm-6.3.p1/src' Error building GMP-ECM. real 0m40.318s user 0m19.521s sys 0m6.124s sage: An error occurred while installing ecm-6.3.p1 Does it look likehttp://trac.sagemath.org/sage_trac/ticket/10252? In any case we would need a little more details than what you have posted to form an opinion. Francois Sorry I couldnt reply earlier. The quoted ticket seems like a different problem. But I appreciate now that alphas arent tested for every platform so I'll leave build reports for released versions from now on. Thanks -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] sage-4.6.1.alpha2 failed to build on Ubuntu 10.10
Thought you might like to know that sage-4.6.1.alpha1 built with no probs but alpha2 failed to build on Ubuntu 10.10 (linux 2.6.35-23-generic) (PC = 2GB Ram, Intel Pentium 4 CPU 3.2GHz) Error was... make[2]: *** [all] Error 2 make[2]: Leaving directory `/home/kyprir/sage-4.6.1.alpha2/spkg/build/ ecm-6.3.p1/src' Error building GMP-ECM. real0m40.318s user0m19.521s sys 0m6.124s sage: An error occurred while installing ecm-6.3.p1 -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: Extend a real function's valid input types in Sage
A checklist is forming... 1) speed (that probably means C or Cython) 2) correctness (demonstrate correct randomness according to the distribution AND on differerent platforms) 3) documentation (references, etc) (any other ideas, feel free to add to this thread ;-) On Sun, Sep 5, 2010 at 5:08 PM, David Kirkby david.kir...@onetel.netwrote: On 5 September 2010 05:28, William Stein wst...@gmail.com wrote: scipy.stats has random number generators for about a 100 different families of distributions. The last time I tried them, they were of variable quality, in that some of them were (very, very) slow. But the range of distributions was really impressive. You should look at the official book about numpy (yes, numpy), which Travis Oliphant wrote. It has a pretty good list of the distributions in numpy.stats = scipy.stats. Whatever you do, I hope you'll benchmark carefully as you go. A package that generates random numbers 1000 times slower than MATLAB is going to be very annoying to use. Non-cryptography people usually generate random numbers because they want a lot of them. If they are of variable quality, I would suggest that not only benchmarking them is important, but testing them for randomness is too. I know that some implementations that work on one word-size computer perform really poor if the word size is increased. So an algorithm only tested on a 32-bit system might perform very badly in a 64-bit one. Most make use of a CPUs register overflowing at some point. If the word size changes, so the overflow point changes, so the algorithm has changes. Dave -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.comsage-devel%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: Extend a real function's valid input types in Sage
Thanks guys exp, log, sqrt etc covers well over 50% of the requirement so Im really ahead - Once again - THANKS! It seems functional.py is definitely the place to be looking at. Whats needed is a catch-all/anonymous function in functional.py so that X.myfunction() is try'ed whenever myfunction(X) is called (much like exp(X) invokes X.exp() in functional.py) (can lambda functions or __call__ help here?) Anyone have any ideas what mechanism might do that? On Sat, Sep 4, 2010 at 1:37 PM, Jason Grout jason-s...@creativetrax.comwrote: On 9/3/10 10:53 PM, Ross Kyprianou wrote: Ive defined a class and need to pass instances of it to any standard real function in Sage such as exp and log (i.e. functions that accept numbers (ints, reals etc) and symbolic vars but obviously they wont accept this new class thats been created). I cant modify the functions to accept this new type (because I dont own them, they are part of the Sage library) but there is a well-defined value that can be returned for ANY Sage/Python real function and any instance of the class. (If youre into Probability and Statistics: Ive defined a Random Variable class and for any instance X, the expressions exp(X) or log(X) (or F(X) for any real function F) are well-defined random variables and should be returned as new instances defined in terms of X - but ignore this if youre not into ProbStats). When I try X = NormalRV(mu,sigma) Y = log(X) I (quite expectedly) get TypeError: cannot coerce arguments: no canonical coercion fromclass '__main__.NormalRV' to Symbolic Ring By implementing the python __call__() method I get the answer needed i.e. the expression Y = X(log) works as desired but looks really weird: Y = log(X) looks natural but not Y = X(log). Is there any way I can get Sage to execute Y = X(log) to invoke the __call__ method and get the right answer, every time the user enters the more natural Y = log(X) ? The log function (and many other top-level functions defined in sage/misc/functional.py) first try to call the .log() method of the object. So in the case of logs, you should be able to define a .log() method that does the right thing, and log(X) will then first try to call X.log(). See the code in sage/misc/functional.py for details. Thanks, Jason Ive had limited success with the preparser and now thinking of hooking into the exception handling or using coercion to somehow make exp, log, sin etc understand this new class (without modifying them) in the same way they understand symbolic variables as well as numbers. Is coercion possible? Is it the way to go or is there a better approach? -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.comsage-devel%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: Extend a real function's valid input types in Sage
Thanks for the advice William - will take everything on board On Sun, Sep 5, 2010 at 1:58 PM, William Stein wst...@gmail.com wrote: On Sat, Sep 4, 2010 at 7:27 PM, Ross Kyprianou ros...@gmail.com wrote: +10 Certainly agree that the module is relevant and my work should be interwoven into it It was very timely that you drew my attention to this. I think I should draw up an initial design for the functionality Im aiming for and possibly put it in a new thread for comment. Im happy to do the most of the work for this (its directly relevant to my thesis). I will also look out for (and welcome any news about) other open source code that is relevant. (e.g. Im sure scipy has random number generation for many probability distributions that would be useful, and R certainly comes to mind - I dont want to reinvent the wheel and will have to work out what I write anew, what gets called by a wrapper and what gets called directly) scipy.stats has random number generators for about a 100 different families of distributions. The last time I tried them, they were of variable quality, in that some of them were (very, very) slow. But the range of distributions was really impressive. You should look at the official book about numpy (yes, numpy), which Travis Oliphant wrote. It has a pretty good list of the distributions in numpy.stats = scipy.stats. The primary aim is a probability and stats module/package that has a number of stats primitives like random variables, probability distributions etc available for building algorithms of statistical signal processing (altho my background is maths, my target users are engineers that need to build algorithms easily for tracking, classification etc but only use matlab currently so it will be nice if this plays a small part in making Sage a viable alternative to matlab for these potentially new users :-) Whatever you do, I hope you'll benchmark carefully as you go. A package that generates random numbers 1000 times slower than MATLAB is going to be very annoying to use. Non-cryptography people usually generate random numbers because they want a lot of them. Here's an example of some code in Sage that's generated a million numbers randomly normally distributed in .1 seconds: sage: time stats.TimeSeries(10^6).randomize('normal', 0, 1) CPU times: user 0.10 s, sys: 0.01 s, total: 0.11 s Wall time: 0.11 s [-1.3444, -0.4416, -1.3075, -0.4803, 0.2128 ... -0.2946, 1.0673, -0.5859, -0.0213, 0.1013] I wrote this from scratch in Cython. (Thanks to all for all the help to date) On Sep 5, 10:35 am, kcrisman kcris...@gmail.com wrote: (If youre into Probability and Statistics: Ive defined a Random Variable class and for any instance X, the expressions exp(X) or log(X) (or F(X) for any real function F) are well-defined random variables and should be returned as new instances defined in terms of X - but ignore this if youre not into ProbStats). This isn't relevant to the main point of this thread, but is this at all connected to the already existing module below? I at one point started to improve the documentation of this but didn't have many good examples of its intended use. Anyway, probably your thing should be interwoven with this somehow. - kcrisman sage: sage.probability.random_variable? Type: module Base Class: type 'module' String Form:module 'sage.probability.random_variable' from '/mnt/ usb1/scratch/kcrisman/sage-4.5.2.rc1-sage.m ... hington.edu-x86_64- Linux/local/lib/python2.6/site-packages/sage/probability/ random_variable.pyc' Namespace: Interactive File: /mnt/usb1/scratch/kcrisman/sage-4.5.2.rc1- sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site- packages/sage/probability/random_variable.py Docstring: Random variables and probability spaces This introduces a class of random variables, with the focus on discrete random variables (i.e. on a discrete probability space). This avoids the problem of defining a measure space and measurable functions. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.comsage-devel%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.comsage-devel%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from
[sage-devel] Extend a real function's valid input types in Sage
Ive defined a class and need to pass instances of it to any standard real function in Sage such as exp and log (i.e. functions that accept numbers (ints, reals etc) and symbolic vars but obviously they wont accept this new class thats been created). I cant modify the functions to accept this new type (because I dont own them, they are part of the Sage library) but there is a well-defined value that can be returned for ANY Sage/Python real function and any instance of the class. (If youre into Probability and Statistics: Ive defined a Random Variable class and for any instance X, the expressions exp(X) or log(X) (or F(X) for any real function F) are well-defined random variables and should be returned as new instances defined in terms of X - but ignore this if youre not into ProbStats). When I try X = NormalRV(mu,sigma) Y = log(X) I (quite expectedly) get TypeError: cannot coerce arguments: no canonical coercion from class '__main__.NormalRV' to Symbolic Ring By implementing the python __call__() method I get the answer needed i.e. the expression Y = X(log) works as desired but looks really weird: Y = log(X) looks natural but not Y = X(log). Is there any way I can get Sage to execute Y = X(log) to invoke the __call__ method and get the right answer, every time the user enters the more natural Y = log(X) ? Ive had limited success with the preparser and now thinking of hooking into the exception handling or using coercion to somehow make exp, log, sin etc understand this new class (without modifying them) in the same way they understand symbolic variables as well as numbers. Is coercion possible? Is it the way to go or is there a better approach? -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] 90% doctest coverage update: 14 June 2010
It seems harmless as a short term strategy to use the 130 modules that have been identified to get Sage to 90% coverage. Once that is met, I imagine the next goal would be 95% then 100% coverage. And from what Ive seen of the Sage developer community there would then be a revisiting and addition of these threads to decide which metrics/strategies to next adopt (be they branch testing or something else) to meet the next new testing milestones. Its unlikely that someone will sometime declare we dont need any more tests for existing code so are we just debating over the order that the tests will be incorporated? On Mon, Jun 14, 2010 at 9:47 PM, Dr. David Kirkby david.kir...@onetel.net wrote: On 06/14/10 12:18 PM, Tim Joseph Dumol wrote: On Mon, Jun 14, 2010 at 7:09 PM, Dr. David Kirkby david.kir...@onetel.net wrote: On 06/14/10 11:41 AM, Tim Joseph Dumol wrote: Doctests are used to prevent regressions and (unwanted) backward incompatibilities. Since the code used in these modules are not ever going to be modified, it does not seem necessary to provide doctests, IMHO. Personally I'd beg to differ. A change in gcc's behavior could easily result in the code acting differently, as could any number of other system changes. Here are a few tickets for issues that result of just changing compiler versions. * segfault in Sage-4.4 built using GCC-4.5.0 http://trac.sagemath.org/sage_trac/ticket/8788 * frobby optional spkg doesn't build with newer GCC's http://trac.sagemath.org/sage_trac/ticket/8783 * GCC-4.5.0 breaks GAP -- the workspace is broken, hence gap('2+2') fails. http://trac.sagemath.org/sage_trac/ticket/8773 * http://trac.sagemath.org/sage_trac/ticket/8767 http://trac.sagemath.org/sage_trac/ticket/8767 As far as I can see, all those bugs were a result of changing just compiler versions. Add to the mix the possibility of different versions of cython behaving differently, and it seems a bad idea to me. It's certainly not unknown for a doc test to fail on one machine but pass on another. So having the same code never guarantees you get the same result. Over the years, I've come across a lot of code which runs ok on fast computers, but not on slow ones, or visa versa. One case I recall was someone being rather stupid and seeing the random number generator from the time of day multiple times in a loop. On a slow computer, the seed was effectively random each time so they got a different pseudo random number. On a fast computer, the code executed in less than a second, and so the RNG was seeded twice with hte same value. Mathematica on Solaris had a bug when Solaris 10 was updated only on slow computers. http://www.g8wrb.org/mathematica/ So I've known all these to cause bugs, while the source code remains unchanged. * Changes in compiler version * Changes in the speed of the computer * Upgrade of the operating system. As one more final point, there are ports in progress to * FreeBSD * OpenSolaris * 64-bit on Solaris SPARC All of them have the potential to create problems on one platform, not seen on another. Can you dismiss all the above possibilities? If not, why should the code be exempt from testing? Dave As for Cython and gcc, the Sage notebook uses pure Python. I do acknowledge that there's a minuscule chance that a Python update could change runtime behaviour. But what is used to build python? - gcc of course! So we have *at least* the following possibilities which could result in a problem. * gcc update * python update * someone patching python (it is already at patch level 8 or so in Sage) * operating system update * port to another platform (Cygwin, OpenSolaris and FreeBSD are all being worked on.) * someone's computer may be mis-configured. Less likely, but still not impossibe, would be the speed of someone's computer (BSD.py was such an example), or any of numerous other things I can think of. It is worthwhile to note that the code under sage/server/* is only used to be able to load old pickles of Sage notebooks, and the only reasonable way I could think a Python update could mess this up is by a change in pickle format (which is guaranteed against in Python documentation). The code is not used for any other purpose aside from that. Maybe, but it seems a poor idea to remove it to me the fact the code is still used - even if only rarely used. What do we gain this from removing this code from doctesting. * Faster doctesting. * Better looking statistics. I know what I'd rather have. Is there *any* other motivation for removing this from the testing, apart from increasing the percentage of doctest coverage? If not, it boils down to sacrificing quality for better looking statistics. Dave -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options,
Re: [sage-devel] Re: Can LaTeX of strings be improved?
I couldnt see a solution to this in this thread so heres a related question The following produces the exact output Id like to produce (to assign to the _repr_ property of a class) %latex N(\mu,\sigma^2) How can I set things up to do this in a (_repr_) function (as a sage statement/function call)? Does a function exist so I call it to produce such an output? I was hoping something like this would work from sage.misc.latex import pretty_print pretty_print_default(True) pretty_print('N('+'\mu'+','+'\sigma^2'+')') but all it displays is N(\mu,\sigma^2) (hope I didnt miss something too obvious - thanks) -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: erf + solve
Burcin BTW, you could also try to make a patch for the erf() function, to add the _eval_() method I mentioned in this thread on sage-devel. Don't worry about details I wrote in that email, just put an _eval_ method that returns 0 when the input is 0 Heres the patch. I hope I created it properly. I used Mercurial Queues. Assuming its ok, as my first patch, it was an ideal for learning about creating patches. Well done to the people that created [1]. It was very clear and meant I did this without the usual newbie questions. (So that documentation was an excellent investment in time Guys ! :-) (And let me know if the patch can be improved (even if you can make the improvement yourself quickly) Everything Im doing at this stage is worthwhile experience e.g. If you think its appropriate for me to create a ticket, to go through that exercise, Id be happy to) I know youre busy so Ill work on the integrals until I here from you cheers Ross [1] Walking Through the Development Process http://www.sagemath.org/doc/developer/walk_through.html#chapter-walk-through -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org # HG changeset patch # User Ross Kyprianou ros...@gmail.com # Date 1273148141 -34200 # Node ID ffad4517cf8c8fc0f5d5b724652672cf42781864 # Parent e2ccb846f2962cbe254f534ececfd0fbc9ff5045 Evaluate erf(0) as 0 diff -r e2ccb846f296 -r ffad4517cf8c sage/functions/other.py --- a/sage/functions/other.py +++ b/sage/functions/other.py @@ -60,6 +60,17 @@ BuiltinFunction.__init__(self, erf, latex_name=r\text{erf}) +def _eval_(self, x): + +EXAMPLES:: + +sage: erf(0) +0 + +if x == 0: +return 0 +return BuiltinFunction._eval_default(self, x) + def _evalf_(self, x, parent=None): EXAMPLES::
Re: [sage-devel] Re: erf + solve
Burcin Your example is a good test case, so please keep on trying, sending emails, and poking people (me) to work on this. Can you post some example code (your integrator function) so I have something to experiment with? Id like to do as much as possible. This might be a good example for me to start in development. Ill can start with specs (the integral formulas Ive listed) and try to express these in code and send you that first. (And to keep this reply short, Ill just state I acknowledge all your points above about the implementation details) the order we call these functions might be important. Im sure this is important We are definitely aiming to implement symbolic integration natively in Sage. Wow. Sounds like a huge project. Same or bigger scope than Maxima integration? There are some existing implementations even. It's just a matter of getting things cleaned up and submitted to Sage. Since the work is done for research, it can be hard to get them ready for public consumption. :) Integration has been discussed on this list but havent seen any detail of this new integration system Im very interested because the two areas I need to get most into (for my thesis) is 1) integration (particularly of functions associated with common probability distributions and their multivariate counterparts) and 2) signal processing (which Im looking out for open source libraries - I know about scipy but Im sure there may be more out there to collate and bring together consistently) Id like to think Ill be doing sage development in integration and signal processing before long all the best Ross -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: abstract matrices
This turned out as good as it looked Nicolas A lot of the planned functionality is already in place with this initial code - Thanks! Now it should be possible (for me) to implement some more code (which is indicated in the second section (below) i.e. under the section with title I need to implement these). I studied matrix.sage and some of the python scripts in .../devel/sage/ sage/categories I just need some guidance where to put new code or what to overload. e.g. I tried to create a def sum_on_basis(self, w1, w2): under the code where I saw def product_on_basis(self, w1, w2): but that had no effect on the addition bug shown below. Below, the working functionality is indicated first and below that is the new work Ill do with a little guidance. I think the coding I need to do is straight forward. The challenge should just be where to put the code associated each bug below. e.g. Ive written the fix to the sum bug below but - do I put it in a _sum_( ) method? - do I put it in a sum_on_basis(self, w1, w2) method? - and where (or which class?) do I put these methods in? Heres the results of some testing... = Starting with these definitions... sage: Alg = SymbolicMatrixAlgebra(QQ) sage: A = Alg.matrix(A,3,2) sage: B = Alg.matrix(B,2,3) sage: C = Alg.matrix(C,2,3) sage: D = Alg.matrix(D,3,3) === The following worked well === # Conformable matrix sizes for multiplication passes sage: A*B A B sage: B*C.transpose() B C^t # Non-Conformable matrix sizes for multiplication is caught sage: B*C --- AssertionErrorTraceback (most recent call last) ... AssertionError: Non-conformable matrices: matrix sizes are incompatible for multiplication # Additive inverse sage: D-D 0 #Additive identity (no probs with sizes is intuitively ok) sage: A+0 A # Conformable matrix sizes for addition passes sage: B+C B + C # transposes sage: A.transpose() A^t sage: (A+B).transpose() A^t + B^t # only square matrices have an inverse (we'll think about pseudo- inverses later) sage: ~A --- AssertionErrorTraceback (most recent call last) ... AssertionError: Can't inverse non square matrix = I need to implement these = # Non-Conformable matrix sizes for addition is *NOT* caught # (Also need to change the unusual reversal of order being printed) # QUESTION sage: A+B B + A # simplify multiplicative inverse (i.e. return I but not the one from the symbolic ring) sage: ~D*D D^-1 D # allow ~(A*B) to work (currently crashes with size error because Ive specified this should be returned as B^-1 A^-1 and neither are square: but A*B is square so ~(A*B) should return (A*B)^-1 unsimplified - later we can introduce assume(A*B,'invertible') sage: ~(A*B) # multiplying by identity (question of size of I arises - see additive identity example above) sage: D*I D === Probably these too === # (a) ~~D returns D but ~~D == D returns false (confusing) i.e. sage: ~~D D sage: ~~D == D False # (b) define _pow_() so D^-1 returns ~D cheers! -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: erf + solve
You should add a new integrator function and register it in the dictionary sage.symbolic.integration.integral.available_integrators. At some point we also need to come up with a protocol to allow these functions to transform the input and pass it on to be processed by the next one in the queue. So I guess registering means adding (to sage.symbolic.integration.integral) the last line (shown here) available_integrators['maxima'] = external.maxima_integrator available_integrators['sympy'] = external.sympy_integrator available_integrators['mathematica_free'] = external.mma_free_integrator available_integrators['sage'] = external.sage_integrator and including a corresponding function to sage.symbolic.integration.external I think the aim would be that anybody needing a known integral that is not caught by the other 3 integrators, patching this integral in this last chance sage integrator which we have more control over than the other integrators. (Alternatively, can we patch into sympy as an alternative and get an upstream update to their integrator instead?) Ive looked at the 1-2 year old threads in this list on integration and I guess most of the discussion have been implemented. It seems the schema above was implemented so we are using existing integrators rather than opting to recreate another large internal integrator (is that correct?). If so, it might be that the integrals made available very quickly with patches to this new sage integrator would ideally find themselves implemented in maxima and/or sympy eventually and dropped from this new sage integrator to keep it compact. Regardless of the responses to the above, is the following what I should implement? 1) Add to sage.symbolic.integration.integral.available_integrators... available_integrators['sage'] = external.sage_integrator 2) Include a corresponding function (to return the integral result) in sage.symbolic.integration.external def sage_integrator(expression, v, a=None, b=None): ... all the best -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] ubuntu 10.4
I just upgraded to Ubuntu 10.4 I downloaded the Sage 32 bit Ubuntu 9.10 version to see how it will go and got the error at the end of the email Am I right in thinking I should just try making Sage from source? ~/sage-4.4$ ./sage -- | Sage Version 4.4, Release Date: 2010-04-24 | | Type notebook() for the GUI, and license() for information.| -- ** WARNING! This Sage install was built on a machine that supports instructions that are not available on this computer. Sage will likely fail with ILLEGAL INSTRUCTION errors! The following processor flags were on the build machine but are not on this computer: pni Email http://groups.google.com/group/sage-support for help. To remove this warning and make Sage start, just delete /home/ross/sage-4.4/local/lib/sage-flags.txt ** -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: ubuntu 10.4
Guys Thanks for your feedback Certainly dont mind building from source and I will I thought I should report this in case it was of interest to those involved in the build process. The 32bit 9.04 - 9.10 Ubuntu binaries have been working for quite a few versions on this exact PC. The only thing that has changed is the upgrade to 10.04 this morning (hence my post). The CPU info is below in case its of use Thanks again $ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Pentium(R) 4 CPU 3.00GHz stepping: 9 cpu MHz : 2992.243 cache size : 512 KB physical id : 0 siblings: 2 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fdiv_bug: no hlt_bug : no f00f_bug: no coma_bug: no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr bogomips: 5984.48 clflush size: 64 cache_alignment : 128 address sizes : 36 bits physical, 32 bits virtual power management: On Sat, May 1, 2010 at 11:08 PM, Nathan O'Treally not.rea...@online.de wrote: On 1 Mai, 14:13, Ross Kyprianou ros...@gmail.com wrote: I just upgraded to Ubuntu 10.4 I downloaded the Sage 32 bit Ubuntu 9.10 version to see how it will go What processor are you on? (Afaik the 32bit binaries aren't built for too old CPUs.) -Leif and got the error at the end of the email Am I right in thinking I should just try making Sage from source? ~/sage-4.4$ ./sage -- | Sage Version 4.4, Release Date: 2010-04-24 | | Type notebook() for the GUI, and license() for information. | -- ** WARNING! This Sage install was built on a machine that supports instructions that are not available on this computer. Sage will likely fail with ILLEGAL INSTRUCTION errors! The following processor flags were on the build machine but are not on this computer: pni Emailhttp://groups.google.com/group/sage-supportfor help. To remove this warning and make Sage start, just delete /home/ross/sage-4.4/local/lib/sage-flags.txt ** -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/sage-devel URL:http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: ubuntu 10.4
You can try (or might want) to build on a newer (and faster) x86 machine with SAGE_FAT_BINARY=YES (see README.txt). Oh to have the option! (I just have this PC for the moment ;-) (The binary you downloaded seems to not have been built with this switch, or something really goes wrong on 10.04.) It will be interesting to know what other peoples experiences are with 10.04 The 32bit 9.04 - 9.10 Ubuntu binaries have been working for quite a few versions on this exact PC. Sage binaries prior to 4.4? (I.e., the *same* binary worked under 9.10 but not 10.04? / see above) I hope this makes more sense... Ive been using sage successfully either by building from source or using the binaries as they were released, for approximately a year on this same PC. I recall things were ok both under Ubuntu 9.04 and 9.10. This is the 1st serious problem Ive had and its coincided with Ubuntu 10.04 but that may be a coincidence. Ill post one more time after a build from source Until then... :-) The CPU info is below in case its of use It's a pre-Prescott Pentium 4 (Northwood), hence without pni and sse3). -Leif -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: ubuntu 10.4
(You may ask someone else to build a binary for your machine. Otherwise you could report how long the build took on your system, though this depends on the amount of RAM and disk speed as well. Last time I've built 4.3.5 on a Pentium 4 *Prescott*/Socket 478/3,2 GHz, with 4GB DDR1-400 CL2, it took 4 hours.) Happy to report a successful build of Sage 4.4 on Ubuntu 10.04 ! :-) Sage builds usually take about 4-5 hours for me with this PC and only 1GB RAM but thats ok. I left this build going overnight so I dont have a better estimate unfortunately. I have access to a 2nd PC, similar CPU but with Ubuntu 9.10. I can time the build of Sage 4.4 on this other PC and this time Ill build Sage 4.4 before I upgrade Ubuntu. Am I right you upgraded to *both* Sage 4.4 and Ubuntu 10.04 at the same time? (It wasn't clear to me if the Sage *4.4* binary previously worked under 9.04/9.10 on the same machine.) Yes thats right - upgraded to Ubuntu 10.04 and then decided to upgrade from Sage 4.3.4 to 4.4 so I could look at reviewing a couple of patches. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/sage-devel URL:http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: erf + solve
Excellent Burcin - thanks! Ill try your ideas below. Ross On Sat, Apr 24, 2010 at 7:42 PM, Burcin Erocal bur...@erocal.org wrote: On Thu, 22 Apr 2010 20:52:53 -0700 (PDT) Ross Kyprianou ros...@gmail.com wrote: Addendum: I suppose a general query would be how do we incorporate new knowledge into Sage (narrowing this down to things like (a) closed form expressions of integrals You should add a new integrator function and register it in the dictionary sage.symbolic.integration.integral.available_integrators. At some point we also need to come up with a protocol to allow these functions to transform the input and pass it on to be processed by the next one in the queue. (b) well known expressions of finite or infinite sums This is not possible at the moment. We need to setup something like the framework in sage.symbolic.integration. (c) well known solutions of equations such as the previous message This can be done by adding an _eval_() method to sage.functions.other.Function_erf. It might look like: def _eval_(self, x): if x == 0: return 0 return BuiltinFunction._eval_default(self, x) Note that checking if a symbolic expression is equal to 0 might be expensive. Looking at sage/symbolic/expression.pyx, I see that there is no way to call the is_zero() method of pynac directly from Python. Perhaps we should allow this, and call this function if the argument to _eval_ is a symbolic expression. Is it a matter of identifying the area (e.g. pynac, pari, maxima) and proposing a change to that codebase (possibly in C or Lisp)? All of the above can be done in Python/Cython, if not we should fix that too. Cheers, Burcin -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] erf + solve
Question 1: Is it possible (and reasonable) to have the error function, erf, return 0 for erf(0)? Currently it returns the expression: erf(0) Question 2 (related): The standard normal (or Gaussian) curve has half its (unit) area to the left (and right) of x==0 as we see here... sage: gaussian = 1/sqrt(2*pi)*exp( -(1/2)*x^2 ) sage: integrate( gaussian, x, -oo, 0) 1/2 To find the value of t for which the area is 1/2 we might try sage: solve( integrate(gaussian, x, -oo, t)==1/2, t ) Unfortunately we get the expression [erf(1/2*sqrt(2)*t) == 0] which for t==0 reduces to erf(0) which ideally would reduce to 0 hence Question 1 above ;-) I suppose Question 2 is: Although the erf doco suggests this is all done with PARI, is it possible for [erf(1/2*sqrt(2)*t) == 0] to be made to reduce to [t==0]? -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: erf + solve
Addendum: I suppose a general query would be how do we incorporate new knowledge into Sage (narrowing this down to things like (a) closed form expressions of integrals (b) well known expressions of finite or infinite sums (c) well known solutions of equations such as the previous message Is it a matter of identifying the area (e.g. pynac, pari, maxima) and proposing a change to that codebase (possibly in C or Lisp)? On Apr 23, 11:27 am, Ross Kyprianou ros...@gmail.com wrote: Question 1: Is it possible (and reasonable) to have the error function, erf, return 0 for erf(0)? Currently it returns the expression: erf(0) Question 2 (related): The standard normal (or Gaussian) curve has half its (unit) area to the left (and right) of x==0 as we see here... sage: gaussian = 1/sqrt(2*pi)*exp( -(1/2)*x^2 ) sage: integrate( gaussian, x, -oo, 0) 1/2 To find the value of t for which the area is 1/2 we might try sage: solve( integrate(gaussian, x, -oo, t)==1/2, t ) Unfortunately we get the expression [erf(1/2*sqrt(2)*t) == 0] which for t==0 reduces to erf(0) which ideally would reduce to 0 hence Question 1 above ;-) I suppose Question 2 is: Although the erf doco suggests this is all done with PARI, is it possible for [erf(1/2*sqrt(2)*t) == 0] to be made to reduce to [t==0]? -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/sage-devel URL:http://www.sagemath.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: abstract matrices
Send me your code, and I refactor it to its simplest form, as a basis for further work. Very kind offer :-) The most efficient would be to upload it on the Sage-Combinat queue, but that will take some learning the tool: http://wiki.sagemath.org/combinat/MercurialStepByStep; otherwise e-mail is fine. Reviewing some patches gave me some valuable experience with Mercurial but Ill email you if thats ok until I have some more experience with developing good code for Sage. Ill write and test some more and then send you what I come up with as soon as possible Keep up the good work! Thanks for the encouragement! The Sage developer community is one of the most helpful and encouraging group of people I have ever been associated with! -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: abstract matrices
Any ideas of why _repr_ might not be working inside the class? Was this class that of the category or the parent? I made a copy of AlgebrasWithBasis.py (so that's the category isnt it?) and placed my version of _repr_ is various places within that code but it didnt override the default _repr_ If you do (with x some of your elements): sage: x.__class__.mro() you will see that the category classes appear quite late there, and in particular after Parent. Hence, it is (currently) not possible to override _repr_, or anything else implemented in Parent, by code in categories. I called mro on an element P, as suggested... (P,Q,R)= MtxAlgebrasWithBasis(QQ).example(('P','Q','R')).algebra_generators() P.__class__.mro() Does the output (at the end of this reply) mean: _repr_ cant be overridden somehere as you stated above? (It would be a huge shame. I checked with support from both commercial players (Mma Mple) and both said they dont support this but have been asked for it multiple times. I understand its been asked by our users also. And now that I need it, Im highly motivated to implement it :-) As a last resort - just to get some of my work progressing for now - Im happy to copy and customize enough existing categories code to make matrices work it but if I can do this properly it could end up in the sage code base for others to use. Question is is: it possible to implement this properly? All that is needed, to make a basic prototype matrix algebra, is Distributivity == P(Q+R) = PQ + QR (already working thanks to existing categories code) Non-commutivity PQ does not equal QR (also is working) Printing i.e. show P Q + Q R rather than B[word: PQ] + B[word: PR] (by overloading _repr_ or by some other means?) Substitution i.e. P^-1 * P results in identity - And - (P * Q).Transpose() results in Q.Transpose() + P.Transpose() So two tasks done - two to go if possible! Keen to hear your thoughts when you have time cheers and thanks [class 'sage.combinat.free_module.FreeAlgebra_with_category.element_class', class 'sage.combinat.free_module.CombinatorialFreeModuleElement', type 'sage.structure.element.Element', type 'sage.structure.sage_object.SageObject', class 'sage.categories.algebras_with_basis.AlgebrasWithBasis.element_class'\ ;, class 'sage.categories.modules_with_basis.ModulesWithBasis.element_class', class sage.categories.tensor.CategoryWithTensorProduct.ElementMethods at 0xaba7bfc, class sage.categories.cartesian_product.CategoryWithCartesianProduct.ElementMe\ thods at 0xaba7d7c, class 'sage.categories.vector_spaces.VectorSpaces.element_class', class 'sage.categories.algebras.Algebras.element_class', class 'sage.categories.rings.Rings.element_class', class 'sage.categories.rngs.Rngs.element_class', class 'sage.categories.modules.Modules.element_class', class 'sage.categories.bimodules.Bimodules.element_class', class 'sage.categories.left_modules.LeftModules.element_class', class 'sage.categories.right_modules.RightModules.element_class', class 'sage.categories.commutative_additive_groups.CommutativeAdditiveGroups.e\ lement_class', class 'sage.categories.commutative_additive_monoids.CommutativeAdditiveMonoids\ .element_class', class 'sage.categories.commutative_additive_semigroups.CommutativeAdditiveSemi\ groups.element_class', class 'sage.categories.monoids.Monoids.element_class', class 'sage.categories.semigroups.Semigroups.element_class', class 'sage.categories.sets_cat.Sets.element_class', class 'sage.categories.objects.Objects.element_class', type 'object'] -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: abstract matrices
# This made things very interesting. # Using WordOptions(identifier='') does most of the work needed ### Example 1 ### sage: (P,Q,R)= MtxAlgebrasWithBasis(QQ).example(('P','Q','R')).algebra_generators() sage: P*(Q+R) B[word: PQ] + B[word: PR] ### Example 2 ### sage: WordOptions(identifier='') sage: P*(Q+R) B[PQ] + B[PR] # To go all the way a bit more code seems to be needed # this is based on the _repr_ referred to in previous tip from Nicolas def _repr_(self): v = self._monomial_coefficients.items() try: v = sorted(v) except StandardError: # Sorting the output is a plus, but if we can't, no big deal pass repr_term = self.parent()._repr_term # mons = [ repr_term(m) for (m, _) in v ] mons = [ m.string_rep() for (m, _) in v ] cffs = [ x for (_, x) in v ] x = repr_lincomb(mons, cffs).replace(*1 , ) if x[len(x)-2:] == *1: return x[:len(x)-2] else: return x # was tested using ... _repr_((P+Q)*R) 'PR + QR' This is what I was aiming to be printed when I do (P+Q)*R Does this code (in the new _repr_) look ok? Im aiming to do things consistently or to standards. Anything better recommended? I should be returning a string from _repr_ - shouldnt I ? thanks Ross On Mon, Apr 12, 2010 at 6:41 PM, slabbe sla...@gmail.com wrote: Hi, Im guessing the code to make the B[word: ] string may have been in a python file that corresponded to one of the Categories above but couldnt find it The 'word: ' part comes from sage/combinat/words : sage: Word(range(10)) word: 0123456789 sage: Word(lambda n:n) word: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,... Currently, one can change the identifier 'word: ' globaly by doing : sage: WordOptions(identifier='somethingelse') sage: Word(lambda n:n%10, length=20) somethingelse01234567890123456789 Or one can erase it completely by doing : sage: WordOptions(identifier='') sage: Word(range(10)) 0123456789 Hence, we get the following which look better : sage: WordOptions(identifier='') sage: A = AlgebrasWithBasis(QQ).example() sage: A.an_element() B[] + 2*B[a] + 3*B[b] sage: A.one() B[] sage: A(1) B[] A cleaner solution would avoid changing the global identifier... but this needs some thoughts and adapt the code somewhere. Cheers, Sébastien Labbé -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe, reply using remove me as the subject. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: abstract matrices
On Tue, Apr 13, 2010 at 2:53 AM, Nicolas M. Thiery nicolas.thi...@u-psud.fr wrote: ### Example 1 ### sage: (P,Q,R)= MtxAlgebrasWithBasis(QQ).example(('P','Q','R')).algebra_generators() Do you need a specific category for your application? In particular, will you have several parents between which to share code? Its a possibility- still getting my head around all the parents I can choose from. The application is just to implement matrices - which if I recall correctly from early University (many years ago ;-) - is vector space and Im sure these categories are a great way to represent vetcor spaces (especially with the amendments you suggested of including rows,cols so we check sizes are ok when adding / multiplying 2 matrices) (Note - not referring to the usual matrices that we find in software (with matrix elements) ) - just the symbolic kind where we can simplify (AB)^-1 as B^-1 A^-1 ) If the only change is on the repr_term line, you might as well override the method _repr_term in the parent; that's its purpose! Great idea! Will try this today. P.S. One problem I found yesterday is I worked on the _repr_ outside the class until it worked as planned then when I cut and pasted it inside the class (right at the top, as the first function) it didnt seem to change what was printed. Any ideas of why it might not be working inside the class? Many thanks Nicolas Ross -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe, reply using remove me as the subject.
Re: [sage-devel] abstract matrices
Nicolas C = AlgebrasWithBasis(QQ) C? certainly did report back more info! And the categories seem to be the very classes needed for abstract matrices! Its a bit time-consuming to get on top of this if one is new to Categories (like me ;-) but the amount of functionality that you inherit makes it very worthwhile. Im looking at the code to get more familiar with everything Thanks for this tip Ross On Sun, Apr 11, 2010 at 7:25 PM, Nicolas M. Thiery nicolas.thi...@u-psud.fr wrote: On Sat, Apr 10, 2010 at 03:20:42PM +0100, John Cremona wrote: On 9 April 2010 21:42, Nicolas M. Thiery nicolas.thi...@u-psud.fr wrote: You may want to look at: sage: A? For how to easily implement things like free commutative algebras. This intrigued me, so I did exactly the above; and found that I could not understand anything that A? displayed! Ah, thanks John for the notice; I had forgotten that the more detailed examples are actually in: sage: C? There should be at least a link to there. I'll do that! Please try the above and report back! This documentation needs to be improved, and feedback (or best patches!) is most welcome. Best, Nicolas -- Nicolas M. Thiéry Isil nthi...@users.sf.net http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe, reply using remove me as the subject.
Re: [sage-devel] abstract matrices
Hi Nicolas Learned a little about the Categories setup Next step is to override the __repr__ method Is the B[word: ] string formed in a __str__ or __repr__ method? If so, Im trying to work out where it is (so I can base the new code on it) I ran these... sage: C = AlgebrasWithBasis(QQ) sage: A = C.example(('p','q','r')) sage: (P,Q,R) = A.algebra_generators() sage: P.__repr__() 'B[word: p]' sage: P.__repr__?? # showed me code from devel/sage/sage/structure/sage_object.pyx sage: A.categories() [Category of algebras with basis over Rational Field, Category of modules with basis over Rational Field, Category of vector spaces over Rational Field, Category of algebras over Rational Field, Category of rings, Category of rngs, Category of monoids, Category of semigroups, Category of modules over Rational Field, Category of bimodules over Rational Field on the left and Rational Field on the right, Category of left modules over Rational Field, Category of right modules over Rational Field, Category of commutative additive groups, Category of commutative additive monoids, Category of commutative additive semigroups, Category of sets, Category of objects] Im guessing the code to make the B[word: ] string may have been in a python file that corresponded to one of the Categories above but couldnt find it Appreciate any help thanks! Ross On Sat, Apr 10, 2010 at 6:12 AM, Nicolas M. Thiery nicolas.thi...@u-psud.fr wrote: On Thu, Apr 01, 2010 at 04:41:53PM -0700, Ross Kyprianou wrote: Id like to write a package that can do pure/abstract matrix expressions such as in the following examples ... This isnt a full specification - there are many issues not addressed and note we are considering pure matrix expressions only (i.e. no matrix components). Also the matrix size N is arbitrary - doesnt ever need to be assigned a value. I can think of two ways of doing this and just asking for peoples gut feeling which direction I should go in to implement this within Sage. Possibility 1) We consider this a noncommutative algebra and look at GAP (are there other possiblilities?) You may want to look at: sage: A = AlgebrasWithBasis(QQ).example() sage: A? For how to easily implement things like free commutative algebras. Here your basis could typically be indexed by a triple of the form: (name, nrows, ncols) where name is a string, and nrows / ncols integer or anything else. This triple should probably be wrapped as a python object in some new class for nicer output. Then the product of two such triples would just check equality of ncols w.r.t. nrows, and throw an error if not (ok because of that, you don't quite get an algebra, but that's good enough as a starter). Feel free to ask for help if needed! Best, Nicolas -- Nicolas M. Thiéry Isil nthi...@users.sf.net http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe, reply using remove me as the subject. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] abstract matrices
Hi Id like to write a package that can do pure/abstract matrix expressions such as in the following examples To keep things simple, in the examples below, let A, B, C... be matrices; k be a scalar * be matrix or scalar multiplication, ^-1 and ^T and ^n be matrix inverse, transpose and power sage: (A * B)^2 A * B * A * B sage: (A * B)^-1 B^-1 * A^-1 sage: assume(A = B^-1) sage: A * B I# this is the identity matrix sage: A * (B+ C) A * B + A * C sage: (A * B + A * C).factor() A * (B+ C) sage: k * (B+ C) k * B + k * C # Note: Assume I probably did a few things first, like sage: var('k,N'); A = abstractmatrix(N, N); B = abstractmatrix(N, N); C = abstractmatrix(N, N) # this is so sage knows what kind of objects * and + are acting on and so I cant add/multiply nonconforming matrices This isnt a full specification - there are many issues not addressed and note we are considering pure matrix expressions only (i.e. no matrix components). Also the matrix size N is arbitrary - doesnt ever need to be assigned a value. I can think of two ways of doing this and just asking for peoples gut feeling which direction I should go in to implement this within Sage. Possibility 1) We consider this a noncommutative algebra and look at GAP (are there other possiblilities?) Possibility 2) Consider these matrix expressions as symbol expressions and use pattern matching with rewrite rules to transform expressions such as those shown above (python has regular expression capabilities and I expect something can be done using maxima or pynac - is there anything else? Lisp maybe?) I expect this will be wanted by some people. Some guidance will hopefully realize it sooner. BTW Its ok if the solution involves python, C++ or Lisp Thanks -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe, reply using remove me as the subject.
[sage-devel] Re: Add 'gcc' libraries to Sage binaries ( 0.5% bloat)
Its a good thing that we already make available binaries for those people with less Linux experience Whatever we can do to make Sage work out of the box is good (i.e. I know its 99% there but it will be even better if we can avoid asking people to ensure certain things are installed and are certain versions - even when people choose to build) So, in a nutshell, its a +1 from me FWIW (Of course this is subject to any vetos from anyone saying why this wont work under certain circumstances) On Feb 22, 10:52 pm, Bill Hart goodwillh...@googlemail.com wrote: Are we sure this would work? Won't those libraries depend on what kernel is installed, etc, etc? I'm completely ignorant on this, so may be talk out my proverbial. Bill. On 22 Feb, 11:27, Dr. David Kirkby david.kir...@onetel.net wrote: This came up on the thread mercurial on t2 but I thought I'd start a new thread on it. I'd propose that we include in any binary distribution gcc's C, C++ and Fortran shared libraries. They would be placed in $SAGE_LOCAL/lib. Then we can ensure that people will run Sage with what libraries Sage was built with, rather than what versions they may or may not have lying around. The amount of bloat this would add to the binary would be very small. For Solaris, the compressed sizes of the files are: -rwxr-xr-x 1 drkirkby staff 1.5M Feb 22 10:10 libstdc++.so.6.0.10.gz -rwxr-xr-x 1 drkirkby staff 717K Feb 22 10:10 libgfortran.so.3.0.0.gz -rw-r--r-- 1 drkirkby staff 80K Feb 22 10:10 libgcc_s.so.1.gz So adding all 3 adds 2.3 MB of extra code to the binary. But given the binary is 500 MB (not untypical), that is less than 0.5% of bloat. By doing this, we ensure that people * Always have the libraries. * Always have the exact same versions Sage was built with. I believe the Fortran library might already be included for Linux (I have not checked), but I'd suggest all 3 were added to binaries. The C library is the one people most likely will have, but given it is by far the smallest, we might as well include it to be 100% sure. Comments? Dave -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: creating a random matrix is slow
Apologies for asking Harold but how big was s? On Feb 19, 12:05 am, Harald Schilly harald.schi...@gmail.com wrote: Hi, I did some benchmarks and during that i noticed that it takes quite long to create a random_matrix. Is there something obvious I'm missing or is there a better way to do this? Ticket? Benchmark Matlab 2009a vs. Sage 4.3.2: tic; m = randn(s,s); toc Elapsed time is 0.060981 seconds. sage: %time m = random_matrix(RDF, 1000) CPU times: user 1.77 s, sys: 0.01 s, total: 1.78 s Wall time: 1.78 s That's a factor of 30x! H -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: creating a random matrix is slow
Harald There seems to be definitely a problem Just tried it on sage.math sage: %time random_matrix(RDF, 1) took over 2mins () tic; m = randn(100,100); toc took 0.0003 secs! On Feb 19, 12:05 am, Harald Schilly harald.schi...@gmail.com wrote: Hi, I did some benchmarks and during that i noticed that it takes quite long to create a random_matrix. Is there something obvious I'm missing or is there a better way to do this? Ticket? Benchmark Matlab 2009a vs. Sage 4.3.2: tic; m = randn(s,s); toc Elapsed time is 0.060981 seconds. sage: %time m = random_matrix(RDF, 1000) CPU times: user 1.77 s, sys: 0.01 s, total: 1.78 s Wall time: 1.78 s That's a factor of 30x! H -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: creating a random matrix is slow
Oops (read the doco (for random_matrix) Ross!) Apologies for the silly mistake Matlab's rand() samples from the uniform distribution (I believe) and randn() from the normal distribution. That has a small bearing when we want to compare. But there should still be a problem (unless I made another mistake?) when we compare #matlab tic; m = rand(1,1); toc Elapsed time is 2.301789 seconds. sage: %time random_matrix(RDF, 1) CPU times: user 139.01 s, sys: 1.37 s, total: 140.38 s Wall time: 140.46 s 1 x 1 dense matrix over Real Double Field The elapsed time of matlab is similar to the sys time of Sage (but matlab returned in about 2 secs and sage returned in over 2 mins) Apologies if I missed something again but one can always learn from mistakes :) On Feb 19, 1:33 am, Martin Albrecht m...@informatik.uni-bremen.de wrote: On Thursday 18 February 2010, Ross Kyprianou wrote: Harald There seems to be definitely a problem Just tried it on sage.math sage: %time random_matrix(RDF, 1) took over 2mins () this is a 1 x 1 matrix tic; m = randn(100,100); toc took 0.0003 secs! and this a 100 x 100 matrix Martin -- name: Martin Albrecht _pgp:http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x8EF0DC99 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF _www:http://www.informatik.uni-bremen.de/~malb _jab: martinralbre...@jabber.ccc.de -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org