Skip to content

Commit 54abb0f

Browse files
authored
Merge pull request sympy#20242 from Soumi7/GSoD_simplify_1
Added required sections in sympy.simplify
2 parents 99701a5 + d8f366c commit 54abb0f

File tree

8 files changed

+89
-41
lines changed

8 files changed

+89
-41
lines changed

sympy/simplify/combsimp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def combsimp(expr):
1515
r"""
1616
Simplify combinatorial expressions.
1717
18+
Explanation
19+
===========
20+
1821
This function takes as input an expression containing factorials,
1922
binomials, Pochhammer symbol and other "combinatorial" functions,
2023
and tries to minimize the number of those functions and reduce

sympy/simplify/cse_main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
def reps_toposort(r):
38-
"""Sort replacements `r` so (k1, v1) appears before (k2, v2)
38+
"""Sort replacements ``r`` so (k1, v1) appears before (k2, v2)
3939
if k2 is in v1's free symbols. This orders items in the
4040
way that cse returns its results (hence, in order to use the
4141
replacements in a substitution option it would make sense
@@ -196,8 +196,8 @@ def stop_arg_tracking(self, func_i):
196196
def get_common_arg_candidates(self, argset, min_func_i=0):
197197
"""Return a dict whose keys are function numbers. The entries of the dict are
198198
the number of arguments said function has in common with
199-
`argset`. Entries have at least 2 items in common. All keys have
200-
value at least `min_func_i`.
199+
``argset``. Entries have at least 2 items in common. All keys have
200+
value at least ``min_func_i``.
201201
"""
202202
from collections import defaultdict
203203
count_map = defaultdict(lambda: 0)
@@ -309,9 +309,9 @@ def match_common_args(func_class, funcs, opt_subs):
309309
func_class: class
310310
The function class (e.g. Add, Mul)
311311
funcs: list of functions
312-
A list of function calls
312+
A list of function calls.
313313
opt_subs: dict
314-
A dictionary of substitutions which this function may update
314+
A dictionary of substitutions which this function may update.
315315
"""
316316

317317
# Sort to ensure that whole-function subexpressions come before the items
@@ -384,7 +384,7 @@ def match_common_args(func_class, funcs, opt_subs):
384384

385385
def opt_cse(exprs, order='canonical'):
386386
"""Find optimization opportunities in Adds, Muls, Pows and negative
387-
coefficient Muls
387+
coefficient Muls.
388388
389389
Parameters
390390
==========

sympy/simplify/epathtools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ def epath(path, expr=None, func=None, args=None, kwargs=None):
284284
r"""
285285
Manipulate parts of an expression selected by a path.
286286
287+
Explanation
288+
===========
289+
287290
This function allows to manipulate large nested expressions in single
288291
line of code, utilizing techniques to those applied in XML processing
289292
standards (e.g. XPath).

sympy/simplify/fu.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def TR6(rv, max=4, pow=False):
378378

379379

380380
def TR7(rv):
381-
"""Lowering the degree of cos(x)**2
381+
"""Lowering the degree of cos(x)**2.
382382
383383
Examples
384384
========
@@ -928,7 +928,7 @@ def f(rv):
928928

929929
def TR12i(rv):
930930
"""Combine tan arguments as
931-
(tan(y) + tan(x))/(tan(x)*tan(y) - 1) -> -tan(x + y)
931+
(tan(y) + tan(x))/(tan(x)*tan(y) - 1) -> -tan(x + y).
932932
933933
Examples
934934
========
@@ -1153,7 +1153,7 @@ def TRmorrie(rv):
11531153
References
11541154
==========
11551155
1156-
https://en.wikipedia.org/wiki/Morrie%27s_law
1156+
.. [1] https://en.wikipedia.org/wiki/Morrie%27s_law
11571157
11581158
"""
11591159

@@ -1475,7 +1475,7 @@ def TRpower(rv):
14751475
References
14761476
==========
14771477
1478-
https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Power-reduction_formulae
1478+
.. [1] https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Power-reduction_formulae
14791479
14801480
"""
14811481

@@ -1623,8 +1623,8 @@ def fu(rv, measure=lambda x: (L(x), x.count_ops())):
16231623
16241624
References
16251625
==========
1626-
http://rfdz.ph-noe.ac.at/fileadmin/Mathematik_Uploads/ACDCA/
1627-
DESTIME2006/DES_contribs/Fu/simplification.pdf
1626+
1627+
.. [1] https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.657.2478&rep=rep1&type=pdf
16281628
"""
16291629
fRL1 = greedy(RL1, measure)
16301630
fRL2 = greedy(RL2, measure)
@@ -1648,7 +1648,7 @@ def fu(rv, measure=lambda x: (L(x), x.count_ops())):
16481648

