-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better docs for Subs. #2649
Better docs for Subs. #2649
Conversation
The substitution is literal replacement of old arguments with new one | ||
and it may not reflect the limiting behaviour of the expression. | ||
|
||
>>> (x**3 - 3*x).subs({x:oo}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after colon. or just subs(x, oo)
?
Also, may be you can include limit result as well? See, for example, a demo for simultaneous=True
.
anyway, +1 |
Move the example down. You've injected it in the middle of a discussion about the difference between subs and xreplace. |
See Also | ||
======== | ||
replace: replacement capable of doing wildcard-like matching, | ||
parsing of match, and conditional replacements | ||
xreplace: exact node replacement in expr tree; also capable of | ||
using matching rules | ||
evalf: evaluate the given formula to a given accuracy of digits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..and note that evalf calculates to a desired level of precision.
On Thu, Dec 5, 2013 at 8:19 AM, Sergey B Kirpichev <notifications@github.com
wrote:
In sympy/core/basic.py:
See Also ======== replace: replacement capable of doing wildcard-like matching, parsing of match, and conditional replacements xreplace: exact node replacement in expr tree; also capable of using matching rules
evalf: evaluate the given formula to a given accuracy of digits
Why this?
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/2649/files#r8129547
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skirpichev I did this because I thought people might try to substitute the variable with a constant to evaluate the expression. My unnecessary pull request [1] was also in some ways a result of confusion between evalf and subs. So I think adding evalf
in the See Also
section might serve as a good pointer.
ok, if there is no objection against, I'll merge this in 24h. @hargup, I think it's good to give a bit more verbose and descriptive commit message. |
- Added examples to resolve confusion regarding the result of subs and the limiting value of the expression at that point - Added examples to clearly show the difference between substitution and numerical evaluation. - Added `evalf` in the `See Also` of `Subs` documentation section.
@skirpichev Thanks, I have updated the commit message and the pull request description. |
evalf
in theSee Also
ofSubs
documentation section.