From 6f9e187dc7c69bcad15111f17867f283218f8615 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Sat, 23 Jan 2021 18:08:12 -0600 Subject: [PATCH 01/20] Create Equations.md --- Equations.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Equations.md diff --git a/Equations.md b/Equations.md new file mode 100644 index 0000000..e1404a6 --- /dev/null +++ b/Equations.md @@ -0,0 +1,32 @@ +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 +``` From e94a31abdbaf89428c3b15100ce31fdf29c76c3e Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Sat, 23 Jan 2021 18:10:14 -0600 Subject: [PATCH 02/20] new line for binary operators heading --- Equations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Equations.md b/Equations.md index e1404a6..cba7aa2 100644 --- a/Equations.md +++ b/Equations.md @@ -11,6 +11,7 @@ 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. From 0c80c8f882972ce975eeaa1032a32e2f58b32451 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Sat, 23 Jan 2021 18:34:40 -0600 Subject: [PATCH 03/20] Sections there has been discussion on --- Equations.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Equations.md b/Equations.md index cba7aa2..137c027 100644 --- a/Equations.md +++ b/Equations.md @@ -31,3 +31,39 @@ 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_ + +_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 `.apply()`, `.applyrhs()`, `.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()`. From ff01f81b0eb9861d14aeb37060cc6def482128e6 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Sat, 23 Jan 2021 18:37:47 -0600 Subject: [PATCH 04/20] Update Applications of methods --- Equations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Equations.md b/Equations.md index 137c027..c4a3a7f 100644 --- a/Equations.md +++ b/Equations.md @@ -52,6 +52,8 @@ equations as solutions. To avoid breaking past behavior this should only occur w 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()`, `.applyrhs()`, `.applyrhs()`, `.do.`, `.dolhs.`,`.dorhs.`. * Methods that can be applied to a SymPy expression as a Python method should also work on an Equation: From c298cc76f7dd40d5f3a3e9503efef0aa413a184c Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Sun, 24 Jan 2021 08:23:33 -0600 Subject: [PATCH 05/20] remove extra `applyrhs()` --- Equations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Equations.md b/Equations.md index c4a3a7f..68bc928 100644 --- a/Equations.md +++ b/Equations.md @@ -54,7 +54,7 @@ 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()`, `.applyrhs()`, `.applyrhs()`, `.do.`, `.dolhs.`,`.dorhs.`. +* 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: ``` From 7c572aafc80b7ee2035c7c09f63ec247b1c95d75 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Tue, 26 Jan 2021 15:57:56 -0600 Subject: [PATCH 06/20] Minimal suggesttion for integration --- Equations.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Equations.md b/Equations.md index 68bc928..48bdf06 100644 --- a/Equations.md +++ b/Equations.md @@ -45,6 +45,16 @@ _Simplification_ _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) +``` _Solve_ * Solve should accept equations and lists of equations and return equations or lists of From baa2436da7fa80cb33c294dc129b0b03ec0f397e Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Wed, 27 Jan 2021 20:38:01 -0600 Subject: [PATCH 07/20] Try template proposal --- Equations.md | 190 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 183 insertions(+), 7 deletions(-) diff --git a/Equations.md b/Equations.md index 48bdf06..ef586c5 100644 --- a/Equations.md +++ b/Equations.md @@ -1,16 +1,184 @@ -SymPEP for behavior of the Equation class +SymPEP XXXX Equation class ========================================= + +**Author** Jonathan Gutow +**Status** Draft +**Type** Standards Track +**Created** 2021-01-25 +**Resolution** url to discussion (required for Accepted | Rejected | Withdrawn) + + +## Abstract + 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 +part of this proposal. This class facilitates 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, +it makes sense they would 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. +mathematical notation. This class also aims to provide output in standard mathematical +notation when used within tools such as Jupyter, that support typeset LaTex. + +## Motivation and Scope + +There are a number of motivations for the development of the Equation class: +1. Make interactive manipulation of equations as similar to doing the work on paper as +possible and make the results easier to read by having results that look like +`x = 2*y + 1` rather than `2*y + 1`, with what it is equal to on a separate line. +1. Have equations on which manual algebra can be done by having SymPy perform the actual +symbolic manipulation. This allows people to perform messy manipulations with fewer errors, much +as calculators, spreadsheets and other numerical computation tools facilitate arithmetic. +1. From an educational and new user perspective this increases the ease of use of SymPy +by decreasing the cognitive load of using SymPy. This would be acheived by maintaining as +close to standard mathematical notation for operations as possible (see +(Detailed Description)[#Detailed-Descripton]). Making SymPy easier to begin using will +increase its adoption and encourage people to learn to use symbolic math tools. +1. The `Equality` class does not reliably support general SymPy operations on both sides +of the equality without collapsing to a Boolean value of `True` or `False`. Parts of SymPy +depend on this Boolean behavior; thus this proposal for a separate `Equation` class rather +than an extension of `Equality`. +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. + +## Usage and Impact + +The class would have the name `Equation` and `Eqn` would be a synonym. The expectation is +that this would be used primarily interactively for symbolic algebra. Some examples: +``` +>>> a, b, c, x = var('a b c x') +>>> Equation(a,b/c) +a = b/c +>>> t=Eqn(a,b/c) +>>> t +a = b/c +>>> t*c +a*c = b +>>> c*t +a*c = b +>>> exp(t) +exp(a) = exp(b/c) +>>> exp(log(t)) +a = b/c + +Simplification and Expansion +>>> f = Eqn(x**2 - 1, c) +>>> f +x**2 - 1 = c +>>> f/(x+1) +(x**2 - 1)/(x + 1) = c/(x + 1) +>>> (f/(x+1)).simplify() +x - 1 = c/(x + 1) +>>> simplify(f/(x+1)) +x - 1 = c/(x + 1) +>>> (f/(x+1)).expand() +x**2/(x + 1) - 1/(x + 1) = c/(x + 1) +>>> expand(f/(x+1)) +x**2/(x + 1) - 1/(x + 1) = c/(x + 1) +>>> factor(f) +(x - 1)*(x + 1) = c +>>> f.factor() +(x - 1)*(x + 1) = c +>>> f2 = f+a*x**2+b*x +c +>>> f2 +a*x**2 + b*x + c + x**2 - 1 = a*x**2 + b*x + 2*c +>>> collect(f2,x) +b*x + c + x**2*(a + 1) - 1 = a*x**2 + b*x + 2*c + +Apply operation to only one side +>>> poly = Eqn(a*x**2 + b*x + c*x**2, a*x**3 + b*x**3 + c*x) +>>> poly.applyrhs(factor,x) +a*x**2 + b*x + c*x**2 = x*(c + x**2*(a + b)) +>>> poly.applylhs(factor) +x*(a*x + b + c*x) = a*x**3 + b*x**3 + c*x +>>> poly.applylhs(collect,x) +b*x + x**2*(a + c) = a*x**3 + b*x**3 + c*x + +``.apply...`` also works with user defined python functions +>>> def addsquare(eqn): +... return eqn+eqn**2 +... +>>> t.apply(addsquare) +a**2 + a = b**2/c**2 + b/c +>>> t.applyrhs(addsquare) +a = b**2/c**2 + b/c +>>> t.apply(addsquare, side = 'rhs') +a = b**2/c**2 + b/c +>>> t.applylhs(addsquare) +a**2 + a = b/c +>>> addsquare(t) +a**2 + a = b**2/c**2 + b/c -__Proposed Behaviors__ +Inaddition to ``.apply...`` there is also the less general ``.do``, +``.dolhs``, ``.dorhs``, which only works for operations defined on the +``Expr`` class (e.g.``.collect(), .factor(), .expand()``, etc...). +>>> poly.dolhs.collect(x) +b*x + x**2*(a + c) = a*x**3 + b*x**3 + c*x +>>> poly.dorhs.collect(x) +a*x**2 + b*x + c*x**2 = c*x + x**3*(a + b) +>>> poly.do.collect(x) +b*x + x**2*(a + c) = c*x + x**3*(a + b) +>>> poly.dorhs.factor() +a*x**2 + b*x + c*x**2 = x*(a*x**2 + b*x**2 + c) + +``poly.do.exp()`` or other sympy math functions will raise an error. + +Rearranging an equation (simple example made complicated as illustration) +>>> p, V, n, R, T = var('p V n R T') +>>> eq1=Eqn(p*V,n*R*T) +>>> eq1 +V*p = R*T*n +>>> eq2 =eq1/V +>>> eq2 +p = R*T*n/V +>>> eq3 = eq2/R/T +>>> eq3 +p/(R*T) = n/V +>>> eq4 = eq3*R/p +>>> eq4 +1/T = R*n/(V*p) +>>> 1/eq4 +T = V*p/(R*n) +>>> eq5 = 1/eq4 - T +>>> eq5 +0 = -T + V*p/(R*n) + +Substitution (#'s and units) +>>> L, atm, mol, K = var('L atm mol K', positive=True, real=True) # units +>>> eq2.subs({R:0.08206*L*atm/mol/K,T:273*K,n:1.00*mol,V:24.0*L}) +p = 0.9334325*atm +>>> eq2.subs({R:0.08206*L*atm/mol/K,T:273*K,n:1.00*mol,V:24.0*L}).evalf(4) +p = 0.9334*atm + +Combining equations (Math with equations: lhs with lhs and rhs with rhs) +>>> q = Eqn(a*c, b/c**2) +>>> q +a*c = b/c**2 +>>> t +a = b/c +>>> q+t +a*c + a = b/c + b/c**2 +>>> q/t +c = 1/c +>>> t**q +a**(a*c) = (b/c)**(b/c**2) + +``solve()`` +>>> t=Eqn(a,b/c) +>>> t +a = b/c +>>> solve(t,c) +c = b/a +``` + +## Backwards compatibility + +No backwards compatiblity breaks are necessary. However, it has been suggested that the +`Equality` class might eventually be replaced and then `Eq` and `Equality` could become +synomyms for `Equation`. + +## Detailed Description _Binary Operations (+,-, *, /, %, **)_ * If combining an equation with a SymPy expression the expression will be applied to both @@ -79,3 +247,11 @@ _Miscellaneous_ * `.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()`. + +## Related Work + +## Implementation + +## Alternatives + +## Discussions From 10b27ecdb06afa4aed6266eb1e647924e6e943b1 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Wed, 27 Jan 2021 20:39:14 -0600 Subject: [PATCH 08/20] Add linebreaks to header information --- Equations.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Equations.md b/Equations.md index ef586c5..6f0291a 100644 --- a/Equations.md +++ b/Equations.md @@ -2,9 +2,13 @@ SymPEP XXXX Equation class ========================================= **Author** Jonathan Gutow + **Status** Draft + **Type** Standards Track + **Created** 2021-01-25 + **Resolution** url to discussion (required for Accepted | Rejected | Withdrawn) From 445e0122ef60614ff2dd61e4689c9d33b2c6d19d Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Wed, 27 Jan 2021 20:44:06 -0600 Subject: [PATCH 09/20] anchor fixes --- Equations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Equations.md b/Equations.md index 6f0291a..47e1d9a 100644 --- a/Equations.md +++ b/Equations.md @@ -1,7 +1,7 @@ SymPEP XXXX Equation class ========================================= -**Author** Jonathan Gutow +**Author** Jonathan Gutow, **Status** Draft @@ -35,7 +35,7 @@ as calculators, spreadsheets and other numerical computation tools facilitate ar 1. From an educational and new user perspective this increases the ease of use of SymPy by decreasing the cognitive load of using SymPy. This would be acheived by maintaining as close to standard mathematical notation for operations as possible (see -(Detailed Description)[#Detailed-Descripton]). Making SymPy easier to begin using will +[Detailed Description](#Detailed-Descripton)). Making SymPy easier to begin using will increase its adoption and encourage people to learn to use symbolic math tools. 1. The `Equality` class does not reliably support general SymPy operations on both sides of the equality without collapsing to a Boolean value of `True` or `False`. Parts of SymPy From 4310893f2d012855b99ec0636f811777f2965de1 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Wed, 27 Jan 2021 20:44:59 -0600 Subject: [PATCH 10/20] more anchor fixes --- Equations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Equations.md b/Equations.md index 47e1d9a..f90c39d 100644 --- a/Equations.md +++ b/Equations.md @@ -35,7 +35,7 @@ as calculators, spreadsheets and other numerical computation tools facilitate ar 1. From an educational and new user perspective this increases the ease of use of SymPy by decreasing the cognitive load of using SymPy. This would be acheived by maintaining as close to standard mathematical notation for operations as possible (see -[Detailed Description](#Detailed-Descripton)). Making SymPy easier to begin using will +[Detailed Description](#detailed-descripton)). Making SymPy easier to begin using will increase its adoption and encourage people to learn to use symbolic math tools. 1. The `Equality` class does not reliably support general SymPy operations on both sides of the equality without collapsing to a Boolean value of `True` or `False`. Parts of SymPy From ad0a95d9fea6aed200060d327b8d564e0c8fe68b Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Wed, 27 Jan 2021 20:45:53 -0600 Subject: [PATCH 11/20] typo --- Equations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Equations.md b/Equations.md index f90c39d..77ff083 100644 --- a/Equations.md +++ b/Equations.md @@ -35,7 +35,7 @@ as calculators, spreadsheets and other numerical computation tools facilitate ar 1. From an educational and new user perspective this increases the ease of use of SymPy by decreasing the cognitive load of using SymPy. This would be acheived by maintaining as close to standard mathematical notation for operations as possible (see -[Detailed Description](#detailed-descripton)). Making SymPy easier to begin using will +[Detailed Description](#detailed-description)). Making SymPy easier to begin using will increase its adoption and encourage people to learn to use symbolic math tools. 1. The `Equality` class does not reliably support general SymPy operations on both sides of the equality without collapsing to a Boolean value of `True` or `False`. Parts of SymPy From 59a32337489f71dadd29e9f3fc81344afcb0c790 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Thu, 28 Jan 2021 19:34:43 -0600 Subject: [PATCH 12/20] related work, implementation, discussions, copyright --- Equations.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Equations.md b/Equations.md index 77ff083..7d4ad37 100644 --- a/Equations.md +++ b/Equations.md @@ -254,8 +254,38 @@ _Miscellaneous_ ## Related Work +Similar functionality is found in [SageMath](https://www.sagemath.org/), [Maple](https://maplesoft.com), +and other symbolic math packages. +An python module that implements much of the proposed capabilities is available via pip: +`pip install -U Algebra_with_SymPy`. This module requires SymPy. + ## Implementation +1. All the proposed behaviors except for those associated with `solve` being implemented in +[PR 19749](https://github.com/sympy/sympy/pull/19479). +2. The `solve` features will be implemented after step 1 is completed. ## Alternatives +An alternative would be to implement this as part of the work being done on polyadic predicate +[PR 20656](https://github.com/sympy/sympy/pull/20656). This option was discussed in both PR 19749 +and PR 20656. The concensus was that until the predicate work reached the stage of being able to +replace the assumptions module it would be better to keep the two pieces separate. At that point +if combination still appeared straightforward the `Equation` class could become a subclass of the general +class of relations that the predicate work is moving towards. + ## Discussions + +In decending order of volume discussions within the SymPy community have occured on: +* [PR 19749](https://github.com/sympy/sympy/pull/19479) +* [PR 20656](https://github.com/sympy/sympy/pull/20656) +* [SymPy Google Group](https://groups.google.com/g/sympy/c/rSi_I42i35I) +* Non-public discussions by J. Gutow with Physical Science Educators using SymPy in their classes. +These discussions were the original impetus for development of this class to facilitate demonstrating +algebraic manipulations in physical science classes. +* [Issue 4986](https://github.com/sympy/sympy/issues/4986) + +## References + +## Copyright + +This documente has been placed in the public domain. From 0e767a9d8da17671095359da8e2c5b2a6505dad3 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Thu, 28 Jan 2021 19:43:10 -0600 Subject: [PATCH 13/20] Update motivation and scope --- Equations.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Equations.md b/Equations.md index 7d4ad37..6eb9485 100644 --- a/Equations.md +++ b/Equations.md @@ -24,8 +24,11 @@ mathematical notation. This class also aims to provide output in standard mathem notation when used within tools such as Jupyter, that support typeset LaTex. ## Motivation and Scope +The original impetus for development of the `Equation` class came from discussions J. Gutow +had with Physical Science Educators using SymPy in their classes. They wanted this on-paper-like +behavior to facilitate demonstrating algebraic manipulations in physical science classes. -There are a number of motivations for the development of the Equation class: +There are a number of specific motivations for the development of the `Equation` class: 1. Make interactive manipulation of equations as similar to doing the work on paper as possible and make the results easier to read by having results that look like `x = 2*y + 1` rather than `2*y + 1`, with what it is equal to on a separate line. From f64411f760277b2f4998517e0583cc289afb7d6e Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Thu, 28 Jan 2021 19:44:48 -0600 Subject: [PATCH 14/20] typo fix --- Equations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Equations.md b/Equations.md index 6eb9485..7188cf2 100644 --- a/Equations.md +++ b/Equations.md @@ -259,7 +259,7 @@ _Miscellaneous_ Similar functionality is found in [SageMath](https://www.sagemath.org/), [Maple](https://maplesoft.com), and other symbolic math packages. -An python module that implements much of the proposed capabilities is available via pip: +A python module that implements much of the proposed capabilities is available via pip: `pip install -U Algebra_with_SymPy`. This module requires SymPy. ## Implementation From 757ee90094e151b5f910d1f9e9e525922edf30a3 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Thu, 28 Jan 2021 19:45:45 -0600 Subject: [PATCH 15/20] typo fix --- Equations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Equations.md b/Equations.md index 7188cf2..a2b1fd3 100644 --- a/Equations.md +++ b/Equations.md @@ -291,4 +291,4 @@ algebraic manipulations in physical science classes. ## Copyright -This documente has been placed in the public domain. +This document has been placed in the public domain. From 9510c739c343b721d8232fa2afbd9f4fe6cd1a36 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Thu, 28 Jan 2021 20:07:05 -0600 Subject: [PATCH 16/20] add .subs() to implementation section --- Equations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Equations.md b/Equations.md index a2b1fd3..eaa5ef5 100644 --- a/Equations.md +++ b/Equations.md @@ -266,6 +266,8 @@ A python module that implements much of the proposed capabilities is available v 1. All the proposed behaviors except for those associated with `solve` being implemented in [PR 19749](https://github.com/sympy/sympy/pull/19479). 2. The `solve` features will be implemented after step 1 is completed. +3. Acceptance of lists of equations by `.subs()` will be implemented in parallel with or after the +solve features. ## Alternatives From ec8324e5f919737b571b33c4324f468453306c96 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Fri, 16 Apr 2021 15:57:30 -0500 Subject: [PATCH 17/20] Delete `int` and `diff`, update links to discussions --- Equations.md | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/Equations.md b/Equations.md index eaa5ef5..ff38b09 100644 --- a/Equations.md +++ b/Equations.md @@ -217,26 +217,16 @@ cos(a) = cos(b/c) _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) -``` +_Differentiation and Integration_ +* No special support although they could be done on the separate sides of the equation + or utilizing the [_Applications of methods_](#Applications-of-methods) _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_ +#### _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.`. @@ -263,8 +253,9 @@ A python module that implements much of the proposed capabilities is available v `pip install -U Algebra_with_SymPy`. This module requires SymPy. ## Implementation -1. All the proposed behaviors except for those associated with `solve` being implemented in -[PR 19749](https://github.com/sympy/sympy/pull/19479). +1. All the proposed behaviors except for those associated with `solve` have been implemented in +[PR 21333](https://github.com/sympy/sympy/pull/21333). A smaller subset that begings building +`Equation` as a specific case of `relational` has been implemented in [PR 21325](https://github.com/sympy/sympy/pull/21325) 2. The `solve` features will be implemented after step 1 is completed. 3. Acceptance of lists of equations by `.subs()` will be implemented in parallel with or after the solve features. @@ -287,6 +278,8 @@ In decending order of volume discussions within the SymPy community have occured * Non-public discussions by J. Gutow with Physical Science Educators using SymPy in their classes. These discussions were the original impetus for development of this class to facilitate demonstrating algebraic manipulations in physical science classes. +* [PR 21325](https://github.com/sympy/sympy/pull/21325) +* [PR 21333](https://github.com/sympy/sympy/pull/21333) * [Issue 4986](https://github.com/sympy/sympy/issues/4986) ## References From 5f82ba43a6e6a6a00afd89aefa572efed6b6da7f Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Thu, 27 May 2021 18:41:29 -0500 Subject: [PATCH 18/20] Update Equations.md --- Equations.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Equations.md b/Equations.md index ff38b09..1f5351c 100644 --- a/Equations.md +++ b/Equations.md @@ -48,11 +48,17 @@ than an extension of `Equality`. 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. +1. As an equation with an `=` connecting the two sides can be thought of as a specific +example of a general relation (`=`, `>`, `<`, etc...) as much as possible the `Equation` +class should draw upon the underlying logic in the `relational` class. ## Usage and Impact The class would have the name `Equation` and `Eqn` would be a synonym. The expectation is -that this would be used primarily interactively for symbolic algebra. Some examples: +that this would be used primarily interactively for symbolic algebra. Some examples +(__Note__ that for illustration purposes results of operations are written with the two +sides connected by `=`, however this will only be the case in environments with Latex +output): ``` >>> a, b, c, x = var('a b c x') >>> Equation(a,b/c) @@ -207,7 +213,9 @@ b = c**2 a + b = b/c + c**2 ``` _Functions (sin, cos, exp, etc...)_ -* Functions will apply to both sides. +* Functions will apply to both sides. Functions that take more than one parameter will +only accept an equation as one of the parameters. It will be up to the user to make +sure the equation is used appropriately. ``` >>> cos(eq1) cos(a) = cos(b/c) @@ -248,7 +256,9 @@ _Miscellaneous_ ## Related Work Similar functionality is found in [SageMath](https://www.sagemath.org/), [Maple](https://maplesoft.com), -and other symbolic math packages. +and other symbolic math packages. The SageMath implementation has essentially no limitations +on the lhs and rhs making it possible to set objects that are incompatible equal to each other. +The proposed implementation here currently requires lhs and rhs to be valid sympy expressions. A python module that implements much of the proposed capabilities is available via pip: `pip install -U Algebra_with_SymPy`. This module requires SymPy. From 5cc260ace2bb5cb3a035afef7d94b7b41060e3f3 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Thu, 27 May 2021 18:52:07 -0500 Subject: [PATCH 19/20] suggest possible user switches to control form of output --- Equations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Equations.md b/Equations.md index 1f5351c..0ddf886 100644 --- a/Equations.md +++ b/Equations.md @@ -269,6 +269,8 @@ A python module that implements much of the proposed capabilities is available v 2. The `solve` features will be implemented after step 1 is completed. 3. Acceptance of lists of equations by `.subs()` will be implemented in parallel with or after the solve features. +4. A later potential extension might be to allow the user to set parameters to control whether human readable,code or +both forms of the expression are produced as output. ## Alternatives From 31d547b57e2d8f7c25ffa735f517efddd15d91b9 Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Sun, 30 May 2021 17:00:11 -0500 Subject: [PATCH 20/20] typo fix --- Equations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Equations.md b/Equations.md index 0ddf886..0e4c393 100644 --- a/Equations.md +++ b/Equations.md @@ -264,7 +264,7 @@ A python module that implements much of the proposed capabilities is available v ## Implementation 1. All the proposed behaviors except for those associated with `solve` have been implemented in -[PR 21333](https://github.com/sympy/sympy/pull/21333). A smaller subset that begings building +[PR 21333](https://github.com/sympy/sympy/pull/21333). A smaller subset that begins building `Equation` as a specific case of `relational` has been implemented in [PR 21325](https://github.com/sympy/sympy/pull/21325) 2. The `solve` features will be implemented after step 1 is completed. 3. Acceptance of lists of equations by `.subs()` will be implemented in parallel with or after the