16491649

16501650
def process_common_addends(rv, do, key2=None, key1=True):
1651-
"""Apply ``do`` to addends of ``rv`` that (if key1=True) share at least
1651+
"""Apply ``do`` to addends of ``rv`` that (if ``key1=True``) share at least
16521652
a common absolute value of their coefficient and the value of ``key2`` when
16531653
applied to the argument. If ``key1`` is False ``key2`` must be supplied and
16541654
will be the only key applied.
@@ -1956,7 +1956,7 @@ def _osborne(e, d):
19561956
References
19571957
==========
19581958
1959-
https://en.wikipedia.org/wiki/Hyperbolic_function
1959+
.. [1] https://en.wikipedia.org/wiki/Hyperbolic_function
19601960
"""
19611961

19621962
def f(rv):
@@ -1995,7 +1995,7 @@ def _osbornei(e, d):
19951995
References
19961996
==========
19971997
1998-
https://en.wikipedia.org/wiki/Hyperbolic_function
1998+
.. [1] https://en.wikipedia.org/wiki/Hyperbolic_function
19991999
"""
20002000

20012001
def f(rv):
@@ -2045,7 +2045,7 @@ def hyper_as_trig(rv):
20452045
References
20462046
==========
20472047
2048-
https://en.wikipedia.org/wiki/Hyperbolic_function
2048+
.. [1] https://en.wikipedia.org/wiki/Hyperbolic_function
20492049
"""
20502050
from sympy.simplify.simplify import signsimp
20512051
from sympy.simplify.radsimp import collect
@@ -2067,6 +2067,9 @@ def hyper_as_trig(rv):
20672067
def sincos_to_sum(expr):
20682068
"""Convert products and powers of sin and cos to sums.
20692069
2070+
Explanation
2071+
===========
2072+
20702073
Applied power reduction TRpower first, then expands products, and
20712074
converts products to sums with TR8.
20722075

sympy/simplify/gammasimp.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ def gammasimp(expr):
1414
r"""
1515
Simplify expressions with gamma functions.
1616
17+
Explanation
18+
===========
19+
1720
This function takes as input an expression containing gamma
1821
functions or functions that can be rewritten in terms of gamma
1922
functions and tries to minimize the number of those functions and
@@ -39,8 +42,8 @@ def gammasimp(expr):
3942
4043
All transformation rules can be found (or was derived from) here:
4144
42-
1. http://functions.wolfram.com/GammaBetaErf/Pochhammer/17/01/02/
43-
2. http://functions.wolfram.com/GammaBetaErf/Pochhammer/27/01/0005/
45+
.. [1] http://functions.wolfram.com/GammaBetaErf/Pochhammer/17/01/02/
46+
.. [2] http://functions.wolfram.com/GammaBetaErf/Pochhammer/27/01/0005/
4447
4548
Examples
4649
========
@@ -65,6 +68,9 @@ def _gammasimp(expr, as_comb):
6568
"""
6669
Helper function for gammasimp and combsimp.
6770
71+
Explanation
72+
===========
73+
6874
Simplifies expressions written in terms of gamma function. If
6975
as_comb is True, it tries to preserve integer arguments. See
7076
docstring of gammasimp for more information. This was part of

