SageMath – Open-Source Mathematical Software System
sagemath.org
sagemath.org
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.
[efd]: https://www.hyperelliptic.org/EFD/g1p/auto-shortw.html
[set8]: https://cryptopals.com/sets/8
Curve25519 and its sister curve Ed25519 are really good at what they were designed for. Unfortunately people also use them for things that they're not good at, and then you get bugs like the Monero double spend. Montgomery curves necessarily don't have cofactor 1 -- so that's an example of a bug that could only have occurred on X25519.
Something seems a bit weird about that to me, because when I used it ~8 years ago Sage was great and none of the features I care about changed.
Do can I get a meta-comment on why Sage might struggle to get packaged for Debian in the way that, eg, Octave/maxima/R/etc do?
In sage 5.x the source code was quite small compared to today and could be patched with some effort. Today the project is huge and this would be impossible for one person to do.
It's vastly easier to just install sage using their own scripts from source and have some libraries duplicated. The sage source code build script is one of the simplest to use.
The problem is that sage actually depends on Octave, Maxima, R and many other packages. It parses binary output of many dependencies and often needs the exact version it expects because of that. It also has relatively brittle doctests testing everything an as a result often breaking on minor changes in dependencies.
If you have too much time, there is a very lengthy discussion on this on sage-packaging: https://groups.google.com/forum/#!topic/sage-packaging/ZJmJZ...
It attacks a hard, hard problem and I’m super happy that it will eventually replace Mathematica so that anyone who wishes can see how the black box works.
I think sage should advertise more that it can be viewed as a big library + modified but compatible python 2, i.e. all your weird file parsers just work. I am looking forward a lot to finally get python 3 compatibility, for that reason (write as much of my code as possibly to run on cpython as well, not just sage-python; possibility of using stuff where only python 3 bindings exist).
Thank you.
I have almost completely finished a visualization block coding system which sits on top of Numpy, Scipy, and Sage designed to help kids who are learning math on youtube, to be able to create "problem set" style save files which can be shared to supplement math education videos, and to create animations for my upcoming youtube channel for math education. It also has a fully functional debugger and console, its like web inspector but for math, so I have named it Math Inspector.
I think it's really exciting what is happening in the world of math education and the way that the medium of video is being used for the first time to communicate the joy of mathematics to the world, especially to young people. It's revolutionary. My goal has been to create a tool which enables people to be able to interact with Sage without needing to even know python at all. I wish you the best!
I'm doing some research on ed-tech tools and helping students learn by creating and experimenting! I'd love to check out your tool and talk to you about it, but I see no way to contact you! Could you add a email or Twitter handle to your profile, or you could contact me, my details are on my HN user page.
I prefer to only correspond with serious mathematicians, and for fun recently I have been using Sage to work through Mochizuki's paper on Inter-universal Teichmüller theory, I got a little stuck on this passage, if you can explain it to me I will tell you more about my project:
"In the first three papers of the series, we introduced and studied the theory surrounding the log-theta-lattice, a highly non-commutative two-dimensional diagram of “miniature models of conventional scheme theory”, called Θ±ell NF-Hodge theaters, that were associated, in the first paper of the series, to certain data, called initial Θ-data. This data includes an elliptic curve EF over a number field F , together with a prime number l ≥ 5. Consideration of various properties of the log-theta-lattice led naturally to the establishment, in the third paper of the series, of multiradial algorithms for constructing “splitting monoids of LGP-monoids”.
Just Kidding!!!!! I sent you an email =) Thanks so much for your interest in this project, looking forward to hearing more about what you are working on as well. Cheers!
These days I'm a computational scientist, so I end up using numeric tools anyway (numpy is my life). That said, it'd be great to have access to an open source symbolic tool for the times I need them. How has Sage improved for engineer/science types in the last few years?
Mathematica is optimized for giving you results you need in undergrad classes. Sage is not optimized at all, but can solve problems useful to researchers.
It's the difference between osx and linux.
What makes you think this? Mathematica is used in all sorts research projects, technical fields, finance, and so on. I've seen Mathematica required or recommended in many, many job listings, especially for quants. I've never seen Sage there.
For evidence, here [1] is what you get for searching for Mathematica on Indeed.com. Note pretty much every one of those jobs lists several math related packages. Not one mentions Sage.
Unfortunately you cannot run the same search on Sage, since there is an ERP package that shows up instead. However, from browsing those listing again I find zero hits for the math package Sage.
I'd suggest that Sage is likely less good for those uses since Sage is good at the kinds of things you're likely to find academics use Sage for (e.g. tons of discrete math and most things cryptography). Secondly, since there's very little pressure for high-end uses of commercial packages to worry about the licensing cost of a mathematics package like JMP or Mathematica.
Most math quants use is at the undergrad level, the finance industry in general is pretty backwards. A very large chunk of it is run on spreadsheets that are passed around in emails. I've worked in it and having seem what it takes to run some of the clients spreadsheets still gives me nightmares.
Again, the difference between osx and linux.
---
To clarify what I mean by undergrad level: Something that is taught to some undergrads in some degree.
Someone who specialized in pure symbolic mathematics is likely to see integrals in their last year that other people will not see until they start doing postdoc work.
Do you have any idea what a quant is? I have a PhD in math, and am decently well versed in the math quants use, and it's nothing like undergrad math. Many of the people I got PhD's with became quants, and we've had plenty of discussions on the math they use.
Quants build models using math far beyond what an undergrad learns, including tools such as martingales, stochastic calculus, Black-Scholes (and vast generalizations), Brownian motion, Stochastic differential Equations, numerical methods (usually much more advanced than an undergrad will see), and more.
Quant jobs usually want a PhD in math or related field. If an undergrad math degree covered what they needed they'd not require a PhD for most positions.
What do you think a quant does?
Here's a site [1] for quant jobs. Probably none for someone with only an undergrad math degree.
1). The domain you posted is for sale and appears to be broken or slow. Given it uses aspx and a Microsoft stack that's ten years out of date I'd say it's perfectly representative of the state of the larger finance industry.
2). What is a quant. Depends on the job. I was hired as a quant for risk management then got switched to algos when the pm found out I have a lot of hard real time experience with Linux. The first job was all discrete math, the second was optimizing x86 assembly.
3). Credential inflation is real. The application of the maths you talked about was something I saw first hand. The assumptions under which the formal models would work were so thread bare a stiff breeze would tear them down quote Keynes:
>The object of our analysis is, not to provide a machine, or method of blind manipulation, which will furnish an infallible answer, but to provide ourselves with an organised and orderly method of thinking out particular problems; and, after we have reached a provisional conclusion by isolating the complicating factors one by one, we then have to go back on ourselves and allow, as well as we can, for the probable interactions of the factors amongst themselves. This is the nature of economic thinking. Any other way of applying our formal principles of thought (without which, however, we shall be lost in the wood) will lead us into error. It is a great fault of symbolic pseudo-mathematical methods of formalising a system of economic analysis, such as we shall set down in section vi of this chapter, that they expressly assume strict independence between the factors involved and lose all their cogency and authority if this hypothesis is disallowed; whereas, in ordinary discourse, where we are not blindly manipulating but know all the time what we are doing and what the words mean, we can keep 'at the back of our heads' the necessary reserves and qualifications and the adjustments which we shall have to make later on, in a way in which we cannot keep complicated partial differentials 'at the back' of several pages of algebra which assume that they all vanish. Too large a proportion of recent 'mathematical' economics are merely concoctions, as imprecise as the initial assumptions they rest on, which allow the author to lose sight of the complexities and interdependencies of the real world in a maze of pretentious and unhelpful symbols.
The above is still excellent advice, most often never followed. Of course the lunch talks we had were very interesting, completely divorced from reality, but very interesting.
4). Most undergrads will never see the mathematics. True. But some will. My numerical methods 4th year project was a symplectic integrator for the gravitational interaction between Jupiter, Mars, the Sun and the asteroid belt. It wasn't new research, the results were known 50 years ago, but it was on par with the state of the art in industry in terms of complexity of implementation (cleanness of implementation was a completely different thing, while not spaghetti code it's rightly never seen the light of day).
2) >The first job was all discrete math, the second was optimizing x86 assembly.
I suspect you didn't have the math so ended up pushed to the programming side, right? If so, how can you judge what math a quant uses?
3) >Credential inflation is real.
Job requirements are real too. Keynes was not a quant, and his quote is irrelevant compared to simply addressing the point. If you're simply going to start quoting random people instead of addressing he issue then we'll be here forever.
4). > Most undergrads will never see the mathematics. True.
Didn't you just write "Most math quants use is at the undergrad level"? If it's undergrad level math, won't most undergrads see it? If most won't see it, perhaps it's taught more often in graduate level courses (which it is).
Just curious - since you worked as a quant, can you explain in your own words the importance and mechanism of Black-Scholes? And if that's too easy, how about explaining more recent generalizations?
The compensation was 30% higher.
You're arguing in bad faith here so I'm done.
Then you weren't what most places call a quant. You were a programmer at a financial company with a toe in finance.
Did you use the math tools above or not? If you didn't how are you able to judge their efficacy?
>You're arguing in bad faith here so I'm done.
Convenient considering above you routinely did not address your claims, reversed positions, and discounted jobs on a quant site because the tech stack was aspx.
I figured your position may have been borne from not knowing the other side and from career sour grapes.
Quant jobs are making models of markets (or other financial items), using the best math and tools available. For practical performance these models need implemented, so you'll program. Developing these models is often done in math packages like Mathematica, then once nicely tested, ported to high performance code in C/C++/asm or sometimes even into FPGAs or ASICs.
Quant job are a mix between math and programming. The better you are at both, the more valuable you become. If you're really strong at one compared to the other, you'll drift that way. If you are terrible at either, you'll not get hired.
These are all practically the same thing, i.e. the single field of stochastic processes. The "meat" of stochastic processes is the underlying topology, measure theory and probability upon which it's built, all of which an undergrad learns (e.g. I'd expect a good undergrad to be able to follow and understand the proof of Ito's lemma, and the proof of Ito's lemma is way more mathematically interesting and involved than that of Black-Scholes).
It also probably depends on whether the firm in question is HFT or not, and whether it trades options. It'd be perfectly possible to be a quant pricing futures at a HFT without even understanding stochastic calculus, as most of the logic ends up boiling down to just some variant of "oh shit, would you look at the size of that trade tick, better giddy up and follow it!".
You absolutely don't need a PhD to learn those things. Black-Scholes and Brownian motion was covered in my undergrad courses and the rest of the topics you mentioned where covered in my Masters degree. Certainly most of the quants I know in Europe only have a masters degree.
True. You can learn anything without a PhD. A PhD requirement reduces the cost to hire qualified people. Instead of having to pay to interview 1000 people to get 5 you can interview 20.
Companies recruit PhDs because they have amassed many techniques, and have modelling skills on average that are better than non-PhDs.
There's also quite a difference between seeing these topics in class, having been exposed to them, and being able to wield them at a fundamental level. This difference is also increased by having the rigor of a PhD program teach far more skills than a masters or undergrad teaches.
A good example is the Fourier transform. Many people have seen it and have a rough idea what it is. Very few of them truly understand it at a basic level and all it can do, it's generalizations, etc.
>covered in my Masters degree.
Bingo. The claim I was refuting above was that these things are rarely taught to undergrads.
Having a degree does diddly-squat to the requirement to interview. It can even (famously) be counter-productive. The only good indicator of what somebody knows, is to ask them to demonstrate facility.
That's true. But not making the pool as concentrated as possible before asking them is a waste of limited resources.
Candidates cost money. When resources are limited, such as money to fly candidates out, time spent screening instead of building, time for senior people to work on interviews instead of getting billable work done, time to get a project done, then it is very valuable to winnow the search to places where there is a higher chance of finding a candidate.
So, one doesn't interview people randomly sampled from the entire populace for a reason. Sure you will get the best candidate, eventually, but the cost to do so is silly. Finding predictors that make your search smaller is extremely valuable.
Thus many jobs have educational requirements. Having hired probably 100ish people in my career, (as well as many friends of mine who have hired similarly), I can without a doubt tell you that demonstrated academic aptitude is a good predictor of overall candidate quality for these types of jobs.
>Having a degree does diddly-squat to the requirement to interview.
So you would claim for jobs using advanced math there is zero difference in mean skill among those with only a 6th grade education and those with a PhD?
How so? Do you think for some jobs without requiring a PhD they'd find the candidate they want without having to interview more people?
>I'd take evidence of working successfully with math, regardless of degree.
A PhD in math, especially from a good school, most certainly gives evidence of working successfully with math. It's easier to fake resume experience than to get a PhD, something that I've found quite common when interviewing people. And it's trivial to check someone actually got PhD - I've yet to find a candidate lie about that part.
I've probably interviewed a ~100 people over the years. I've found from experience that anything to reduce the pool quickly saves time and money, and I've still ended up with excellent candidates. Before learning how to weed quickly, I spent far more time and money on people that had very little ability to solve the problems we wanted solved.
Done much hiring?
While everything you say is no doubt true, I've got a a lot of friends who have had no problem getting quant jobs in most major finance centers in Europe despite only having Masters degrees
It's just a pleasure to use. Thank you williamstein!!
If you're a programmer and you've used Mathematica or Maple and you've ever found yourself wishing that you'd have something like that except in a real programming environment, Sage is it. Sage is Python (with some syntactical extensions).
Every time I've tried it though, it just didn't feel as polished and integrated as Mathematica.
Total@Map[Function[{L}, Min @@ Table[dist[func[Array[c[#, k]&, n]]][L], {k, m}]], dd]
is normal and common in Mathematica code. Like with Perl, the culture has started from small scripts making heavy use of shorthands provided by the language, and slowly evolved to writing larger codebases.Some of this can, on an individual level, be fixed by adopting a clearer coding style. But like Perl 5, the language kind of lures you to use the shorthands a lot.
If you define modules, it’s nearly the same as as a scripting language.
I am looking forward to the day I can switch to Sage and return to coding in emacs.
I've found that you can generally do most things you can do with MATLAB in Python, but the experience in MATLAB is buttery smooth while the experience with numerical Python is clunky and obnoxious (whether it be all the useless textual noise in the code itself, the inferior quality of the plotting and visualization capabilities or the fact the Python scientific computing library ecosystem is so disjoint (this thing can handle pandas frames, this other thing needs numpy vectors, this other thing expects Python lists, whatever).
I had high hopes for Julia, I have a test for it. How annoying is it to plot(sin(0:0.01:6*pi)) out of the box? For the extreme challenge question, how annoying is it to also open a new plot window and plot(cos(0:0.01:6:pi)) alongside it. I want to be able to pan around and inspect these complicated functions.
So far, it has not yet passed the qualifiers.
Just use the plot command in Makie.jl? This is a nice first few commands to check the install.
In 1.0, I tried Plots.jl again. I tried adding it using the package manager and it blew up trying to build. This is with no special state from me, I unpacked the 1.0.0 release, started it and did Pkg.add('Plots')... boom.
There's such a great story around it and I really want to like it, but this is like extremely basic suitably to task stuff... Who knows, maybe I'm using it wrong.
I don't use matlab but I don't consider "matlab people" as bad scientists or limited in terms of what they can potentially do due to their tool. The limit of access for matlab due to licensing and expensive external modules such is the problem in my view. That isn't a critique at all of matlab's actual numerical and scientific utility, of course it's apt in that arena otherwise people wouldn't use it.
As far as I'm concerned, this essentially precludes doing anything publishable using Mathematica.
Now there is also SageMathCloud, that makes it even more convenient to adopt.