Skip to content
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

transcendental equation solver for solveset: transolve #14736

Merged
merged 34 commits into from Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
059b5ae
initial commit for transolved and exponential solver
Yathartha22 May 23, 2018
f7c38cb
added tests for exponential solver
Yathartha22 May 23, 2018
885923b
added docstring for exponential solver
Yathartha22 May 23, 2018
fd0a4f6
Merge branch 'master' of https://github.com/sympy/sympy into transolv…
Yathartha22 May 23, 2018
f8bc1ad
added documentation for transolve
Yathartha22 May 24, 2018
9dfaf58
minor changes in code and tests.
Yathartha22 May 24, 2018
a2305da
minor changes
Yathartha22 May 25, 2018
d2f067c
improved documentation and imported tests from solve.
Yathartha22 May 31, 2018
217b11f
minor documentation fixes
Yathartha22 Jun 2, 2018
c38ea87
added proof of correctness and minor changes in documentation
Yathartha22 Jun 5, 2018
197355d
imported tests for log and lambert form solve, minor documentation fi…
Yathartha22 Jun 8, 2018
5be292f
improvements for XFAILS to pass
Yathartha22 Jun 8, 2018
ffef477
updated and improved documentation for sphinx
Yathartha22 Jun 10, 2018
a7574b0
removed repeated test
Yathartha22 Jun 11, 2018
648da0e
minor documentation fixes
Yathartha22 Jun 12, 2018
f8597b5
documentation fxes according to pep8; made `_check_expo` to work for …
Yathartha22 Jun 13, 2018
a45df5c
documentation fixes for: `transolve`, `check_expo` and `expo_solver`;…
Yathartha22 Jun 18, 2018
3e0972c
improved case for handling more than 2 terms in `expo_solver`
Yathartha22 Jun 21, 2018
2309ce7
minor documentation changes
Yathartha22 Jun 21, 2018
5e89449
removed unnecessay lines from documentation
Yathartha22 Jun 21, 2018
f2e6ab0
do test before working with args
smichr Jun 21, 2018
89ce4c9
added test for `expo_solver` to return `None`; used top import for Ad…
Yathartha22 Jun 21, 2018
e2f12ac
removed `pow_type()` as this case is handled in `solveset`; removed l…
Yathartha22 Jun 26, 2018
154ee3b
minor document changes
Yathartha22 Jun 28, 2018
8345107
documentation imporovements
Yathartha22 Jul 3, 2018
c0bc441
improved `Philosophy behind the module`; changed the naming conventio…
Yathartha22 Jul 4, 2018
6ddc927
minor documnetation changes
Yathartha22 Jul 4, 2018
de66d1e
Improved documentation for "How to add new class of equations"
Yathartha22 Jul 5, 2018
cca2d14
added `make_expr_args()` to get all the terms of the expressions
Yathartha22 Jul 7, 2018
e49647e
renamed `make_expr_args` to `term_factors()` and improved its documen…
Yathartha22 Jul 8, 2018
e329518
made `term_factors()` an iterator; added some examples in its docstring
Yathartha22 Jul 9, 2018
90efc7a
removed unused list in `term_factors()`; improved doctests for the same
Yathartha22 Jul 9, 2018
e51734a
made `term_factors()` private; minor documentation changes; renamed l…
Yathartha22 Jul 10, 2018
254f45f
removed repeated test and minor change in documentation
Yathartha22 Jul 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 15 additions & 4 deletions sympy/solvers/solveset.py
Expand Up @@ -987,14 +987,25 @@ def _solveset(f, symbol, domain, _check=False):

def term_factors(f):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making this an iterator? So instead of returning all, yield one at a time. That could be used like uniq(term_factors(foo)) to give the unique term factors of an expression in an efficient manner.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good @smichr. I will make changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make it private

"""
Returns a list of the factors of all terms present in the
expression.
An iterator that returns the factors of all terms
present in the expression.

Examples
========

>>> from sympy import symbols
>>> from sympy.solvers.solveset import term_factors
>>> x = symbols('x')
>>> term_factors_obj = term_factors(x**2 - 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> list(term_factors(-2 - x**2 + x*(x + 1)))
[-2, -1, x**2, x, x + 1]

>>> for term in term_factors_obj:
... print(term)
-1
x**2
"""
args = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed anymore

for add_arg in Add.make_args(f):
for mul_arg in Mul.make_args(add_arg):
args.append(mul_arg)
return args
yield mul_arg


def _solve_expo(f, symbol):
Expand Down
6 changes: 3 additions & 3 deletions sympy/solvers/tests/test_solveset.py
Expand Up @@ -1733,10 +1733,10 @@ def test_issue_14454():


def test_term_factors():
assert term_factors(3**x - 2) == [-2, 3**x]
assert list(term_factors(3**x - 2)) == [-2, 3**x]
expr = 4**(x + 1) + 4**(x + 2) + 4**(x - 1) - 3**(x + 2) - 3**(x + 3)
assert term_factors(expr) == \
[4**(x + 1), 4**(x - 1), 4**(x + 2), -1, 3**(x + 2), -1, 3**(x + 3)]
assert set(term_factors(expr)) == set([
3**(x + 2), 4**(x + 2), 3**(x + 3), 4**(x - 1), -1, 4**(x + 1)])


#################### tests for transolve and its helpers ###############
Expand Down