-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Equations SymPEP #1
base: main
Are you sure you want to change the base?
Conversation
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.
Suggested behavior for diff(eqn)
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.
Questions thoughts on Integral/integrate
.
I appreciate the initiative here. However, I plan to start a SymPEP 1 that outlines what SymPEPs are and what they should look like, including a template. So that work should be completed before any actual SymPEPs are done. |
Should we close this pull request and reopen it later? |
Based on some of the discussion that has happened on the mailing list, perhaps we should reduce the scope of this to only those things that have been uncontroversial. For example, the behavior of diff() has been controversial, as has the behavior of |
I believe that the way
This all occurs before the object |
I think that my comments had been spread over many places and quite misinterpreted a lot
Unlike you have stated in sympy/sympy#21325 (comment)
In my experience, I don't think that applying |
I am not sure what kinds of problems you are envisioning or have encountered. Can you provide some specific examples? In 18 months of testing the implementation I have devised with students, I have encountered only the issue above with sqrt, which I believe has to do with calls to |
I think that your need more clear statements about the expected users and their proficiency. In this point of view, you may also want to state clear in proposal that this tool shouldn't become some complicated syntactical manipulation or theorem prover in the future, even if they are more sophisticated, and this should stay as a stable beginner tool. |
Actually, I expect this to be very useful even for people who are adept at coding. I use the proposed features almost daily. Although not a professional programmer, I have been writing computer code since 1976. I have programmed in assembly, direct binary, multiple flavors of Fortran, Basic, C, Pascal, Forth, Perl, shell-scripting, DOS batch file commands, java, java-script, Mathematica, Maple, Python, and a number of scripting languages specific to particular data-analysis software. Thus, I am quite comfortable writing code when necessary. However, I do not wish to spend anymore time than necessary getting a computer to do things for me. Thus, in this case, I prefer to use the succinct and familiar notation used for math on paper whenever possible. Although the computer can often do the algebra faster than I can, it is not useful to me if it takes me so long to tell it what to do that I can nearly complete the task manually in the same amount of time. Imagine if it took 1 minute to input numbers into your calculator to multiply 1358.9 X 547. If that were the case, it would be a waste to use the calculator rather than do the math by hand. The other place I find these features handy is when I want to quickly produce typeset versions of the steps in a manipulation. With this tool SymPy converts the relatively easily typed
I think you are beginning to understand the motivation behind this proposal. However, you read too much into it. I actually think the addition of syntactically complicated programmer extensions are a useful idea. I just do not think the programming extensions should prevent the use of math-on-paper syntax. Programming extensions should be an alternative that can provide access to more powerful tools. Below is the Motivation section extracted from the SymPEP, I am trying to be clear that this is intended as an on-ramp for new sympy users and a convenience for those of us who routinely manipulate equations where both sides are messy expressions. If that is not clear please point out where you believe further clarification would help. Motivation and ScopeThe original impetus for development of the There are a number of specific motivations for the development of the
|
As I recall, one of my arguments about designing multiplication and division for equation was from the future design of inequality classes. I originally thought that multiplication or division for equation could branch like inequality (to appear) depending on zero assumption ( But if you don't want to branch multiplication or division for equality, then this should automatically lead to a design for inequality (to appear) that multiplication and division should only branch with either strictly positive or strictly negative cases. ( I'm not sure if you had thought in this direction, but this was one of the clue I could support my arguments about multiplication and division previously. |
Obvious and expected. Thus, if the sign of the divisor is unknown the appropriate response is to return a set of two relations, one valid for each sign of the divisor. This is equivalent to the solution set returned by
It is unclear to me how you propose to include branching directly in equations. We already have piecewise expressions and sets of solutions as the way sympy handles branching. I may be misunderstanding you, but you appear to want equations to include branching sets of equations. Why do we need the equation type to include branching sets of equations? Isn't it more flexible and code efficient to keep them as sets of equations, where an equation is defined as a single relation of the form Can you provide a specific example demonstrating what you mean and how it would be superior to using sets of equations? If you are unclear what I mean by sets of equations, look at the sets of solutions returned by |
No. If the sign of symbol |
@JSS95 Thank you that clearly explains what the intent is. I like the idea of not evaluating unless requested for relations. That solves a lot of the branching issues. Additionally, that is completely compatible with the proposed equation class and your suggestion that when relations are included A related question: Have you thought about how to implement something like I have not got time right now, but will try to update the language in the proposal to include this soon. If you have specific suggestions please use the code comments feature on this pull request to suggest them. I really believe that equations and relations do belong together, but would like to get the simpler |
I strongly disagree that Here is how I think
|
A couple of thoughts/questions: Why wouldn't There seems to be something weird with the proposed interaction of inequalities and assumptions. Of course, To me, the core of this idea is some sort of |
The design that has been made so far is that boolean relational and symbolic relational should be strictly discerned. Mathematically, we cannot do numeric field operations |
This makes me more convinced that the relation operator should be an entity on its own that one is able to do arithmetic with and doesn't have a lhs or rhs. Then a Of course, there could (and should?) be syntactic sugar for common cases like an equality. I know sympy has a |
@siefkenj in #1 (comment) are you suggesting that we should not make an effort to combine the proposed |
I don't quite know what you're asking, but my proposal is that a Then, there would be a separate class (I don't know a good name for it...) The benefits of this proposal is that only one new mathematical object would be added (the Or, let me state it a different way: the current proposal combines a mathematical proposal with a UI proposal. I think these should be separated. |
@siefkenj In PR sympy/sympy#21325, |
That is different. And now that I have thought about it now, I have some new proposals for consistent vocabulary.
What is currently called I think |
I am not sure how you have a UI without the binary operations and application of sympy functions on both sides of the equation. There are certainly some operations (e.g. The key question we have to decide is what is the minimal functionality that is a valuable improvement to sympy? I propose the minimum is the functioning on-paper-like manipulations of expressions with the form The more difficult general relations can be hooked into this as they are developed. See PR sympy/sympy#21333, for an implementation that does not require making immediate decisions about how the relationals work, but would give us the basic behavior for I feel we are delaying useful functionality, because we have not settled on all the possible extensions. IMHO this is silly, because those extensions can be added relatively simply when they are settled. |
Why this SymPEP uses the name
|
When would you differentiate only one side of an equation?
It's important to have the proper abstraction. There are lots of places in sympy (for example, the geometry module and the matrix module) where operations were added whose conventions conflict with other modules and it's very hard to modify them while staying compatible. (Isn't that why there's a PEP procedure now, so things can get thoroughly discussed?)
I agree. Documentation is key! |
I don't think you should, but the current implementation of differentiation in sympy (and other math tools such as Sagemath) makes it not work well. The problem is that I am fiddling with ideas for adding the concept of an |
|
@siefkenj What is the benefit from having |
For only
would behave basically like Now that I think about it...why isn't this proposal just a wrapper around |
Why would we want cheap-and-dirty implementation of equation when we can define it in clean and robust way?
|
I think you may want to take a look at
|
1. Currently cycling between expressions and the results of the `solve` operation is quite | ||
messy. This proposal includes extending the `solve` operation so that if passed an equation | ||
or set of equations it would return the solutions as a set of equations. | ||
1. `.subs()` could also be made more natural to use if it could take a list of equations. |
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.
This should not be confused with xreplace
to be changed to unpack equation objects.
I think that for xreplace
, the only xreplace
to be allowed with equation is substituting the whole equation object with any other specified target, if equation matches some of the subtree.
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.
At this point I was only envisioning that .subs(Eqn(a,b))
would be equivalent to .subs({a:b})
. A wholesale update to .subs()
should probably be a separate SymPEP or at least issue. Getting even more generic syntax such as .subs(a=b)
being equivalent to .subs({a:b})
will require more involved workarounds (preparsing?) as Sagemath uses. That is definitely beyond the scope of this proposal.
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.
It is possible to make Eqn recognized as some rule table (like how sympy's own Tuple or Dict are recognized as rule. But at least I'm sure that they shoul)
For making subs(a=b)
work, I think that we can lookup for unknown keyword argument passed to **kwargs
by kwargs.items
, but the possible problem is conflicting with the options for subs
, If the symbol is named like simulatneous
.
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.
For making s
ubs(a=b)
work, I think that we can lookup for unknown keyword argument passed to**kwargs
bykwargs.items
, but the possible problem is conflicting with the options for subs, If the symbol is named likesimulatneous
.
This is why I think .subs(a=b)
would need more sophisticated preparsing to make it work.
Although @siefkenj's ideas look interesting, I'm not sure there are known algorithms to implement such abstractions. I think the part to vectorize could be easy to implement, but the idea of having operation like On the contrary, I think that we should use some mathematical formalism for algebra over equations to make people converge on the idea about how |
I am not sure why there can't be a "let me shoot myself in the foot" functionality that doesn't impose mathematical rigor on what is written. Can we just think of the Eqn class as a type-setting class? If I want to change |
No description provided.