12 ms·
SageMath – Open-Source Mathematical Software System
- gnramires 6y ago"It builds on top of many existing open-source packages: NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT, R and many more. Access their combined power through a common, Python-based language or directly via interfaces or wrappers."
- mathgeek 6y agoPrevious discussions for perusal: https://news.ycombinator.com/item?id=266040 https://news.ycombinator.com/item?id=266040 (2008) https://news.ycombinator.com/item?id=17995031 https://news.ycombinator.com/item?id=17995031 (2018)
- dang 6y agoSee also: https://news.ycombinator.com/item?id=19682126 https://news.ycombinator.com/item?id=19682126 - "Should I Resign from My Full Professor Job to Work Fulltime on Cocalc?" - 2019 https://news.ycombinator.com/item?id=19485166 https://news.ycombinator.com/item?id=19485166 - "Computational Mathematics with SageMath" - 2019 https://news.ycombinator.com/item?id=11883987 https://news.ycombinator.com/item?id=11883987 - "The Origins of SageMath" - 2016 https://news.ycombinator.com/item?id=11078220 https://news.ycombinator.com/item?id=11078220 - "Open source is now ready to compete with Mathematica for use in the classroom" - 2016 https://news.ycombinator.com/item?id=10175563 https://news.ycombinator.com/item?id=10175563 - "The Simons Foundation and Open Source Software" - 2015 https://news.ycombinator.com/item?id=10147401 https://news.ycombinator.com/item?id=10147401 - "React, Flux, RethinkDB and SageMathCloud – Summer 2015 Update" - 2015 https://news.ycombinator.com/item?id=2088871 https://news.ycombinator.com/item?id=2088871 - "SageMath: Python-based Mathematics. Rock it." - 2011 - a little bit of editorializing there... https://news.ycombinator.com/item?id=983423 https://news.ycombinator.com/item?id=983423 - "Conception, birth and developement of a Free math software (Sage)" - ditto... https://news.ycombinator.com/item?id=179416 https://news.ycombinator.com/item?id=179416 - "Sage: Can There be a Viable Free Open Source Alternative to Magma, Maple, Mathematica, and Matlab?" - 2008 Any others?
- noir_lord 6y agoSaved my bacon about 5-6 years ago, the company we where going to depend on to do a whole bunch of complex calculations related to solar insolation discontinued their API but didn't tell anyone, I found out when I rang up to get a price. So suddenly I was in the situation of dealing with maths that was harder than anything I'd done at school years and years ago. In the end I transliterated the equations into sage, checked the results carefully and then wrote the PHP to do the same calculations using a large set of tests against the official stuff, stressful two weeks but sage was useful as hell.
- fho 6y agoSame for me ... my MsC thesis relied heavily on the result of a single complex three-dimensional integral ... I spend weeks trying to solve it by hand. SageMath wasn't able to solve it either, but it helped me towards the solution.
- bollu 6y agoI'm a huge fan of SAGE! I keep using it to discover new math. I generally play with the associate Sage module of any algebraic structure to get a real feel for what is going on. Some examples of: 1. Grobner basis: http://bollu.github.io/#computing-equivalent-gate-sets-using-grobner-bases http://bollu.github.io/#computing-equivalent-gate-sets-using... 2. Commutators of subgroups: http://bollu.github.io/#5age-code-to-play-around-with-commutators-of- http://bollu.github.io/#5age-code-to-play-around-with-commut... 3. Graph/group theory: https://github.com/bollu/bollu.github.io/blob/2f88c28efc54fb16463e2d9e0ac63f28620e223b/content/blog/math/intro_to_sage.md https://github.com/bollu/bollu.github.io/blob/2f88c28efc54fb...
- Alkhwarizmi 6y agoI LOVE your blog man! Keep it up
- abdullahkhalids 6y agoCompletely off topic question. Can Grobner basis techniques be used to solve a set of quadratic inequalities?
- thechao 6y agoNot ... really? I usually compare the Gröbner basis to generalized matrix decomposition in the sense of solving systems of linear equations. If you’re solving systems of quadratic equations, you should look into interior barrier solving methods, which generalize the simplex method.
- blt 6y agoReally? I thought the simplex method was kind of the opposite of an interior point method.
- generationP 6y agoGröbner bases appear in the standard reference on real algebraic geometry ( https://perso.univ-rennes1.fr/marie-francoise.roy/bpr-ed2-posted3.pdf https://perso.univ-rennes1.fr/marie-francoise.roy/bpr-ed2-po... ), so the answer may well be "yes", but don't ask me for the details. (All I can tell is that quadratic systems are no easier than degree-n systems in general -- there's a known trick how any system can be reduced to degree 2 by introduced extra variables.)
- chaoxu 6y agoI've contributed some code to matroid optimization. The people working on it are very knowledgable, often professors at universities donating their time. I definitely learned a lot through implementing some algorithms from the 70s.
- haberman 6y agoAs someone who needs math software somewhat infrequently, I had assumed that SageMath was a sort of de facto standard for people using Python with math. I was surprised to see that Google Colab doesn't support Sage in its notebooks. I asked a coworker about it, someone who had previously worked on Sage. It sounds like some parts of the community are now favoring using lighter-weight libraries directly (like SymPy for symbolic math). I discovered that Sage is not pure Python: Sage is translated to Python before running, which is how it can support syntax like "f(x) = x + 1" to define a function (whereas in pure Python you would need to use "def".
- krastanov 6y agoBe careful with your last statement: Sage is actually accessible as a python library with purely python syntax, but it also has an interface that supports weirder syntax like the one you mentioned.
- sgdpk 6y agoDo you know how to install the library in a Python environment?
- williamstein 6y agoIn one sense, what you want is possible but not currently supported, though people are working on it (https://trac.sagemath.org/ticket/29705 https://trac.sagemath.org/ticket/29705 is a good start). In another sense, the SageMath install is just a Python environment. When you install Sage (from source or a binary) you are install a Python environment, similar to Anaconda. You can then type "sage -sh" to setup the environment, then install packages (pip3 install), or run a Python interpreter (by typing "python3") and do "import sage.all" to get the full sage library as a normal Python library. You could write a Python program and use any of Sage in them by importing "sage.all" in your Python program. The reason Sage is currently distributed this way is similar to the reason Anaconda exists, which is that Python's package manager isn't (or wasn't in 2005 when I started this!) meant to build something as complicated as Sage, which has about 100 complicated dependencies. I really hope this eventually changes someday and people can type "pip install sagemath" and get something useful. Oh, I think for several Linux distributions there are SageMath packages that just build Sage into the standard system-wide Python. So if you're using Linux, the problem may already be solved for you.
- vsskanth 6y agoI really wish I started using Sage instead of maxima directly. The documentation for maxima is pretty difficult to understand for a noob just looking to solve some non linear equations
- deleted 6y ago[deleted]
- amir734jj 6y agoI used SageMath for my master's thesis in cryptography and group theory. It was awesome! I highly recommended it and its unfortunately very underrated.
- seamyb88 6y agoUsing it extensively for my crypto PhD. Several well-known cryptographers contribute to it. It's an amazing bit of kit. But I'm not without criticisms. I feel it could do with the kind of fresh-start overhaul that really isn't practical for an open-source code base of this nature. E.g. move python 2.6 to python3. Also, you have excellent multi-precision support, but many of the algorithms from other modules don't support precision beyond machine lengths. But really really good. Love it.
- williamstein 6y agoSagemath already switched to python3 a while ago.
- nenadst 6y agofyi from the website : Since version 9.0 released in January 2020, SageMath is using Python 3.
- 29athrowaway 6y agoIf you are interested in trying sagemath, read the PREP tutorials. https://doc.sagemath.org/html/en/prep/quickstart.html https://doc.sagemath.org/html/en/prep/quickstart.html These contain have examples for linear algebra, calculus, diff equations, statistics, etc. I use sagemath with Jupyter lab and it works pretty well. You can evaluate an expression and ask sage to output the LaTeX code for it, so you can have everything nicely formatted.
- grizzles 6y agoIs there an easy way to embed a sage notebook viewer / editor inside a webpage without installing a sagecell server?
- williamstein 6y agoYou can upload it to cocalc.com, then share it publicly, then click the embed link to get a version that is suitable for embedding in an iframe...
- grizzles 6y agoIt might be a good strategic move to publish a React component to do this for the non iframe solution enthusiasts out there. It would be good to see people start using SageMath notebooks where they otherwise might be using Katex or Mathjax today. It could always have an "Open/Run on CoCalc" link as part of it.
- williamstein 6y agoI probably should, since the underlying renderer mentioned above is actually implemented using React (it takes as input JSON describing a notebook and renders it, entirely on the frontend). Also, in case it isn't clear, these days "Sage notebook" just means "Jupyter notebook with the SageMath kernel"... since "the Sage notebook" (=the SageMath project's predecessory to Jupyter, but written in 2007) is basically deprecated now in favor of the official Jupyter notebook project.
- esrh 6y agoHow good is it for machine learning? I'm currently using julia which I also really enjoy.
- yza 6y agoSage is not something that you would want to use for ML per say. It can, however, help you with understanding of the underlaying math and algorithms. It has excellent support for symbolic math, statistics (distributions etc.) and just about everything else you are going to need to study ML. I recently switched from Mathematica and could not be happier.
- noobermin 6y agoHow are sage's differential equation solvers now? How does it compare to Mathematica's? I'd love to get back into sage if it worked better with that sort of thing now.
- fish45 6y agoI love sage and I used it for multivar calc this year but unfortunately it's not as good in some aspects (mainly symbolic integration) as Mathematica. One of my primary motivations for learning math is being able to contribute
- deleted 6y ago[deleted]
- heavyset_go 6y agoI highly suggest using this package if you're in school or otherwise learning higher level math. Being able to programmatically interact and manipulate abstractions over the mathematical concepts you're learning is an enriching experience, and it can help you check your answers to your homework. It's also a Python module so you can learn a skill that transfers well to other domains compared to, say, Mathematica.
- fizixer 6y agoCould you refer to a tutorial or a bit more description about what you mean by 'manipulate abstraction over the mathematical concepts', especially when doing higher math? Simple arithmetic, or even computer-algebra simplifications are too simplistic. They help with high-school stuff but are useless for higher math where the bread and butter are theorem-proof-theorem-proof based learning/understanding/research. Geometric plotting/vis, again, good for high-school and freshman stuff mainly. (Plotting is useful for research, data science, numerics, what not, but that's a whole other story. And computer graphics is a rabbit hole). Same with Analysis. Good to have an automatic integrator for Calculus, useless for Real Analysis. Numerical calculations are too laborious and you have to have a good understanding of a wide body of numerical literature, plus have experience. (again a rabbit hole) That leaves us with proof-assistants, model-checkers, and small-scale automatic theorem-provers. And experience research mathematicians are still learning those. Am I missing something?
- gnramires 6y agoNot a mathematician. Used Sage for engineering purposes. But I think one example would be: you're investigating something and get a large linear system, a polynomial, etc. Sage can solve equations with symbols. It saves a lot of manual labor. Various expressions can be manipulated, simplified, etc. It can readily verify equality of huge expressions (which can be error prone by hand), and so on. More specific fields have more specific tools that could be used to assist, so it would depend on the field I guess. See here: https://ask.sagemath.org/question/24866/how-to-simplify-with-sage/ https://ask.sagemath.org/question/24866/how-to-simplify-with... Edit: I also think it should be fairly common to need to perform an actual numerical calculation in mathematical work? I think it's quite better than a simple calculator for that too, since it gives exact e.g. rational results, and approximations would be unfit for a proof (unless extensive precautions are made). I remember I got an expression for an eigenvalue of a matrix (as a function of some parameters) that would be very laborious to get by hand.
- lvh 6y agoSage is wonderful. It has a huge number of uses but I mostly use it for cryptography. Sage has the best (certainly open source) support I know of for a myriad of things like group theory and elliptic curves. Here's a short example for how easy it is to play around with a tiny elliptic curve: sage: p = 19; p.is_prime() True sage: K = GF(p); K Finite Field of size 19 sage: E = EllipticCurve(K, [5, 9]); E Elliptic Curve defined by y^2 = x^3 + 5*x + 9 over Finite Field of size 19 sage: E.count_points(), E.order(), E.gens() (19, 19, [(4 : 6 : 1)]) There are far too many things to name that sage can do, but the CLI has a great autocomplete. Here's an example: let's say you have ECDH with point compression, and you specify only an x coordinate. Point compression limits the effectiveness of invalid curve attacks, where an attacker gives you a maliciously picked Diffie-Hellman value that isn't actually on the curve you're supposed to be on. However, if the x coordinate doesn't map to a point on the curve, it's necessarily on its "nontrivial quadratic twist". Sage makes this easy to play with because sage makes pretty much everything easy to play with: sage: E.lift_x(6, all=True) [] sage: E.quadratic_twist() Elliptic Curve defined by y^2 = x^3 + 6*x + 13 over Finite Field of size 19 sage: E.quadratic_twist().lift_x(6, all=True) [(6 : 6 : 1), (6 : 13 : 1)] If you want to do a full-on invalid curve attack, the easiest way to do that is with Sage. You look up how the explicit formulas work in the EFD[efd], you write a ladder, you figure out how to create other elliptic curves for which the short Weierstrass doubling formulas still work (which parameter doesn't appear in the formula?), and then just let sage generate every possible curve and see which ones have the poor cryptographic properties you're after. There's a reason the introduction to Cryptopals Set 8[set8] sends with the words: > By the time you're done, you will have written an ad hoc, informally-specified, bug-ridden, slow implementation of one percent of SageMath. As much as I'm a Clojure fanboy none of the Java libraries come even close. Unfortunately, sage is mildly annoying to use/install as a Python library (that would help interop significantly). [efd]: https://www.hyperelliptic.org/EFD/g1p/auto-shortw.html https://www.hyperelliptic.org/EFD/g1p/auto-shortw.html [set8]: https://cryptopals.com/sets/8 https://cryptopals.com/sets/8
- oefrha 6y agoI haven’t used CAS for nontrivial algebra and number theory in a while (think half a decade), but IIRC Magma is a fair bit more powerful than Sage on these topics and more consistent as well. But alas, it’s not open source and not free. There’s a free calculator though subject to limits. http://magma.maths.usyd.edu.au/calc/ http://magma.maths.usyd.edu.au/calc/
- Yushi212 6y agov.vhackservice @ gmail . com for any of your hack service. GET ACCESS TO YOUR SPOUSE DEVICE AND SPY ON THEM CONVO.
- skeeks 6y agoWe used SageMath in cryptography lessons at university. Very useful stuff and easy to get!
- shuringai 6y agowhy is the existence of sagemath have any news relevance on HN?
- johnsonjo 6y ago> why is the existence of sagemath have any news relevance on HN? Ideas from STEM (Science Technology Engineering and Mathematics) are pretty large and pervasive throughout the tech industry. I think there are also a large area of tech startups that could come from any area of STEM. Also one of the goals of info on hacker news is to be intriguing to hackers themselves and to fulfill some sense of intellectual curiosity. For me personally SAGEMath opens doors for me as a programmer to better understand abstract math concepts that might or might not have relevance to my daily work as a programmer and as a cofounder. In that sense I think SAGEMath helps fulfill that intellectual curiosity. Heck it may even help me complete that next projecteuler problem. (Which also is only done for the fun and experience of it.) Also people who come up with really creative company ideas or that build free software that really do something quite amazing are often at the intersection of tech and some other field. This is not to say that tech solves all other fields’ problems. It’s that tech can benefit other fields when it takes the approach of how can I make this field’s work easier which often comes from a good amount of knowledge of how that field actually works otherwise it’s just too superficial. SAGEMath is a great example of tech actually helping research mathematicians and most of it is made by mathematicians themselves (who clearly have some programming prowess.) By the way I’m sorry you were downvoted. Looking at your profile I see you’ve only been on here for 82 days. I see your comment as very genuine but I also understand a little of why you might have been downvoted but for that I’ll just point you to the sites guidelines: https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html The original post very clearly meets the guidelines though it is not your typical news, it is news to hackers. Happy Hacking. :)
- amw-zero 6y agoHow does it compare to Mathematica?
- BeetleB 6y agoNothing compares to Mathematica, unfortunately. Mathematica really is the best, if you can afford it.
- williamstein 6y agoMore realistically. Mathematica is the best at some things, but is hopelessly behind in others (e.g. algebraic number theory and group theory). Computational mathematics is deep and vast.
- BeetleB 6y agoWell, I can't argue with the Father of Sage :-) A bit surprised to hear that, though. Do you mean Sage is better in algebraic number theory as a whole, or is it more of some aspects are better with Sage and others with Mathematica? Any one done a writeup comparing the strengths of Sage w.r.t Mathematica/Maple/etc? (In detail, not just big picture).
- enriquto 6y agoThere was a "mock" mathematica a few years ago called "mathomatica" which was the mathematica language implemented in common lisp (if I recall correctly). It was a pleasure to use and a drop-in replacement of the language (but not for all the standard library of functions). Unfortunately, they god bullied to death and its trace is almost gone. The author just wanted to prove a point "you are so damn crazy by that silly language that anybody can re-implement in a few hundred lines of lisp", and once his point was proven he did not want to pursue it any further. And here we are. EDIT: got some names wrong, here's a possible starting point for this rabbit hole https://def.fe.up.pt/pipermail/maxima-discuss/2009/029211.html https://def.fe.up.pt/pipermail/maxima-discuss/2009/029211.ht...
- abdullahkhalids 6y agoI used Mathematica a lot during my PhD. Now, using Sage and I am disconcerted by it. The great things about the Wolfram Language is that it is functional, which is a very nice way to think about maths, and how I am now used to. Sage is not functional. You create mathematical objects and those objects have properties that have to extract using Python class functions. My other gripe, more objective than the above, with Sage is the lack of good documentation. The documentation is certainly complete, but it is painful to read. Mathematica documentation is a treat to read. Every function has its own page with plenty of examples to show capabilities, and show relations to other functions. With Sage I constantly have to search the web to how to do things, while in Mathematica, I rarely had to leave the inbuilt help.
- williamstein 6y agoThe programming language of Sage is indeed imperative (Python) rather than functional. Python's approach is much better than Mathematica's for some kinds of mathematics, and much worse for others. This is more generally true of imperative versus functional programming -- each is good for some classes of problems and terrible for others. Regarding examples, currently there are 50,283 functions defined in the Sage library, and 96.8% of these functions have documentation that is illustrated with working tested examples. Also, you can read the source code of 100% of these functions (unlike with Mathematica) in case something isn't clear. Much of the Sage reference manual (find it here: https://doc.sagemath.org/ https://doc.sagemath.org/) is autogenerated from the sagemath library source code; that's why there are 1,287,666 source lines of comments in sage, versus 636,899 lines of non-comment code.
- smabie 6y agoWhat stuff is functional programming bad at? You can just introduce loops and mutation with tail recursion and get all the "benefits" of imperative code.
- carlob 6y agoNot OP. First of all I wanna say that Mathematica/Wolfram Language is not just functional and certainly not purely functional. Thus said, I feel trying to be purely functional has its drawbacks whenever you have to keep track of a lot of stuff that requires state: for example if you have to declare that some of your constants are real you end up having to use Assuming or Assumptions a lot and that can get verbose quickly. Setting the $Assumptions global makes for terser code. If you wanna dig more into the differences of the two approaches in the same language you can look at the xAct package vs. the built-in symbolic tensors: xAct has many more features but feels less idiomatic, because you have to set they type of your symbols beforehand and expressions are not really self-contained.
- xvilka 6y agoI hope these systems will be more modern in terms of tooling. For example, having the LSP server[1] will help a lot for those who don't want to leave their favorite editor. Or a better Unicode support[2]. [1] https://savannah.gnu.org/bugs/?57106 https://savannah.gnu.org/bugs/?57106 [2] https://savannah.gnu.org/bugs/?57103 https://savannah.gnu.org/bugs/?57103
- BeetleB 6y agoSagemath is probably the best you'll get in the free software ecosystem. I don't think anything comes close. Yes, better tooling would be nice. But I think better math support would be better. I encourage everyone to read William Stein's posts on the challenges they face on that front (incredibly hard to get funding, etc). Their resources are very limited, and they have to prioritize heavily.
- williamstein 6y agoRegarding LSP support, SageMath is a Python library and Python has LSP support, as does JupyterLab...
- fipar 6y agoOn emacs, sagemath can be used on babel blocks in org mode, and it can keep a sage session open for all such blocks, updates result blocks when executing, etc. Since with babel you can do this with multiple languages, this means you can create multi-language documents (that are like notebooks, minus the collaborating part) that include sage blocks.
- st1ck 6y agoWould anyone suggest a way to make use of Sage for non-mathematical work? Is it better for plotting things, compared to plain matplotlib for example? I once used Sympy to parse formulas written in infix notation and convert them to S-expressions. But that's just less than 1% of what Sympy can do. I'd like to find more uses for it.
- boothby 6y agoPlotting is a killer feature of Sage, IMO. It's a wrapper over matplotlib, and eliminates reams of boilerplate. In my experience, it's not just easier to use, but also easier to navigate the Sage docs than figure out the right way to do something in matplotlib. I'm a weensy bit biased; I probably took part in conversations around the plotting interface as it was taking shape, and got familiar with that before learning matplotlib in earnest.
- williamstein 6y ago> It's a wrapper over matplotlib, and eliminates reams of boilerplate. What happened is that in 2006 I hired Alex Clemesha to implement a "Mathematica-like API on top of matplotlib for Sage", and he spent a year doing so. Then Robert Bradshaw (lead dev of Cython) and Carl Witty wrote some really sophisticated just in time compiler code to make it more efficient to evaluate symbolic expression at many floating point values, which helps in plotting (especially for 3d plots). Over many years after that other people filled in little missing pieces of functionality and exposed more of Matplotlib's functionality, and also just added a bunch of new functionality (e.g., for drawing gridlines, 3d implicit plots, etc.) that wasn't available in the Python ecosystem. And that's Sage's plotting functionality...
- jwilber 6y agoNever used sage but William Stein is a dope skater and I’m always very stoked to have other skateboarders involved in tech.
- noobermin 6y agoI used Sage years ago. Since I've felt that jupyter and such have taken its place. Does sage have a place outside of use for mathematicians? I'm a physicist, and the most I'd need a CAS for is essentially mathematica's "Simplify". DESolve is great too but back then (2010 or so) Sage's diffeq solvers felt limited.
- ktm5j 6y agoI remember way back when this project was getting started (around 2005), I hosted a public use Sage instance that was linked to on their website! I was in high school at the time