[HN Gopher] SageMath - Open-Source Mathematical Software System
       ___________________________________________________________________
        
       SageMath - Open-Source Mathematical Software System
        
       Author : gnramires
       Score  : 210 points
       Date   : 2020-06-13 17:48 UTC (5 hours ago)
        
 (HTM) web link (www.sagemath.org)
 (TXT) w3m dump (www.sagemath.org)
        
       | 29athrowaway wrote:
       | If you are interested in trying sagemath, read the PREP
       | tutorials.
       | 
       | 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.
        
       | esrh wrote:
       | How good is it for machine learning? I'm currently using julia
       | which I also really enjoy.
        
         | yza wrote:
         | Sage 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.
        
       | [deleted]
        
       | vsskanth wrote:
       | I 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
        
       | shuringai wrote:
       | why is the existence of sagemath have any news relevance on HN?
        
       | fish45 wrote:
       | I 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]
        
       | amir734jj wrote:
       | I 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 wrote:
         | Using 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 wrote:
           | Sagemath already switched to python3 a while ago.
        
           | nenadst wrote:
           | fyi from the website :
           | 
           | Since version 9.0 released in January 2020, SageMath is using
           | Python 3.
        
       | gnramires wrote:
       | "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."
        
       | Yushi212 wrote:
       | v.vhackservice @ gmail . com for any of your hack service. GET
       | ACCESS TO YOUR SPOUSE DEVICE AND SPY ON THEM CONVO.
        
       | grizzles wrote:
       | Is there an easy way to embed a sage notebook viewer / editor
       | inside a webpage without installing a sagecell server?
        
         | williamstein wrote:
         | You 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 wrote:
           | It 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 wrote:
             | I 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.
        
       | mathgeek wrote:
       | Previous discussions for perusal:
       | 
       | https://news.ycombinator.com/item?id=266040 (2008)
       | 
       | https://news.ycombinator.com/item?id=17995031 (2018)
        
         | dang wrote:
         | See also:
         | 
         | 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 - "Computational
         | Mathematics with SageMath" - 2019
         | 
         | https://news.ycombinator.com/item?id=11883987 - "The Origins of
         | SageMath" - 2016
         | 
         | 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 - "The Simons
         | Foundation and Open Source Software" - 2015
         | 
         | https://news.ycombinator.com/item?id=10147401 - "React, Flux,
         | RethinkDB and SageMathCloud - Summer 2015 Update" - 2015
         | 
         | 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 - "Conception,
         | birth and developement of a Free math software (Sage)" -
         | ditto...
         | 
         | 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 wrote:
       | Saved 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.
        
       | heavyset_go wrote:
       | I 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.
        
       | bollu wrote:
       | I'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...
       | 
       | 2. Commutators of subgroups: http://bollu.github.io/#5age-code-
       | to-play-around-with-commut...
       | 
       | 3. Graph/group theory:
       | https://github.com/bollu/bollu.github.io/blob/2f88c28efc54fb...
        
         | Alkhwarizmi wrote:
         | I LOVE your blog man! Keep it up
        
         | abdullahkhalids wrote:
         | Completely off topic question. Can Grobner basis techniques be
         | used to solve a set of quadratic inequalities?
        
           | enriquto wrote:
           | > Can Grobner basis techniques be used to solve a set of
           | quadratic inequalities?
           | 
           | One application of Grobner bases is to solve systems of
           | polynomial equations [0], and characterize their solutions.
           | In many circumstances it is not however the best method, for
           | example if you are content with a numerical solution you can
           | use other techniques.
           | 
           | Notice that this concerns equations, not inequalities. After
           | a cursory search, I cannot find any "big" reference for
           | solving polynomial inequalities using Grobner bases. There is
           | this [1], still, not sure how serious it is.
           | 
           | [0] https://en.wikipedia.org/wiki/Gr%C3%B6bner_basis#Solution
           | s_o...
           | 
           | [1] https://arxiv.org/abs/1603.01183
        
           | thechao wrote:
           | Not ... really? I usually compare the Grobner 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.
        
           | generationP wrote:
           | Grobner bases appear in the standard reference on real
           | algebraic geometry ( 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.)
        
       | skeeks wrote:
       | We used SageMath in cryptography lessons at university. Very
       | useful stuff and easy to get!
        
       | lvh wrote:
       | Sage 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
       | 
       | [set8]: https://cryptopals.com/sets/8
        
       | amw-zero wrote:
       | How does it compare to Mathematica?
        
       | chaoxu wrote:
       | I'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 wrote:
       | As 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".
        
         | watwatinthewat wrote:
         | Graduate educational background in math here and working in
         | software engineering and machine learning. Like your coworker
         | said, I do my work in Python and libraries like
         | Sympy/pandas/numpy, not Sage. Sage never made more sense than
         | Python since Python covers everything I need to do, including
         | what Sage does that I need.
         | 
         | I've never met anyone who uses Sage and work at large research
         | center. If your college background is math, you used Matlab in
         | school. If your background is in computer science, you go with
         | Python or another programming language. Sage seems like the
         | middle ground between those two, but who is that?
         | 
         | The cases posted here seem to be like yours where there is
         | occasional need for workers or students whose employer or
         | school doesn't or won't supply a Matlab license. Matlab is in
         | most college math departments and offers keys directly to
         | students for like $50-100, so there are few of those cases. An
         | employer with math researchers isn't going blink at the $2k for
         | a perpetual license, so anyone doing the work regularly gets
         | Matlab who wants it.
         | 
         | I do think Sage is good software and it is important to have a
         | free alternative to Matlab. The audience is pretty limited,
         | though.
        
           | boothby wrote:
           | > An employer with math researchers isn't going blink at the
           | $2k for a perpetual license, so anyone doing the work
           | regularly gets Matlab who wants it.
           | 
           | Not all employers can splash for matlab. You might be right
           | about a simple license, but in my experience most matlab
           | developers rely on toolkits which ratchet that price up
           | through the roof.
           | 
           | For one example, somebody I worked with rewrote the parfor
           | functionality as a c extension, because we couldn't justify
           | the expense of that addon for every seat. Not a _great_ use
           | of that math researcher 's time, but it got the job done, I
           | guess.
           | 
           | I and a couple others at my company showed that Python /
           | Cython could be meet and beat matlab's performance, and we
           | built up an open source stack that our customers love and
           | contribute to -- good luck doing that with matlab.
           | 
           | Our physicists found that the only feature they needed of
           | matlab was its plotting functionality -- so they rewrote that
           | in their native lisp and moved on with their lives.
           | 
           | Today, we only need a few seats for some researchers with
           | seniority. I can't say how much we're saving, obviously, but
           | we eliminated a significant cost in two departments' budgets
           | and our finance folks are quite pleased.
           | 
           | My regret in this is that I used to be a Sage developer, but
           | I've only got so much sway at the company and GPL'd code is a
           | no-go.
        
           | williamstein wrote:
           | Sage is primarily written and developed to support pure
           | mathematics research, and you're describing applied/numerical
           | mathematics. They are completely different things. Look at
           | the chapters and sections in the Sage reference manual to
           | begin to get a sense of what Sage is about:
           | https://doc.sagemath.org/html/en/reference/index.html Sage
           | has basically no overlap at all with Matlab in terms of new
           | interesting code, but does have around a million lines of new
           | code written by over 600 people:
           | https://trac.sagemath.org/#AccountNamesMappedtoRealNames That
           | code is mostly about the world of pure mathematics research,
           | which has almost nothing to do with Matlab.
        
             | watwatinthewat wrote:
             | My background is pure math; sorry if that wasn't clear.
             | Even in that environment I have not seen someone use Sage
             | over Matlab.
        
               | sdenton4 wrote:
               | In my experience, the math community is a very lumpy
               | peanut butter... People use matlab, mathematica or sage
               | depending largely on what was easily available and usable
               | when they were in grad school, and or what their
               | colleagues and collaborators were using. So some areas
               | end up with lots of Matlab plugins, and other freedom-
               | loving folks work in sage, slowly winning others to the
               | cause with the promise of open source.
        
               | williamstein wrote:
               | - The total available functionality of Matlab is
               | __dramatically __different than that of SageMath. It 's
               | apples to oranges. I've never once even heard of a single
               | research in arithmetic geometry (my area) using Matlab
               | for research. For example, look at the top google hit for
               | matlab and "elliptic curve": https://www.mathworks.com/ma
               | tlabcentral/answers/282367-may-i... Compare that with
               | what you find for Sage: https://doc.sagemath.org/html/en/
               | constructions/elliptic_curv...
               | 
               | - Research mathematicians often use Sage not just because
               | they are "freedom-loving folks", but because their
               | research fundamentally demands that they can see, modify
               | and extend the source code of the software they are using
               | to do computations, and in many cases this simply isn't
               | possible with commercial options.
        
           | krastanov wrote:
           | I very strongly disagree with your suggestion. Matlab is
           | mostly for numerical work (e.g. what NumPy/SciPy/R/Octave are
           | usually used for). Almost universally, this is __not
           | __research mathematics (although it is certainly useful for
           | many cutting edge engineering research topics and plenty of
           | applied math work).
           | 
           | Sage can deal with these tasks as well as Matlab, simply by
           | virtue of having interfaces to NumPy/SciPy/Octave/others, but
           | this is not where Sage shines. Sage is indispensable for
           | research math (some examples I understand: group theory,
           | cryptography, abstract algebras; but there are many others
           | that are far beyond my level of math education).
           | 
           | In short, I think you are misrepresenting or missing who Sage
           | is really useful for. Matlab simply does not have these
           | features. The competitors would be Mathematica/Maple/Magma.
        
             | nxpnsv wrote:
             | Applied math can still be research and often is.
        
               | krastanov wrote:
               | You are right. Bad phrasing on my part. Research applied
               | math and research "pure" math even overlap, and the
               | distinction is fuzzy. I do try to distinguish them from
               | engineering research.
        
         | krastanov wrote:
         | Be 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 wrote:
           | Do you know how to install the library in a Python
           | environment?
        
             | williamstein wrote:
             | In one sense, what you want is possible but not currently
             | supported, though people are working on it
             | (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.
        
       ___________________________________________________________________
       (page generated 2020-06-13 23:00 UTC)