Skip to content

Instantly share code, notes, and snippets.

View Shekharrajak's full-sized avatar
📚
Being Geek!

Shekhar Prasad Rajak Shekharrajak

📚
Being Geek!
View GitHub Profile
def substitution(system, symbols, result=[{}], known_symbols=[],
exclude=[], all_symbols=None):
r""" Solves the `system` using substitution method.
A helper function for `nonlinsolve`. This will be called from
`nonlinsolve` when any equation(s) is non polynomial equation.
Parameters
==========
system : list of equations
def _solve_using_known_values(result, solver):
"""Solves the system using already known solution
(result contains the dict <symbol: value>).
solver is `solveset_complex` or `solveset_real`.
"""
# stores imageset <expr: imageset(Lambda(n, expr), base)>.
soln_imageset = {}
total_solveset_call_inner = 0
total_conditionset_inner = 0
def _extract_main_soln(sol, soln_imageset):
"""separate the Complements, Intersections, ImageSet lambda expr
and it's base_set.
"""
# if there is union, then need to check
# complement, intersection, Imageset
# order should not be changed.
if isinstance(sol, Complement):
# extract solution and complement
complements[sym] = sol.args[1]
def _solve_using_known_values(result, solver):
"""Solves the system using already known solution
(result contains the dict <symbol: value>).
solver is `solveset_complex` or `solveset_real`.
"""
# helper functions
def _append_new_soln(sol, rnew, newresult, imgset_info):
"""If rnew (A dict <symbol: soln> ) contains valid soln
append it to newresult list.
##############################################################################
# ------------------------------nonlinsolve ---------------------------------#
##############################################################################
def substitution(system, symbols, result=[{}], known_symbols=[],
exclude=[], all_symbols=None):
r""" Solves the `system` using substitution method.
A helper function for `nonlinsolve`. This will be called from
`nonlinsolve` when any equation(s) is non polynomial equation.
# used in class Set(Basic):sets.py file
def _union_simplify(self, other):
"""
Try to reduce number of imageset in the args. Helper method for
ImageSet `_union `. It helps to get simpler imageset or
union of imageset.
First extract the expression of imageset and store in separate list
(self_expr for self and final_list for other). If there is any expr in
self_list have difference of pi or -pi with any final_expr expr. then
##############################################################################
# ------------------------------nonlinsolve ---------------------------------#
##############################################################################
def substitution(system, symbols=None, result=[{}], known_symbols=[],
exclude=[], all_symbols=None):
r""" Solves the `system` using substitution method.
##############################################################################
# ------------------------------nonlinsolve ---------------------------------#
##############################################################################
def substitution(system, symbols=None, result=[{}], known_symbols=[], exclude=[],
all_symbols=None):
r""" Solves the `system` using substitution method.
A helper function for `nonlinsolve`. This will be called from
`nonlinsolve` when any equation(s) is non polynomial equation.
def solveset_univariate_trig_inequality(expr, gen, relational=True):
"""Solves a real univariate inequality.
Examples
========
>>> from sympy.solvers.inequalities import solveset_univariate_trig_inequality
>>> from sympy.core.symbol import Symbol
>>> x = Symbol('x')
>>> solveset((2*cos(x)+1)/(2*cos(x)-1) > 0, x, S.Reals)
@Shekharrajak
Shekharrajak / reduce_imageset_v2.py
Created June 10, 2016 19:36
Secod attempt for reduce_imageset methoid
def reduce_imageset(new_imgset, imgset = S.EmptySet):
"""
Try to reduce number of imageset in the args.
It is mostly helper to _solve_trig method defined in
solvers/solveset.py.
First extract the expression of imageset and put in list in new_list
(for new_imgset expr) and final_list(for imgset expr). If there is any
expr in new_list have difference of pi or -pi with any final_list expr.