Comments (4)
We use the Gruntz algorithm for limits, which is not typically how you do the limit by hand. But it would be really cool to show the steps, they are in fact quite easy to follow. That is also good for debugging, in case it produces the wrong answer.
from sympy_gamma.
Here is how to show steps in SymPy:
ondrej@kittiwake:~/repos/sympy(master)$ SYMPY_DEBUG=True ./bin/isympy
IPython console for SymPy 0.7.3 (Python 2.7.3-64-bit) (ground types: python, debugging: on)
These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
Documentation can be found at http://www.sympy.org
In [1]: limit(sin(x)/x, x, 0)
limitinf(x*sin(1/x), x) = 1
+-mrv_leadterm(_p*sin(1/_p), _p) = (1, 0)
| +-mrv(_p*sin(1/_p), _p) = ({_p: _Dummy_14}, {}, _Dummy_14*sin(1/_Dummy_14))
| | +-mrv(_p, _p) = ({_p: _Dummy_14}, {}, _Dummy_14)
| | +-mrv(sin(1/_p), _p) = ({_p: _Dummy_15}, {}, sin(1/_Dummy_15))
| | +-mrv(1/_p, _p) = ({_p: _Dummy_15}, {}, 1/_Dummy_15)
| | +-mrv(_p, _p) = ({_p: _Dummy_15}, {}, _Dummy_15)
| +-rewrite(_Dummy_14*sin(1/_Dummy_14), {exp(_p): _Dummy_14}, {}, _p, _w) = (sin(_w)/_w, -_p)
| | +-sign(_p, _p) = 1
| | +-limitinf(1, _p) = 1
| +-calculate_series(sin(_w)/_w, _w) = 1
| +-limitinf(_w, _w) = oo
| | +-mrv_leadterm(_w, _w) = (1, -1)
| | | +-mrv(_w, _w) = ({_w: _Dummy_17}, {}, _Dummy_17)
| | | +-rewrite(_Dummy_17, {exp(_w): _Dummy_17}, {}, _w, _w) = (1/_w, -_w)
| | | | +-sign(_w, _w) = 1
| | | | +-limitinf(1, _w) = 1
| | | +-calculate_series(1/_w, _w) = 1/_w
| | +-sign(-1, _w) = -1
| | +-sign(1, _w) = 1
| +-limitinf(_w, _w) = oo
| +-limitinf(_w, _w) = oo
| +-limitinf(_w, _w) = oo
+-sign(0, _p) = 0
+-limitinf(1, _p) = 1
Out[1]: 1
It just needs to be rewritten into some nice human readable form, so that it's obvious what it is doing.
Here is another example:
In [4]: limit((2-sqrt(x))/(4-x), x, 4)
limitinf(-x*(-sqrt(4 + 1/x) + 2), x) = 1/4
+-mrv_leadterm(-_p*(-sqrt(4 + 1/_p) + 2), _p) = (1/4, 0)
| +-mrv(-_p*(-sqrt(4 + 1/_p) + 2), _p) = ({_p: _Dummy_66}, {}, -_Dummy_66*(-sqrt(4 + 1/_Dummy_66) + 2))
| | +-mrv(-sqrt(4 + 1/_p) + 2, _p) = ({_p: _Dummy_66}, {}, -sqrt(4 + 1/_Dummy_66) + 2)
| | | +-mrv(-sqrt(4 + 1/_p), _p) = ({_p: _Dummy_66}, {}, -sqrt(4 + 1/_Dummy_66))
| | | +-mrv(sqrt(4 + 1/_p), _p) = ({_p: _Dummy_66}, {}, sqrt(4 + 1/_Dummy_66))
| | | +-mrv(4 + 1/_p, _p) = ({_p: _Dummy_66}, {}, 4 + 1/_Dummy_66)
| | | +-mrv(1/_p, _p) = ({_p: _Dummy_66}, {}, 1/_Dummy_66)
| | | +-mrv(_p, _p) = ({_p: _Dummy_66}, {}, _Dummy_66)
| | +-mrv(_p, _p) = ({_p: _Dummy_67}, {}, _Dummy_67)
| +-rewrite(-_Dummy_66*(-sqrt(4 + 1/_Dummy_66) + 2), {exp(_p): _Dummy_66}, {}, _p, _w) = (-(-sqrt(_w + 4) + 2)/_w, -_p)
| | +-sign(_p, _p) = 1
| | +-limitinf(1, _p) = 1
| +-calculate_series(-(-sqrt(_w + 4) + 2)/_w, _w) = 1/4
| +-limitinf(_w, _w) = oo
| | +-mrv_leadterm(_w, _w) = (1, -1)
| | | +-mrv(_w, _w) = ({_w: _Dummy_69}, {}, _Dummy_69)
| | | +-rewrite(_Dummy_69, {exp(_w): _Dummy_69}, {}, _w, _w) = (1/_w, -_w)
| | | | +-sign(_w, _w) = 1
| | | | +-limitinf(1, _w) = 1
| | | +-calculate_series(1/_w, _w) = 1/_w
| | +-sign(-1, _w) = -1
| | +-sign(1, _w) = 1
| +-limitinf(_w, _w) = oo
| +-limitinf(_w, _w) = oo
| +-limitinf(log(_w**(-2))/log(1/_w), _w) = 2
| | +-mrv_leadterm(log(_w**(-2))/log(1/_w), _w) = (2, 0)
| | | +-mrv(log(_w**(-2))/log(1/_w), _w) = ({_w: _Dummy_71}, {}, log(_Dummy_71**(-2))/log(1/_Dummy_71))
| | | | +-mrv(1/log(1/_w), _w) = ({_w: _Dummy_71}, {}, 1/log(1/_Dummy_71))
| | | | | +-mrv(log(1/_w), _w) = ({_w: _Dummy_71}, {}, log(1/_Dummy_71))
| | | | | +-mrv(1/_w, _w) = ({_w: _Dummy_71}, {}, 1/_Dummy_71)
| | | | | +-mrv(_w, _w) = ({_w: _Dummy_71}, {}, _Dummy_71)
| | | | +-mrv(log(_w**(-2)), _w) = ({_w: _Dummy_72}, {}, log(_Dummy_72**(-2)))
| | | | +-mrv(_w**(-2), _w) = ({_w: _Dummy_72}, {}, _Dummy_72**(-2))
| | | | +-mrv(_w, _w) = ({_w: _Dummy_72}, {}, _Dummy_72)
| | | +-rewrite(log(_Dummy_71**(-2))/log(1/_Dummy_71), {exp(_w): _Dummy_71}, {}, _w, _w) = (log(_w**2)/log(_w), -_w)
| | | | +-sign(_w, _w) = 1
| | | | +-limitinf(1, _w) = 1
| | | +-calculate_series(log(_w**2)/log(_w), _w) = 2
| | +-sign(0, _w) = 0
| | +-limitinf(2, _w) = 2
| +-limitinf(_w, _w) = oo
| +-limitinf(_w**(-2), _w) = 0
| +-mrv_leadterm(_w**(-2), _w) = (1, 2)
| | +-mrv(_w**(-2), _w) = ({_w: _Dummy_74}, {}, _Dummy_74**(-2))
| | | +-mrv(_w, _w) = ({_w: _Dummy_74}, {}, _Dummy_74)
| | +-rewrite(_Dummy_74**(-2), {exp(_w): _Dummy_74}, {}, _w, _w) = (_w**2, -_w)
| | | +-sign(_w, _w) = 1
| | | +-limitinf(1, _w) = 1
| | +-calculate_series(_w**2, _w) = _w**2
| +-sign(2, _w) = 1
+-sign(0, _p) = 0
+-limitinf(1/4, _p) = 1/4
Out[4]: 1/4
from sympy_gamma.
I think something more in line with what he's looking for would be to implement a limit analogue of manualintegrate, which does compute the limit as you would by hand, and keeps track of how it does so that it can show the steps. This requires some thought, though. For instance, if you implement l'Hopital's rule naively, it will either badly fail in some cases (it can repeat forever without ever giving an answer), or, if you limit it, it will not always work. Plus, to work effectively, it often requires various tricks to make sure that you write your expression as a/d in the right way.
That isn't to say it isn't worth trying to implement such a thing. Limits of rational functions would be a good start, as those are the easiest.
from sympy_gamma.
The Gruntz thesis has info at the beginning how to do this manual
heuristics. And examples that fail.
Sent from my mobile phone.
On Nov 27, 2013 2:54 PM, "Aaron Meurer" [email protected] wrote:
I think something more in line with what he's looking for would be to
implement a limit analogue of manualintegrate, which does compute the limit
as you would by hand, and keeps track of how it does so that it can show
the steps. This requires some thought, though. For instance, if you
implement l'Hopital's rule naively, it will either badly fail in some cases
(it can repeat forever without ever giving an answer), or, if you limit it,
it will not always work. Plus, to work effectively, it often requires
various tricks to make sure that you write your expression as a/d in the
right way.That isn't to say it isn't worth trying to implement such a thing. Limits
of rational functions would be a good start, as those are the easiest.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/13#issuecomment-29423389
.
from sympy_gamma.
Related Issues (20)
- Server whitelist issue HOT 1
- Show deployed SymPy version along with Gamma version HOT 1
- Add test coverage
- Add report an issue button/link HOT 3
- PWA support? HOT 3
- error serving on apache vhost reverse proxy
- unsupported operand type(s) for -: 'list' and 'Integer' HOT 3
- Upgrade the GAE runtime to Python 3.8 HOT 1
- Substitution example linked from the SymPy site fails. HOT 14
- Broken datastore client used via ndb
- solveset(sin(x), x) HOT 1
- error: Union of two Ranges in SymPy Gamma
- change apt source difficulty HOT 3
- Extreme Value Analysis for Multivariate Functions
- Plotting of functions of a complex variable
- Introducing SymPy Beta HOT 2
- GSoC Project to rebuild SymPy Gamma using Pyodide HOT 3
- Failure to compute the integral with parameter manual=True HOT 2
- Help with the translation of the comments
- unsupported operand type(s) for *: 'UndefinedFunction' and 'Symbol' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sympy_gamma.