6 ms·
Taming math and physics using SymPy [pdf]
- dergachev 12y agoGood stuff, but maybe it would be nice to do a mini tutorial in the blog post itself. I only like PDFs if I'm going to spend 20m+ reading something.
- ivan_ah 12y agoGood idea. It would make a nice series of blog posts... though I must say the easy-to-print PDF format has some nice things going for it too ;)
- zokier 12y agoI think IPython notebook would be the best format for this.
- lutusp 12y agoComplete agreement -- IPython is a nice, relatively lightweight mathematical environment based on Python. Runs locally in a browser [EDIT: and command line as well]. Easy to use. Free. My IPython tutorial: http://www.arachnoid.com/IPython http://www.arachnoid.com/IPython
- omaranto 12y agoWhy? If you have a browser plugin that can display PDFs they seem as convenient as a webpage to me. Better in some ways: usually layed out better, often faster to navigate and sometimes even smaller to download considering how bloated websites tend to be now, no ads, much better looking if printed.
- lutusp 12y agoIt would have been useful to say that sympy means "symbolic Python" or, more generally, "a symbolic mathematics library". This means one can submit algebraic and differential equations to be solved, and sympy can solve a great number of them. http://docs.sympy.org/dev/modules/solvers/solvers.html http://docs.sympy.org/dev/modules/solvers/solvers.html
- JadeNB 12y ago> It would have been useful to say that sympy means "symbolic Python" or, more generally, "a symbolic mathematics library". This means one can submit algebraic and differential equations to be solved, and sympy can solve a great number of them. I'm not sure I understand this comment; SymPy here is the name of the program (http://sympy.org http://sympy.org), not the author's abbreviation. Surely one need not explain the etymology of the name of a program in order to give a tutorial on it? If, on the other hand, you meant that it is good to learn how to use any sort of symbolic mathematics library, not just SymPy, then that is certainly true—but the author's advice appears to be quite specific to SymPy.
- lutusp 12y ago> SymPy here is the name of the program (http://sympy.org http://sympy.org), not the author's abbreviation. It's not a program, it's the name of a Python library responsible for mathematical functions: http://sympy.org/en/index.html http://sympy.org/en/index.html Quote: "SymPy is a Python library for symbolic mathematics." > Surely one need not explain the etymology of the name of a program in order to give a tutorial on it? It's useful to know what these terms mean. > ... but the author's advice appears to be quite specific to SymPy. Yes, no problem there. SymPy's abilities appear in IPython (http://en.wikipedia.org/wiki/IPython http://en.wikipedia.org/wiki/IPython) and Sage (http://www.sagemath.org/ http://www.sagemath.org/) to some extent also -- I've been involved in these projects for years. My Sage tutorial: http://arachnoid.com/sage http://arachnoid.com/sage My IPython tutorial: http://www.arachnoid.com/IPython http://www.arachnoid.com/IPython My Python tutorial: http://www.arachnoid.com/python http://www.arachnoid.com/python
- 12y ago
- deleted 12y ago[deleted]
- jbarrow 12y agoI've never used SymPy, but after looking through the tutorial, it looks like a nicer symbolic mathematical library than Theano. I know that the libraries have different focuses; Theano is about speed and tensors, while SymPy appears to be about algebra, but I would be interested in seeing if they have similar capabilities.
- krastanov 12y agoThey are different projects with different goals, but some of the sympy team do try to employ sympy's capabilities in order to help theano generate better optimized code.
- bayesianhorse 12y agoSympy can output Theano functions.
- zokier 12y ago> Special care is required when specifying rational numbers, because integer division might not produce the answer you want. In other words, Python will not automatically convert the answer to a floating point number, but instead round the answer to the closest integer Note that this applies only to Python2, Py3k does float-division by default and integer division with // operator: Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 1/7 0 >>> from __future__ import division >>> 1/7 0.14285714285714285 >>> 1//7 0 >>>
- krastanov 12y agoWhich is still not what you want as floating point numbers do not cover all possible rationals. When the input is done correctly sympy can deal with arbitrary rationals as well.
- tjl 12y agoThere's a couple of other things you can do. Since those are Python integers, you can specify a SymPy Integer instead with Integer(1)/7 instead. The other thing you can do is S(1)/7. Both of these should work.
- like_do_i_care 12y agoPython really is taking centre stage these days - glad to see. I still use R sometimes, but my Python usage grows daily. Also nice I can stick a web front end on things via Django or Flask.
- Edmond 12y agoby the way your students might like jasymchat.com, it is a mobile web app for jasymca..not as capable as sympy but ideal for undergrad work...shoot me a message if you have any thoughts.
- graycat 12y agoThe PDF has "Calculus is the study of the properties of functions." Better would be: Calculus is some mathematics for analyzing systems that change continuously, usually over time. The first motivation, by Newton, was to analyze the motion of the planets. Since then, calculus is central in nearly all of of physics, most of engineering, a lot of chemistry, much of the rest of mathematics, and also probability and statistics. Calculus works, first, with real valued functions of a real variable. An example would be the speed of a baseball as a function of time. Later calculus works with real valued functions of several real variables. The first important concept in calculus is 'rate of change' or the 'first derivative' of a function. The second important concept is the integral which in effect 'adds up' changes. Integration can be used both to define and to find areas and volumes, e.g., the volume or the surface area of a sphere. Or if apply a force of 500 pounds to a car weighing 3000 pounds, how much time will the car need to accelerate from 0 to 60 MPH? The fundamental theorem of calculus is that, with mild assumptions, if take the first derivative of a function and integrate that, then get back the original function. Sometimes we have some information about the first derivative of a function and want to find the function; in this way we have a start on the subject differential equations. Some of the elementary parts of differential equations are also in a first course in calculus. Here is a simple differential equation: Suppose t denotes time in days and our revenue per day is y(t). Suppose we know the revenue now, that is, at t = 0. So, we know y(0). Suppose we believe that we will have saturated our market when our revenue reaches b per day. Suppose we believe that the rate of growth of revenue is directly proportional to both the number of our current customers and also the number of our target customers we do not yet have. Calculus denotes the rate of growth as y'(t). Then for some constant k we have y'(t) = k y(t) (b - y(t)) Then with integration in calculus, we can find y(t). What we get, depending on k, is a lazy S curve that rises slowly, then more rapidly, then slowly, and approaches b from below. So, this is an elementary case of differential equations. At one point, this differential equation and its solution kept FedEx from going out of business. Differential equations are important in calculating trajectories of space craft, how to get a fighter jet to 60,000 feet in least time, the analysis of analog circuits in electronic engineering, Maxwell's equations in electricity and magnetism, the differential geometry of general relativity, Newton's second law, the heat equation, the stiffness of beams, etc. Calculus is one of the main pillars of mathematics, science, engineering, technology, and civilization.