-
-
Notifications
You must be signed in to change notification settings - Fork 6
Equations SymPEP #1
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
Open
gutow
wants to merge
20
commits into
sympy:main
Choose a base branch
from
gutow:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6f9e187
Create Equations.md
gutow e94a31a
new line for binary operators heading
gutow 0c80c8f
Sections there has been discussion on
gutow ff01f81
Update Applications of methods
gutow c298cc7
remove extra `applyrhs()`
gutow 7c572aa
Minimal suggesttion for integration
gutow baa2436
Try template proposal
gutow 10b27ec
Add linebreaks to header information
gutow 445e012
anchor fixes
gutow 4310893
more anchor fixes
gutow ad0a95d
typo
gutow 59a3233
related work, implementation, discussions, copyright
gutow 0e767a9
Update motivation and scope
gutow f64411f
typo fix
gutow 757ee90
typo fix
gutow 9510c73
add .subs() to implementation section
gutow ec8324e
Delete `int` and `diff`, update links to discussions
gutow 5f82ba4
Update Equations.md
gutow 5cc260a
suggest possible user switches to control form of output
gutow 31d547b
typo fix
gutow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| SymPEP for behavior of the Equation class | ||
| ========================================= | ||
| Fundamentally this is an object with two SymPy expressions connected by an equals sign. | ||
| Potentially this could be extended to a general relational expression, but that is not | ||
| part of this proposal. | ||
|
|
||
| The initial motivation for this class is to facilitate manipulating mathematical expressions | ||
| in a manner as similar to what is done on paper as possible. For operations/methods where | ||
| it makes sense they should be applied to both sides of the equation. As much as possible, | ||
| operations on the equations should be initiated using syntax mimicking standard | ||
| mathematical notation. | ||
|
|
||
| __Proposed Behaviors__ | ||
|
|
||
| _Binary Operations (+,-, *, /, %, **)_ | ||
| * If combining an equation with a SymPy expression the expression will be applied to both | ||
| sides of the equation as specified by the binary operator. | ||
| ``` | ||
| >>> a, b, c = Symbol('a b c') | ||
| >>> eq1 = Equation(a, b/c) | ||
| >>> eq1 | ||
| a = b/c | ||
| >>> eq1*c | ||
| a*c = b | ||
| ``` | ||
| * If combining two equations the lhs will combine with the lhs and the rhs with the rhs. | ||
| ``` | ||
| >>> eq2 = Equation(b, c**2) | ||
| >>> eq2 | ||
| b = c**2 | ||
| >>> eq1 + eq2 | ||
| a + b = b/c + c**2 | ||
| ``` | ||
| _Functions (sin, cos, exp, etc...)_ | ||
| * Functions will apply to both sides. | ||
| ``` | ||
| >>> cos(eq1) | ||
| cos(a) = cos(b/c) | ||
| ``` | ||
| * Keywords and additional parameters will be passed through to the function. | ||
|
|
||
| _Simplification_ | ||
| * Behavior should mimic the behavior for expressions and default to applying to both sides. | ||
|
|
||
| _Differentiation_ | ||
|
|
||
| _Integration_ | ||
| * Support integration of each side through `.doXXX.integrate(variable-of-integration)` | ||
| and `.doXXX.Integral(variable-of-integration)`, where `XXX` is either `rhs` or `lhs`. | ||
|
|
||
| Integration of each side with respect to different variables | ||
| ``` | ||
| >>> eq1.dorhs.integrate(b).dolhs.integrate(a) | ||
| a**2/2 = b**2/(2*c) | ||
| >>> eq1.dorhs.integrate(b).dolhs.Integral(a) | ||
| Integral(a,a) = b**2/(2*c) | ||
| ``` | ||
gutow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| _Solve_ | ||
| * Solve should accept equations and lists of equations and return equations or lists of | ||
| equations as solutions. To avoid breaking past behavior this should only occur when solve | ||
| is used on equations or lists of equations. | ||
|
|
||
| _Applications of methods_ | ||
| * Support `.method()` calls for any method that applies to expressions. Apply the method | ||
| to both sides of the equation. | ||
| * Support `.apply()`, `.applylhs()`, `.applyrhs()`, `.do.`, `.dolhs.`,`.dorhs.`. | ||
| * Methods that can be applied to a SymPy expression as a Python method should also work | ||
| on an Equation: | ||
| ``` | ||
| >>> collect(a*x + b*x**2 + c*x, x) | ||
| (a + c)*x + b*x**2 | ||
| >>> collect(Equation(a*x + b*x**2 + c*x,a*x**2 + b*x + c*x, x) | ||
| (a + c)*x + b*x**2 = a*x**2 + (b + c)*x | ||
| ``` | ||
| _Miscellaneous_ | ||
| * `.as_Boolean()` returns the equation cast as an `Equality`. | ||
| * `.lhs` returns the expression on the left hand side. | ||
| * `.rhs` returns the expression on the right hand side. | ||
| * `.swap` returns the equation with the lhs and rhs swapped. | ||
| * `.check()` shortcut for `.as_Boolean().simplify()`. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.