sympy/simplify/hyperexpand.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ def build_invariants(self):
514514
"""
515515
Compute the invariant vector.
516516
517+
Explanation
518+
===========
519+
517520
The invariant vector is:
518521
(gamma, ((s1, n1), ..., (sk, nk)), ((t1, m1), ..., (tr, mr)))
519522
where gamma is the number of integer a < 0,
@@ -581,6 +584,9 @@ def _is_suitable_origin(self):
581584
"""
582585
Decide if ``self`` is a suitable origin.
583586
587+
Explanation
588+
===========
589+
584590
A function is a suitable origin iff:
585591
* none of the ai equals bj + n, with n a non-negative integer
586592
* none of the ai is zero
@@ -628,6 +634,9 @@ def compute_buckets(self):
628634
"""
629635
Compute buckets for the fours sets of parameters.
630636
637+
Explanation
638+
===========
639+
631640
We guarantee that any two equal Mod objects returned are actually the
632641
same, and that the buckets are sorted by real part (an and bq
633642
descendending, bm and ap ascending).
@@ -670,6 +679,9 @@ class Formula(object):
670679
"""
671680
This class represents hypergeometric formulae.
672681
682+
Explanation
683+
===========
684+
673685
Its data members are:
674686
- z, the argument
675687
- closed_form, the closed form expression
@@ -944,6 +956,9 @@ class Operator(object):
944956
"""
945957
Base class for operators to be applied to our functions.
946958
959+
Explanation
960+
===========
961+
947962
These operators are differential operators. They are by convention
948963
expressed in the variable D = z*d/dz (although this base class does
949964
not actually care).
@@ -1438,6 +1453,9 @@ def reduce_order(func):
14381453
Given the hypergeometric function ``func``, find a sequence of operators to
14391454
reduces order as much as possible.
14401455
1456+
Explanation
1457+
===========
1458+
14411459
Return (newfunc, [operators]), where applying the operators to the
14421460
hypergeometric function newfunc yields func.
14431461
@@ -1960,9 +1978,12 @@ def _hyperexpand(func, z, ops0=[], z0=Dummy('z0'), premult=1, prem=0,
19601978
"""
19611979
Try to find an expression for the hypergeometric function ``func``.
19621980
1963-
The result is expressed in terms of a dummy variable z0. Then it
1964-
is multiplied by premult. Then ops0 is applied.
1965-
premult must be a*z**prem for some a independent of z.
1981+
Explanation
1982+
===========
1983+
1984+
The result is expressed in terms of a dummy variable ``z0``. Then it
1985+
is multiplied by ``premult``. Then ``ops0`` is applied.
1986+
``premult`` must be a*z**prem for some a independent of ``z``.
19661987
"""
19671988

19681989
if z.is_zero:
@@ -2062,12 +2083,15 @@ def devise_plan_meijer(fro, to, z):
20622083
"""
20632084
Find operators to convert G-function ``fro`` into G-function ``to``.
20642085
2065-
It is assumed that fro and to have the same signatures, and that in fact
2086+
Explanation
2087+
===========
2088+
2089+
It is assumed that ``fro`` and ``to`` have the same signatures, and that in fact
20662090
any corresponding pair of parameters differs by integers, and a direct path
20672091
is possible. I.e. if there are parameters a1 b1 c1 and a2 b2 c2 it is
20682092
assumed that a1 can be shifted to a2, etc. The only thing this routine
20692093
determines is the order of shifts to apply, nothing clever will be tried.
2070-
It is also assumed that fro is suitable.
2094+
It is also assumed that ``fro`` is suitable.
20712095
20722096
Examples
20732097
========

sympy/simplify/powsimp.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def powsimp(expr, deep=False, combine='all', force=False, measure=count_ops):
1818
"""
1919
reduces expression by combining powers with similar bases and exponents.
2020
21-
Notes
22-
=====
21+
Explanation
22+
===========
2323
24-
If deep is True then powsimp() will also simplify arguments of
25-
functions. By default deep is set to False.
24+
If ``deep`` is ``True`` then powsimp() will also simplify arguments of
25+
functions. By default ``deep`` is set to ``False``.
2626
27-
If force is True then bases will be combined without checking for
27+
If ``force`` is ``True`` then bases will be combined without checking for
2828
assumptions, e.g. sqrt(x)*sqrt(y) -> sqrt(x*y) which is not true
2929
if x and y are both negative.
3030
@@ -490,6 +490,9 @@ def powdenest(eq, force=False, polar=False):
490490
r"""
491491
Collect exponents on powers as assumptions allow.
492492
493+
Explanation
494+
===========
495+
493496
Given ``(bb**be)**e``, this can be simplified as follows:
494497
* if ``bb`` is positive, or
495498
* ``e`` is an integer, or
@@ -506,11 +509,11 @@ def powdenest(eq, force=False, polar=False):
506509
of the exponent can be removed from any term and the gcd of such
507510
integers can be joined with e
508511
509-
Setting ``force`` to True will make symbols that are not explicitly
512+
Setting ``force`` to ``True`` will make symbols that are not explicitly
510513
negative behave as though they are positive, resulting in more
511514
denesting.
512515
513-
Setting ``polar`` to True will do simplifications on the Riemann surface of
516+
Setting ``polar`` to ``True`` will do simplifications on the Riemann surface of
514517
the logarithm, also resulting in more denestings.
515518
516519
When there are sums of logs in exp() then a product of powers may be

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy